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 <svx/xtable.hxx> 28cdf0e10cSrcweir #include <svx/xpool.hxx> 2997e8a929SArmin Le Grand #include <svx/svdobj.hxx> 3097e8a929SArmin Le Grand #include <svx/svdpool.hxx> 31*c7be74b1SArmin Le Grand #include <vcl/virdev.hxx> 32*c7be74b1SArmin Le Grand #include <svx/svdmodel.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #define GLOBALOVERFLOW 35cdf0e10cSrcweir 36cdf0e10cSrcweir // Vergleichsstrings 37cdf0e10cSrcweir sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 }; 38cdf0e10cSrcweir 39cdf0e10cSrcweir // Konvertiert in echte RGB-Farben, damit in den Listboxen 40cdf0e10cSrcweir // endlich mal richtig selektiert werden kann. 41cdf0e10cSrcweir Color RGB_Color( ColorData nColorName ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir Color aColor( nColorName ); 44cdf0e10cSrcweir Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() ); 45cdf0e10cSrcweir return aRGBColor; 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48*c7be74b1SArmin Le Grand sharedModelAndVDev::sharedModelAndVDev() 49*c7be74b1SArmin Le Grand : mnUseCount(0), 50*c7be74b1SArmin Le Grand mpVirtualDevice(0), 51*c7be74b1SArmin Le Grand mpSdrModel(0) 52*c7be74b1SArmin Le Grand { 53*c7be74b1SArmin Le Grand } 54*c7be74b1SArmin Le Grand 55*c7be74b1SArmin Le Grand sharedModelAndVDev::~sharedModelAndVDev() 56*c7be74b1SArmin Le Grand { 57*c7be74b1SArmin Le Grand delete mpVirtualDevice; 58*c7be74b1SArmin Le Grand delete mpSdrModel; 59*c7be74b1SArmin Le Grand } 60*c7be74b1SArmin Le Grand 61*c7be74b1SArmin Le Grand void sharedModelAndVDev::increaseUseCount() 62*c7be74b1SArmin Le Grand { 63*c7be74b1SArmin Le Grand mnUseCount++; 64*c7be74b1SArmin Le Grand } 65*c7be74b1SArmin Le Grand 66*c7be74b1SArmin Le Grand bool sharedModelAndVDev::decreaseUseCount() 67*c7be74b1SArmin Le Grand { 68*c7be74b1SArmin Le Grand if(mnUseCount) 69*c7be74b1SArmin Le Grand { 70*c7be74b1SArmin Le Grand mnUseCount--; 71*c7be74b1SArmin Le Grand } 72*c7be74b1SArmin Le Grand 73*c7be74b1SArmin Le Grand return 0 == mnUseCount; 74*c7be74b1SArmin Le Grand } 75*c7be74b1SArmin Le Grand 76*c7be74b1SArmin Le Grand SdrModel& sharedModelAndVDev::getSharedSdrModel() 77*c7be74b1SArmin Le Grand { 78*c7be74b1SArmin Le Grand if(!mpSdrModel) 79*c7be74b1SArmin Le Grand { 80*c7be74b1SArmin Le Grand mpSdrModel = new SdrModel(); 81*c7be74b1SArmin Le Grand OSL_ENSURE(0 != mpSdrModel, "XPropertyList sharedModelAndVDev: no SdrModel created!" ); 82*c7be74b1SArmin Le Grand mpSdrModel->GetItemPool().FreezeIdRanges(); 83*c7be74b1SArmin Le Grand } 84*c7be74b1SArmin Le Grand 85*c7be74b1SArmin Le Grand return *mpSdrModel; 86*c7be74b1SArmin Le Grand } 87*c7be74b1SArmin Le Grand 88*c7be74b1SArmin Le Grand VirtualDevice& sharedModelAndVDev::getSharedVirtualDevice() 89*c7be74b1SArmin Le Grand { 90*c7be74b1SArmin Le Grand if(!mpVirtualDevice) 91*c7be74b1SArmin Le Grand { 92*c7be74b1SArmin Le Grand mpVirtualDevice = new VirtualDevice; 93*c7be74b1SArmin Le Grand OSL_ENSURE(0 != mpVirtualDevice, "XPropertyList sharedModelAndVDev: no VirtualDevice created!" ); 94*c7be74b1SArmin Le Grand mpVirtualDevice->SetMapMode(MAP_100TH_MM); 95*c7be74b1SArmin Le Grand } 96*c7be74b1SArmin Le Grand 97*c7be74b1SArmin Le Grand return *mpVirtualDevice; 98*c7be74b1SArmin Le Grand } 99*c7be74b1SArmin Le Grand 100*c7be74b1SArmin Le Grand sharedModelAndVDev* XPropertyList::pGlobalsharedModelAndVDev = 0; 101*c7be74b1SArmin Le Grand 102cdf0e10cSrcweir // -------------------- 103cdf0e10cSrcweir // class XPropertyList 104cdf0e10cSrcweir // -------------------- 105cdf0e10cSrcweir 106*c7be74b1SArmin Le Grand XPropertyList::XPropertyList( const String& rPath ) : 10797e8a929SArmin Le Grand maName ( pszStandard, 8 ), 10897e8a929SArmin Le Grand maPath ( rPath ), 109*c7be74b1SArmin Le Grand maContent(), 11097e8a929SArmin Le Grand mbListDirty (true) 111cdf0e10cSrcweir { 112*c7be74b1SArmin Le Grand if(!pGlobalsharedModelAndVDev) 113cdf0e10cSrcweir { 114*c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev = new sharedModelAndVDev(); 115cdf0e10cSrcweir } 116*c7be74b1SArmin Le Grand 117*c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev->increaseUseCount(); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir /************************************************************************* 121cdf0e10cSrcweir |* 122cdf0e10cSrcweir |* XPropertyList::~XPropertyList() 123cdf0e10cSrcweir |* 124cdf0e10cSrcweir *************************************************************************/ 125cdf0e10cSrcweir 126cdf0e10cSrcweir XPropertyList::~XPropertyList() 127cdf0e10cSrcweir { 128*c7be74b1SArmin Le Grand while(!maContent.empty()) 129cdf0e10cSrcweir { 130*c7be74b1SArmin Le Grand delete maContent.back(); 131*c7be74b1SArmin Le Grand maContent.pop_back(); 132*c7be74b1SArmin Le Grand } 133*c7be74b1SArmin Le Grand 134*c7be74b1SArmin Le Grand if(pGlobalsharedModelAndVDev && pGlobalsharedModelAndVDev->decreaseUseCount()) 135*c7be74b1SArmin Le Grand { 136*c7be74b1SArmin Le Grand delete pGlobalsharedModelAndVDev; 137*c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev = 0; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir /************************************************************************* 142cdf0e10cSrcweir |* 143cdf0e10cSrcweir |* XPropertyList::Clear() 144cdf0e10cSrcweir |* 145cdf0e10cSrcweir *************************************************************************/ 146cdf0e10cSrcweir 147cdf0e10cSrcweir void XPropertyList::Clear() 148cdf0e10cSrcweir { 149*c7be74b1SArmin Le Grand while(!maContent.empty()) 150*c7be74b1SArmin Le Grand { 151*c7be74b1SArmin Le Grand delete maContent.back(); 152*c7be74b1SArmin Le Grand maContent.pop_back(); 153*c7be74b1SArmin Le Grand } 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir /************************************************************************/ 157cdf0e10cSrcweir 158cdf0e10cSrcweir long XPropertyList::Count() const 159cdf0e10cSrcweir { 16097e8a929SArmin Le Grand if( mbListDirty ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir // ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load() 163cdf0e10cSrcweir if( !( (XPropertyList*) this )->Load() ) 164cdf0e10cSrcweir ( (XPropertyList*) this )->Create(); 165cdf0e10cSrcweir } 166*c7be74b1SArmin Le Grand 167*c7be74b1SArmin Le Grand return maContent.size(); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir /************************************************************************* 171cdf0e10cSrcweir |* 172cdf0e10cSrcweir |* XPropertyEntry* XPropertyList::Get() 173cdf0e10cSrcweir |* 174cdf0e10cSrcweir *************************************************************************/ 175cdf0e10cSrcweir 176*c7be74b1SArmin Le Grand XPropertyEntry* XPropertyList::Get( long nIndex ) const 177cdf0e10cSrcweir { 17897e8a929SArmin Le Grand if( mbListDirty ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir if( !( (XPropertyList*) this )->Load() ) 181cdf0e10cSrcweir ( (XPropertyList*) this )->Create(); 182cdf0e10cSrcweir } 183*c7be74b1SArmin Le Grand 184*c7be74b1SArmin Le Grand if(nIndex >= maContent.size()) 185*c7be74b1SArmin Le Grand { 186*c7be74b1SArmin Le Grand return 0; 187*c7be74b1SArmin Le Grand } 188*c7be74b1SArmin Le Grand 189*c7be74b1SArmin Le Grand return maContent[nIndex]; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir /************************************************************************* 193cdf0e10cSrcweir |* 194cdf0e10cSrcweir |* XPropertyList::Get() 195cdf0e10cSrcweir |* 196cdf0e10cSrcweir *************************************************************************/ 197cdf0e10cSrcweir 198*c7be74b1SArmin Le Grand long XPropertyList::GetIndex(const XubString& rName) const 199cdf0e10cSrcweir { 20097e8a929SArmin Le Grand if( mbListDirty ) 201cdf0e10cSrcweir { 202*c7be74b1SArmin Le Grand if( !( (XPropertyList*) this )->Load() ) 203*c7be74b1SArmin Le Grand ( (XPropertyList*) this )->Create(); 204cdf0e10cSrcweir } 205*c7be74b1SArmin Le Grand 206*c7be74b1SArmin Le Grand ::std::vector< XPropertyEntry* >::const_iterator aStart(maContent.begin()); 207*c7be74b1SArmin Le Grand const ::std::vector< XPropertyEntry* >::const_iterator aEnd(maContent.end()); 208*c7be74b1SArmin Le Grand 209*c7be74b1SArmin Le Grand for(long a(0); aStart != aEnd; a++, aStart++) 210cdf0e10cSrcweir { 211*c7be74b1SArmin Le Grand const XPropertyEntry* pEntry = *aStart; 212*c7be74b1SArmin Le Grand 213*c7be74b1SArmin Le Grand if(pEntry && pEntry->GetName() == rName) 214*c7be74b1SArmin Le Grand { 215*c7be74b1SArmin Le Grand return a; 216cdf0e10cSrcweir } 217*c7be74b1SArmin Le Grand } 218*c7be74b1SArmin Le Grand 219*c7be74b1SArmin Le Grand return -1; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir /************************************************************************* 223cdf0e10cSrcweir |* 224cdf0e10cSrcweir |* Bitmap* XPropertyList::GetBitmap() 225cdf0e10cSrcweir |* 226cdf0e10cSrcweir *************************************************************************/ 227cdf0e10cSrcweir 22897e8a929SArmin Le Grand Bitmap XPropertyList::GetUiBitmap( long nIndex ) const 229cdf0e10cSrcweir { 23097e8a929SArmin Le Grand Bitmap aRetval; 231*c7be74b1SArmin Le Grand XPropertyEntry* pEntry = Get(nIndex); 23297e8a929SArmin Le Grand 23397e8a929SArmin Le Grand if(pEntry) 234cdf0e10cSrcweir { 23597e8a929SArmin Le Grand aRetval = pEntry->GetUiBitmap(); 23697e8a929SArmin Le Grand 23797e8a929SArmin Le Grand if(aRetval.IsEmpty()) 238cdf0e10cSrcweir { 23997e8a929SArmin Le Grand aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex); 24097e8a929SArmin Le Grand pEntry->SetUiBitmap(aRetval); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 24397e8a929SArmin Le Grand 24497e8a929SArmin Le Grand return aRetval; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir /************************************************************************* 248cdf0e10cSrcweir |* 249cdf0e10cSrcweir |* void XPropertyList::Insert() 250cdf0e10cSrcweir |* 251cdf0e10cSrcweir *************************************************************************/ 252cdf0e10cSrcweir 253cdf0e10cSrcweir void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex ) 254cdf0e10cSrcweir { 255*c7be74b1SArmin Le Grand if(pEntry) 256*c7be74b1SArmin Le Grand { 257*c7be74b1SArmin Le Grand if(nIndex >= maContent.size()) 258*c7be74b1SArmin Le Grand { 259*c7be74b1SArmin Le Grand maContent.push_back(pEntry); 260*c7be74b1SArmin Le Grand } 261*c7be74b1SArmin Le Grand else 262*c7be74b1SArmin Le Grand { 263*c7be74b1SArmin Le Grand maContent.insert(maContent.begin() + nIndex, pEntry); 264*c7be74b1SArmin Le Grand } 265*c7be74b1SArmin Le Grand } 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir /************************************************************************* 269cdf0e10cSrcweir |* 270cdf0e10cSrcweir |* void XPropertyList::Replace() 271cdf0e10cSrcweir |* 272cdf0e10cSrcweir *************************************************************************/ 273cdf0e10cSrcweir 274cdf0e10cSrcweir XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex ) 275cdf0e10cSrcweir { 276*c7be74b1SArmin Le Grand XPropertyEntry* pRetval = 0; 277*c7be74b1SArmin Le Grand 278*c7be74b1SArmin Le Grand if(pEntry) 279*c7be74b1SArmin Le Grand { 280*c7be74b1SArmin Le Grand if(nIndex < maContent.size()) 281*c7be74b1SArmin Le Grand { 282*c7be74b1SArmin Le Grand pRetval = maContent[nIndex]; 283*c7be74b1SArmin Le Grand maContent[nIndex] = pEntry; 284*c7be74b1SArmin Le Grand } 285*c7be74b1SArmin Le Grand } 286*c7be74b1SArmin Le Grand 287*c7be74b1SArmin Le Grand return pRetval; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir /************************************************************************* 291cdf0e10cSrcweir |* 292cdf0e10cSrcweir |* void XPropertyList::Remove() 293cdf0e10cSrcweir |* 294cdf0e10cSrcweir *************************************************************************/ 295cdf0e10cSrcweir 296*c7be74b1SArmin Le Grand XPropertyEntry* XPropertyList::Remove( long nIndex ) 297cdf0e10cSrcweir { 298*c7be74b1SArmin Le Grand XPropertyEntry* pRetval = 0; 299*c7be74b1SArmin Le Grand 300*c7be74b1SArmin Le Grand if(nIndex < maContent.size()) 301*c7be74b1SArmin Le Grand { 302*c7be74b1SArmin Le Grand if(nIndex + 1 == maContent.size()) 303*c7be74b1SArmin Le Grand { 304*c7be74b1SArmin Le Grand pRetval = maContent.back(); 305*c7be74b1SArmin Le Grand maContent.pop_back(); 306*c7be74b1SArmin Le Grand } 307*c7be74b1SArmin Le Grand else 308*c7be74b1SArmin Le Grand { 309*c7be74b1SArmin Le Grand pRetval = maContent[nIndex]; 310*c7be74b1SArmin Le Grand maContent.erase(maContent.begin() + nIndex); 311*c7be74b1SArmin Le Grand } 312*c7be74b1SArmin Le Grand } 313*c7be74b1SArmin Le Grand 314*c7be74b1SArmin Le Grand return pRetval; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir /************************************************************************/ 318cdf0e10cSrcweir 319cdf0e10cSrcweir void XPropertyList::SetName( const String& rString ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir if(rString.Len()) 322cdf0e10cSrcweir { 32397e8a929SArmin Le Grand maName = rString; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327*c7be74b1SArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 328*c7be74b1SArmin Le Grand 329*c7be74b1SArmin Le Grand XColorListSharedPtr XPropertyListFactory::CreateSharedXColorList( const String& rPath ) 330*c7be74b1SArmin Le Grand { 331*c7be74b1SArmin Le Grand return XColorListSharedPtr(new XColorList(rPath)); 332*c7be74b1SArmin Le Grand } 333*c7be74b1SArmin Le Grand 334*c7be74b1SArmin Le Grand XLineEndListSharedPtr XPropertyListFactory::CreateSharedXLineEndList( const String& rPath ) 335*c7be74b1SArmin Le Grand { 336*c7be74b1SArmin Le Grand return XLineEndListSharedPtr(new XLineEndList(rPath)); 337*c7be74b1SArmin Le Grand } 338*c7be74b1SArmin Le Grand 339*c7be74b1SArmin Le Grand XDashListSharedPtr XPropertyListFactory::CreateSharedXDashList( const String& rPath ) 340*c7be74b1SArmin Le Grand { 341*c7be74b1SArmin Le Grand return XDashListSharedPtr(new XDashList(rPath)); 342*c7be74b1SArmin Le Grand } 343*c7be74b1SArmin Le Grand 344*c7be74b1SArmin Le Grand XHatchListSharedPtr XPropertyListFactory::CreateSharedXHatchList( const String& rPath ) 345*c7be74b1SArmin Le Grand { 346*c7be74b1SArmin Le Grand return XHatchListSharedPtr(new XHatchList(rPath)); 347*c7be74b1SArmin Le Grand } 348*c7be74b1SArmin Le Grand 349*c7be74b1SArmin Le Grand XGradientListSharedPtr XPropertyListFactory::CreateSharedXGradientList( const String& rPath ) 350*c7be74b1SArmin Le Grand { 351*c7be74b1SArmin Le Grand return XGradientListSharedPtr(new XGradientList(rPath)); 352*c7be74b1SArmin Le Grand } 353*c7be74b1SArmin Le Grand 354*c7be74b1SArmin Le Grand XBitmapListSharedPtr XPropertyListFactory::CreateSharedXBitmapList( const String& rPath ) 355*c7be74b1SArmin Le Grand { 356*c7be74b1SArmin Le Grand return XBitmapListSharedPtr(new XBitmapList(rPath)); 357*c7be74b1SArmin Le Grand } 358*c7be74b1SArmin Le Grand 359*c7be74b1SArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 36097e8a929SArmin Le Grand // eof 361