xref: /aoo42x/main/svx/source/xoutdev/xtabbtmp.cxx (revision 3e407bd8)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_svx.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
26cdf0e10cSrcweir #include "svx/XPropertyTable.hxx"
27cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
2870d3707aSArmin Le Grand #include <xmlxtexp.hxx>
2970d3707aSArmin Le Grand #include <xmlxtimp.hxx>
30cdf0e10cSrcweir #include <tools/urlobj.hxx>
31cdf0e10cSrcweir #include <vcl/virdev.hxx>
32cdf0e10cSrcweir #include <svl/itemset.hxx>
33cdf0e10cSrcweir #include <sfx2/docfile.hxx>
34cdf0e10cSrcweir #include <svx/dialogs.hrc>
35cdf0e10cSrcweir #include <svx/dialmgr.hxx>
36cdf0e10cSrcweir #include <svx/xtable.hxx>
37cdf0e10cSrcweir #include <svx/xpool.hxx>
3870d3707aSArmin Le Grand #include <svx/xbtmpit.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define GLOBALOVERFLOW
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using namespace com::sun::star;
43cdf0e10cSrcweir using namespace rtl;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir sal_Unicode const pszExtBitmap[]  = {'s','o','b'};
46cdf0e10cSrcweir 
47cdf0e10cSrcweir static char const aChckBitmap[]  = { 0x04, 0x00, 'S','O','B','L'};	// very old
48cdf0e10cSrcweir static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'};	// old
49cdf0e10cSrcweir static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'};	// = 5.2
50cdf0e10cSrcweir static char const aChckXML[]     = { 'P', 'K', 0x03, 0x04 };		// = 6.0
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // ------------------
53cdf0e10cSrcweir // class XBitmapList
54cdf0e10cSrcweir // ------------------
55cdf0e10cSrcweir 
XBitmapList(const String & rPath)56c7be74b1SArmin Le Grand XBitmapList::XBitmapList( const String& rPath ) :
57c7be74b1SArmin Le Grand 				XPropertyList( rPath )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /************************************************************************/
62cdf0e10cSrcweir 
~XBitmapList()63cdf0e10cSrcweir XBitmapList::~XBitmapList()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /************************************************************************/
68cdf0e10cSrcweir 
Replace(XBitmapEntry * pEntry,long nIndex)69cdf0e10cSrcweir XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex);
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /************************************************************************/
75cdf0e10cSrcweir 
Remove(long nIndex)76cdf0e10cSrcweir XBitmapEntry* XBitmapList::Remove(long nIndex)
77cdf0e10cSrcweir {
78c7be74b1SArmin Le Grand 	return (XBitmapEntry*) XPropertyList::Remove(nIndex);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /************************************************************************/
82cdf0e10cSrcweir 
GetBitmap(long nIndex) const83cdf0e10cSrcweir XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const
84cdf0e10cSrcweir {
85c7be74b1SArmin Le Grand 	return (XBitmapEntry*) XPropertyList::Get(nIndex);
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir /************************************************************************/
89cdf0e10cSrcweir 
Load()90*3e407bd8SArmin Le Grand bool XBitmapList::Load()
91cdf0e10cSrcweir {
9297e8a929SArmin Le Grand 	if( mbListDirty )
93cdf0e10cSrcweir 	{
9497e8a929SArmin Le Grand 		mbListDirty = false;
95cdf0e10cSrcweir 
9697e8a929SArmin Le Grand 		INetURLObject aURL( maPath );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
99cdf0e10cSrcweir 		{
10097e8a929SArmin Le Grand 			DBG_ASSERT( !maPath.Len(), "invalid URL" );
101*3e407bd8SArmin Le Grand 			return false;
102cdf0e10cSrcweir 		}
103cdf0e10cSrcweir 
10497e8a929SArmin Le Grand 		aURL.Append( maName );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		if( !aURL.getExtension().getLength() )
107cdf0e10cSrcweir 			aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 		uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
110cdf0e10cSrcweir 		return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
111cdf0e10cSrcweir 	}
112*3e407bd8SArmin Le Grand 
113*3e407bd8SArmin Le Grand     return false;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir /************************************************************************/
117cdf0e10cSrcweir 
Save()118*3e407bd8SArmin Le Grand bool XBitmapList::Save()
119cdf0e10cSrcweir {
12097e8a929SArmin Le Grand 	INetURLObject aURL( maPath );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
123cdf0e10cSrcweir 	{
12497e8a929SArmin Le Grand 		DBG_ASSERT( !maPath.Len(), "invalid URL" );
125*3e407bd8SArmin Le Grand 		return false;
126cdf0e10cSrcweir 	}
127cdf0e10cSrcweir 
12897e8a929SArmin Le Grand 	aURL.Append( maName );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	if( !aURL.getExtension().getLength() )
131cdf0e10cSrcweir 		aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
134cdf0e10cSrcweir 	return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /************************************************************************/
138cdf0e10cSrcweir // Umgestellt am 27.07.95 auf XBitmap
139cdf0e10cSrcweir 
Create()140*3e407bd8SArmin Le Grand bool XBitmapList::Create()
141cdf0e10cSrcweir {
14270d3707aSArmin Le Grand 	String aStr(SVX_RES(RID_SVXSTR_BITMAP));
14370d3707aSArmin Le Grand     sal_uInt16 aArray[64];
14470d3707aSArmin Le Grand     Bitmap aBitmap;
14570d3707aSArmin Le Grand 	const xub_StrLen nLen(aStr.Len() - 1);
146cdf0e10cSrcweir 
14770d3707aSArmin Le Grand     memset(aArray, 0, sizeof(aArray));
148cdf0e10cSrcweir 
14970d3707aSArmin Le Grand     // white/white bitmap
150cdf0e10cSrcweir 	aStr.AppendAscii(" 1");
15170d3707aSArmin Le Grand     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_WHITE), RGB_Color(COL_WHITE));
15270d3707aSArmin Le Grand 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
153cdf0e10cSrcweir 
15470d3707aSArmin Le Grand     // black/white bitmap
155cdf0e10cSrcweir 	aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
156cdf0e10cSrcweir 	aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
157cdf0e10cSrcweir 	aStr.SetChar(nLen, sal_Unicode('2'));
15870d3707aSArmin Le Grand     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
15970d3707aSArmin Le Grand 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
160cdf0e10cSrcweir 
16170d3707aSArmin Le Grand     // lightred/white bitmap
162cdf0e10cSrcweir 	aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
163cdf0e10cSrcweir 	aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
164cdf0e10cSrcweir 	aStr.SetChar(nLen, sal_Unicode('3'));
16570d3707aSArmin Le Grand     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTRED), RGB_Color(COL_WHITE));
16670d3707aSArmin Le Grand 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
167cdf0e10cSrcweir 
16870d3707aSArmin Le Grand     // lightblue/white bitmap
169cdf0e10cSrcweir 	aArray[24] = 1; aArray[25] = 1; aArray[26] = 1;
170cdf0e10cSrcweir 	aArray[29] = 1; aArray[30] = 1; aArray[31] = 1;
171cdf0e10cSrcweir 	aStr.SetChar(nLen, sal_Unicode('4'));
17270d3707aSArmin Le Grand     aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTBLUE), RGB_Color(COL_WHITE));
17370d3707aSArmin Le Grand 	Insert(new XBitmapEntry(Graphic(aBitmap), aStr));
174cdf0e10cSrcweir 
175*3e407bd8SArmin Le Grand 	return true;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir /************************************************************************/
179cdf0e10cSrcweir 
CreateBitmapForUI(long)18097e8a929SArmin Le Grand Bitmap XBitmapList::CreateBitmapForUI( long /*nIndex*/ )
181cdf0e10cSrcweir {
18297e8a929SArmin Le Grand 	return Bitmap();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir // eof
186