1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef _XTABLE_HXX 23 #define _XTABLE_HXX 24 25 // include --------------------------------------------------------------- 26 27 #include <svx/xpoly.hxx> 28 #include <svx/xdash.hxx> 29 #include <svx/xhatch.hxx> 30 #include <svx/xgrad.hxx> 31 #include <svx/xflasit.hxx> 32 #include <svx/xlnasit.hxx> 33 #include <tools/color.hxx> 34 #include <tools/string.hxx> 35 #include <svx/svxdllapi.h> 36 #include <basegfx/polygon/b2dpolypolygon.hxx> 37 #include <svtools/grfmgr.hxx> 38 #include <svx/XPropertyEntry.hxx> 39 40 class Color; 41 class Bitmap; 42 class VirtualDevice; 43 class SdrModel; 44 class SdrObject; 45 46 // Standard-Vergleichsstring 47 extern sal_Unicode __FAR_DATA pszStandard[]; // "standard" 48 49 // Funktion zum Konvertieren in echte RGB-Farben, da mit 50 // enum COL_NAME nicht verglichen werden kann. 51 SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName ); 52 53 ////////////////////////////////////////////////////////////////////////////// 54 // class XColorEntry 55 56 class XColorEntry : public XPropertyEntry 57 { 58 Color aColor; 59 60 public: 61 XColorEntry(const Color& rColor, const String& rName) : 62 XPropertyEntry(rName), aColor(rColor) {} 63 XColorEntry(const XColorEntry& rOther) : 64 XPropertyEntry(rOther), aColor(rOther.aColor) {} 65 66 void SetColor(const Color& rColor) { aColor = rColor; } 67 const Color& GetColor() const { return aColor; } 68 }; 69 70 ////////////////////////////////////////////////////////////////////////////// 71 // class XLineEndEntry 72 73 class XLineEndEntry : public XPropertyEntry 74 { 75 basegfx::B2DPolyPolygon aB2DPolyPolygon; 76 77 public: 78 XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName) 79 : XPropertyEntry(rName), 80 aB2DPolyPolygon(rB2DPolyPolygon) 81 {} 82 83 XLineEndEntry(const XLineEndEntry& rOther) 84 : XPropertyEntry(rOther), 85 aB2DPolyPolygon(rOther.aB2DPolyPolygon) 86 {} 87 88 void SetLineEnd(const basegfx::B2DPolyPolygon& rB2DPolyPolygon) 89 { 90 aB2DPolyPolygon = rB2DPolyPolygon; 91 } 92 93 const basegfx::B2DPolyPolygon& GetLineEnd() const 94 { 95 return aB2DPolyPolygon; 96 } 97 }; 98 99 ////////////////////////////////////////////////////////////////////////////// 100 // class XDashEntry 101 102 class XDashEntry : public XPropertyEntry 103 { 104 XDash aDash; 105 106 public: 107 XDashEntry(const XDash& rDash, const String& rName) : 108 XPropertyEntry(rName), aDash(rDash) {} 109 XDashEntry(const XDashEntry& rOther) : 110 XPropertyEntry(rOther), aDash(rOther.aDash) {} 111 112 void SetDash(const XDash& rDash) { aDash = rDash; } 113 const XDash& GetDash() const { return aDash; } 114 }; 115 116 ////////////////////////////////////////////////////////////////////////////// 117 // class XHatchEntry 118 119 class XHatchEntry : public XPropertyEntry 120 { 121 XHatch aHatch; 122 123 public: 124 XHatchEntry(const XHatch& rHatch, const String& rName) : 125 XPropertyEntry(rName), aHatch(rHatch) {} 126 XHatchEntry(const XHatchEntry& rOther) : 127 XPropertyEntry(rOther), aHatch(rOther.aHatch) {} 128 129 void SetHatch(const XHatch& rHatch) { aHatch = rHatch; } 130 const XHatch& GetHatch() const { return aHatch; } 131 }; 132 133 ////////////////////////////////////////////////////////////////////////////// 134 // class XGradientEntry 135 136 class XGradientEntry : public XPropertyEntry 137 { 138 XGradient aGradient; 139 140 public: 141 XGradientEntry(const XGradient& rGradient, const String& rName): 142 XPropertyEntry(rName), aGradient(rGradient) {} 143 XGradientEntry(const XGradientEntry& rOther) : 144 XPropertyEntry(rOther), aGradient(rOther.aGradient) {} 145 146 void SetGradient(const XGradient& rGrad) { aGradient = rGrad; } 147 const XGradient& GetGradient() const { return aGradient; } 148 }; 149 150 ////////////////////////////////////////////////////////////////////////////// 151 // class XBitmapEntry 152 153 class XBitmapEntry : public XPropertyEntry 154 { 155 private: 156 GraphicObject maGraphicObject; 157 158 public: 159 XBitmapEntry(const GraphicObject& rGraphicObject, const String& rName) 160 : XPropertyEntry(rName), 161 maGraphicObject(rGraphicObject) 162 { 163 } 164 165 XBitmapEntry(const XBitmapEntry& rOther) 166 : XPropertyEntry(rOther), 167 maGraphicObject(rOther.maGraphicObject) 168 { 169 } 170 171 const GraphicObject& GetGraphicObject() const 172 { 173 return maGraphicObject; 174 } 175 176 void SetGraphicObject(const GraphicObject& rGraphicObject) 177 { 178 maGraphicObject = rGraphicObject; 179 } 180 }; 181 182 ////////////////////////////////////////////////////////////////////////////// 183 // helper class for UI visualization previews 184 185 class sharedModelAndVDev 186 { 187 private: 188 sal_uInt32 mnUseCount; 189 VirtualDevice* mpVirtualDevice; 190 SdrModel* mpSdrModel; 191 192 public: 193 sharedModelAndVDev(); 194 ~sharedModelAndVDev(); 195 196 void increaseUseCount(); 197 bool decreaseUseCount(); 198 199 SdrModel& getSharedSdrModel(); 200 VirtualDevice& getSharedVirtualDevice(); 201 }; 202 203 ////////////////////////////////////////////////////////////////////////////// 204 // class XPropertyList 205 206 class SVX_DLLPUBLIC XPropertyList 207 { 208 protected: 209 static sharedModelAndVDev* pGlobalsharedModelAndVDev; 210 211 String maName; // nicht persistent ! 212 String maPath; 213 214 ::std::vector< XPropertyEntry* > maContent; 215 216 /// bitfield 217 bool mbListDirty : 1; 218 219 XPropertyList( const String& rPath ); 220 void Clear(); 221 virtual Bitmap CreateBitmapForUI( long nIndex ) = 0; 222 223 public: 224 virtual ~XPropertyList(); 225 226 long Count() const; 227 228 void Insert( XPropertyEntry* pEntry, long nIndex = LIST_APPEND ); 229 XPropertyEntry* Replace( XPropertyEntry* pEntry, long nIndex ); 230 XPropertyEntry* Remove( long nIndex ); 231 XPropertyEntry* Get( long nIndex ) const; 232 233 long GetIndex(const String& rName) const; 234 Bitmap GetUiBitmap( long nIndex ) const; 235 236 const String& GetName() const { return maName; } 237 void SetName( const String& rString ); 238 const String& GetPath() const { return maPath; } 239 void SetPath( const String& rString ) { maPath = rString; } 240 bool IsDirty() const { return mbListDirty; } 241 void SetDirty( bool bDirty = true ) { mbListDirty = bDirty; } 242 243 virtual sal_Bool Load() = 0; 244 virtual sal_Bool Save() = 0; 245 virtual sal_Bool Create() = 0; 246 }; 247 248 ////////////////////////////////////////////////////////////////////////////// 249 // predefines for XList classes and the SharedPtr typedefs for these to have 250 // them in a central place for better overview 251 252 class XColorList; 253 class XLineEndList; 254 class XDashList; 255 class XHatchList; 256 class XGradientList; 257 class XBitmapList; 258 259 typedef ::boost::shared_ptr< XColorList > XColorListSharedPtr; 260 typedef ::boost::shared_ptr< XLineEndList > XLineEndListSharedPtr; 261 typedef ::boost::shared_ptr< XDashList > XDashListSharedPtr; 262 typedef ::boost::shared_ptr< XHatchList > XHatchListSharedPtr; 263 typedef ::boost::shared_ptr< XGradientList > XGradientListSharedPtr; 264 typedef ::boost::shared_ptr< XBitmapList > XBitmapListSharedPtr; 265 266 ////////////////////////////////////////////////////////////////////////////// 267 // XPropertyListFactory to limit XListSharedPtr creation and thus XPropertyList creation 268 // to this factory, so noone can instantiate a non-shared instace of XPropertyList 269 // or it's derivates 270 271 class SVX_DLLPUBLIC XPropertyListFactory 272 { 273 public: 274 static XColorListSharedPtr CreateSharedXColorList( const String& rPath ); 275 static XLineEndListSharedPtr CreateSharedXLineEndList( const String& rPath ); 276 static XDashListSharedPtr CreateSharedXDashList( const String& rPath ); 277 static XHatchListSharedPtr CreateSharedXHatchList( const String& rPath ); 278 static XGradientListSharedPtr CreateSharedXGradientList( const String& rPath ); 279 static XBitmapListSharedPtr CreateSharedXBitmapList( const String& rPath ); 280 }; 281 282 ////////////////////////////////////////////////////////////////////////////// 283 // class XColorList 284 285 class SVX_DLLPUBLIC XColorList : public XPropertyList 286 { 287 private: 288 friend class XPropertyListFactory; 289 XColorList( const String& rPath ); 290 291 protected: 292 virtual Bitmap CreateBitmapForUI( long nIndex ); 293 294 public: 295 virtual ~XColorList(); 296 297 using XPropertyList::Replace; 298 XColorEntry* Replace(XColorEntry* pEntry, long nIndex ); 299 using XPropertyList::Remove; 300 XColorEntry* Remove(long nIndex); 301 XColorEntry* GetColor(long nIndex) const; 302 303 virtual sal_Bool Load(); 304 virtual sal_Bool Save(); 305 virtual sal_Bool Create(); 306 307 static XColorListSharedPtr GetStdColorList(); 308 }; 309 310 ////////////////////////////////////////////////////////////////////////////// 311 // class XLineEndList 312 313 class SVX_DLLPUBLIC XLineEndList : public XPropertyList 314 { 315 private: 316 friend class XPropertyListFactory; 317 XLineEndList(const String& rPath ); 318 319 SdrObject* mpBackgroundObject; 320 SdrObject* mpLineObject; 321 322 protected: 323 virtual Bitmap CreateBitmapForUI(long nIndex); 324 325 public: 326 virtual ~XLineEndList(); 327 328 using XPropertyList::Replace; 329 XLineEndEntry* Replace(XLineEndEntry* pEntry, long nIndex); 330 using XPropertyList::Remove; 331 XLineEndEntry* Remove(long nIndex); 332 XLineEndEntry* GetLineEnd(long nIndex) const; 333 334 virtual sal_Bool Load(); 335 virtual sal_Bool Save(); 336 virtual sal_Bool Create(); 337 }; 338 339 ////////////////////////////////////////////////////////////////////////////// 340 // class XDashList 341 342 class SVX_DLLPUBLIC XDashList : public XPropertyList 343 { 344 private: 345 friend class XPropertyListFactory; 346 XDashList(const String& rPath ); 347 348 SdrObject* mpBackgroundObject; 349 SdrObject* mpLineObject; 350 Bitmap maBitmapSolidLine; 351 String maStringSolidLine; 352 String maStringNoLine; 353 354 protected: 355 Bitmap ImpCreateBitmapForXDash(const XDash* pDash); 356 virtual Bitmap CreateBitmapForUI(long nIndex); 357 358 public: 359 virtual ~XDashList(); 360 361 using XPropertyList::Replace; 362 XDashEntry* Replace(XDashEntry* pEntry, long nIndex); 363 using XPropertyList::Remove; 364 XDashEntry* Remove(long nIndex); 365 XDashEntry* GetDash(long nIndex) const; 366 367 virtual sal_Bool Load(); 368 virtual sal_Bool Save(); 369 virtual sal_Bool Create(); 370 371 // Special call to get a bitmap for the solid line representation. It 372 // creates a bitmap fitting in size and style to the ones you get by 373 // using GetUiBitmap for existing entries. 374 Bitmap GetBitmapForUISolidLine() const; 375 376 // Special calls to get the translated strings for the UI entry for no 377 // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs 378 String GetStringForUiSolidLine() const; 379 String GetStringForUiNoLine() const; 380 }; 381 382 ////////////////////////////////////////////////////////////////////////////// 383 // class XHatchList 384 385 class SVX_DLLPUBLIC XHatchList : public XPropertyList 386 { 387 private: 388 friend class XPropertyListFactory; 389 XHatchList(const String& rPath ); 390 391 SdrObject* mpBackgroundObject; 392 SdrObject* mpHatchObject; 393 394 protected: 395 virtual Bitmap CreateBitmapForUI(long nIndex); 396 397 public: 398 ~XHatchList(); 399 400 using XPropertyList::Replace; 401 XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex); 402 using XPropertyList::Remove; 403 XHatchEntry* Remove(long nIndex); 404 XHatchEntry* GetHatch(long nIndex) const; 405 406 virtual sal_Bool Load(); 407 virtual sal_Bool Save(); 408 virtual sal_Bool Create(); 409 }; 410 411 ////////////////////////////////////////////////////////////////////////////// 412 // class XGradientList 413 414 class SVX_DLLPUBLIC XGradientList : public XPropertyList 415 { 416 private: 417 friend class XPropertyListFactory; 418 XGradientList(const String& rPath ); 419 420 SdrObject* mpBackgroundObject; 421 422 protected: 423 virtual Bitmap CreateBitmapForUI(long nIndex); 424 425 public: 426 virtual ~XGradientList(); 427 428 using XPropertyList::Replace; 429 XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex); 430 using XPropertyList::Remove; 431 XGradientEntry* Remove(long nIndex); 432 XGradientEntry* GetGradient(long nIndex) const; 433 434 virtual sal_Bool Load(); 435 virtual sal_Bool Save(); 436 virtual sal_Bool Create(); 437 }; 438 439 ////////////////////////////////////////////////////////////////////////////// 440 // class XBitmapList 441 442 class SVX_DLLPUBLIC XBitmapList : public XPropertyList 443 { 444 private: 445 friend class XPropertyListFactory; 446 XBitmapList( const String& rPath ); 447 448 protected: 449 virtual Bitmap CreateBitmapForUI( long nIndex ); 450 451 public: 452 virtual ~XBitmapList(); 453 454 using XPropertyList::Replace; 455 XBitmapEntry* Replace(XBitmapEntry* pEntry, long nIndex ); 456 using XPropertyList::Remove; 457 XBitmapEntry* Remove(long nIndex); 458 XBitmapEntry* GetBitmap(long nIndex) const; 459 460 virtual sal_Bool Load(); 461 virtual sal_Bool Save(); 462 virtual sal_Bool Create(); 463 }; 464 465 ////////////////////////////////////////////////////////////////////////////// 466 467 #endif // _XTABLE_HXX 468 469 ////////////////////////////////////////////////////////////////////////////// 470 // eof 471