xref: /AOO41X/main/svx/source/xoutdev/xtabbtmp.cxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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 #ifndef SVX_LIGHT
28 
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include "svx/XPropertyTable.hxx"
31 #include <unotools/ucbstreamhelper.hxx>
32 
33 #include "xmlxtexp.hxx"
34 #include "xmlxtimp.hxx"
35 
36 #endif
37 
38 #include <tools/urlobj.hxx>
39 #include <vcl/virdev.hxx>
40 #include <svl/itemset.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <svx/dialogs.hrc>
43 #include <svx/dialmgr.hxx>
44 #include <svx/xtable.hxx>
45 #include <svx/xpool.hxx>
46 
47 #define GLOBALOVERFLOW
48 
49 using namespace com::sun::star;
50 using namespace rtl;
51 
52 sal_Unicode const pszExtBitmap[]  = {'s','o','b'};
53 
54 static char const aChckBitmap[]  = { 0x04, 0x00, 'S','O','B','L'};  // very old
55 static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'};  // old
56 static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'};  // = 5.2
57 static char const aChckXML[]     = { 'P', 'K', 0x03, 0x04 };        // = 6.0
58 
59 // -------------------
60 // class XBitmapTable
61 // -------------------
62 
63 /*************************************************************************
64 |*
65 |* XBitmapTable::XBitmapTable()
66 |*
67 *************************************************************************/
68 
69 XBitmapTable::XBitmapTable( const String& rPath,
70                             XOutdevItemPool* pInPool,
71                             sal_uInt16 nInitSize, sal_uInt16 nReSize ) :
72                 XPropertyTable( rPath, pInPool, nInitSize, nReSize)
73 {
74     pBmpTable = new Table( nInitSize, nReSize );
75 }
76 
77 /************************************************************************/
78 
79 XBitmapTable::~XBitmapTable()
80 {
81 }
82 
83 /************************************************************************/
84 
85 XBitmapEntry* XBitmapTable::Replace(long nIndex, XBitmapEntry* pEntry )
86 {
87     return (XBitmapEntry*) XPropertyTable::Replace(nIndex, pEntry);
88 }
89 
90 /************************************************************************/
91 
92 XBitmapEntry* XBitmapTable::Remove(long nIndex)
93 {
94     return (XBitmapEntry*) XPropertyTable::Remove(nIndex, 0);
95 }
96 
97 /************************************************************************/
98 
99 XBitmapEntry* XBitmapTable::GetBitmap(long nIndex) const
100 {
101     return (XBitmapEntry*) XPropertyTable::Get(nIndex, 0);
102 }
103 
104 /************************************************************************/
105 
106 sal_Bool XBitmapTable::Load()
107 {
108     return( sal_False );
109 }
110 
111 /************************************************************************/
112 
113 sal_Bool XBitmapTable::Save()
114 {
115     return( sal_False );
116 }
117 
118 /************************************************************************/
119 
120 sal_Bool XBitmapTable::Create()
121 {
122     return( sal_False );
123 }
124 
125 /************************************************************************/
126 
127 sal_Bool XBitmapTable::CreateBitmapsForUI()
128 {
129     return( sal_False );
130 }
131 
132 /************************************************************************/
133 
134 Bitmap* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/)
135 {
136     return( NULL );
137 }
138 
139 // ------------------
140 // class XBitmapList
141 // ------------------
142 
143 /*************************************************************************
144 |*
145 |* XBitmapList::XBitmapList()
146 |*
147 *************************************************************************/
148 
149 XBitmapList::XBitmapList( const String& rPath,
150                             XOutdevItemPool* pInPool,
151                             sal_uInt16 nInitSize, sal_uInt16 nReSize ) :
152                 XPropertyList( rPath, pInPool, nInitSize, nReSize)
153 {
154     // pBmpList = new List( nInitSize, nReSize );
155 }
156 
157 /************************************************************************/
158 
159 XBitmapList::~XBitmapList()
160 {
161 }
162 
163 /************************************************************************/
164 
165 XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex )
166 {
167     return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex);
168 }
169 
170 /************************************************************************/
171 
172 XBitmapEntry* XBitmapList::Remove(long nIndex)
173 {
174     return (XBitmapEntry*) XPropertyList::Remove(nIndex, 0);
175 }
176 
177 /************************************************************************/
178 
179 XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const
180 {
181     return (XBitmapEntry*) XPropertyList::Get(nIndex, 0);
182 }
183 
184 /************************************************************************/
185 
186 sal_Bool XBitmapList::Load()
187 {
188     if( bListDirty )
189     {
190         bListDirty = sal_False;
191 
192         INetURLObject aURL( aPath );
193 
194         if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
195         {
196             DBG_ASSERT( !aPath.Len(), "invalid URL" );
197             return sal_False;
198         }
199 
200         aURL.Append( aName );
201 
202         if( !aURL.getExtension().getLength() )
203             aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
204 
205         uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
206         return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
207     }
208     return( sal_False );
209 }
210 
211 /************************************************************************/
212 
213 sal_Bool XBitmapList::Save()
214 {
215     INetURLObject aURL( aPath );
216 
217     if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
218     {
219         DBG_ASSERT( !aPath.Len(), "invalid URL" );
220         return sal_False;
221     }
222 
223     aURL.Append( aName );
224 
225     if( !aURL.getExtension().getLength() )
226         aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
227 
228     uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
229     return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
230 }
231 
232 /************************************************************************/
233 // Umgestellt am 27.07.95 auf XBitmap
234 
235 sal_Bool XBitmapList::Create()
236 {
237     // Array der Bitmap
238     //-----------------------
239     // 00 01 02 03 04 05 06 07
240     // 08 09 10 11 12 13 14 15
241     // 16 17 18 19 20 21 22 23
242     // 24 25 26 27 28 29 30 31
243     // 32 33 34 35 36 37 38 39
244     // 40 41 42 43 44 45 46 47
245     // 48 49 50 51 52 53 54 55
246     // 56 57 58 59 60 61 62 63
247 
248     String  aStr( SVX_RES( RID_SVXSTR_BITMAP ) );
249     Color   aColWhite( RGB_Color( COL_WHITE ) );
250     xub_StrLen nLen;
251     sal_uInt16  aArray[64];
252 
253     memset( aArray, 0, sizeof( aArray ) );
254     aStr.AppendAscii(" 1");
255     nLen = aStr.Len() - 1;
256     Insert( new XBitmapEntry( XOBitmap( aArray, aColWhite, aColWhite ), aStr ) );
257 
258     aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
259     aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
260     aStr.SetChar(nLen, sal_Unicode('2'));
261     Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_BLACK ), aColWhite ), aStr ) );
262 
263     aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
264     aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
265     aStr.SetChar(nLen, sal_Unicode('3'));
266     Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTRED ), aColWhite ), aStr ) );
267 
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     Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTBLUE ), aColWhite ), aStr ) );
272 
273     return( sal_True );
274 }
275 
276 /************************************************************************/
277 
278 sal_Bool XBitmapList::CreateBitmapsForUI()
279 {
280     return( sal_False );
281 }
282 
283 /************************************************************************/
284 
285 Bitmap* XBitmapList::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/)
286 {
287     return( NULL );
288 }
289 
290 // eof
291