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 #include <svx/xpoly.hxx> 27 #include <svx/xdash.hxx> 28 #include <svx/xhatch.hxx> 29 #include <svx/xgrad.hxx> 30 #include <svtools/grfmgr.hxx> 31 #include <svx/XPropertyEntry.hxx> 32 #include <vcl/bitmap.hxx> 33 34 // Standard-Vergleichsstring 35 extern sal_Unicode __FAR_DATA pszStandard[]; // "standard" 36 37 // Funktion zum Konvertieren in echte RGB-Farben, da mit 38 // enum COL_NAME nicht verglichen werden kann. 39 SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName ); 40 41 ////////////////////////////////////////////////////////////////////////////// 42 // class XColorEntry 43 44 class XColorEntry : public XPropertyEntry 45 { 46 Color aColor; 47 48 public: 49 XColorEntry(const Color& rColor, const String& rName) : 50 XPropertyEntry(rName), aColor(rColor) {} 51 XColorEntry(const XColorEntry& rOther) : 52 XPropertyEntry(rOther), aColor(rOther.aColor) {} 53 54 void SetColor(const Color& rColor) { aColor = rColor; } 55 const Color& GetColor() const { return aColor; } 56 }; 57 58 ////////////////////////////////////////////////////////////////////////////// 59 // class XLineEndEntry 60 61 class XLineEndEntry : public XPropertyEntry 62 { 63 basegfx::B2DPolyPolygon aB2DPolyPolygon; 64 65 public: 66 XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName) 67 : XPropertyEntry(rName), 68 aB2DPolyPolygon(rB2DPolyPolygon) 69 {} 70 71 XLineEndEntry(const XLineEndEntry& rOther) 72 : XPropertyEntry(rOther), 73 aB2DPolyPolygon(rOther.aB2DPolyPolygon) 74 {} 75 76 void SetLineEnd(const basegfx::B2DPolyPolygon& rB2DPolyPolygon) 77 { 78 aB2DPolyPolygon = rB2DPolyPolygon; 79 } 80 81 const basegfx::B2DPolyPolygon& GetLineEnd() const 82 { 83 return aB2DPolyPolygon; 84 } 85 }; 86 87 ////////////////////////////////////////////////////////////////////////////// 88 // class XDashEntry 89 90 class XDashEntry : public XPropertyEntry 91 { 92 XDash aDash; 93 94 public: 95 XDashEntry(const XDash& rDash, const String& rName) : 96 XPropertyEntry(rName), aDash(rDash) {} 97 XDashEntry(const XDashEntry& rOther) : 98 XPropertyEntry(rOther), aDash(rOther.aDash) {} 99 100 void SetDash(const XDash& rDash) { aDash = rDash; } 101 const XDash& GetDash() const { return aDash; } 102 }; 103 104 ////////////////////////////////////////////////////////////////////////////// 105 // class XHatchEntry 106 107 class XHatchEntry : public XPropertyEntry 108 { 109 XHatch aHatch; 110 111 public: 112 XHatchEntry(const XHatch& rHatch, const String& rName) : 113 XPropertyEntry(rName), aHatch(rHatch) {} 114 XHatchEntry(const XHatchEntry& rOther) : 115 XPropertyEntry(rOther), aHatch(rOther.aHatch) {} 116 117 void SetHatch(const XHatch& rHatch) { aHatch = rHatch; } 118 const XHatch& GetHatch() const { return aHatch; } 119 }; 120 121 ////////////////////////////////////////////////////////////////////////////// 122 // class XGradientEntry 123 124 class XGradientEntry : public XPropertyEntry 125 { 126 XGradient aGradient; 127 128 public: 129 XGradientEntry(const XGradient& rGradient, const String& rName): 130 XPropertyEntry(rName), aGradient(rGradient) {} 131 XGradientEntry(const XGradientEntry& rOther) : 132 XPropertyEntry(rOther), aGradient(rOther.aGradient) {} 133 134 void SetGradient(const XGradient& rGrad) { aGradient = rGrad; } 135 const XGradient& GetGradient() const { return aGradient; } 136 }; 137 138 ////////////////////////////////////////////////////////////////////////////// 139 // class XBitmapEntry 140 141 class XBitmapEntry : public XPropertyEntry 142 { 143 private: 144 GraphicObject maGraphicObject; 145 146 public: 147 XBitmapEntry(const GraphicObject& rGraphicObject, const String& rName) 148 : XPropertyEntry(rName), 149 maGraphicObject(rGraphicObject) 150 { 151 } 152 153 XBitmapEntry(const XBitmapEntry& rOther) 154 : XPropertyEntry(rOther), 155 maGraphicObject(rOther.maGraphicObject) 156 { 157 } 158 159 const GraphicObject& GetGraphicObject() const 160 { 161 return maGraphicObject; 162 } 163 164 void SetGraphicObject(const GraphicObject& rGraphicObject) 165 { 166 maGraphicObject = rGraphicObject; 167 } 168 }; 169 170 ////////////////////////////////////////////////////////////////////////////// 171 // class XPropertyList 172 173 class SVX_DLLPUBLIC XPropertyList 174 { 175 protected: 176 String maName; // nicht persistent ! 177 String maPath; 178 179 ::std::vector< XPropertyEntry* > maContent; 180 181 /// bitfield 182 bool mbListDirty : 1; 183 184 XPropertyList( const String& rPath ); 185 void Clear(); 186 virtual Bitmap CreateBitmapForUI( long nIndex ) = 0; 187 188 public: 189 virtual ~XPropertyList(); 190 191 long Count() const; 192 193 void Insert( XPropertyEntry* pEntry, long nIndex = LIST_APPEND ); 194 XPropertyEntry* Replace( XPropertyEntry* pEntry, long nIndex ); 195 XPropertyEntry* Remove( long nIndex ); 196 XPropertyEntry* Get( long nIndex ) const; 197 198 long GetIndex(const String& rName) const; 199 Bitmap GetUiBitmap( long nIndex ) const; 200 201 const String& GetName() const { return maName; } 202 void SetName( const String& rString ); 203 const String& GetPath() const { return maPath; } 204 void SetPath( const String& rString ) { maPath = rString; } 205 bool IsDirty() const { return mbListDirty; } 206 void SetDirty( bool bDirty = true ) { mbListDirty = bDirty; } 207 208 virtual sal_Bool Load() = 0; 209 virtual sal_Bool Save() = 0; 210 virtual sal_Bool Create() = 0; 211 }; 212 213 ////////////////////////////////////////////////////////////////////////////// 214 // predefines for XList classes and the SharedPtr typedefs for these to have 215 // them in a central place for better overview 216 217 class XColorList; 218 class XLineEndList; 219 class XDashList; 220 class XHatchList; 221 class XGradientList; 222 class XBitmapList; 223 224 typedef ::boost::shared_ptr< XColorList > XColorListSharedPtr; 225 typedef ::boost::shared_ptr< XLineEndList > XLineEndListSharedPtr; 226 typedef ::boost::shared_ptr< XDashList > XDashListSharedPtr; 227 typedef ::boost::shared_ptr< XHatchList > XHatchListSharedPtr; 228 typedef ::boost::shared_ptr< XGradientList > XGradientListSharedPtr; 229 typedef ::boost::shared_ptr< XBitmapList > XBitmapListSharedPtr; 230 231 ////////////////////////////////////////////////////////////////////////////// 232 // XPropertyListFactory to limit XListSharedPtr creation and thus XPropertyList creation 233 // to this factory, so noone can instantiate a non-shared instace of XPropertyList 234 // or it's derivates 235 236 class SVX_DLLPUBLIC XPropertyListFactory 237 { 238 public: 239 static XColorListSharedPtr CreateSharedXColorList( const String& rPath ); 240 static XLineEndListSharedPtr CreateSharedXLineEndList( const String& rPath ); 241 static XDashListSharedPtr CreateSharedXDashList( const String& rPath ); 242 static XHatchListSharedPtr CreateSharedXHatchList( const String& rPath ); 243 static XGradientListSharedPtr CreateSharedXGradientList( const String& rPath ); 244 static XBitmapListSharedPtr CreateSharedXBitmapList( const String& rPath ); 245 }; 246 247 ////////////////////////////////////////////////////////////////////////////// 248 // class XColorList 249 250 class SVX_DLLPUBLIC XColorList : public XPropertyList 251 { 252 private: 253 friend class XPropertyListFactory; 254 XColorList( const String& rPath ); 255 256 protected: 257 virtual Bitmap CreateBitmapForUI( long nIndex ); 258 259 public: 260 virtual ~XColorList(); 261 262 using XPropertyList::Replace; 263 XColorEntry* Replace(XColorEntry* pEntry, long nIndex ); 264 using XPropertyList::Remove; 265 XColorEntry* Remove(long nIndex); 266 XColorEntry* GetColor(long nIndex) const; 267 268 virtual sal_Bool Load(); 269 virtual sal_Bool Save(); 270 virtual sal_Bool Create(); 271 272 static XColorListSharedPtr GetStdColorList(); 273 }; 274 275 ////////////////////////////////////////////////////////////////////////////// 276 // class XLineEndList 277 278 class SVX_DLLPUBLIC XLineEndList : public XPropertyList 279 { 280 private: 281 friend class XPropertyListFactory; 282 XLineEndList(const String& rPath ); 283 284 protected: 285 virtual Bitmap CreateBitmapForUI(long nIndex); 286 287 public: 288 virtual ~XLineEndList(); 289 290 using XPropertyList::Replace; 291 XLineEndEntry* Replace(XLineEndEntry* pEntry, long nIndex); 292 using XPropertyList::Remove; 293 XLineEndEntry* Remove(long nIndex); 294 XLineEndEntry* GetLineEnd(long nIndex) const; 295 296 virtual sal_Bool Load(); 297 virtual sal_Bool Save(); 298 virtual sal_Bool Create(); 299 }; 300 301 ////////////////////////////////////////////////////////////////////////////// 302 // class XDashList 303 304 class SVX_DLLPUBLIC XDashList : public XPropertyList 305 { 306 private: 307 friend class XPropertyListFactory; 308 XDashList(const String& rPath ); 309 310 Bitmap maBitmapSolidLine; 311 String maStringSolidLine; 312 String maStringNoLine; 313 314 protected: 315 Bitmap ImpCreateBitmapForXDash(const XDash* pDash); 316 virtual Bitmap CreateBitmapForUI(long nIndex); 317 318 public: 319 virtual ~XDashList(); 320 321 using XPropertyList::Replace; 322 XDashEntry* Replace(XDashEntry* pEntry, long nIndex); 323 using XPropertyList::Remove; 324 XDashEntry* Remove(long nIndex); 325 XDashEntry* GetDash(long nIndex) const; 326 327 virtual sal_Bool Load(); 328 virtual sal_Bool Save(); 329 virtual sal_Bool Create(); 330 331 // Special call to get a bitmap for the solid line representation. It 332 // creates a bitmap fitting in size and style to the ones you get by 333 // using GetUiBitmap for existing entries. 334 Bitmap GetBitmapForUISolidLine() const; 335 336 // Special calls to get the translated strings for the UI entry for no 337 // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs 338 String GetStringForUiSolidLine() const; 339 String GetStringForUiNoLine() const; 340 }; 341 342 ////////////////////////////////////////////////////////////////////////////// 343 // class XHatchList 344 345 class SVX_DLLPUBLIC XHatchList : public XPropertyList 346 { 347 private: 348 friend class XPropertyListFactory; 349 XHatchList(const String& rPath ); 350 351 protected: 352 virtual Bitmap CreateBitmapForUI(long nIndex); 353 354 public: 355 ~XHatchList(); 356 357 using XPropertyList::Replace; 358 XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex); 359 using XPropertyList::Remove; 360 XHatchEntry* Remove(long nIndex); 361 XHatchEntry* GetHatch(long nIndex) const; 362 363 virtual sal_Bool Load(); 364 virtual sal_Bool Save(); 365 virtual sal_Bool Create(); 366 }; 367 368 ////////////////////////////////////////////////////////////////////////////// 369 // class XGradientList 370 371 class SVX_DLLPUBLIC XGradientList : public XPropertyList 372 { 373 private: 374 friend class XPropertyListFactory; 375 XGradientList(const String& rPath ); 376 377 protected: 378 virtual Bitmap CreateBitmapForUI(long nIndex); 379 380 public: 381 virtual ~XGradientList(); 382 383 using XPropertyList::Replace; 384 XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex); 385 using XPropertyList::Remove; 386 XGradientEntry* Remove(long nIndex); 387 XGradientEntry* GetGradient(long nIndex) const; 388 389 virtual sal_Bool Load(); 390 virtual sal_Bool Save(); 391 virtual sal_Bool Create(); 392 }; 393 394 ////////////////////////////////////////////////////////////////////////////// 395 // class XBitmapList 396 397 class SVX_DLLPUBLIC XBitmapList : public XPropertyList 398 { 399 private: 400 friend class XPropertyListFactory; 401 XBitmapList( const String& rPath ); 402 403 protected: 404 virtual Bitmap CreateBitmapForUI( long nIndex ); 405 406 public: 407 virtual ~XBitmapList(); 408 409 using XPropertyList::Replace; 410 XBitmapEntry* Replace(XBitmapEntry* pEntry, long nIndex ); 411 using XPropertyList::Remove; 412 XBitmapEntry* Remove(long nIndex); 413 XBitmapEntry* GetBitmap(long nIndex) const; 414 415 virtual sal_Bool Load(); 416 virtual sal_Bool Save(); 417 virtual sal_Bool Create(); 418 }; 419 420 ////////////////////////////////////////////////////////////////////////////// 421 422 #endif // _XTABLE_HXX 423 424 ////////////////////////////////////////////////////////////////////////////// 425 // eof 426