xref: /aoo41x/main/svx/source/xoutdev/xtabbtmp.cxx (revision 70d3707a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <com/sun/star/container/XNameContainer.hpp>
28 #include "svx/XPropertyTable.hxx"
29 #include <unotools/ucbstreamhelper.hxx>
30 #include <xmlxtexp.hxx>
31 #include <xmlxtimp.hxx>
32 #include <tools/urlobj.hxx>
33 #include <vcl/virdev.hxx>
34 #include <svl/itemset.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <svx/dialogs.hrc>
37 #include <svx/dialmgr.hxx>
38 #include <svx/xtable.hxx>
39 #include <svx/xpool.hxx>
40 #include <svx/xbtmpit.hxx>
41 
42 #define GLOBALOVERFLOW
43 
44 using namespace com::sun::star;
45 using namespace rtl;
46 
47 sal_Unicode const pszExtBitmap[]  = {'s','o','b'};
48 
49 static char const aChckBitmap[]  = { 0x04, 0x00, 'S','O','B','L'};	// very old
50 static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'};	// old
51 static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'};	// = 5.2
52 static char const aChckXML[]     = { 'P', 'K', 0x03, 0x04 };		// = 6.0
53 
54 // -------------------
55 // class XBitmapTable
56 // -------------------
57 
58 /*************************************************************************
59 |*
60 |* XBitmapTable::XBitmapTable()
61 |*
62 *************************************************************************/
63 
64 XBitmapTable::XBitmapTable( const String& rPath,
65 							XOutdevItemPool* pInPool,
66 							sal_uInt16 nInitSize, sal_uInt16 nReSize ) :
67 				XPropertyTable( rPath, pInPool, nInitSize, nReSize)
68 {
69 	pBmpTable = new Table( nInitSize, nReSize );
70 }
71 
72 /************************************************************************/
73 
74 XBitmapTable::~XBitmapTable()
75 {
76 }
77 
78 /************************************************************************/
79 
80 XBitmapEntry* XBitmapTable::Replace(long nIndex, XBitmapEntry* pEntry )
81 {
82 	return (XBitmapEntry*) XPropertyTable::Replace(nIndex, pEntry);
83 }
84 
85 /************************************************************************/
86 
87 XBitmapEntry* XBitmapTable::Remove(long nIndex)
88 {
89 	return (XBitmapEntry*) XPropertyTable::Remove(nIndex, 0);
90 }
91 
92 /************************************************************************/
93 
94 XBitmapEntry* XBitmapTable::GetBitmap(long nIndex) const
95 {
96 	return (XBitmapEntry*) XPropertyTable::Get(nIndex, 0);
97 }
98 
99 /************************************************************************/
100 
101 sal_Bool XBitmapTable::Load()
102 {
103 	return( sal_False );
104 }
105 
106 /************************************************************************/
107 
108 sal_Bool XBitmapTable::Save()
109 {
110 	return( sal_False );
111 }
112 
113 /************************************************************************/
114 
115 sal_Bool XBitmapTable::Create()
116 {
117 	return( sal_False );
118 }
119 
120 /************************************************************************/
121 
122 sal_Bool XBitmapTable::CreateBitmapsForUI()
123 {
124 	return( sal_False );
125 }
126 
127 /************************************************************************/
128 
129 Bitmap* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/)
130 {
131 	return( NULL );
132 }
133 
134 // ------------------
135 // class XBitmapList
136 // ------------------
137 
138 /*************************************************************************
139 |*
140 |* XBitmapList::XBitmapList()
141 |*
142 *************************************************************************/
143 
144 XBitmapList::XBitmapList( const String& rPath,
145 							XOutdevItemPool* pInPool,
146 							sal_uInt16 nInitSize, sal_uInt16 nReSize ) :
147 				XPropertyList( rPath, pInPool, nInitSize, nReSize)
148 {
149 	// pBmpList = new List( nInitSize, nReSize );
150 }
151 
152 /************************************************************************/
153 
154 XBitmapList::~XBitmapList()
155 {
156 }
157 
158 /************************************************************************/
159 
160 XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex )
161 {
162 	return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex);
163 }
164 
165 /************************************************************************/
166 
167 XBitmapEntry* XBitmapList::Remove(long nIndex)
168 {
169 	return (XBitmapEntry*) XPropertyList::Remove(nIndex, 0);
170 }
171 
172 /************************************************************************/
173 
174 XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const
175 {
176 	return (XBitmapEntry*) XPropertyList::Get(nIndex, 0);
177 }
178 
179 /************************************************************************/
180 
181 sal_Bool XBitmapList::Load()
182 {
183 	if( bListDirty )
184 	{
185 		bListDirty = sal_False;
186 
187 		INetURLObject aURL( aPath );
188 
189 		if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
190 		{
191 			DBG_ASSERT( !aPath.Len(), "invalid URL" );
192 			return sal_False;
193 		}
194 
195 		aURL.Append( aName );
196 
197 		if( !aURL.getExtension().getLength() )
198 			aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
199 
200 		uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
201 		return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
202 	}
203 	return( sal_False );
204 }
205 
206 /************************************************************************/
207 
208 sal_Bool XBitmapList::Save()
209 {
210 	INetURLObject aURL( aPath );
211 
212 	if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
213 	{
214 		DBG_ASSERT( !aPath.Len(), "invalid URL" );
215 		return sal_False;
216 	}
217 
218 	aURL.Append( aName );
219 
220 	if( !aURL.getExtension().getLength() )
221 		aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
222 
223 	uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
224 	return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
225 }
226 
227 /************************************************************************/
228 // Umgestellt am 27.07.95 auf XBitmap
229 
230 sal_Bool XBitmapList::Create()
231 {
232 	//-----------------------
233 	// 00 01 02 03 04 05 06 07
234 	// 08 09 10 11 12 13 14 15
235 	// 16 17 18 19 20 21 22 23
236 	// 24 25 26 27 28 29 30 31
237 	// 32 33 34 35 36 37 38 39
238 	// 40 41 42 43 44 45 46 47
239 	// 48 49 50 51 52 53 54 55
240 	// 56 57 58 59 60 61 62 63
241 	String aStr(SVX_RES(RID_SVXSTR_BITMAP));
242     sal_uInt16 aArray[64];
243     Bitmap aBitmap;
244 	const xub_StrLen nLen(aStr.Len() - 1);
245 
246     memset(aArray, 0, sizeof(aArray));
247 
248     // white/white bitmap
249 	aStr.AppendAscii(" 1");
250     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_WHITE), RGB_Color(COL_WHITE));
251 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
252 
253     // black/white bitmap
254 	aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
255 	aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
256 	aStr.SetChar(nLen, sal_Unicode('2'));
257     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
258 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
259 
260     // lightred/white bitmap
261 	aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
262 	aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
263 	aStr.SetChar(nLen, sal_Unicode('3'));
264     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTRED), RGB_Color(COL_WHITE));
265 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
266 
267     // lightblue/white bitmap
268 	aArray[24] = 1; aArray[25] = 1; aArray[26] = 1;
269 	aArray[29] = 1; aArray[30] = 1; aArray[31] = 1;
270 	aStr.SetChar(nLen, sal_Unicode('4'));
271     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTBLUE), RGB_Color(COL_WHITE));
272 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
273 
274 	return( sal_True );
275 }
276 
277 /************************************************************************/
278 
279 sal_Bool XBitmapList::CreateBitmapsForUI()
280 {
281 	return( sal_False );
282 }
283 
284 /************************************************************************/
285 
286 Bitmap* XBitmapList::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/)
287 {
288 	return( NULL );
289 }
290 
291 // eof
292