1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xtabbtmp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include "XPropertyTable.hxx"
38 #include <unotools/ucbstreamhelper.hxx>
40 #include "xmlxtexp.hxx"
41 #include "xmlxtimp.hxx"
45 #include <tools/urlobj.hxx>
46 #include <vcl/virdev.hxx>
47 #include <svtools/itemset.hxx>
48 #include <sfx2/docfile.hxx>
49 #include <svx/dialogs.hrc>
50 #include <svx/dialmgr.hxx>
51 #include <svx/xtable.hxx>
52 #include <svx/xpool.hxx>
54 #define GLOBALOVERFLOW
56 using namespace com::sun::star
;
59 sal_Unicode
const pszExtBitmap
[] = {'s','o','b'};
61 static char const aChckBitmap
[] = { 0x04, 0x00, 'S','O','B','L'}; // very old
62 static char const aChckBitmap0
[] = { 0x04, 0x00, 'S','O','B','0'}; // old
63 static char const aChckBitmap1
[] = { 0x04, 0x00, 'S','O','B','1'}; // = 5.2
64 static char const aChckXML
[] = { 'P', 'K', 0x03, 0x04 }; // = 6.0
66 // -------------------
68 // -------------------
70 /*************************************************************************
72 |* XBitmapTable::XBitmapTable()
74 *************************************************************************/
76 XBitmapTable::XBitmapTable( const String
& rPath
,
77 XOutdevItemPool
* pInPool
,
78 USHORT nInitSize
, USHORT nReSize
) :
79 XPropertyTable( rPath
, pInPool
, nInitSize
, nReSize
)
81 pBmpTable
= new Table( nInitSize
, nReSize
);
84 /************************************************************************/
86 XBitmapTable::~XBitmapTable()
90 /************************************************************************/
92 XBitmapEntry
* XBitmapTable::Replace(long nIndex
, XBitmapEntry
* pEntry
)
94 return (XBitmapEntry
*) XPropertyTable::Replace(nIndex
, pEntry
);
97 /************************************************************************/
99 XBitmapEntry
* XBitmapTable::Remove(long nIndex
)
101 return (XBitmapEntry
*) XPropertyTable::Remove(nIndex
, 0);
104 /************************************************************************/
106 XBitmapEntry
* XBitmapTable::GetBitmap(long nIndex
) const
108 return (XBitmapEntry
*) XPropertyTable::Get(nIndex
, 0);
111 /************************************************************************/
113 BOOL
XBitmapTable::Load()
118 /************************************************************************/
120 BOOL
XBitmapTable::Save()
125 /************************************************************************/
127 BOOL
XBitmapTable::Create()
132 /************************************************************************/
134 BOOL
XBitmapTable::CreateBitmapsForUI()
139 /************************************************************************/
141 Bitmap
* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, BOOL
/*bDelete*/)
146 // ------------------
148 // ------------------
150 /*************************************************************************
152 |* XBitmapList::XBitmapList()
154 *************************************************************************/
156 XBitmapList::XBitmapList( const String
& rPath
,
157 XOutdevItemPool
* pInPool
,
158 USHORT nInitSize
, USHORT nReSize
) :
159 XPropertyList( rPath
, pInPool
, nInitSize
, nReSize
)
161 // pBmpList = new List( nInitSize, nReSize );
164 /************************************************************************/
166 XBitmapList::~XBitmapList()
170 /************************************************************************/
172 XBitmapEntry
* XBitmapList::Replace(XBitmapEntry
* pEntry
, long nIndex
)
174 return (XBitmapEntry
*) XPropertyList::Replace(pEntry
, nIndex
);
177 /************************************************************************/
179 XBitmapEntry
* XBitmapList::Remove(long nIndex
)
181 return (XBitmapEntry
*) XPropertyList::Remove(nIndex
, 0);
184 /************************************************************************/
186 XBitmapEntry
* XBitmapList::GetBitmap(long nIndex
) const
188 return (XBitmapEntry
*) XPropertyList::Get(nIndex
, 0);
191 /************************************************************************/
193 BOOL
XBitmapList::Load()
199 INetURLObject
aURL( aPath
);
201 if( INET_PROT_NOT_VALID
== aURL
.GetProtocol() )
203 DBG_ASSERT( !aPath
.Len(), "invalid URL" );
207 aURL
.Append( aName
);
209 if( !aURL
.getExtension().getLength() )
210 aURL
.setExtension( rtl::OUString( pszExtBitmap
, 3 ) );
212 uno::Reference
< container::XNameContainer
> xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY
);
213 return SvxXMLXTableImport::load( aURL
.GetMainURL( INetURLObject::NO_DECODE
), xTable
);
218 /************************************************************************/
220 BOOL
XBitmapList::Save()
222 INetURLObject
aURL( aPath
);
224 if( INET_PROT_NOT_VALID
== aURL
.GetProtocol() )
226 DBG_ASSERT( !aPath
.Len(), "invalid URL" );
230 aURL
.Append( aName
);
232 if( !aURL
.getExtension().getLength() )
233 aURL
.setExtension( rtl::OUString( pszExtBitmap
, 3 ) );
235 uno::Reference
< container::XNameContainer
> xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY
);
236 return SvxXMLXTableExportComponent::save( aURL
.GetMainURL( INetURLObject::NO_DECODE
), xTable
);
239 /************************************************************************/
240 // Umgestellt am 27.07.95 auf XBitmap
242 BOOL
XBitmapList::Create()
245 //-----------------------
246 // 00 01 02 03 04 05 06 07
247 // 08 09 10 11 12 13 14 15
248 // 16 17 18 19 20 21 22 23
249 // 24 25 26 27 28 29 30 31
250 // 32 33 34 35 36 37 38 39
251 // 40 41 42 43 44 45 46 47
252 // 48 49 50 51 52 53 54 55
253 // 56 57 58 59 60 61 62 63
255 String
aStr( SVX_RES( RID_SVXSTR_BITMAP
) );
256 Color
aColWhite( RGB_Color( COL_WHITE
) );
260 memset( aArray
, 0, sizeof( aArray
) );
261 aStr
.AppendAscii(" 1");
262 nLen
= aStr
.Len() - 1;
263 Insert( new XBitmapEntry( XOBitmap( aArray
, aColWhite
, aColWhite
), aStr
) );
265 aArray
[ 0] = 1; aArray
[ 9] = 1; aArray
[18] = 1; aArray
[27] = 1;
266 aArray
[36] = 1; aArray
[45] = 1; aArray
[54] = 1; aArray
[63] = 1;
267 aStr
.SetChar(nLen
, sal_Unicode('2'));
268 Insert( new XBitmapEntry( XOBitmap( aArray
, RGB_Color( COL_BLACK
), aColWhite
), aStr
) );
270 aArray
[ 7] = 1; aArray
[14] = 1; aArray
[21] = 1; aArray
[28] = 1;
271 aArray
[35] = 1; aArray
[42] = 1; aArray
[49] = 1; aArray
[56] = 1;
272 aStr
.SetChar(nLen
, sal_Unicode('3'));
273 Insert( new XBitmapEntry( XOBitmap( aArray
, RGB_Color( COL_LIGHTRED
), aColWhite
), aStr
) );
275 aArray
[24] = 1; aArray
[25] = 1; aArray
[26] = 1;
276 aArray
[29] = 1; aArray
[30] = 1; aArray
[31] = 1;
277 aStr
.SetChar(nLen
, sal_Unicode('4'));
278 Insert( new XBitmapEntry( XOBitmap( aArray
, RGB_Color( COL_LIGHTBLUE
), aColWhite
), aStr
) );
283 /************************************************************************/
285 BOOL
XBitmapList::CreateBitmapsForUI()
290 /************************************************************************/
292 Bitmap
* XBitmapList::CreateBitmapForUI( long /*nIndex*/, BOOL
/*bDelete*/)