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(); 83085702f6SArmin Le Grand mpSdrModel->SetAutomaticXPropertyListCreation(false); 84c7be74b1SArmin Le Grand } 85c7be74b1SArmin Le Grand 86c7be74b1SArmin Le Grand return *mpSdrModel; 87c7be74b1SArmin Le Grand } 88c7be74b1SArmin Le Grand 89c7be74b1SArmin Le Grand VirtualDevice& sharedModelAndVDev::getSharedVirtualDevice() 90c7be74b1SArmin Le Grand { 91c7be74b1SArmin Le Grand if(!mpVirtualDevice) 92c7be74b1SArmin Le Grand { 93c7be74b1SArmin Le Grand mpVirtualDevice = new VirtualDevice; 94c7be74b1SArmin Le Grand OSL_ENSURE(0 != mpVirtualDevice, "XPropertyList sharedModelAndVDev: no VirtualDevice created!" ); 95c7be74b1SArmin Le Grand mpVirtualDevice->SetMapMode(MAP_100TH_MM); 96c7be74b1SArmin Le Grand } 97c7be74b1SArmin Le Grand 98c7be74b1SArmin Le Grand return *mpVirtualDevice; 99c7be74b1SArmin Le Grand } 100c7be74b1SArmin Le Grand 101c7be74b1SArmin Le Grand sharedModelAndVDev* XPropertyList::pGlobalsharedModelAndVDev = 0; 102c7be74b1SArmin Le Grand 103cdf0e10cSrcweir // -------------------- 104cdf0e10cSrcweir // class XPropertyList 105cdf0e10cSrcweir // -------------------- 106cdf0e10cSrcweir 107c7be74b1SArmin Le Grand XPropertyList::XPropertyList( const String& rPath ) : 10897e8a929SArmin Le Grand maName ( pszStandard, 8 ), 10997e8a929SArmin Le Grand maPath ( rPath ), 110c7be74b1SArmin Le Grand maContent(), 11197e8a929SArmin Le Grand mbListDirty (true) 112cdf0e10cSrcweir { 113c7be74b1SArmin Le Grand if(!pGlobalsharedModelAndVDev) 114cdf0e10cSrcweir { 115c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev = new sharedModelAndVDev(); 116cdf0e10cSrcweir } 117c7be74b1SArmin Le Grand 118c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev->increaseUseCount(); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir /************************************************************************* 122cdf0e10cSrcweir |* 123cdf0e10cSrcweir |* XPropertyList::~XPropertyList() 124cdf0e10cSrcweir |* 125cdf0e10cSrcweir *************************************************************************/ 126cdf0e10cSrcweir 127cdf0e10cSrcweir XPropertyList::~XPropertyList() 128cdf0e10cSrcweir { 129c7be74b1SArmin Le Grand while(!maContent.empty()) 130cdf0e10cSrcweir { 131c7be74b1SArmin Le Grand delete maContent.back(); 132c7be74b1SArmin Le Grand maContent.pop_back(); 133c7be74b1SArmin Le Grand } 134c7be74b1SArmin Le Grand 135c7be74b1SArmin Le Grand if(pGlobalsharedModelAndVDev && pGlobalsharedModelAndVDev->decreaseUseCount()) 136c7be74b1SArmin Le Grand { 137c7be74b1SArmin Le Grand delete pGlobalsharedModelAndVDev; 138c7be74b1SArmin Le Grand pGlobalsharedModelAndVDev = 0; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir /************************************************************************* 143cdf0e10cSrcweir |* 144cdf0e10cSrcweir |* XPropertyList::Clear() 145cdf0e10cSrcweir |* 146cdf0e10cSrcweir *************************************************************************/ 147cdf0e10cSrcweir 148cdf0e10cSrcweir void XPropertyList::Clear() 149cdf0e10cSrcweir { 150c7be74b1SArmin Le Grand while(!maContent.empty()) 151c7be74b1SArmin Le Grand { 152c7be74b1SArmin Le Grand delete maContent.back(); 153c7be74b1SArmin Le Grand maContent.pop_back(); 154c7be74b1SArmin Le Grand } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir /************************************************************************/ 158cdf0e10cSrcweir 159cdf0e10cSrcweir long XPropertyList::Count() const 160cdf0e10cSrcweir { 16197e8a929SArmin Le Grand if( mbListDirty ) 162cdf0e10cSrcweir { 1636e1a87e1SArmin Le Grand if(!const_cast< XPropertyList* >(this)->Load()) 1646e1a87e1SArmin Le Grand { 1656e1a87e1SArmin Le Grand const_cast< XPropertyList* >(this)->Create(); 1666e1a87e1SArmin Le Grand } 167cdf0e10cSrcweir } 168c7be74b1SArmin Le Grand 169c7be74b1SArmin Le Grand return maContent.size(); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir /************************************************************************* 173cdf0e10cSrcweir |* 174cdf0e10cSrcweir |* XPropertyEntry* XPropertyList::Get() 175cdf0e10cSrcweir |* 176cdf0e10cSrcweir *************************************************************************/ 177cdf0e10cSrcweir 178c7be74b1SArmin Le Grand XPropertyEntry* XPropertyList::Get( long nIndex ) const 179cdf0e10cSrcweir { 18097e8a929SArmin Le Grand if( mbListDirty ) 181cdf0e10cSrcweir { 1826e1a87e1SArmin Le Grand if(!const_cast< XPropertyList* >(this)->Load()) 1836e1a87e1SArmin Le Grand { 1846e1a87e1SArmin Le Grand const_cast< XPropertyList* >(this)->Create(); 1856e1a87e1SArmin Le Grand } 186cdf0e10cSrcweir } 187c7be74b1SArmin Le Grand 1886e1a87e1SArmin Le Grand const long nObjectCount(maContent.size()); 1896e1a87e1SArmin Le Grand 1906e1a87e1SArmin Le Grand if(nIndex >= nObjectCount) 191c7be74b1SArmin Le Grand { 192c7be74b1SArmin Le Grand return 0; 193c7be74b1SArmin Le Grand } 194c7be74b1SArmin Le Grand 195c7be74b1SArmin Le Grand return maContent[nIndex]; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir /************************************************************************* 199cdf0e10cSrcweir |* 200cdf0e10cSrcweir |* XPropertyList::Get() 201cdf0e10cSrcweir |* 202cdf0e10cSrcweir *************************************************************************/ 203cdf0e10cSrcweir 204c7be74b1SArmin Le Grand long XPropertyList::GetIndex(const XubString& rName) const 205cdf0e10cSrcweir { 20697e8a929SArmin Le Grand if( mbListDirty ) 207cdf0e10cSrcweir { 2086e1a87e1SArmin Le Grand if(!const_cast< XPropertyList* >(this)->Load()) 2096e1a87e1SArmin Le Grand { 2106e1a87e1SArmin Le Grand const_cast< XPropertyList* >(this)->Create(); 2116e1a87e1SArmin Le Grand } 212cdf0e10cSrcweir } 213c7be74b1SArmin Le Grand 214c7be74b1SArmin Le Grand ::std::vector< XPropertyEntry* >::const_iterator aStart(maContent.begin()); 215c7be74b1SArmin Le Grand const ::std::vector< XPropertyEntry* >::const_iterator aEnd(maContent.end()); 216c7be74b1SArmin Le Grand 217c7be74b1SArmin Le Grand for(long a(0); aStart != aEnd; a++, aStart++) 218cdf0e10cSrcweir { 219c7be74b1SArmin Le Grand const XPropertyEntry* pEntry = *aStart; 220c7be74b1SArmin Le Grand 221c7be74b1SArmin Le Grand if(pEntry && pEntry->GetName() == rName) 222c7be74b1SArmin Le Grand { 223c7be74b1SArmin Le Grand return a; 224cdf0e10cSrcweir } 225c7be74b1SArmin Le Grand } 226c7be74b1SArmin Le Grand 227c7be74b1SArmin Le Grand return -1; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir /************************************************************************* 231cdf0e10cSrcweir |* 232cdf0e10cSrcweir |* Bitmap* XPropertyList::GetBitmap() 233cdf0e10cSrcweir |* 234cdf0e10cSrcweir *************************************************************************/ 235cdf0e10cSrcweir 23697e8a929SArmin Le Grand Bitmap XPropertyList::GetUiBitmap( long nIndex ) const 237cdf0e10cSrcweir { 23897e8a929SArmin Le Grand Bitmap aRetval; 239c7be74b1SArmin Le Grand XPropertyEntry* pEntry = Get(nIndex); 24097e8a929SArmin Le Grand 24197e8a929SArmin Le Grand if(pEntry) 242cdf0e10cSrcweir { 24397e8a929SArmin Le Grand aRetval = pEntry->GetUiBitmap(); 24497e8a929SArmin Le Grand 24597e8a929SArmin Le Grand if(aRetval.IsEmpty()) 246cdf0e10cSrcweir { 24797e8a929SArmin Le Grand aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex); 24897e8a929SArmin Le Grand pEntry->SetUiBitmap(aRetval); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 25197e8a929SArmin Le Grand 25297e8a929SArmin Le Grand return aRetval; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir /************************************************************************* 256cdf0e10cSrcweir |* 257cdf0e10cSrcweir |* void XPropertyList::Insert() 258cdf0e10cSrcweir |* 259cdf0e10cSrcweir *************************************************************************/ 260cdf0e10cSrcweir 261cdf0e10cSrcweir void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex ) 262cdf0e10cSrcweir { 263c7be74b1SArmin Le Grand if(pEntry) 264c7be74b1SArmin Le Grand { 2656e1a87e1SArmin Le Grand const long nObjectCount(maContent.size()); 2666e1a87e1SArmin Le Grand 267*67abfbd7SPavel Janík if(static_cast<long>(LIST_APPEND) == nIndex || nIndex >= nObjectCount) 268c7be74b1SArmin Le Grand { 269c7be74b1SArmin Le Grand maContent.push_back(pEntry); 270c7be74b1SArmin Le Grand } 271c7be74b1SArmin Le Grand else 272c7be74b1SArmin Le Grand { 273c7be74b1SArmin Le Grand maContent.insert(maContent.begin() + nIndex, pEntry); 274c7be74b1SArmin Le Grand } 275c7be74b1SArmin Le Grand } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir /************************************************************************* 279cdf0e10cSrcweir |* 280cdf0e10cSrcweir |* void XPropertyList::Replace() 281cdf0e10cSrcweir |* 282cdf0e10cSrcweir *************************************************************************/ 283cdf0e10cSrcweir 284cdf0e10cSrcweir XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex ) 285cdf0e10cSrcweir { 286c7be74b1SArmin Le Grand XPropertyEntry* pRetval = 0; 287c7be74b1SArmin Le Grand 288c7be74b1SArmin Le Grand if(pEntry) 289c7be74b1SArmin Le Grand { 2906e1a87e1SArmin Le Grand const long nObjectCount(maContent.size()); 2916e1a87e1SArmin Le Grand 2926e1a87e1SArmin Le Grand if(nIndex < nObjectCount) 293c7be74b1SArmin Le Grand { 294c7be74b1SArmin Le Grand pRetval = maContent[nIndex]; 295c7be74b1SArmin Le Grand maContent[nIndex] = pEntry; 296c7be74b1SArmin Le Grand } 297c7be74b1SArmin Le Grand } 298c7be74b1SArmin Le Grand 299c7be74b1SArmin Le Grand return pRetval; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir /************************************************************************* 303cdf0e10cSrcweir |* 304cdf0e10cSrcweir |* void XPropertyList::Remove() 305cdf0e10cSrcweir |* 306cdf0e10cSrcweir *************************************************************************/ 307cdf0e10cSrcweir 308c7be74b1SArmin Le Grand XPropertyEntry* XPropertyList::Remove( long nIndex ) 309cdf0e10cSrcweir { 310c7be74b1SArmin Le Grand XPropertyEntry* pRetval = 0; 3116e1a87e1SArmin Le Grand const long nObjectCount(maContent.size()); 312c7be74b1SArmin Le Grand 3136e1a87e1SArmin Le Grand if(nIndex < nObjectCount) 314c7be74b1SArmin Le Grand { 3156e1a87e1SArmin Le Grand if(nIndex + 1 == nObjectCount) 316c7be74b1SArmin Le Grand { 317c7be74b1SArmin Le Grand pRetval = maContent.back(); 318c7be74b1SArmin Le Grand maContent.pop_back(); 319c7be74b1SArmin Le Grand } 320c7be74b1SArmin Le Grand else 321c7be74b1SArmin Le Grand { 322c7be74b1SArmin Le Grand pRetval = maContent[nIndex]; 323c7be74b1SArmin Le Grand maContent.erase(maContent.begin() + nIndex); 324c7be74b1SArmin Le Grand } 325c7be74b1SArmin Le Grand } 326c7be74b1SArmin Le Grand 327c7be74b1SArmin Le Grand return pRetval; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir /************************************************************************/ 331cdf0e10cSrcweir 332cdf0e10cSrcweir void XPropertyList::SetName( const String& rString ) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir if(rString.Len()) 335cdf0e10cSrcweir { 33697e8a929SArmin Le Grand maName = rString; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir } 339cdf0e10cSrcweir 340c7be74b1SArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 341c7be74b1SArmin Le Grand 342c7be74b1SArmin Le Grand XColorListSharedPtr XPropertyListFactory::CreateSharedXColorList( const String& rPath ) 343c7be74b1SArmin Le Grand { 344c7be74b1SArmin Le Grand return XColorListSharedPtr(new XColorList(rPath)); 345c7be74b1SArmin Le Grand } 346c7be74b1SArmin Le Grand 347c7be74b1SArmin Le Grand XLineEndListSharedPtr XPropertyListFactory::CreateSharedXLineEndList( const String& rPath ) 348c7be74b1SArmin Le Grand { 349c7be74b1SArmin Le Grand return XLineEndListSharedPtr(new XLineEndList(rPath)); 350c7be74b1SArmin Le Grand } 351c7be74b1SArmin Le Grand 352c7be74b1SArmin Le Grand XDashListSharedPtr XPropertyListFactory::CreateSharedXDashList( const String& rPath ) 353c7be74b1SArmin Le Grand { 354c7be74b1SArmin Le Grand return XDashListSharedPtr(new XDashList(rPath)); 355c7be74b1SArmin Le Grand } 356c7be74b1SArmin Le Grand 357c7be74b1SArmin Le Grand XHatchListSharedPtr XPropertyListFactory::CreateSharedXHatchList( const String& rPath ) 358c7be74b1SArmin Le Grand { 359c7be74b1SArmin Le Grand return XHatchListSharedPtr(new XHatchList(rPath)); 360c7be74b1SArmin Le Grand } 361c7be74b1SArmin Le Grand 362c7be74b1SArmin Le Grand XGradientListSharedPtr XPropertyListFactory::CreateSharedXGradientList( const String& rPath ) 363c7be74b1SArmin Le Grand { 364c7be74b1SArmin Le Grand return XGradientListSharedPtr(new XGradientList(rPath)); 365c7be74b1SArmin Le Grand } 366c7be74b1SArmin Le Grand 367c7be74b1SArmin Le Grand XBitmapListSharedPtr XPropertyListFactory::CreateSharedXBitmapList( const String& rPath ) 368c7be74b1SArmin Le Grand { 369c7be74b1SArmin Le Grand return XBitmapListSharedPtr(new XBitmapList(rPath)); 370c7be74b1SArmin Le Grand } 371c7be74b1SArmin Le Grand 372c7be74b1SArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 37397e8a929SArmin Le Grand // eof 374