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