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