1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svx/xtable.hxx> 32*cdf0e10cSrcweir #include <svx/xpool.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #define GLOBALOVERFLOW 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir // Vergleichsstrings 37*cdf0e10cSrcweir sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 }; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir // Konvertiert in echte RGB-Farben, damit in den Listboxen 40*cdf0e10cSrcweir // endlich mal richtig selektiert werden kann. 41*cdf0e10cSrcweir Color RGB_Color( ColorData nColorName ) 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir Color aColor( nColorName ); 44*cdf0e10cSrcweir Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() ); 45*cdf0e10cSrcweir return aRGBColor; 46*cdf0e10cSrcweir } 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // --------------------- 49*cdf0e10cSrcweir // class XPropertyTable 50*cdf0e10cSrcweir // --------------------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /************************************************************************* 53*cdf0e10cSrcweir |* 54*cdf0e10cSrcweir |* XPropertyTable::XPropertyTable() 55*cdf0e10cSrcweir |* 56*cdf0e10cSrcweir *************************************************************************/ 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir XPropertyTable::XPropertyTable( const String& rPath, 59*cdf0e10cSrcweir XOutdevItemPool* pInPool, 60*cdf0e10cSrcweir sal_uInt16 nInitSize, sal_uInt16 nReSize ) : 61*cdf0e10cSrcweir aName ( pszStandard, 8 ), 62*cdf0e10cSrcweir aPath ( rPath ), 63*cdf0e10cSrcweir pXPool ( pInPool ), 64*cdf0e10cSrcweir aTable ( nInitSize, nReSize ), 65*cdf0e10cSrcweir pBmpTable ( NULL ), 66*cdf0e10cSrcweir bTableDirty ( sal_True ), 67*cdf0e10cSrcweir bBitmapsDirty ( sal_True ), 68*cdf0e10cSrcweir bOwnPool ( sal_False ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir if( !pXPool ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir bOwnPool = sal_True; 73*cdf0e10cSrcweir pXPool = new XOutdevItemPool; 74*cdf0e10cSrcweir DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" ); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir /************************************************************************* 79*cdf0e10cSrcweir |* 80*cdf0e10cSrcweir |* XPropertyTable::XPropertyTable( SvStraem& ) 81*cdf0e10cSrcweir |* 82*cdf0e10cSrcweir *************************************************************************/ 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir XPropertyTable::XPropertyTable( SvStream& /*rIn*/) : 85*cdf0e10cSrcweir pBmpTable ( NULL ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir /************************************************************************* 90*cdf0e10cSrcweir |* 91*cdf0e10cSrcweir |* XPropertyTable::~XPropertyTable() 92*cdf0e10cSrcweir |* 93*cdf0e10cSrcweir *************************************************************************/ 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir XPropertyTable::~XPropertyTable() 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First(); 98*cdf0e10cSrcweir Bitmap* pBitmap = NULL; 99*cdf0e10cSrcweir for (sal_uIntPtr nIndex = 0; nIndex < aTable.Count(); nIndex++) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir delete pEntry; 102*cdf0e10cSrcweir pEntry = (XPropertyEntry*)aTable.Next(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir // Hier wird die Bitmaptabelle geloescht 105*cdf0e10cSrcweir if( pBmpTable ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir pBitmap = (Bitmap*) pBmpTable->First(); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir for( sal_uIntPtr nIndex = 0; nIndex < pBmpTable->Count(); nIndex++ ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir delete pBitmap; 112*cdf0e10cSrcweir pBitmap = (Bitmap*) pBmpTable->Next(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir delete pBmpTable; 115*cdf0e10cSrcweir pBmpTable = NULL; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir // Eigener Pool wird geloescht 118*cdf0e10cSrcweir if( bOwnPool && pXPool ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir SfxItemPool::Free(pXPool); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /************************************************************************* 125*cdf0e10cSrcweir |* 126*cdf0e10cSrcweir |* XPropertyTable::Clear() 127*cdf0e10cSrcweir |* 128*cdf0e10cSrcweir *************************************************************************/ 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir void XPropertyTable::Clear() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir aTable.Clear(); 133*cdf0e10cSrcweir if( pBmpTable ) 134*cdf0e10cSrcweir pBmpTable->Clear(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /************************************************************************/ 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir long XPropertyTable::Count() const 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir if( bTableDirty ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir // ( (XPropertyTable*) this )->bTableDirty = sal_False; <- im Load() 144*cdf0e10cSrcweir if( !( (XPropertyTable*) this )->Load() ) 145*cdf0e10cSrcweir ( (XPropertyTable*) this )->Create(); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir return( aTable.Count() ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir /************************************************************************* 151*cdf0e10cSrcweir |* 152*cdf0e10cSrcweir |* XPropertyEntry* XPropertyTable::Get() 153*cdf0e10cSrcweir |* 154*cdf0e10cSrcweir *************************************************************************/ 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir XPropertyEntry* XPropertyTable::Get( long nIndex, sal_uInt16 /*nDummy*/) const 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir if( bTableDirty ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir // ( (XPropertyTable*) this )->bTableDirty = sal_False; <- im Load() 161*cdf0e10cSrcweir if( !( (XPropertyTable*) this )->Load() ) 162*cdf0e10cSrcweir ( (XPropertyTable*) this )->Create(); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir return (XPropertyEntry*) aTable.GetObject( (sal_uIntPtr) nIndex ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /************************************************************************* 168*cdf0e10cSrcweir |* 169*cdf0e10cSrcweir |* long XPropertyTable::Get(const String& rName) 170*cdf0e10cSrcweir |* 171*cdf0e10cSrcweir *************************************************************************/ 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir long XPropertyTable::Get(const XubString& rName) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if( bTableDirty ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir // bTableDirty = sal_False; 178*cdf0e10cSrcweir if( !Load() ) 179*cdf0e10cSrcweir Create(); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir long nPos = 0; 182*cdf0e10cSrcweir XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First(); 183*cdf0e10cSrcweir while (pEntry && pEntry->GetName() != rName) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir nPos++; 186*cdf0e10cSrcweir pEntry = (XPropertyEntry*)aTable.Next(); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir if (!pEntry) nPos = -1; 189*cdf0e10cSrcweir return nPos; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir /************************************************************************* 193*cdf0e10cSrcweir |* 194*cdf0e10cSrcweir |* Bitmap* XPropertyTable::GetBitmap() 195*cdf0e10cSrcweir |* 196*cdf0e10cSrcweir *************************************************************************/ 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir Bitmap* XPropertyTable::GetBitmap( long nIndex ) const 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir if( pBmpTable ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if( bBitmapsDirty ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir ( (XPropertyTable*) this )->bBitmapsDirty = sal_False; 205*cdf0e10cSrcweir ( (XPropertyTable*) this )->CreateBitmapsForUI(); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir if( pBmpTable->Count() >= (sal_uIntPtr) nIndex ) 209*cdf0e10cSrcweir return (Bitmap*) pBmpTable->GetObject( (sal_uIntPtr) nIndex ); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir return( NULL ); 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir /************************************************************************* 215*cdf0e10cSrcweir |* 216*cdf0e10cSrcweir |* void XPropertyTable::Insert() 217*cdf0e10cSrcweir |* 218*cdf0e10cSrcweir *************************************************************************/ 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir sal_Bool XPropertyTable::Insert( long nIndex, XPropertyEntry* pEntry ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir sal_Bool bReturn = aTable.Insert( (sal_uIntPtr) nIndex, pEntry ); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if( pBmpTable && !bBitmapsDirty ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir Bitmap* pBmp = CreateBitmapForUI( (sal_uIntPtr) nIndex ); 227*cdf0e10cSrcweir pBmpTable->Insert( (sal_uIntPtr) nIndex, pBmp ); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir return bReturn; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir /************************************************************************* 233*cdf0e10cSrcweir |* 234*cdf0e10cSrcweir |* void XPropertyTable::Replace() 235*cdf0e10cSrcweir |* 236*cdf0e10cSrcweir *************************************************************************/ 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir XPropertyEntry* XPropertyTable::Replace( long nIndex, XPropertyEntry* pEntry ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir XPropertyEntry* pOldEntry = (XPropertyEntry*) aTable.Replace( (sal_uIntPtr) nIndex, pEntry ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if( pBmpTable && !bBitmapsDirty ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir Bitmap* pBmp = CreateBitmapForUI( (sal_uIntPtr) nIndex ); 245*cdf0e10cSrcweir Bitmap* pOldBmp = (Bitmap*) pBmpTable->Replace( (sal_uIntPtr) nIndex, pBmp ); 246*cdf0e10cSrcweir if( pOldBmp ) 247*cdf0e10cSrcweir delete pOldBmp; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir return pOldEntry; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir /************************************************************************* 253*cdf0e10cSrcweir |* 254*cdf0e10cSrcweir |* void XPropertyTable::Remove() 255*cdf0e10cSrcweir |* 256*cdf0e10cSrcweir *************************************************************************/ 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir XPropertyEntry* XPropertyTable::Remove( long nIndex, sal_uInt16 /*nDummy*/) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir if( pBmpTable && !bBitmapsDirty ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir Bitmap* pOldBmp = (Bitmap*) pBmpTable->Remove( (sal_uIntPtr) nIndex ); 263*cdf0e10cSrcweir if( pOldBmp ) 264*cdf0e10cSrcweir delete pOldBmp; 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir return (XPropertyEntry*) aTable.Remove((sal_uIntPtr)nIndex); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir /************************************************************************/ 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir void XPropertyTable::SetName( const String& rString ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if(rString.Len()) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir aName = rString; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir // -------------------- 280*cdf0e10cSrcweir // class XPropertyList 281*cdf0e10cSrcweir // -------------------- 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir /************************************************************************* 285*cdf0e10cSrcweir |* 286*cdf0e10cSrcweir |* XPropertyList::XPropertyList() 287*cdf0e10cSrcweir |* 288*cdf0e10cSrcweir *************************************************************************/ 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir XPropertyList::XPropertyList( const String& rPath, 291*cdf0e10cSrcweir XOutdevItemPool* pInPool, 292*cdf0e10cSrcweir sal_uInt16 nInitSize, sal_uInt16 nReSize ) : 293*cdf0e10cSrcweir aName ( pszStandard, 8 ), 294*cdf0e10cSrcweir aPath ( rPath ), 295*cdf0e10cSrcweir pXPool ( pInPool ), 296*cdf0e10cSrcweir aList ( nInitSize, nReSize ), 297*cdf0e10cSrcweir pBmpList ( NULL ), 298*cdf0e10cSrcweir bListDirty ( sal_True ), 299*cdf0e10cSrcweir bBitmapsDirty ( sal_True ), 300*cdf0e10cSrcweir bOwnPool ( sal_False ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir if( !pXPool ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir bOwnPool = sal_True; 305*cdf0e10cSrcweir pXPool = new XOutdevItemPool; 306*cdf0e10cSrcweir DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" ); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir /************************************************************************* 311*cdf0e10cSrcweir |* 312*cdf0e10cSrcweir |* XPropertyList::XPropertyList( SvStraem& ) 313*cdf0e10cSrcweir |* 314*cdf0e10cSrcweir *************************************************************************/ 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir XPropertyList::XPropertyList( SvStream& /*rIn*/) : 317*cdf0e10cSrcweir pBmpList ( NULL ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir /************************************************************************* 322*cdf0e10cSrcweir |* 323*cdf0e10cSrcweir |* XPropertyList::~XPropertyList() 324*cdf0e10cSrcweir |* 325*cdf0e10cSrcweir *************************************************************************/ 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir XPropertyList::~XPropertyList() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir XPropertyEntry* pEntry = (XPropertyEntry*)aList.First(); 330*cdf0e10cSrcweir Bitmap* pBitmap = NULL; 331*cdf0e10cSrcweir for( sal_uIntPtr nIndex = 0; nIndex < aList.Count(); nIndex++ ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir delete pEntry; 334*cdf0e10cSrcweir pEntry = (XPropertyEntry*)aList.Next(); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if( pBmpList ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir pBitmap = (Bitmap*) pBmpList->First(); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir for( sal_uIntPtr nIndex = 0; nIndex < pBmpList->Count(); nIndex++ ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir delete pBitmap; 344*cdf0e10cSrcweir pBitmap = (Bitmap*) pBmpList->Next(); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir delete pBmpList; 347*cdf0e10cSrcweir pBmpList = NULL; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if( bOwnPool && pXPool ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir SfxItemPool::Free(pXPool); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir /************************************************************************* 357*cdf0e10cSrcweir |* 358*cdf0e10cSrcweir |* XPropertyList::Clear() 359*cdf0e10cSrcweir |* 360*cdf0e10cSrcweir *************************************************************************/ 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir void XPropertyList::Clear() 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir aList.Clear(); 365*cdf0e10cSrcweir if( pBmpList ) 366*cdf0e10cSrcweir pBmpList->Clear(); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir /************************************************************************/ 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir long XPropertyList::Count() const 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir if( bListDirty ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir // ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load() 376*cdf0e10cSrcweir if( !( (XPropertyList*) this )->Load() ) 377*cdf0e10cSrcweir ( (XPropertyList*) this )->Create(); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir return( aList.Count() ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir /************************************************************************* 383*cdf0e10cSrcweir |* 384*cdf0e10cSrcweir |* XPropertyEntry* XPropertyList::Get() 385*cdf0e10cSrcweir |* 386*cdf0e10cSrcweir *************************************************************************/ 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir XPropertyEntry* XPropertyList::Get( long nIndex, sal_uInt16 /*nDummy*/) const 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir if( bListDirty ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir // ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load() 393*cdf0e10cSrcweir if( !( (XPropertyList*) this )->Load() ) 394*cdf0e10cSrcweir ( (XPropertyList*) this )->Create(); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir return (XPropertyEntry*) aList.GetObject( (sal_uIntPtr) nIndex ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir /************************************************************************* 400*cdf0e10cSrcweir |* 401*cdf0e10cSrcweir |* XPropertyList::Get() 402*cdf0e10cSrcweir |* 403*cdf0e10cSrcweir *************************************************************************/ 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir long XPropertyList::Get(const XubString& rName) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir if( bListDirty ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir //bListDirty = sal_False; 410*cdf0e10cSrcweir if( !Load() ) 411*cdf0e10cSrcweir Create(); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir long nPos = 0; 414*cdf0e10cSrcweir XPropertyEntry* pEntry = (XPropertyEntry*)aList.First(); 415*cdf0e10cSrcweir while (pEntry && pEntry->GetName() != rName) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir nPos++; 418*cdf0e10cSrcweir pEntry = (XPropertyEntry*)aList.Next(); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir if (!pEntry) nPos = -1; 421*cdf0e10cSrcweir return nPos; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir /************************************************************************* 425*cdf0e10cSrcweir |* 426*cdf0e10cSrcweir |* Bitmap* XPropertyList::GetBitmap() 427*cdf0e10cSrcweir |* 428*cdf0e10cSrcweir *************************************************************************/ 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir Bitmap* XPropertyList::GetBitmap( long nIndex ) const 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir if( pBmpList ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir if( bBitmapsDirty ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir ( (XPropertyList*) this )->bBitmapsDirty = sal_False; 437*cdf0e10cSrcweir ( (XPropertyList*) this )->CreateBitmapsForUI(); 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir if( pBmpList->Count() >= (sal_uIntPtr) nIndex ) 440*cdf0e10cSrcweir return (Bitmap*) pBmpList->GetObject( (sal_uIntPtr) nIndex ); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir return( NULL ); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir /************************************************************************* 446*cdf0e10cSrcweir |* 447*cdf0e10cSrcweir |* void XPropertyList::Insert() 448*cdf0e10cSrcweir |* 449*cdf0e10cSrcweir *************************************************************************/ 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir aList.Insert( pEntry, (sal_uIntPtr) nIndex ); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir if( pBmpList && !bBitmapsDirty ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir Bitmap* pBmp = CreateBitmapForUI( 458*cdf0e10cSrcweir (sal_uIntPtr) nIndex < aList.Count() ? nIndex : aList.Count() - 1 ); 459*cdf0e10cSrcweir pBmpList->Insert( pBmp, (sal_uIntPtr) nIndex ); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir /************************************************************************* 464*cdf0e10cSrcweir |* 465*cdf0e10cSrcweir |* void XPropertyList::Replace() 466*cdf0e10cSrcweir |* 467*cdf0e10cSrcweir *************************************************************************/ 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex ) 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir XPropertyEntry* pOldEntry = (XPropertyEntry*) aList.Replace( pEntry, (sal_uIntPtr) nIndex ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir if( pBmpList && !bBitmapsDirty ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir Bitmap* pBmp = CreateBitmapForUI( (sal_uIntPtr) nIndex ); 476*cdf0e10cSrcweir Bitmap* pOldBmp = (Bitmap*) pBmpList->Replace( pBmp, (sal_uIntPtr) nIndex ); 477*cdf0e10cSrcweir if( pOldBmp ) 478*cdf0e10cSrcweir delete pOldBmp; 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir return pOldEntry; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir /************************************************************************* 484*cdf0e10cSrcweir |* 485*cdf0e10cSrcweir |* void XPropertyList::Remove() 486*cdf0e10cSrcweir |* 487*cdf0e10cSrcweir *************************************************************************/ 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir XPropertyEntry* XPropertyList::Remove( long nIndex, sal_uInt16 /*nDummy*/) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir if( pBmpList && !bBitmapsDirty ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir Bitmap* pOldBmp = (Bitmap*) pBmpList->Remove( (sal_uIntPtr) nIndex ); 494*cdf0e10cSrcweir if( pOldBmp ) 495*cdf0e10cSrcweir delete pOldBmp; 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir return (XPropertyEntry*) aList.Remove( (sal_uIntPtr) nIndex ); 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir /************************************************************************/ 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir void XPropertyList::SetName( const String& rString ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir if(rString.Len()) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir aName = rString; 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir 512