1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #ifndef SVX_LIGHT 32 33 #include <com/sun/star/container/XNameContainer.hpp> 34 #include "svx/XPropertyTable.hxx" 35 #include <unotools/ucbstreamhelper.hxx> 36 37 #include "xmlxtexp.hxx" 38 #include "xmlxtimp.hxx" 39 40 #endif 41 42 #include <tools/urlobj.hxx> 43 #include <vcl/virdev.hxx> 44 #include <svl/itemset.hxx> 45 #include <sfx2/docfile.hxx> 46 #include <svx/dialogs.hrc> 47 #include <svx/dialmgr.hxx> 48 #include <svx/xtable.hxx> 49 #include <svx/xpool.hxx> 50 51 #define GLOBALOVERFLOW 52 53 using namespace com::sun::star; 54 using namespace rtl; 55 56 sal_Unicode const pszExtBitmap[] = {'s','o','b'}; 57 58 static char const aChckBitmap[] = { 0x04, 0x00, 'S','O','B','L'}; // very old 59 static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'}; // old 60 static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'}; // = 5.2 61 static char const aChckXML[] = { 'P', 'K', 0x03, 0x04 }; // = 6.0 62 63 // ------------------- 64 // class XBitmapTable 65 // ------------------- 66 67 /************************************************************************* 68 |* 69 |* XBitmapTable::XBitmapTable() 70 |* 71 *************************************************************************/ 72 73 XBitmapTable::XBitmapTable( const String& rPath, 74 XOutdevItemPool* pInPool, 75 sal_uInt16 nInitSize, sal_uInt16 nReSize ) : 76 XPropertyTable( rPath, pInPool, nInitSize, nReSize) 77 { 78 pBmpTable = new Table( nInitSize, nReSize ); 79 } 80 81 /************************************************************************/ 82 83 XBitmapTable::~XBitmapTable() 84 { 85 } 86 87 /************************************************************************/ 88 89 XBitmapEntry* XBitmapTable::Replace(long nIndex, XBitmapEntry* pEntry ) 90 { 91 return (XBitmapEntry*) XPropertyTable::Replace(nIndex, pEntry); 92 } 93 94 /************************************************************************/ 95 96 XBitmapEntry* XBitmapTable::Remove(long nIndex) 97 { 98 return (XBitmapEntry*) XPropertyTable::Remove(nIndex, 0); 99 } 100 101 /************************************************************************/ 102 103 XBitmapEntry* XBitmapTable::GetBitmap(long nIndex) const 104 { 105 return (XBitmapEntry*) XPropertyTable::Get(nIndex, 0); 106 } 107 108 /************************************************************************/ 109 110 sal_Bool XBitmapTable::Load() 111 { 112 return( sal_False ); 113 } 114 115 /************************************************************************/ 116 117 sal_Bool XBitmapTable::Save() 118 { 119 return( sal_False ); 120 } 121 122 /************************************************************************/ 123 124 sal_Bool XBitmapTable::Create() 125 { 126 return( sal_False ); 127 } 128 129 /************************************************************************/ 130 131 sal_Bool XBitmapTable::CreateBitmapsForUI() 132 { 133 return( sal_False ); 134 } 135 136 /************************************************************************/ 137 138 Bitmap* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/) 139 { 140 return( NULL ); 141 } 142 143 // ------------------ 144 // class XBitmapList 145 // ------------------ 146 147 /************************************************************************* 148 |* 149 |* XBitmapList::XBitmapList() 150 |* 151 *************************************************************************/ 152 153 XBitmapList::XBitmapList( const String& rPath, 154 XOutdevItemPool* pInPool, 155 sal_uInt16 nInitSize, sal_uInt16 nReSize ) : 156 XPropertyList( rPath, pInPool, nInitSize, nReSize) 157 { 158 // pBmpList = new List( nInitSize, nReSize ); 159 } 160 161 /************************************************************************/ 162 163 XBitmapList::~XBitmapList() 164 { 165 } 166 167 /************************************************************************/ 168 169 XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex ) 170 { 171 return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex); 172 } 173 174 /************************************************************************/ 175 176 XBitmapEntry* XBitmapList::Remove(long nIndex) 177 { 178 return (XBitmapEntry*) XPropertyList::Remove(nIndex, 0); 179 } 180 181 /************************************************************************/ 182 183 XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const 184 { 185 return (XBitmapEntry*) XPropertyList::Get(nIndex, 0); 186 } 187 188 /************************************************************************/ 189 190 sal_Bool XBitmapList::Load() 191 { 192 if( bListDirty ) 193 { 194 bListDirty = sal_False; 195 196 INetURLObject aURL( aPath ); 197 198 if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) 199 { 200 DBG_ASSERT( !aPath.Len(), "invalid URL" ); 201 return sal_False; 202 } 203 204 aURL.Append( aName ); 205 206 if( !aURL.getExtension().getLength() ) 207 aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); 208 209 uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); 210 return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); 211 } 212 return( sal_False ); 213 } 214 215 /************************************************************************/ 216 217 sal_Bool XBitmapList::Save() 218 { 219 INetURLObject aURL( aPath ); 220 221 if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) 222 { 223 DBG_ASSERT( !aPath.Len(), "invalid URL" ); 224 return sal_False; 225 } 226 227 aURL.Append( aName ); 228 229 if( !aURL.getExtension().getLength() ) 230 aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); 231 232 uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); 233 return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); 234 } 235 236 /************************************************************************/ 237 // Umgestellt am 27.07.95 auf XBitmap 238 239 sal_Bool XBitmapList::Create() 240 { 241 // Array der Bitmap 242 //----------------------- 243 // 00 01 02 03 04 05 06 07 244 // 08 09 10 11 12 13 14 15 245 // 16 17 18 19 20 21 22 23 246 // 24 25 26 27 28 29 30 31 247 // 32 33 34 35 36 37 38 39 248 // 40 41 42 43 44 45 46 47 249 // 48 49 50 51 52 53 54 55 250 // 56 57 58 59 60 61 62 63 251 252 String aStr( SVX_RES( RID_SVXSTR_BITMAP ) ); 253 Color aColWhite( RGB_Color( COL_WHITE ) ); 254 xub_StrLen nLen; 255 sal_uInt16 aArray[64]; 256 257 memset( aArray, 0, sizeof( aArray ) ); 258 aStr.AppendAscii(" 1"); 259 nLen = aStr.Len() - 1; 260 Insert( new XBitmapEntry( XOBitmap( aArray, aColWhite, aColWhite ), aStr ) ); 261 262 aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1; 263 aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1; 264 aStr.SetChar(nLen, sal_Unicode('2')); 265 Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_BLACK ), aColWhite ), aStr ) ); 266 267 aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1; 268 aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1; 269 aStr.SetChar(nLen, sal_Unicode('3')); 270 Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTRED ), aColWhite ), aStr ) ); 271 272 aArray[24] = 1; aArray[25] = 1; aArray[26] = 1; 273 aArray[29] = 1; aArray[30] = 1; aArray[31] = 1; 274 aStr.SetChar(nLen, sal_Unicode('4')); 275 Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTBLUE ), aColWhite ), aStr ) ); 276 277 return( sal_True ); 278 } 279 280 /************************************************************************/ 281 282 sal_Bool XBitmapList::CreateBitmapsForUI() 283 { 284 return( sal_False ); 285 } 286 287 /************************************************************************/ 288 289 Bitmap* XBitmapList::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/) 290 { 291 return( NULL ); 292 } 293 294 // eof 295