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