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