1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVX_XTABLE_HXX
20 #define INCLUDED_SVX_XTABLE_HXX
22 #include <rtl/ref.hxx>
23 #include <rtl/ustring.hxx>
24 #include <svx/xpoly.hxx>
25 #include <svx/xdash.hxx>
26 #include <svx/xhatch.hxx>
27 #include <svx/xgrad.hxx>
28 #include <svx/xflasit.hxx>
29 #include <svx/xlnasit.hxx>
31 #include <tools/color.hxx>
32 #include <tools/contnr.hxx>
34 #include <cppuhelper/weak.hxx>
36 #include <svx/svxdllapi.h>
37 #include <com/sun/star/embed/XStorage.hpp>
38 #include <basegfx/polygon/b2dpolypolygon.hxx>
39 #include <com/sun/star/container/XNameContainer.hpp>
40 #include <svtools/grfmgr.hxx>
41 #include <svx/XPropertyEntry.hxx>
47 // Standard-Vergleichsstring
48 extern sal_Unicode pszStandard
[]; // "standard"
50 // Funktion zum Konvertieren in echte RGB-Farben, da mit
51 // enum COL_NAME nicht verglichen werden kann.
52 SVX_DLLPUBLIC Color
RGB_Color( ColorData nColorName
);
58 class SVX_DLLPUBLIC XColorEntry
: public XPropertyEntry
64 XColorEntry(const Color
& rColor
, const OUString
& rName
);
65 XColorEntry(const XColorEntry
& rOther
);
67 const Color
& GetColor() const
73 // --------------------
74 // class XLineEndEntry
75 // --------------------
77 class SVX_DLLPUBLIC XLineEndEntry
: public XPropertyEntry
80 basegfx::B2DPolyPolygon aB2DPolyPolygon
;
83 XLineEndEntry(const basegfx::B2DPolyPolygon
& rB2DPolyPolygon
, const OUString
& rName
);
84 XLineEndEntry(const XLineEndEntry
& rOther
);
86 const basegfx::B2DPolyPolygon
& GetLineEnd() const
88 return aB2DPolyPolygon
;
96 class SVX_DLLPUBLIC XDashEntry
: public XPropertyEntry
102 XDashEntry(const XDash
& rDash
, const OUString
& rName
);
103 XDashEntry(const XDashEntry
& rOther
);
105 const XDash
& GetDash() const
111 // ------------------
113 // ------------------
115 class SVX_DLLPUBLIC XHatchEntry
: public XPropertyEntry
121 XHatchEntry(const XHatch
& rHatch
, const OUString
& rName
);
122 XHatchEntry(const XHatchEntry
& rOther
);
124 const XHatch
& GetHatch() const
130 // ---------------------
131 // class XGradientEntry
132 // ---------------------
134 class SVX_DLLPUBLIC XGradientEntry
: public XPropertyEntry
140 XGradientEntry(const XGradient
& rGradient
, const OUString
& rName
);
141 XGradientEntry(const XGradientEntry
& rOther
);
143 const XGradient
& GetGradient() const
149 // ---------------------
150 // class XBitmapEntry
151 // ---------------------
153 class SVX_DLLPUBLIC XBitmapEntry
: public XPropertyEntry
156 GraphicObject maGraphicObject
;
159 XBitmapEntry(const GraphicObject
& rGraphicObject
, const OUString
& rName
);
160 XBitmapEntry(const XBitmapEntry
& rOther
);
162 const GraphicObject
& GetGraphicObject() const
164 return maGraphicObject
;
168 // --------------------
169 // class XPropertyList
170 // --------------------
172 enum XPropertyListType
{
182 typedef rtl::Reference
< class XPropertyList
> XPropertyListRef
;
184 class XDashList
; typedef rtl::Reference
< class XDashList
> XDashListRef
;
185 class XHatchList
; typedef rtl::Reference
< class XHatchList
> XHatchListRef
;
186 class XColorList
; typedef rtl::Reference
< class XColorList
> XColorListRef
;
187 class XBitmapList
; typedef rtl::Reference
< class XBitmapList
> XBitmapListRef
;
188 class XLineEndList
; typedef rtl::Reference
< class XLineEndList
> XLineEndListRef
;
189 class XGradientList
; typedef rtl::Reference
< class XGradientList
> XGradientListRef
;
191 class SVX_DLLPUBLIC XPropertyList
: public cppu::OWeakObject
194 SAL_DLLPRIVATE
void* operator new(size_t);
196 SAL_DLLPRIVATE
void operator delete(void *);
198 typedef ::std::vector
< XPropertyEntry
* > XPropertyEntryList_impl
;
199 typedef ::std::vector
< Bitmap
* > BitmapList_impl
;
201 XPropertyListType meType
;
202 OUString maName
; // not persistent
206 XPropertyEntryList_impl maList
;
209 bool mbEmbedInDocument
;
211 XPropertyList(XPropertyListType t
, const OUString
& rPath
, const OUString
& rReferer
);
213 virtual Bitmap
CreateBitmapForUI(long nIndex
) = 0;
216 virtual ~XPropertyList();
218 XPropertyListType
Type() const { return meType
; }
221 void Insert(XPropertyEntry
* pEntry
, long nIndex
= CONTAINER_APPEND
);
222 XPropertyEntry
* Replace(XPropertyEntry
* pEntry
, long nIndex
);
223 XPropertyEntry
* Remove(long nIndex
);
225 XPropertyEntry
* Get(long nIndex
) const;
226 long GetIndex(const OUString
& rName
) const;
227 Bitmap
GetUiBitmap(long nIndex
) const;
229 const OUString
& GetName() const { return maName
; }
230 void SetName(const OUString
& rString
);
232 const OUString
& GetPath() const { return maPath
; }
233 void SetPath(const OUString
& rString
) { maPath
= rString
; }
235 bool IsDirty() const { return mbListDirty
; }
236 void SetDirty(bool bDirty
= true) { mbListDirty
= bDirty
; }
238 bool IsEmbedInDocument() const { return mbEmbedInDocument
; }
239 void SetEmbedInDocument(bool b
) { mbEmbedInDocument
= b
; }
241 static OUString
GetDefaultExt(XPropertyListType t
);
242 static OUString
GetDefaultExtFilter(XPropertyListType t
);
243 OUString
GetDefaultExt() const { return GetDefaultExt(meType
); }
245 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>
246 createInstance() = 0;
248 bool LoadFrom(const ::com::sun::star::uno::Reference
<
249 ::com::sun::star::embed::XStorage
> &xStorage
,
250 const OUString
&rURL
, const OUString
&rReferer
);
252 bool SaveTo (const ::com::sun::star::uno::Reference
<
253 ::com::sun::star::embed::XStorage
> &xStorage
,
254 const OUString
&rURL
,
256 virtual bool Create() = 0;
258 // Factory method for sub-classes
259 static XPropertyListRef
CreatePropertyList(XPropertyListType t
,
260 const OUString
& rPath
,
261 const OUString
& rReferer
);
262 // as above but initializes name as expected
263 static XPropertyListRef
CreatePropertyListFromURL(XPropertyListType t
,
264 const OUString
& rUrl
);
267 inline XDashListRef
AsDashList();
268 inline XHatchListRef
AsHatchList();
269 inline XColorListRef
AsColorList();
270 inline XBitmapListRef
AsBitmapList();
271 inline XLineEndListRef
AsLineEndList();
272 inline XGradientListRef
AsGradientList();
275 // ------------------
277 // ------------------
279 class SVX_DLLPUBLIC XColorList
: public XPropertyList
282 virtual Bitmap
CreateBitmapForUI(long nIndex
);
285 XColorList(const OUString
& rPath
, const OUString
& rReferer
)
286 : XPropertyList(XCOLOR_LIST
, rPath
, rReferer
) {}
288 using XPropertyList::Replace
;
289 using XPropertyList::Remove
;
291 XColorEntry
* Replace(long nIndex
, XColorEntry
* pEntry
);
292 XColorEntry
* Remove(long nIndex
);
293 XColorEntry
* GetColor(long nIndex
) const;
294 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
295 virtual bool Create();
297 static XColorListRef
CreateStdColorList();
298 static XColorListRef
GetStdColorList(); // returns a singleton
301 // -------------------
302 // class XLineEndList
303 // -------------------
305 class SVX_DLLPUBLIC XLineEndList
: public XPropertyList
308 virtual Bitmap
CreateBitmapForUI(long nIndex
);
311 XLineEndList(const OUString
& rPath
, const OUString
& rReferer
);
312 virtual ~XLineEndList();
314 using XPropertyList::Remove
;
315 XLineEndEntry
* Remove(long nIndex
);
316 XLineEndEntry
* GetLineEnd(long nIndex
) const;
318 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
319 virtual bool Create();
322 // -------------------
324 // -------------------
326 class SVX_DLLPUBLIC XDashList
: public XPropertyList
329 Bitmap maBitmapSolidLine
;
330 OUString maStringSolidLine
;
331 OUString maStringNoLine
;
334 Bitmap
ImpCreateBitmapForXDash(const XDash
* pDash
);
335 virtual Bitmap
CreateBitmapForUI(long nIndex
);
338 XDashList(const OUString
& rPath
, const OUString
& rReferer
);
339 virtual ~XDashList();
341 using XPropertyList::Replace
;
342 XDashEntry
* Replace(XDashEntry
* pEntry
, long nIndex
);
343 using XPropertyList::Remove
;
344 XDashEntry
* Remove(long nIndex
);
345 XDashEntry
* GetDash(long nIndex
) const;
347 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
348 virtual bool Create();
350 // Special call to get a bitmap for the solid line representation. It
351 // creates a bitmap fitting in size and style to the ones you get by
352 // using GetUiBitmap for existing entries.
353 Bitmap
GetBitmapForUISolidLine() const;
355 // Special calls to get the translated strings for the UI entry for no
356 // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs
357 OUString
GetStringForUiSolidLine() const;
358 OUString
GetStringForUiNoLine() const;
361 // -------------------
363 // -------------------
365 class SVX_DLLPUBLIC XHatchList
: public XPropertyList
368 virtual Bitmap
CreateBitmapForUI(long nIndex
);
371 XHatchList(const OUString
& rPath
, const OUString
& rReferer
);
372 virtual ~XHatchList();
374 using XPropertyList::Replace
;
375 XHatchEntry
* Replace(XHatchEntry
* pEntry
, long nIndex
);
376 using XPropertyList::Remove
;
377 XHatchEntry
* Remove(long nIndex
);
378 XHatchEntry
* GetHatch(long nIndex
) const;
380 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
381 virtual bool Create();
384 // -------------------
385 // class XGradientList
386 // -------------------
387 class SVX_DLLPUBLIC XGradientList
: public XPropertyList
390 virtual Bitmap
CreateBitmapForUI(long nIndex
);
393 XGradientList(const OUString
& rPath
, const OUString
& rReferer
);
394 virtual ~XGradientList();
396 using XPropertyList::Replace
;
397 XGradientEntry
* Replace(XGradientEntry
* pEntry
, long nIndex
);
398 using XPropertyList::Remove
;
399 XGradientEntry
* Remove(long nIndex
);
400 XGradientEntry
* GetGradient(long nIndex
) const;
402 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
403 virtual bool Create();
406 // -------------------
408 // -------------------
410 class SVX_DLLPUBLIC XBitmapList
: public XPropertyList
413 virtual Bitmap
CreateBitmapForUI(long nIndex
);
416 XBitmapList(const OUString
& rPath
, const OUString
& rReferer
)
417 : XPropertyList(XBITMAP_LIST
, rPath
, rReferer
) {}
419 using XPropertyList::Replace
;
420 using XPropertyList::Remove
;
421 XBitmapEntry
* Remove(long nIndex
);
422 XBitmapEntry
* GetBitmap(long nIndex
) const;
424 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> createInstance();
425 virtual bool Create();
429 // FIXME: could add type checking too ...
430 inline XDashListRef
XPropertyList::AsDashList() { return XDashListRef( static_cast<XDashList
*> (this) ); }
431 inline XHatchListRef
XPropertyList::AsHatchList() { return XHatchListRef( static_cast<XHatchList
*> (this) ); }
432 inline XColorListRef
XPropertyList::AsColorList() { return XColorListRef( static_cast<XColorList
*> (this) ); }
433 inline XBitmapListRef
XPropertyList::AsBitmapList() { return XBitmapListRef( static_cast<XBitmapList
*> (this) ); }
434 inline XLineEndListRef
XPropertyList::AsLineEndList() { return XLineEndListRef( static_cast<XLineEndList
*> (this) ); }
435 inline XGradientListRef
XPropertyList::AsGradientList() { return XGradientListRef( static_cast<XGradientList
*> (this) ); }
437 #endif // INCLUDED_SVX_XTABLE_HXX
439 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */