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 <tools/table.hxx> 36 #include <svx/svxdllapi.h> 37 #include <basegfx/polygon/b2dpolypolygon.hxx> 38 #include <svtools/grfmgr.hxx> 39 #include <svx/XPropertyEntry.hxx> 40 41 class Color; 42 class Bitmap; 43 class VirtualDevice; 44 class XOutdevItemPool; 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 57 class XColorEntry : public XPropertyEntry 58 { 59 Color aColor; 60 61 public: 62 XColorEntry(const Color& rColor, const String& rName) : 63 XPropertyEntry(rName), aColor(rColor) {} 64 XColorEntry(const XColorEntry& rOther) : 65 XPropertyEntry(rOther), aColor(rOther.aColor) {} 66 67 void SetColor(const Color& rColor) { aColor = rColor; } 68 const Color& GetColor() const { return aColor; } 69 }; 70 71 // -------------------- 72 // class XLineEndEntry 73 // -------------------- 74 75 class XLineEndEntry : public XPropertyEntry 76 { 77 basegfx::B2DPolyPolygon aB2DPolyPolygon; 78 79 public: 80 XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName) 81 : XPropertyEntry(rName), 82 aB2DPolyPolygon(rB2DPolyPolygon) 83 {} 84 85 XLineEndEntry(const XLineEndEntry& rOther) 86 : XPropertyEntry(rOther), 87 aB2DPolyPolygon(rOther.aB2DPolyPolygon) 88 {} 89 90 void SetLineEnd(const basegfx::B2DPolyPolygon& rB2DPolyPolygon) 91 { 92 aB2DPolyPolygon = rB2DPolyPolygon; 93 } 94 95 const basegfx::B2DPolyPolygon& GetLineEnd() const 96 { 97 return aB2DPolyPolygon; 98 } 99 }; 100 101 // ------------------ 102 // class XDashEntry 103 // ------------------ 104 105 class XDashEntry : public XPropertyEntry 106 { 107 XDash aDash; 108 109 public: 110 XDashEntry(const XDash& rDash, const String& rName) : 111 XPropertyEntry(rName), aDash(rDash) {} 112 XDashEntry(const XDashEntry& rOther) : 113 XPropertyEntry(rOther), aDash(rOther.aDash) {} 114 115 void SetDash(const XDash& rDash) { aDash = rDash; } 116 const XDash& GetDash() const { return aDash; } 117 }; 118 119 // ------------------ 120 // class XHatchEntry 121 // ------------------ 122 123 class XHatchEntry : public XPropertyEntry 124 { 125 XHatch aHatch; 126 127 public: 128 XHatchEntry(const XHatch& rHatch, const String& rName) : 129 XPropertyEntry(rName), aHatch(rHatch) {} 130 XHatchEntry(const XHatchEntry& rOther) : 131 XPropertyEntry(rOther), aHatch(rOther.aHatch) {} 132 133 void SetHatch(const XHatch& rHatch) { aHatch = rHatch; } 134 const XHatch& GetHatch() const { return aHatch; } 135 }; 136 137 // --------------------- 138 // class XGradientEntry 139 // --------------------- 140 141 class XGradientEntry : public XPropertyEntry 142 { 143 XGradient aGradient; 144 145 public: 146 XGradientEntry(const XGradient& rGradient, const String& rName): 147 XPropertyEntry(rName), aGradient(rGradient) {} 148 XGradientEntry(const XGradientEntry& rOther) : 149 XPropertyEntry(rOther), aGradient(rOther.aGradient) {} 150 151 void SetGradient(const XGradient& rGrad) { aGradient = rGrad; } 152 const XGradient& GetGradient() const { return aGradient; } 153 }; 154 155 // --------------------- 156 // class XBitmapEntry 157 // --------------------- 158 159 class XBitmapEntry : public XPropertyEntry 160 { 161 private: 162 GraphicObject maGraphicObject; 163 164 public: 165 XBitmapEntry(const GraphicObject& rGraphicObject, const String& rName) 166 : XPropertyEntry(rName), 167 maGraphicObject(rGraphicObject) 168 { 169 } 170 171 XBitmapEntry(const XBitmapEntry& rOther) 172 : XPropertyEntry(rOther), 173 maGraphicObject(rOther.maGraphicObject) 174 { 175 } 176 177 const GraphicObject& GetGraphicObject() const 178 { 179 return maGraphicObject; 180 } 181 182 void SetGraphicObject(const GraphicObject& rGraphicObject) 183 { 184 maGraphicObject = rGraphicObject; 185 } 186 }; 187 188 // -------------------- 189 // class XPropertyList 190 // -------------------- 191 192 class SVX_DLLPUBLIC XPropertyList 193 { 194 protected: 195 String maName; // nicht persistent ! 196 String maPath; 197 XOutdevItemPool* mpXPool; 198 199 List maList; 200 201 /// bitfield 202 bool mbListDirty : 1; 203 204 XPropertyList( const String& rPath, XOutdevItemPool* pXPool = 0 ); 205 void Clear(); 206 virtual Bitmap CreateBitmapForUI( long nIndex ) = 0; 207 208 public: 209 virtual ~XPropertyList(); 210 211 long Count() const; 212 213 void Insert( XPropertyEntry* pEntry, long nIndex = LIST_APPEND ); 214 XPropertyEntry* Replace( XPropertyEntry* pEntry, long nIndex ); 215 XPropertyEntry* Remove( long nIndex, sal_uInt16 nDummy ); 216 XPropertyEntry* Get( long nIndex, sal_uInt16 nDummy ) const; 217 218 long Get(const String& rName); 219 Bitmap GetUiBitmap( long nIndex ) const; 220 221 const String& GetName() const { return maName; } 222 void SetName( const String& rString ); 223 const String& GetPath() const { return maPath; } 224 void SetPath( const String& rString ) { maPath = rString; } 225 bool IsDirty() const { return mbListDirty; } 226 void SetDirty( bool bDirty = true ) { mbListDirty = bDirty; } 227 228 virtual sal_Bool Load() = 0; 229 virtual sal_Bool Save() = 0; 230 virtual sal_Bool Create() = 0; 231 232 sal_uInt32 getUiBitmapWidth() const; 233 sal_uInt32 getUiBitmapHeight() const; 234 sal_uInt32 getUiBitmapLineWidth() const; 235 }; 236 237 // ------------------- 238 // class XColorList 239 // ------------------- 240 241 class SVX_DLLPUBLIC XColorList : public XPropertyList 242 { 243 protected: 244 virtual Bitmap CreateBitmapForUI( long nIndex ); 245 246 public: 247 XColorList( const String& rPath, XOutdevItemPool* pXPool = 0 ); 248 virtual ~XColorList(); 249 250 using XPropertyList::Replace; 251 XColorEntry* Replace(XColorEntry* pEntry, long nIndex ); 252 using XPropertyList::Remove; 253 XColorEntry* Remove(long nIndex); 254 using XPropertyList::Get; 255 XColorEntry* GetColor(long nIndex) const; 256 257 virtual sal_Bool Load(); 258 virtual sal_Bool Save(); 259 virtual sal_Bool Create(); 260 261 static XColorList* GetStdColorList(); 262 }; 263 264 // ------------------- 265 // class XLineEndList 266 // ------------------- 267 class impXLineEndList; 268 269 class SVX_DLLPUBLIC XLineEndList : public XPropertyList 270 { 271 private: 272 impXLineEndList* mpData; 273 274 void impCreate(); 275 void impDestroy(); 276 277 protected: 278 virtual Bitmap CreateBitmapForUI(long nIndex); 279 280 public: 281 XLineEndList(const String& rPath, XOutdevItemPool* pXPool = 0); 282 virtual ~XLineEndList(); 283 284 using XPropertyList::Replace; 285 XLineEndEntry* Replace(XLineEndEntry* pEntry, long nIndex); 286 using XPropertyList::Remove; 287 XLineEndEntry* Remove(long nIndex); 288 using XPropertyList::Get; 289 XLineEndEntry* GetLineEnd(long nIndex) const; 290 291 virtual sal_Bool Load(); 292 virtual sal_Bool Save(); 293 virtual sal_Bool Create(); 294 }; 295 296 // ------------------- 297 // class XDashList 298 // ------------------- 299 class impXDashList; 300 301 class SVX_DLLPUBLIC XDashList : public XPropertyList 302 { 303 private: 304 impXDashList* mpData; 305 Bitmap maBitmapSolidLine; 306 String maStringSolidLine; 307 String maStringNoLine; 308 309 void impCreate(); 310 void impDestroy(); 311 312 protected: 313 Bitmap ImpCreateBitmapForXDash(const XDash* pDash); 314 virtual Bitmap CreateBitmapForUI(long nIndex); 315 316 public: 317 XDashList(const String& rPath, XOutdevItemPool* pXPool = 0); 318 virtual ~XDashList(); 319 320 using XPropertyList::Replace; 321 XDashEntry* Replace(XDashEntry* pEntry, long nIndex); 322 using XPropertyList::Remove; 323 XDashEntry* Remove(long nIndex); 324 using XPropertyList::Get; 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 impXHatchList; 346 347 class SVX_DLLPUBLIC XHatchList : public XPropertyList 348 { 349 private: 350 impXHatchList* mpData; 351 352 void impCreate(); 353 void impDestroy(); 354 355 protected: 356 virtual Bitmap CreateBitmapForUI(long nIndex); 357 358 public: 359 XHatchList(const String& rPath, XOutdevItemPool* pXPool = 0); 360 ~XHatchList(); 361 362 using XPropertyList::Replace; 363 XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex); 364 using XPropertyList::Remove; 365 XHatchEntry* Remove(long nIndex); 366 using XPropertyList::Get; 367 XHatchEntry* GetHatch(long nIndex) const; 368 369 virtual sal_Bool Load(); 370 virtual sal_Bool Save(); 371 virtual sal_Bool Create(); 372 }; 373 374 // ------------------- 375 // class XGradientList 376 // ------------------- 377 class impXGradientList; 378 379 class SVX_DLLPUBLIC XGradientList : public XPropertyList 380 { 381 private: 382 impXGradientList* mpData; 383 384 void impCreate(); 385 void impDestroy(); 386 387 protected: 388 virtual Bitmap CreateBitmapForUI(long nIndex); 389 390 public: 391 XGradientList(const String& rPath, XOutdevItemPool* pXPool = 0); 392 virtual ~XGradientList(); 393 394 using XPropertyList::Replace; 395 XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex); 396 using XPropertyList::Remove; 397 XGradientEntry* Remove(long nIndex); 398 using XPropertyList::Get; 399 XGradientEntry* GetGradient(long nIndex) const; 400 401 virtual sal_Bool Load(); 402 virtual sal_Bool Save(); 403 virtual sal_Bool Create(); 404 }; 405 406 // ------------------- 407 // class XBitmapList 408 // ------------------- 409 410 class SVX_DLLPUBLIC XBitmapList : public XPropertyList 411 { 412 protected: 413 virtual Bitmap CreateBitmapForUI( long nIndex ); 414 415 public: 416 XBitmapList( const String& rPath, XOutdevItemPool* pXPool = 0); 417 virtual ~XBitmapList(); 418 419 using XPropertyList::Replace; 420 XBitmapEntry* Replace(XBitmapEntry* pEntry, long nIndex ); 421 using XPropertyList::Remove; 422 XBitmapEntry* Remove(long nIndex); 423 using XPropertyList::Get; 424 XBitmapEntry* GetBitmap(long nIndex) const; 425 426 virtual sal_Bool Load(); 427 virtual sal_Bool Save(); 428 virtual sal_Bool Create(); 429 }; 430 431 #endif // _XTABLE_HXX 432 433 // eof 434