Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / xtable.hxx
blob6039e151af3a094296802bb30f54a52e0d6896d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
43 #include <limits>
44 #include <memory>
46 class Color;
47 class Bitmap;
48 class VirtualDevice;
50 // standard reference string
51 extern sal_Unicode pszStandard[]; // "standard"
53 // function to convert in real RGB_Colours;
54 // it can't be compared with enum COL_NAME
55 SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName );
57 class SVX_DLLPUBLIC XColorEntry : public XPropertyEntry
59 private:
60 Color aColor;
62 public:
63 XColorEntry(const Color& rColor, const OUString& rName);
64 XColorEntry(const XColorEntry& rOther);
66 const Color& GetColor() const
68 return aColor;
72 class SVX_DLLPUBLIC XLineEndEntry : public XPropertyEntry
74 private:
75 basegfx::B2DPolyPolygon aB2DPolyPolygon;
77 public:
78 XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const OUString& rName);
79 XLineEndEntry(const XLineEndEntry& rOther);
81 const basegfx::B2DPolyPolygon& GetLineEnd() const
83 return aB2DPolyPolygon;
87 class SVX_DLLPUBLIC XDashEntry : public XPropertyEntry
89 private:
90 XDash aDash;
92 public:
93 XDashEntry(const XDash& rDash, const OUString& rName);
94 XDashEntry(const XDashEntry& rOther);
96 const XDash& GetDash() const
98 return aDash;
102 class SVX_DLLPUBLIC XHatchEntry : public XPropertyEntry
104 private:
105 XHatch aHatch;
107 public:
108 XHatchEntry(const XHatch& rHatch, const OUString& rName);
109 XHatchEntry(const XHatchEntry& rOther);
111 const XHatch& GetHatch() const
113 return aHatch;
117 class SVX_DLLPUBLIC XGradientEntry : public XPropertyEntry
119 private:
120 XGradient aGradient;
122 public:
123 XGradientEntry(const XGradient& rGradient, const OUString& rName);
124 XGradientEntry(const XGradientEntry& rOther);
126 const XGradient& GetGradient() const
128 return aGradient;
132 class SVX_DLLPUBLIC XBitmapEntry : public XPropertyEntry
134 private:
135 GraphicObject maGraphicObject;
137 public:
138 XBitmapEntry(const GraphicObject& rGraphicObject, const OUString& rName);
139 XBitmapEntry(const XBitmapEntry& rOther);
141 const GraphicObject& GetGraphicObject() const
143 return maGraphicObject;
147 enum class XPropertyListType {
148 Unknown = -1,
149 Color,
150 LineEnd,
151 Dash,
152 Hatch,
153 Gradient,
154 Bitmap,
155 Pattern,
156 LAST = Pattern
159 typedef rtl::Reference< class XPropertyList > XPropertyListRef;
161 class XDashList ; typedef rtl::Reference< class XDashList > XDashListRef;
162 class XHatchList ; typedef rtl::Reference< class XHatchList > XHatchListRef;
163 class XColorList ; typedef rtl::Reference< class XColorList > XColorListRef;
164 class XBitmapList ; typedef rtl::Reference< class XBitmapList > XBitmapListRef;
165 class XPatternList ; typedef rtl::Reference< class XPatternList > XPatternListRef;
166 class XLineEndList ; typedef rtl::Reference< class XLineEndList > XLineEndListRef;
167 class XGradientList ; typedef rtl::Reference< class XGradientList > XGradientListRef;
169 class SVX_DLLPUBLIC XPropertyList : public cppu::OWeakObject
171 private:
172 SAL_DLLPRIVATE void* operator new(size_t);
173 protected:
174 SAL_DLLPRIVATE void operator delete(void *);
175 protected:
176 typedef std::vector< std::unique_ptr<XPropertyEntry> > XPropertyEntryList_impl;
178 XPropertyListType meType;
179 OUString maName; // not persistent
180 OUString maPath;
181 OUString maReferer;
183 XPropertyEntryList_impl maList;
185 bool mbListDirty;
186 bool mbEmbedInDocument;
188 XPropertyList(XPropertyListType t, const OUString& rPath, const OUString& rReferer);
189 bool isValidIdx(long nIndex) const;
190 virtual Bitmap CreateBitmapForUI(long nIndex) = 0;
192 public:
193 XPropertyList(const XPropertyList&) = delete;
194 XPropertyList& operator=(const XPropertyList&) = delete;
195 virtual ~XPropertyList() override;
197 XPropertyListType Type() const { return meType; }
198 long Count() const;
200 void Insert(std::unique_ptr<XPropertyEntry> pEntry, long nIndex = std::numeric_limits<long>::max());
201 void Replace(std::unique_ptr<XPropertyEntry> pEntry, long nIndex);
202 void Remove(long nIndex);
204 XPropertyEntry* Get(long nIndex) const;
205 long GetIndex(const OUString& rName) const;
206 Bitmap GetUiBitmap(long nIndex) const;
208 const OUString& GetName() const { return maName; }
209 void SetName(const OUString& rString);
211 const OUString& GetPath() const { return maPath; }
212 void SetPath(const OUString& rString) { maPath = rString; }
214 void SetDirty(bool bDirty) { mbListDirty = bDirty; }
216 bool IsEmbedInDocument() const { return mbEmbedInDocument; }
218 static OUString GetDefaultExt(XPropertyListType t);
219 OUString GetDefaultExt() const { return GetDefaultExt(meType); }
221 virtual css::uno::Reference< css::container::XNameContainer >
222 createInstance() = 0;
223 bool Load();
224 bool LoadFrom(const css::uno::Reference<
225 css::embed::XStorage > &xStorage,
226 const OUString &rURL, const OUString &rReferer);
227 bool Save();
228 bool SaveTo (const css::uno::Reference<
229 css::embed::XStorage > &xStorage,
230 const OUString &rURL,
231 OUString *pOptName);
232 virtual bool Create() = 0;
234 // Factory method for sub-classes
235 static XPropertyListRef CreatePropertyList(XPropertyListType t,
236 const OUString& rPath,
237 const OUString& rReferer);
238 // as above but initializes name as expected
239 static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t,
240 const OUString & rUrl);
242 // helper accessors
243 static inline XDashListRef AsDashList(
244 rtl::Reference<XPropertyList> const & plist);
245 static inline XHatchListRef AsHatchList(
246 rtl::Reference<XPropertyList> const & plist);
247 static inline XColorListRef AsColorList(
248 rtl::Reference<XPropertyList> const & plist);
249 static inline XBitmapListRef AsBitmapList(
250 rtl::Reference<XPropertyList> const & plist);
251 static inline XPatternListRef AsPatternList(
252 rtl::Reference<XPropertyList> const & plist);
253 static inline XLineEndListRef AsLineEndList(
254 rtl::Reference<XPropertyList> const & plist);
255 static inline XGradientListRef AsGradientList(
256 rtl::Reference<XPropertyList> const & plist);
259 class SVX_DLLPUBLIC XColorList : public XPropertyList
261 protected:
262 virtual Bitmap CreateBitmapForUI(long nIndex) override;
264 public:
265 XColorList(const OUString& rPath, const OUString& rReferer)
266 : XPropertyList(XPropertyListType::Color, rPath, rReferer) {}
268 void Replace(long nIndex, std::unique_ptr<XColorEntry> pEntry);
269 XColorEntry* GetColor(long nIndex) const;
270 long GetIndexOfColor( const Color& rColor) const;
271 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
272 virtual bool Create() override;
274 static XColorListRef CreateStdColorList();
275 static XColorListRef GetStdColorList(); // returns a singleton
278 class SVX_DLLPUBLIC XLineEndList : public XPropertyList
280 protected:
281 virtual Bitmap CreateBitmapForUI(long nIndex) override;
283 public:
284 XLineEndList(const OUString& rPath, const OUString& rReferer);
285 virtual ~XLineEndList() override;
287 XLineEndEntry* GetLineEnd(long nIndex) const;
289 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
290 virtual bool Create() override;
293 class SVX_DLLPUBLIC XDashList : public XPropertyList
295 private:
296 Bitmap maBitmapSolidLine;
297 OUString maStringSolidLine;
298 OUString maStringNoLine;
300 protected:
301 static Bitmap ImpCreateBitmapForXDash(const XDash* pDash);
302 virtual Bitmap CreateBitmapForUI(long nIndex) override;
304 public:
305 XDashList(const OUString& rPath, const OUString& rReferer);
306 virtual ~XDashList() override;
308 void Replace(std::unique_ptr<XDashEntry> pEntry, long nIndex);
309 XDashEntry* GetDash(long nIndex) const;
311 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
312 virtual bool Create() override;
314 // Special call to get a bitmap for the solid line representation. It
315 // creates a bitmap fitting in size and style to the ones you get by
316 // using GetUiBitmap for existing entries.
317 Bitmap const & GetBitmapForUISolidLine() const;
319 // Special calls to get the translated strings for the UI entry for no
320 // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs
321 OUString const & GetStringForUiSolidLine() const;
322 OUString const & GetStringForUiNoLine() const;
325 class SVX_DLLPUBLIC XHatchList : public XPropertyList
327 private:
328 Bitmap CreateBitmap(long nIndex, const Size& rSize) const;
329 protected:
330 virtual Bitmap CreateBitmapForUI(long nIndex) override;
331 public:
332 XHatchList(const OUString& rPath, const OUString& rReferer);
333 virtual ~XHatchList() override;
335 void Replace(std::unique_ptr<XHatchEntry> pEntry, long nIndex);
336 XHatchEntry* GetHatch(long nIndex) const;
337 Bitmap GetBitmapForPreview(long nIndex, const Size& rSize);
339 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
340 virtual bool Create() override;
343 class SVX_DLLPUBLIC XGradientList : public XPropertyList
345 private:
346 Bitmap CreateBitmap(long nIndex, const Size& rSize) const;
348 protected:
349 virtual Bitmap CreateBitmapForUI(long nIndex) override;
351 public:
352 XGradientList(const OUString& rPath, const OUString& rReferer);
353 virtual ~XGradientList() override;
355 void Replace(std::unique_ptr<XGradientEntry> pEntry, long nIndex);
356 XGradientEntry* GetGradient(long nIndex) const;
357 Bitmap GetBitmapForPreview(long nIndex, const Size& rSize);
359 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
360 virtual bool Create() override;
363 class SVX_DLLPUBLIC XBitmapList : public XPropertyList
365 private:
366 Bitmap CreateBitmap( long nIndex, const Size& rSize ) const;
368 protected:
369 virtual Bitmap CreateBitmapForUI(long nIndex) override;
371 public:
372 XBitmapList(const OUString& rPath, const OUString& rReferer)
373 : XPropertyList(XPropertyListType::Bitmap, rPath, rReferer) {}
375 XBitmapEntry* GetBitmap(long nIndex) const;
376 Bitmap GetBitmapForPreview(long nIndex, const Size& rSize);
378 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
379 virtual bool Create() override;
382 class SVX_DLLPUBLIC XPatternList : public XPropertyList
384 private:
385 Bitmap CreateBitmap( long nIndex, const Size& rSize ) const;
387 protected:
388 virtual Bitmap CreateBitmapForUI(long nIndex) override;
390 public:
391 XPatternList(const OUString& rPath, const OUString& rReferer)
392 : XPropertyList(XPropertyListType::Pattern, rPath, rReferer) {}
394 XBitmapEntry* GetBitmap(long nIndex) const;
395 Bitmap GetBitmapForPreview(long nIndex, const Size& rSize);
397 virtual css::uno::Reference< css::container::XNameContainer > createInstance() override;
398 virtual bool Create() override;
401 // FIXME: could add type checking too ...
402 inline XDashListRef XPropertyList::AsDashList(
403 rtl::Reference<XPropertyList> const & plist)
404 { return XDashListRef( static_cast<XDashList *> (plist.get()) ); }
405 inline XHatchListRef XPropertyList::AsHatchList(
406 rtl::Reference<XPropertyList> const & plist)
407 { return XHatchListRef( static_cast<XHatchList *> (plist.get()) ); }
408 inline XColorListRef XPropertyList::AsColorList(
409 rtl::Reference<XPropertyList> const & plist)
410 { return XColorListRef( static_cast<XColorList *> (plist.get()) ); }
411 inline XBitmapListRef XPropertyList::AsBitmapList(
412 rtl::Reference<XPropertyList> const & plist)
413 { return XBitmapListRef( static_cast<XBitmapList *> (plist.get()) ); }
414 inline XPatternListRef XPropertyList::AsPatternList(
415 rtl::Reference<XPropertyList> const & plist)
416 { return XPatternListRef( static_cast<XPatternList *> (plist.get()) ); }
417 inline XLineEndListRef XPropertyList::AsLineEndList(
418 rtl::Reference<XPropertyList> const & plist)
419 { return XLineEndListRef( static_cast<XLineEndList *> (plist.get()) ); }
420 inline XGradientListRef XPropertyList::AsGradientList(
421 rtl::Reference<XPropertyList> const & plist)
422 { return XGradientListRef( static_cast<XGradientList *> (plist.get()) ); }
424 #endif // INCLUDED_SVX_XTABLE_HXX
426 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */