xref: /trunk/main/svx/inc/svx/xtable.hxx (revision 70d3707a)
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 
40 class Color;
41 class Bitmap;
42 class VirtualDevice;
43 class XOutdevItemPool;
44 
45 // Breite und Hoehe der LB-Bitmaps
46 #define BITMAP_WIDTH  32
47 #define BITMAP_HEIGHT 12
48 
49 // Standard-Vergleichsstring
50 extern sal_Unicode __FAR_DATA pszStandard[]; // "standard"
51 
52 // Funktion zum Konvertieren in echte RGB-Farben, da mit
53 // enum COL_NAME nicht verglichen werden kann.
54 SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName );
55 
56 // ---------------------
57 // class XPropertyEntry
58 // ---------------------
59 
60 class XPropertyEntry
61 {
62 protected:
63 	String  aName;
64 
65 			XPropertyEntry(const String& rName) : aName(rName) {}
66 			XPropertyEntry(const XPropertyEntry& rOther): aName(rOther.aName) {}
67 public:
68 
69 	virtual        ~XPropertyEntry() {}
70 	void            SetName(const String& rName)    { aName = rName; }
71 	String&         GetName()                       { return aName; }
72 };
73 
74 // ------------------
75 // class XColorEntry
76 // ------------------
77 
78 class XColorEntry : public XPropertyEntry
79 {
80 	Color   aColor;
81 
82 public:
83 			XColorEntry(const Color& rColor, const String& rName) :
84 				XPropertyEntry(rName), aColor(rColor) {}
85 			XColorEntry(const XColorEntry& rOther) :
86 				XPropertyEntry(rOther), aColor(rOther.aColor) {}
87 
88 	void    SetColor(const Color& rColor)   { aColor = rColor; }
89 	Color&  GetColor()                      { return aColor; }
90 };
91 
92 // --------------------
93 // class XLineEndEntry
94 // --------------------
95 
96 class XLineEndEntry : public XPropertyEntry
97 {
98 	basegfx::B2DPolyPolygon	aB2DPolyPolygon;
99 
100 public:
101 	XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName)
102 	:	XPropertyEntry(rName),
103 		aB2DPolyPolygon(rB2DPolyPolygon)
104 	{}
105 
106 	XLineEndEntry(const XLineEndEntry& rOther)
107 	:	XPropertyEntry(rOther),
108 		aB2DPolyPolygon(rOther.aB2DPolyPolygon)
109 	{}
110 
111 	void SetLineEnd(const basegfx::B2DPolyPolygon& rB2DPolyPolygon)
112 	{
113 		aB2DPolyPolygon = rB2DPolyPolygon;
114 	}
115 
116 	basegfx::B2DPolyPolygon& GetLineEnd()
117 	{
118 		return aB2DPolyPolygon;
119 	}
120 };
121 
122 // ------------------
123 // class XDashEntry
124 // ------------------
125 
126 class XDashEntry : public XPropertyEntry
127 {
128 	XDash   aDash;
129 
130 public:
131 			XDashEntry(const XDash& rDash, const String& rName) :
132 				XPropertyEntry(rName), aDash(rDash) {}
133 			XDashEntry(const XDashEntry& rOther) :
134 				XPropertyEntry(rOther), aDash(rOther.aDash) {}
135 
136 	void    SetDash(const XDash& rDash)    { aDash = rDash; }
137 	XDash&  GetDash()                      { return aDash; }
138 };
139 
140 // ------------------
141 // class XHatchEntry
142 // ------------------
143 
144 class XHatchEntry : public XPropertyEntry
145 {
146 	XHatch  aHatch;
147 
148 public:
149 			XHatchEntry(const XHatch& rHatch, const String& rName) :
150 				XPropertyEntry(rName), aHatch(rHatch) {}
151 			XHatchEntry(const XHatchEntry& rOther) :
152 				XPropertyEntry(rOther), aHatch(rOther.aHatch) {}
153 
154 	void    SetHatch(const XHatch& rHatch)  { aHatch = rHatch; }
155 	XHatch& GetHatch()                      { return aHatch; }
156 };
157 
158 // ---------------------
159 // class XGradientEntry
160 // ---------------------
161 
162 class XGradientEntry : public XPropertyEntry
163 {
164 	XGradient  aGradient;
165 
166 public:
167 				XGradientEntry(const XGradient& rGradient, const String& rName):
168 					XPropertyEntry(rName), aGradient(rGradient) {}
169 				XGradientEntry(const XGradientEntry& rOther) :
170 					XPropertyEntry(rOther), aGradient(rOther.aGradient) {}
171 
172 	void        SetGradient(const XGradient& rGrad) { aGradient = rGrad; }
173 	XGradient&  GetGradient()                       { return aGradient; }
174 };
175 
176 // ---------------------
177 // class XBitmapEntry
178 // ---------------------
179 
180 class XBitmapEntry : public XPropertyEntry
181 {
182 private:
183 	GraphicObject   maGraphicObject;
184 
185 public:
186 	XBitmapEntry(const GraphicObject& rGraphicObject, const String& rName)
187     :   XPropertyEntry(rName),
188         maGraphicObject(rGraphicObject)
189     {
190     }
191 
192     XBitmapEntry(const XBitmapEntry& rOther)
193     :   XPropertyEntry(rOther),
194         maGraphicObject(rOther.maGraphicObject)
195     {
196     }
197 
198     const GraphicObject& GetGraphicObject() const
199     {
200         return maGraphicObject;
201     }
202 
203     void SetGraphicObject(const GraphicObject& rGraphicObject)
204     {
205         maGraphicObject = rGraphicObject;
206     }
207 };
208 
209 // ---------------------
210 // class XPropertyTable
211 // ---------------------
212 
213 class SVX_DLLPUBLIC XPropertyTable
214 {
215 protected:
216 	String              aName; // nicht persistent !
217 	String              aPath;
218 	XOutdevItemPool*    pXPool;
219 
220 	Table               aTable;
221 	Table*              pBmpTable;
222 
223 	sal_Bool                bTableDirty;
224 	sal_Bool                bBitmapsDirty;
225 	sal_Bool                bOwnPool;
226 
227 						XPropertyTable( const String& rPath,
228 										XOutdevItemPool* pXPool = NULL,
229 										sal_uInt16 nInitSize = 16,
230 										sal_uInt16 nReSize = 16 );
231 						XPropertyTable( SvStream& rIn );
232 	void                Clear();
233 
234 public:
235 	virtual				~XPropertyTable();
236 
237 	long                Count() const;
238 
239 	sal_Bool                Insert(long nIndex, XPropertyEntry* pEntry);
240 	XPropertyEntry*     Replace(long nIndex, XPropertyEntry* pEntry);
241 	XPropertyEntry*     Remove(long nIndex, sal_uInt16 nDummy);
242 	XPropertyEntry*     Get( long nIndex, sal_uInt16 nDummy ) const;
243 
244 	long                Get(const String& rName);
245 	Bitmap*             GetBitmap( long nIndex ) const;
246 
247 	const String&       GetName() const { return aName; }
248 	void                SetName( const String& rString );
249 	const String&       GetPath() const { return aPath; }
250 	void                SetPath( const String& rString ) { aPath = rString; }
251 	sal_Bool                IsDirty() const { return bTableDirty && bBitmapsDirty; }
252 	void                SetDirty( sal_Bool bDirty = sal_True )
253 							{ bTableDirty = bDirty; bBitmapsDirty = bDirty; }
254 
255 	virtual sal_Bool        Load() = 0;
256 	virtual sal_Bool        Save() = 0;
257 	virtual sal_Bool        Create() = 0;
258 	virtual sal_Bool        CreateBitmapsForUI() = 0;
259 	virtual Bitmap*     CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True ) = 0;
260 };
261 
262 // --------------------
263 // class XPropertyList
264 // --------------------
265 
266 class SVX_DLLPUBLIC XPropertyList
267 {
268 protected:
269 	String              aName; // nicht persistent !
270 	String              aPath;
271 	XOutdevItemPool*    pXPool;
272 
273 	List                aList;
274 	List*               pBmpList;
275 
276 	sal_Bool                bListDirty;
277 	sal_Bool                bBitmapsDirty;
278 	sal_Bool                bOwnPool;
279 
280 						XPropertyList(  const String& rPath,
281 										XOutdevItemPool* pXPool = NULL,
282 										sal_uInt16 nInitSize = 16,
283 										sal_uInt16 nReSize = 16 );
284 						XPropertyList( SvStream& rIn );
285 	void                Clear();
286 
287 public:
288 	virtual				~XPropertyList();
289 
290 	long                Count() const;
291 
292 	void                Insert( XPropertyEntry* pEntry, long nIndex = LIST_APPEND );
293 	XPropertyEntry*     Replace( XPropertyEntry* pEntry, long nIndex );
294 	XPropertyEntry*     Remove( long nIndex, sal_uInt16 nDummy );
295 	XPropertyEntry*     Get( long nIndex, sal_uInt16 nDummy ) const;
296 
297 	long                Get(const String& rName);
298 	Bitmap*             GetBitmap( long nIndex ) const;
299 
300 	const String&       GetName() const { return aName; }
301 	void                SetName( const String& rString );
302 	const String&       GetPath() const { return aPath; }
303 	void                SetPath( const String& rString ) { aPath = rString; }
304 	sal_Bool                IsDirty() const { return bListDirty && bBitmapsDirty; }
305 	void                SetDirty( sal_Bool bDirty = sal_True )
306 							{ bListDirty = bDirty; bBitmapsDirty = bDirty; }
307 
308 	virtual sal_Bool        Load() = 0;
309 	virtual sal_Bool        Save() = 0;
310 	virtual sal_Bool        Create() = 0;
311 	virtual sal_Bool        CreateBitmapsForUI() = 0;
312 	virtual Bitmap*     CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True ) = 0;
313 };
314 
315 // ------------------
316 // class XColorTable
317 // ------------------
318 
319 class SVX_DLLPUBLIC XColorTable : public XPropertyTable
320 {
321 public:
322 					XColorTable( const String& rPath,
323 								 XOutdevItemPool* pXPool = NULL,
324 								 sal_uInt16 nInitSize = 16,
325 								 sal_uInt16 nReSize = 16 );
326 	virtual			~XColorTable();
327 
328 	using XPropertyTable::Replace;
329 	XColorEntry*    Replace(long nIndex, XColorEntry* pEntry );
330 	using XPropertyTable::Remove;
331 	XColorEntry*    Remove(long nIndex);
332 	using XPropertyTable::Get;
333 	XColorEntry*    GetColor(long nIndex) const;
334 
335 	virtual sal_Bool    Load();
336 	virtual sal_Bool    Save();
337 	virtual sal_Bool    Create();
338 	virtual sal_Bool    CreateBitmapsForUI();
339 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
340 
341 	static XColorTable*	GetStdColorTable();
342 };
343 
344 // -------------------
345 // class XColorList
346 // -------------------
347 
348 class XColorList : public XPropertyList
349 {
350 public:
351 					XColorList( const String& rPath,
352 								XOutdevItemPool* pXPool = NULL,
353 								sal_uInt16 nInitSize = 16,
354 								sal_uInt16 nReSize = 16 );
355 	virtual			~XColorList();
356 
357 	using XPropertyList::Replace;
358 	XColorEntry*    Replace(XColorEntry* pEntry, long nIndex );
359 	using XPropertyList::Remove;
360 	XColorEntry*    Remove(long nIndex);
361 	using XPropertyList::Get;
362 	XColorEntry*    GetColor(long nIndex) const;
363 
364 	virtual sal_Bool    Load();
365 	virtual sal_Bool    Save();
366 	virtual sal_Bool    Create();
367 	virtual sal_Bool    CreateBitmapsForUI();
368 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
369 };
370 
371 // --------------------
372 // class XLineEndTable
373 // --------------------
374 
375 class XLineEndTable : public XPropertyTable
376 {
377 public:
378 					XLineEndTable( const String& rPath,
379 									XOutdevItemPool* pXPool = NULL,
380 									sal_uInt16 nInitSize = 16,
381 									sal_uInt16 nReSize = 16 );
382 	virtual			~XLineEndTable();
383 
384 	using XPropertyTable::Replace;
385 	XLineEndEntry*  Replace(long nIndex, XLineEndEntry* pEntry );
386 	using XPropertyTable::Remove;
387 	XLineEndEntry*  Remove(long nIndex);
388 	using XPropertyTable::Get;
389 	XLineEndEntry*  GetLineEnd(long nIndex) const;
390 
391 	virtual sal_Bool    Load();
392 	virtual sal_Bool    Save();
393 	virtual sal_Bool    Create();
394 	virtual sal_Bool    CreateBitmapsForUI();
395 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
396 };
397 
398 // -------------------
399 // class XLineEndList
400 // -------------------
401 class impXLineEndList;
402 
403 class SVX_DLLPUBLIC XLineEndList : public XPropertyList
404 {
405 private:
406     impXLineEndList*    mpData;
407 
408     void impCreate();
409     void impDestroy();
410 
411 public:
412 	XLineEndList(const String& rPath, XOutdevItemPool* pXPool = 0, sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16);
413 	virtual ~XLineEndList();
414 
415 	using XPropertyList::Replace;
416 	XLineEndEntry* Replace(XLineEndEntry* pEntry, long nIndex);
417 	using XPropertyList::Remove;
418 	XLineEndEntry* Remove(long nIndex);
419 	using XPropertyList::Get;
420 	XLineEndEntry* GetLineEnd(long nIndex) const;
421 
422 	virtual sal_Bool Load();
423 	virtual sal_Bool Save();
424 	virtual sal_Bool Create();
425 	virtual sal_Bool CreateBitmapsForUI();
426 	virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
427 };
428 
429 // --------------------
430 // class XDashTable
431 // --------------------
432 
433 class XDashTable : public XPropertyTable
434 {
435 public:
436 					XDashTable( const String& rPath,
437 								XOutdevItemPool* pXPool = NULL,
438 								sal_uInt16 nInitSize = 16,
439 								sal_uInt16 nReSize = 16 );
440 	virtual			~XDashTable();
441 
442 	using XPropertyTable::Replace;
443 	XDashEntry*     Replace(long nIndex, XDashEntry* pEntry );
444 	using XPropertyTable::Remove;
445 	XDashEntry*     Remove(long nIndex);
446 	using XPropertyTable::Get;
447 	XDashEntry*     GetDash(long nIndex) const;
448 
449 	virtual sal_Bool    Load();
450 	virtual sal_Bool    Save();
451 	virtual sal_Bool    Create();
452 	virtual sal_Bool    CreateBitmapsForUI();
453 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
454 };
455 
456 // -------------------
457 // class XDashList
458 // -------------------
459 class impXDashList;
460 
461 class SVX_DLLPUBLIC XDashList : public XPropertyList
462 {
463 private:
464     impXDashList*       mpData;
465 
466     void impCreate();
467     void impDestroy();
468 
469 public:
470     XDashList(const String& rPath, XOutdevItemPool* pXPool = 0, sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16);
471 	virtual ~XDashList();
472 
473 	using XPropertyList::Replace;
474 	XDashEntry* Replace(XDashEntry* pEntry, long nIndex);
475 	using XPropertyList::Remove;
476 	XDashEntry* Remove(long nIndex);
477 	using XPropertyList::Get;
478 	XDashEntry* GetDash(long nIndex) const;
479 
480 	virtual sal_Bool Load();
481 	virtual sal_Bool Save();
482 	virtual sal_Bool Create();
483 	virtual sal_Bool CreateBitmapsForUI();
484 	virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
485 };
486 
487 // --------------------
488 // class XHatchTable
489 // --------------------
490 
491 class XHatchTable : public XPropertyTable
492 {
493 public:
494 					XHatchTable( const String& rPath,
495 									XOutdevItemPool* pXPool = NULL,
496 									sal_uInt16 nInitSize = 16,
497 									sal_uInt16 nReSize = 16 );
498 	virtual			~XHatchTable();
499 
500 	using XPropertyTable::Replace;
501 	XHatchEntry*    Replace(long nIndex, XHatchEntry* pEntry );
502 	using XPropertyTable::Remove;
503 	XHatchEntry*    Remove(long nIndex);
504 	using XPropertyTable::Get;
505 	XHatchEntry*    GetHatch(long nIndex) const;
506 
507 	virtual sal_Bool    Load();
508 	virtual sal_Bool    Save();
509 	virtual sal_Bool    Create();
510 	virtual sal_Bool    CreateBitmapsForUI();
511 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
512 };
513 
514 // -------------------
515 // class XHatchList
516 // -------------------
517 class impXHatchList;
518 
519 class SVX_DLLPUBLIC XHatchList : public XPropertyList
520 {
521 private:
522     impXHatchList*      mpData;
523 
524     void impCreate();
525     void impDestroy();
526 
527 public:
528     XHatchList(const String& rPath, XOutdevItemPool* pXPool = 0, sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16);
529 	~XHatchList();
530 
531 	using XPropertyList::Replace;
532 	XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex);
533 	using XPropertyList::Remove;
534 	XHatchEntry* Remove(long nIndex);
535 	using XPropertyList::Get;
536 	XHatchEntry* GetHatch(long nIndex) const;
537 
538 	virtual sal_Bool Load();
539 	virtual sal_Bool Save();
540 	virtual sal_Bool Create();
541 	virtual sal_Bool CreateBitmapsForUI();
542 	virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
543 };
544 
545 // ---------------------
546 // class XGradientTable
547 // ---------------------
548 
549 class XGradientTable : public XPropertyTable
550 {
551 public:
552 					XGradientTable( const String& rPath,
553 									XOutdevItemPool* pXPool = NULL,
554 									sal_uInt16 nInitSize = 16,
555 									sal_uInt16 nReSize = 16 );
556 	virtual			~XGradientTable();
557 
558 	using XPropertyTable::Replace;
559 	XGradientEntry* Replace(long nIndex, XGradientEntry* pEntry );
560 	using XPropertyTable::Remove;
561 	XGradientEntry* Remove(long nIndex);
562 	using XPropertyTable::Get;
563 	XGradientEntry* GetGradient(long nIndex) const;
564 
565 	virtual sal_Bool    Load();
566 	virtual sal_Bool    Save();
567 	virtual sal_Bool    Create();
568 	virtual sal_Bool    CreateBitmapsForUI();
569 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
570 };
571 
572 // -------------------
573 // class XGradientList
574 // -------------------
575 class impXGradientList;
576 
577 class SVX_DLLPUBLIC XGradientList : public XPropertyList
578 {
579 private:
580     impXGradientList*   mpData;
581 
582     void impCreate();
583     void impDestroy();
584 
585 public:
586     XGradientList(const String& rPath, XOutdevItemPool* pXPool = 0, sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16);
587 	virtual ~XGradientList();
588 
589 	using XPropertyList::Replace;
590 	XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex);
591 	using XPropertyList::Remove;
592 	XGradientEntry* Remove(long nIndex);
593 	using XPropertyList::Get;
594 	XGradientEntry* GetGradient(long nIndex) const;
595 
596 	virtual sal_Bool Load();
597 	virtual sal_Bool Save();
598 	virtual sal_Bool Create();
599 	virtual sal_Bool CreateBitmapsForUI();
600 	virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
601 };
602 
603 // ---------------------
604 // class XBitmapTable
605 // ---------------------
606 
607 class XBitmapTable : public XPropertyTable
608 {
609 public:
610 					XBitmapTable( const String& rPath,
611 									XOutdevItemPool* pXPool = NULL,
612 									sal_uInt16 nInitSize = 16,
613 									sal_uInt16 nReSize = 16 );
614 	virtual			~XBitmapTable();
615 
616 	using XPropertyTable::Replace;
617 	XBitmapEntry*   Replace(long nIndex, XBitmapEntry* pEntry );
618 	using XPropertyTable::Remove;
619 	XBitmapEntry*   Remove(long nIndex);
620 	using XPropertyTable::Get;
621 	XBitmapEntry*   GetBitmap(long nIndex) const;
622 
623 	virtual sal_Bool    Load();
624 	virtual sal_Bool    Save();
625 	virtual sal_Bool    Create();
626 	virtual sal_Bool    CreateBitmapsForUI();
627 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
628 };
629 
630 // -------------------
631 // class XBitmapList
632 // -------------------
633 
634 class SVX_DLLPUBLIC XBitmapList : public XPropertyList
635 {
636 public:
637 					XBitmapList( const String& rPath,
638 									XOutdevItemPool* pXPool = NULL,
639 									sal_uInt16 nInitSize = 16,
640 									sal_uInt16 nReSize = 16 );
641 	virtual			~XBitmapList();
642 
643 	using XPropertyList::Replace;
644 	XBitmapEntry*   Replace(XBitmapEntry* pEntry, long nIndex );
645 	using XPropertyList::Remove;
646 	XBitmapEntry*   Remove(long nIndex);
647 	using XPropertyList::Get;
648 	XBitmapEntry*   GetBitmap(long nIndex) const;
649 
650 	virtual sal_Bool    Load();
651 	virtual sal_Bool    Save();
652 	virtual sal_Bool    Create();
653 	virtual sal_Bool    CreateBitmapsForUI();
654 	virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
655 };
656 
657 #endif // _XTABLE_HXX
658