Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _XTABLE_HXX
29 : : #define _XTABLE_HXX
30 : :
31 : : #include <rtl/ref.hxx>
32 : : #include <svx/xpoly.hxx>
33 : : #include <svx/xdash.hxx>
34 : : #include <svx/xhatch.hxx>
35 : : #include <svx/xgrad.hxx>
36 : : #include <svx/xbitmap.hxx>
37 : : #include <svx/xflasit.hxx>
38 : : #include <svx/xlnasit.hxx>
39 : :
40 : : #include <tools/color.hxx>
41 : : #include <tools/string.hxx>
42 : : #include <tools/contnr.hxx>
43 : :
44 : : #include <cppuhelper/weak.hxx>
45 : :
46 : : #include "svx/svxdllapi.h"
47 : : #include <com/sun/star/embed/XStorage.hpp>
48 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
49 : : #include <com/sun/star/container/XNameContainer.hpp>
50 : :
51 : : class Color;
52 : : class Bitmap;
53 : : class VirtualDevice;
54 : : class XOutdevItemPool;
55 : :
56 : : // Breite und Hoehe der LB-Bitmaps
57 : : #define BITMAP_WIDTH 32
58 : : #define BITMAP_HEIGHT 12
59 : :
60 : : // Standard-Vergleichsstring
61 : : extern sal_Unicode pszStandard[]; // "standard"
62 : :
63 : : // Funktion zum Konvertieren in echte RGB-Farben, da mit
64 : : // enum COL_NAME nicht verglichen werden kann.
65 : : SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName );
66 : :
67 : : // ---------------------
68 : : // class XPropertyEntry
69 : : // ---------------------
70 : :
71 : 0 : class XPropertyEntry
72 : : {
73 : : protected:
74 : : String aName;
75 : :
76 : 0 : XPropertyEntry(const String& rName) : aName(rName) {}
77 : 0 : XPropertyEntry(const XPropertyEntry& rOther): aName(rOther.aName) {}
78 : : public:
79 : :
80 [ # # ]: 0 : virtual ~XPropertyEntry() {}
81 : 0 : void SetName(const String& rName) { aName = rName; }
82 : 0 : String& GetName() { return aName; }
83 : : };
84 : :
85 : : // ------------------
86 : : // class XColorEntry
87 : : // ------------------
88 : :
89 [ # # ]: 0 : class XColorEntry : public XPropertyEntry
90 : : {
91 : : Color aColor;
92 : :
93 : : public:
94 : 0 : XColorEntry(const Color& rColor, const String& rName)
95 : : : XPropertyEntry(rName)
96 : 0 : , aColor(rColor)
97 : 0 : {}
98 : :
99 : 0 : void SetColor(const Color& rColor) { aColor = rColor; }
100 : 0 : Color& GetColor() { return aColor; }
101 : : };
102 : :
103 : : // --------------------
104 : : // class XLineEndEntry
105 : : // --------------------
106 : :
107 [ # # ][ # # ]: 0 : class XLineEndEntry : public XPropertyEntry
108 : : {
109 : : basegfx::B2DPolyPolygon aB2DPolyPolygon;
110 : :
111 : : public:
112 : 0 : XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName)
113 : : : XPropertyEntry(rName),
114 [ # # ]: 0 : aB2DPolyPolygon(rB2DPolyPolygon)
115 : 0 : {}
116 : :
117 : : void SetLineEnd(const basegfx::B2DPolyPolygon& rB2DPolyPolygon)
118 : : {
119 : : aB2DPolyPolygon = rB2DPolyPolygon;
120 : : }
121 : :
122 : 0 : basegfx::B2DPolyPolygon& GetLineEnd()
123 : : {
124 : 0 : return aB2DPolyPolygon;
125 : : }
126 : : };
127 : :
128 : : // ------------------
129 : : // class XDashEntry
130 : : // ------------------
131 : :
132 [ # # ]: 0 : class XDashEntry : public XPropertyEntry
133 : : {
134 : : XDash aDash;
135 : :
136 : : public:
137 : 0 : XDashEntry(const XDash& rDash, const String& rName) :
138 : 0 : XPropertyEntry(rName), aDash(rDash) {}
139 : :
140 : : void SetDash(const XDash& rDash) { aDash = rDash; }
141 : 0 : XDash& GetDash() { return aDash; }
142 : : };
143 : :
144 : : // ------------------
145 : : // class XHatchEntry
146 : : // ------------------
147 : :
148 [ # # ]: 0 : class XHatchEntry : public XPropertyEntry
149 : : {
150 : : XHatch aHatch;
151 : :
152 : : public:
153 : 0 : XHatchEntry(const XHatch& rHatch, const String& rName) :
154 : 0 : XPropertyEntry(rName), aHatch(rHatch) {}
155 : :
156 : : void SetHatch(const XHatch& rHatch) { aHatch = rHatch; }
157 : 0 : XHatch& GetHatch() { return aHatch; }
158 : : };
159 : :
160 : : // ---------------------
161 : : // class XGradientEntry
162 : : // ---------------------
163 : :
164 [ # # ]: 0 : class XGradientEntry : public XPropertyEntry
165 : : {
166 : : XGradient aGradient;
167 : :
168 : : public:
169 : 0 : XGradientEntry(const XGradient& rGradient, const String& rName):
170 : 0 : XPropertyEntry(rName), aGradient(rGradient) {}
171 : :
172 : : void SetGradient(const XGradient& rGrad) { aGradient = rGrad; }
173 : 0 : XGradient& GetGradient() { return aGradient; }
174 : : };
175 : :
176 : : // ---------------------
177 : : // class XBitmapEntry
178 : : // ---------------------
179 : :
180 [ # # ][ # # ]: 0 : class XBitmapEntry : public XPropertyEntry
181 : : {
182 : : XOBitmap aXOBitmap;
183 : :
184 : : public:
185 : 0 : XBitmapEntry( const XOBitmap& rXOBitmap, const String& rName ):
186 [ # # ]: 0 : XPropertyEntry( rName ), aXOBitmap( rXOBitmap ) {}
187 : :
188 : 0 : void SetXBitmap(const XOBitmap& rXOBitmap) { aXOBitmap = rXOBitmap; }
189 : 0 : XOBitmap& GetXBitmap() { return aXOBitmap; }
190 : : };
191 : :
192 : : // --------------------
193 : : // class XPropertyList
194 : : // --------------------
195 : :
196 : : enum XPropertyListType {
197 : : XCOLOR_LIST,
198 : : XLINE_END_LIST,
199 : : XDASH_LIST,
200 : : XHATCH_LIST,
201 : : XGRADIENT_LIST,
202 : : XBITMAP_LIST,
203 : : XPROPERTY_LIST_COUNT
204 : : };
205 : :
206 : : typedef rtl::Reference< class XPropertyList > XPropertyListRef;
207 : :
208 : : class XDashList ; typedef rtl::Reference< class XDashList > XDashListRef;
209 : : class XHatchList ; typedef rtl::Reference< class XHatchList > XHatchListRef;
210 : : class XColorList ; typedef rtl::Reference< class XColorList > XColorListRef;
211 : : class XBitmapList ; typedef rtl::Reference< class XBitmapList > XBitmapListRef;
212 : : class XLineEndList ; typedef rtl::Reference< class XLineEndList > XLineEndListRef;
213 : : class XGradientList ; typedef rtl::Reference< class XGradientList > XGradientListRef;
214 : :
215 : : class SVX_DLLPUBLIC XPropertyList : public cppu::OWeakObject
216 : : {
217 : : private:
218 : : SAL_DLLPRIVATE void* operator new(size_t);
219 : : protected:
220 : : SAL_DLLPRIVATE void operator delete(void *);
221 : : protected:
222 : : typedef ::std::vector< XPropertyEntry* > XPropertyEntryList_impl;
223 : : typedef ::std::vector< Bitmap* > BitmapList_impl;
224 : :
225 : : XPropertyListType eType;
226 : : String aName; // not persistent
227 : : String aPath;
228 : : XOutdevItemPool* pXPool;
229 : :
230 : : XPropertyEntryList_impl aList;
231 : : BitmapList_impl* pBmpList;
232 : :
233 : : bool bListDirty;
234 : : bool bBitmapsDirty;
235 : : bool bOwnPool;
236 : : bool bEmbedInDocument;
237 : :
238 : : XPropertyList( XPropertyListType t, const String& rPath,
239 : : XOutdevItemPool* pXPool = NULL );
240 : :
241 : : public:
242 : : virtual ~XPropertyList();
243 : :
244 : 1756 : XPropertyListType Type() const { return eType; }
245 : : long Count() const;
246 : :
247 : : void Insert( XPropertyEntry* pEntry, long nIndex = CONTAINER_APPEND );
248 : : XPropertyEntry* Replace( XPropertyEntry* pEntry, long nIndex );
249 : : XPropertyEntry* Remove( long nIndex );
250 : :
251 : : // Note: Get(long) & Get( String& ) are ambiguous
252 : : XPropertyEntry* Get( long nIndex, sal_uInt16 nDummy ) const;
253 : : long Get(const String& rName);
254 : :
255 : : Bitmap* GetBitmap( long nIndex ) const;
256 : :
257 : 72 : const String& GetName() const { return aName; }
258 : : void SetName( const String& rString );
259 : 72 : const String& GetPath() const { return aPath; }
260 : 0 : void SetPath( const String& rString ) { aPath = rString; }
261 : : sal_Bool IsDirty() const { return bListDirty && bBitmapsDirty; }
262 : : void SetDirty( sal_Bool bDirty = sal_True )
263 : : { bListDirty = bDirty; bBitmapsDirty = bDirty; }
264 : 72 : bool IsEmbedInDocument() const { return bEmbedInDocument; }
265 : 0 : void SetEmbedInDocument(bool b) { bEmbedInDocument = b; }
266 : :
267 : : static rtl::OUString GetDefaultExt(XPropertyListType t);
268 : : static rtl::OUString GetDefaultExtFilter(XPropertyListType t);
269 : 72 : rtl::OUString GetDefaultExt() const { return GetDefaultExt( eType ); }
270 : :
271 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
272 : : createInstance() = 0;
273 : : bool Load();
274 : : bool LoadFrom( const ::com::sun::star::uno::Reference<
275 : : ::com::sun::star::embed::XStorage > &xStorage,
276 : : const rtl::OUString &rURL );
277 : : bool Save();
278 : : bool SaveTo ( const ::com::sun::star::uno::Reference<
279 : : ::com::sun::star::embed::XStorage > &xStorage,
280 : : const rtl::OUString &rURL,
281 : : rtl::OUString *pOptName );
282 : : virtual sal_Bool Create() = 0;
283 : : virtual sal_Bool CreateBitmapsForUI() = 0;
284 : : virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True ) = 0;
285 : :
286 : : // Factory method for sub-classes
287 : : static XPropertyListRef CreatePropertyList( XPropertyListType t,
288 : : const String& rPath,
289 : : XOutdevItemPool* pXPool = NULL );
290 : : // as above but initializes name as expected
291 : : static XPropertyListRef CreatePropertyListFromURL( XPropertyListType t,
292 : : const rtl::OUString & rUrl,
293 : : XOutdevItemPool* pXPool = NULL );
294 : :
295 : : // helper accessors
296 : : inline XDashListRef AsDashList();
297 : : inline XHatchListRef AsHatchList();
298 : : inline XColorListRef AsColorList();
299 : : inline XBitmapListRef AsBitmapList();
300 : : inline XLineEndListRef AsLineEndList();
301 : : inline XGradientListRef AsGradientList();
302 : : };
303 : :
304 : : // ------------------
305 : : // class XColorList
306 : : // ------------------
307 : :
308 : : class SVX_DLLPUBLIC XColorList : public XPropertyList
309 : : {
310 : : public:
311 : : explicit XColorList( const String& rPath,
312 : : XOutdevItemPool* pXInPool = NULL ) :
313 : : XPropertyList( XCOLOR_LIST, rPath, pXInPool ) {}
314 : :
315 : : using XPropertyList::Replace;
316 : : using XPropertyList::Remove;
317 : : using XPropertyList::Get;
318 : :
319 : : XColorEntry* Replace(long nIndex, XColorEntry* pEntry );
320 : : XColorEntry* Remove(long nIndex);
321 : : XColorEntry* GetColor(long nIndex) const;
322 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
323 : : virtual sal_Bool Create();
324 : : virtual sal_Bool CreateBitmapsForUI();
325 : : virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
326 : :
327 : : static XColorListRef CreateStdColorList();
328 : : static XColorListRef GetStdColorList(); // returns a singleton
329 : : };
330 : :
331 : : // -------------------
332 : : // class XLineEndList
333 : : // -------------------
334 : : class impXLineEndList;
335 : :
336 : : class SVX_DLLPUBLIC XLineEndList : public XPropertyList
337 : : {
338 : : private:
339 : : impXLineEndList* mpData;
340 : :
341 : : void impCreate();
342 : : void impDestroy();
343 : :
344 : : public:
345 : : explicit XLineEndList(
346 : : const String& rPath,
347 : : XOutdevItemPool* pXPool = 0
348 : : );
349 : : virtual ~XLineEndList();
350 : :
351 : : using XPropertyList::Remove;
352 : : XLineEndEntry* Remove(long nIndex);
353 : : using XPropertyList::Get;
354 : : XLineEndEntry* GetLineEnd(long nIndex) const;
355 : :
356 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
357 : : virtual sal_Bool Create();
358 : : virtual sal_Bool CreateBitmapsForUI();
359 : : virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
360 : : };
361 : :
362 : : // -------------------
363 : : // class XDashList
364 : : // -------------------
365 : : class impXDashList;
366 : :
367 : : class SVX_DLLPUBLIC XDashList : public XPropertyList
368 : : {
369 : : private:
370 : : impXDashList* mpData;
371 : :
372 : : void impCreate();
373 : : void impDestroy();
374 : :
375 : : public:
376 : : explicit XDashList(
377 : : const String& rPath,
378 : : XOutdevItemPool* pXPool = 0
379 : : );
380 : : virtual ~XDashList();
381 : :
382 : : using XPropertyList::Replace;
383 : : XDashEntry* Replace(XDashEntry* pEntry, long nIndex);
384 : : using XPropertyList::Remove;
385 : : XDashEntry* Remove(long nIndex);
386 : : using XPropertyList::Get;
387 : : XDashEntry* GetDash(long nIndex) const;
388 : :
389 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
390 : : virtual sal_Bool Create();
391 : : virtual sal_Bool CreateBitmapsForUI();
392 : : virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
393 : : };
394 : :
395 : : // -------------------
396 : : // class XHatchList
397 : : // -------------------
398 : : class impXHatchList;
399 : :
400 : : class SVX_DLLPUBLIC XHatchList : public XPropertyList
401 : : {
402 : : private:
403 : : impXHatchList* mpData;
404 : :
405 : : void impCreate();
406 : : void impDestroy();
407 : :
408 : : public:
409 : : explicit XHatchList( const String& rPath,
410 : : XOutdevItemPool* pXPool = 0 );
411 : : virtual ~XHatchList();
412 : :
413 : : using XPropertyList::Replace;
414 : : XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex);
415 : : using XPropertyList::Remove;
416 : : XHatchEntry* Remove(long nIndex);
417 : : using XPropertyList::Get;
418 : : XHatchEntry* GetHatch(long nIndex) const;
419 : :
420 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
421 : : virtual sal_Bool Create();
422 : : virtual sal_Bool CreateBitmapsForUI();
423 : : virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
424 : : };
425 : :
426 : : // -------------------
427 : : // class XGradientList
428 : : // -------------------
429 : : class impXGradientList;
430 : :
431 : : class SVX_DLLPUBLIC XGradientList : public XPropertyList
432 : : {
433 : : private:
434 : : impXGradientList* mpData;
435 : :
436 : : void impCreate();
437 : : void impDestroy();
438 : :
439 : : public:
440 : : explicit XGradientList(
441 : : const String& rPath,
442 : : XOutdevItemPool* pXPool = 0
443 : : );
444 : : virtual ~XGradientList();
445 : :
446 : : using XPropertyList::Replace;
447 : : XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex);
448 : : using XPropertyList::Remove;
449 : : XGradientEntry* Remove(long nIndex);
450 : : using XPropertyList::Get;
451 : : XGradientEntry* GetGradient(long nIndex) const;
452 : :
453 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
454 : : virtual sal_Bool Create();
455 : : virtual sal_Bool CreateBitmapsForUI();
456 : : virtual Bitmap* CreateBitmapForUI(long nIndex, sal_Bool bDelete = sal_True);
457 : : };
458 : :
459 : : // -------------------
460 : : // class XBitmapList
461 : : // -------------------
462 : :
463 : : class SVX_DLLPUBLIC XBitmapList : public XPropertyList
464 : : {
465 : : public:
466 : : explicit XBitmapList( const String& rPath,
467 : : XOutdevItemPool* pXInPool = NULL )
468 : : : XPropertyList( XBITMAP_LIST, rPath, pXInPool ) {}
469 : :
470 : : using XPropertyList::Replace;
471 : : using XPropertyList::Remove;
472 : : XBitmapEntry* Remove(long nIndex);
473 : : using XPropertyList::Get;
474 : : XBitmapEntry* GetBitmap(long nIndex) const;
475 : :
476 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance();
477 : : virtual sal_Bool Create();
478 : : virtual sal_Bool CreateBitmapsForUI();
479 : : virtual Bitmap* CreateBitmapForUI( long nIndex, sal_Bool bDelete = sal_True );
480 : : };
481 : :
482 : :
483 : : // FIXME: could add type checking too ...
484 : 2132 : inline XDashListRef XPropertyList::AsDashList() { return XDashListRef( static_cast<XDashList *> (this) ); }
485 : 2132 : inline XHatchListRef XPropertyList::AsHatchList() { return XHatchListRef( static_cast<XHatchList *> (this) ); }
486 : 581 : inline XColorListRef XPropertyList::AsColorList() { return XColorListRef( static_cast<XColorList *> (this) ); }
487 : 2132 : inline XBitmapListRef XPropertyList::AsBitmapList() { return XBitmapListRef( static_cast<XBitmapList *> (this) ); }
488 : 2132 : inline XLineEndListRef XPropertyList::AsLineEndList() { return XLineEndListRef( static_cast<XLineEndList *> (this) ); }
489 : 2132 : inline XGradientListRef XPropertyList::AsGradientList() { return XGradientListRef( static_cast<XGradientList *> (this) ); }
490 : :
491 : : #endif // _XTABLE_HXX
492 : :
493 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|