LCOV - code coverage report
Current view: top level - include/svx - xtable.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 38 81.6 %
Date: 2014-04-11 Functions: 33 39 84.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef INCLUDED_SVX_XTABLE_HXX
      20             : #define INCLUDED_SVX_XTABLE_HXX
      21             : 
      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>
      30             : 
      31             : #include <tools/color.hxx>
      32             : #include <tools/contnr.hxx>
      33             : 
      34             : #include <cppuhelper/weak.hxx>
      35             : 
      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>
      42             : 
      43             : #include <limits>
      44             : 
      45             : class Color;
      46             : class Bitmap;
      47             : class VirtualDevice;
      48             : 
      49             : // Standard-Vergleichsstring
      50             : extern sal_Unicode 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 XColorEntry
      58             : 
      59             : 
      60       15030 : class SVX_DLLPUBLIC XColorEntry : public XPropertyEntry
      61             : {
      62             : private:
      63             :     Color   aColor;
      64             : 
      65             : public:
      66             :     XColorEntry(const Color& rColor, const OUString& rName);
      67             :     XColorEntry(const XColorEntry& rOther);
      68             : 
      69       20708 :     const Color& GetColor() const
      70             :     {
      71       20708 :         return aColor;
      72             :     }
      73             : };
      74             : 
      75             : 
      76             : // class XLineEndEntry
      77             : 
      78             : 
      79          80 : class SVX_DLLPUBLIC XLineEndEntry : public XPropertyEntry
      80             : {
      81             : private:
      82             :     basegfx::B2DPolyPolygon aB2DPolyPolygon;
      83             : 
      84             : public:
      85             :     XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const OUString& rName);
      86             :     XLineEndEntry(const XLineEndEntry& rOther);
      87             : 
      88           0 :     const basegfx::B2DPolyPolygon& GetLineEnd() const
      89             :     {
      90           0 :         return aB2DPolyPolygon;
      91             :     }
      92             : };
      93             : 
      94             : 
      95             : // class XDashEntry
      96             : 
      97             : 
      98        1086 : class SVX_DLLPUBLIC XDashEntry : public XPropertyEntry
      99             : {
     100             : private:
     101             :     XDash   aDash;
     102             : 
     103             : public:
     104             :     XDashEntry(const XDash& rDash, const OUString& rName);
     105             :     XDashEntry(const XDashEntry& rOther);
     106             : 
     107         818 :     const XDash& GetDash() const
     108             :     {
     109         818 :         return aDash;
     110             :     }
     111             : };
     112             : 
     113             : 
     114             : // class XHatchEntry
     115             : 
     116             : 
     117         118 : class SVX_DLLPUBLIC XHatchEntry : public XPropertyEntry
     118             : {
     119             : private:
     120             :     XHatch  aHatch;
     121             : 
     122             : public:
     123             :     XHatchEntry(const XHatch& rHatch, const OUString& rName);
     124             :     XHatchEntry(const XHatchEntry& rOther);
     125             : 
     126         286 :     const XHatch& GetHatch() const
     127             :     {
     128         286 :         return aHatch;
     129             :     }
     130             : };
     131             : 
     132             : 
     133             : // class XGradientEntry
     134             : 
     135             : 
     136         248 : class SVX_DLLPUBLIC XGradientEntry : public XPropertyEntry
     137             : {
     138             : private:
     139             :     XGradient  aGradient;
     140             : 
     141             : public:
     142             :     XGradientEntry(const XGradient& rGradient, const OUString& rName);
     143             :     XGradientEntry(const XGradientEntry& rOther);
     144             : 
     145         474 :     const XGradient& GetGradient() const
     146             :     {
     147         474 :         return aGradient;
     148             :     }
     149             : };
     150             : 
     151             : 
     152             : // class XBitmapEntry
     153             : 
     154             : 
     155          84 : class SVX_DLLPUBLIC XBitmapEntry : public XPropertyEntry
     156             : {
     157             : private:
     158             :     GraphicObject   maGraphicObject;
     159             : 
     160             : public:
     161             :     XBitmapEntry(const GraphicObject& rGraphicObject, const OUString& rName);
     162             :     XBitmapEntry(const XBitmapEntry& rOther);
     163             : 
     164           0 :     const GraphicObject& GetGraphicObject() const
     165             :     {
     166           0 :         return maGraphicObject;
     167             :     }
     168             : };
     169             : 
     170             : 
     171             : // class XPropertyList
     172             : 
     173             : 
     174             : enum XPropertyListType {
     175             :     XCOLOR_LIST,
     176             :     XLINE_END_LIST,
     177             :     XDASH_LIST,
     178             :     XHATCH_LIST,
     179             :     XGRADIENT_LIST,
     180             :     XBITMAP_LIST,
     181             :     XPROPERTY_LIST_COUNT
     182             : };
     183             : 
     184             : typedef rtl::Reference< class XPropertyList > XPropertyListRef;
     185             : 
     186             : class XDashList ; typedef rtl::Reference< class XDashList > XDashListRef;
     187             : class XHatchList ; typedef rtl::Reference< class XHatchList > XHatchListRef;
     188             : class XColorList ; typedef rtl::Reference< class XColorList > XColorListRef;
     189             : class XBitmapList ; typedef rtl::Reference< class XBitmapList > XBitmapListRef;
     190             : class XLineEndList ; typedef rtl::Reference< class XLineEndList > XLineEndListRef;
     191             : class XGradientList ; typedef rtl::Reference< class XGradientList > XGradientListRef;
     192             : 
     193             : class SVX_DLLPUBLIC XPropertyList : public cppu::OWeakObject
     194             : {
     195             :  private:
     196             :     SAL_DLLPRIVATE void* operator new(size_t);
     197             :  protected:
     198             :     SAL_DLLPRIVATE void operator delete(void *);
     199             : protected:
     200             :     typedef ::std::vector< XPropertyEntry* > XPropertyEntryList_impl;
     201             :     typedef ::std::vector< Bitmap* > BitmapList_impl;
     202             : 
     203             :     XPropertyListType   meType;
     204             :     OUString            maName; // not persistent
     205             :     OUString            maPath;
     206             :     OUString            maReferer;
     207             : 
     208             :     XPropertyEntryList_impl maList;
     209             : 
     210             :     bool                mbListDirty;
     211             :     bool                mbEmbedInDocument;
     212             : 
     213             :     XPropertyList(XPropertyListType t, const OUString& rPath, const OUString& rReferer);
     214             : 
     215             :     virtual Bitmap CreateBitmapForUI(long nIndex) = 0;
     216             : 
     217             : public:
     218             :     virtual ~XPropertyList();
     219             : 
     220        2119 :     XPropertyListType Type() const { return meType; }
     221             :     long Count() const;
     222             : 
     223             :     void Insert(XPropertyEntry* pEntry, long nIndex = ::std::numeric_limits<long>::max());
     224             :     XPropertyEntry* Replace(XPropertyEntry* pEntry, long nIndex);
     225             :     XPropertyEntry* Remove(long nIndex);
     226             : 
     227             :     XPropertyEntry* Get(long nIndex) const;
     228             :     long GetIndex(const OUString& rName) const;
     229             :     Bitmap GetUiBitmap(long nIndex) const;
     230             : 
     231         132 :     const OUString& GetName() const { return maName; }
     232             :     void SetName(const OUString& rString);
     233             : 
     234         132 :     const OUString& GetPath() const { return maPath; }
     235           0 :     void SetPath(const OUString& rString) { maPath = rString; }
     236             : 
     237             :     bool IsDirty() const { return mbListDirty; }
     238           0 :     void SetDirty(bool bDirty = true) { mbListDirty = bDirty; }
     239             : 
     240         132 :     bool IsEmbedInDocument() const { return mbEmbedInDocument; }
     241           0 :     void SetEmbedInDocument(bool b) { mbEmbedInDocument = b; }
     242             : 
     243             :     static OUString GetDefaultExt(XPropertyListType t);
     244             :     static OUString GetDefaultExtFilter(XPropertyListType t);
     245         297 :     OUString GetDefaultExt() const { return GetDefaultExt(meType); }
     246             : 
     247             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     248             :         createInstance() = 0;
     249             :     bool Load();
     250             :     bool LoadFrom(const ::com::sun::star::uno::Reference<
     251             :                        ::com::sun::star::embed::XStorage > &xStorage,
     252             :                   const OUString &rURL, const OUString &rReferer);
     253             :     bool Save();
     254             :     bool SaveTo  (const ::com::sun::star::uno::Reference<
     255             :                        ::com::sun::star::embed::XStorage > &xStorage,
     256             :                    const OUString &rURL,
     257             :                                   OUString *pOptName);
     258             :     virtual bool Create() = 0;
     259             : 
     260             :     // Factory method for sub-classes
     261             :     static XPropertyListRef CreatePropertyList(XPropertyListType t,
     262             :                                                const OUString& rPath,
     263             :                                                const OUString& rReferer);
     264             :     // as above but initializes name as expected
     265             :     static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t,
     266             :                                                        const OUString & rUrl);
     267             : 
     268             :     // helper accessors
     269             :     inline XDashListRef  AsDashList();
     270             :     inline XHatchListRef AsHatchList();
     271             :     inline XColorListRef AsColorList();
     272             :     inline XBitmapListRef AsBitmapList();
     273             :     inline XLineEndListRef AsLineEndList();
     274             :     inline XGradientListRef AsGradientList();
     275             : };
     276             : 
     277             : 
     278             : // class XColorList
     279             : 
     280             : 
     281         578 : class SVX_DLLPUBLIC XColorList : public XPropertyList
     282             : {
     283             : protected:
     284             :     virtual Bitmap  CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     285             : 
     286             : public:
     287         452 :     XColorList(const OUString& rPath, const OUString& rReferer)
     288         452 :         : XPropertyList(XCOLOR_LIST, rPath, rReferer) {}
     289             : 
     290             :     using XPropertyList::Replace;
     291             :     using XPropertyList::Remove;
     292             : 
     293             :     XColorEntry* Replace(long nIndex, XColorEntry* pEntry);
     294             :     XColorEntry* Remove(long nIndex);
     295             :     XColorEntry* GetColor(long nIndex) const;
     296             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     297             :     virtual bool Create() SAL_OVERRIDE;
     298             : 
     299             :     static XColorListRef CreateStdColorList();
     300             :     static XColorListRef GetStdColorList(); // returns a singleton
     301             : };
     302             : 
     303             : 
     304             : // class XLineEndList
     305             : 
     306             : 
     307             : class SVX_DLLPUBLIC XLineEndList : public XPropertyList
     308             : {
     309             : protected:
     310             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     311             : 
     312             : public:
     313             :     XLineEndList(const OUString& rPath, const OUString& rReferer);
     314             :     virtual ~XLineEndList();
     315             : 
     316             :     using XPropertyList::Remove;
     317             :     XLineEndEntry* Remove(long nIndex);
     318             :     XLineEndEntry* GetLineEnd(long nIndex) const;
     319             : 
     320             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     321             :     virtual bool Create() SAL_OVERRIDE;
     322             : };
     323             : 
     324             : 
     325             : // class XDashList
     326             : 
     327             : 
     328             : class SVX_DLLPUBLIC XDashList : public XPropertyList
     329             : {
     330             : private:
     331             :     Bitmap              maBitmapSolidLine;
     332             :     OUString            maStringSolidLine;
     333             :     OUString            maStringNoLine;
     334             : 
     335             : protected:
     336             :     Bitmap ImpCreateBitmapForXDash(const XDash* pDash);
     337             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     338             : 
     339             : public:
     340             :     XDashList(const OUString& rPath, const OUString& rReferer);
     341             :     virtual ~XDashList();
     342             : 
     343             :     using XPropertyList::Replace;
     344             :     XDashEntry* Replace(XDashEntry* pEntry, long nIndex);
     345             :     using XPropertyList::Remove;
     346             :     XDashEntry* Remove(long nIndex);
     347             :     XDashEntry* GetDash(long nIndex) const;
     348             : 
     349             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     350             :     virtual bool Create() SAL_OVERRIDE;
     351             : 
     352             :     // Special call to get a bitmap for the solid line representation. It
     353             :     // creates a bitmap fitting in size and style to the ones you get by
     354             :     // using GetUiBitmap for existing entries.
     355             :     Bitmap GetBitmapForUISolidLine() const;
     356             : 
     357             :     // Special calls to get the translated strings for the UI entry for no
     358             :     // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs
     359             :     OUString GetStringForUiSolidLine() const;
     360             :     OUString GetStringForUiNoLine() const;
     361             : };
     362             : 
     363             : 
     364             : // class XHatchList
     365             : 
     366             : 
     367             : class SVX_DLLPUBLIC XHatchList : public XPropertyList
     368             : {
     369             : protected:
     370             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     371             : 
     372             : public:
     373             :     XHatchList(const OUString& rPath, const OUString& rReferer);
     374             :     virtual ~XHatchList();
     375             : 
     376             :     using XPropertyList::Replace;
     377             :     XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex);
     378             :     using XPropertyList::Remove;
     379             :     XHatchEntry* Remove(long nIndex);
     380             :     XHatchEntry* GetHatch(long nIndex) const;
     381             : 
     382             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     383             :     virtual bool Create() SAL_OVERRIDE;
     384             : };
     385             : 
     386             : 
     387             : // class XGradientList
     388             : 
     389             : class SVX_DLLPUBLIC XGradientList : public XPropertyList
     390             : {
     391             : protected:
     392             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     393             : 
     394             : public:
     395             :     XGradientList(const OUString& rPath, const OUString& rReferer);
     396             :     virtual ~XGradientList();
     397             : 
     398             :     using XPropertyList::Replace;
     399             :     XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex);
     400             :     using XPropertyList::Remove;
     401             :     XGradientEntry* Remove(long nIndex);
     402             :     XGradientEntry* GetGradient(long nIndex) const;
     403             : 
     404             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     405             :     virtual bool Create() SAL_OVERRIDE;
     406             : };
     407             : 
     408             : 
     409             : // class XBitmapList
     410             : 
     411             : 
     412        4658 : class SVX_DLLPUBLIC XBitmapList : public XPropertyList
     413             : {
     414             : protected:
     415             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     416             : 
     417             : public:
     418        2495 :     XBitmapList(const OUString& rPath, const OUString& rReferer)
     419        2495 :         : XPropertyList(XBITMAP_LIST, rPath, rReferer) {}
     420             : 
     421             :     using XPropertyList::Replace;
     422             :     using XPropertyList::Remove;
     423             :     XBitmapEntry* Remove(long nIndex);
     424             :     XBitmapEntry* GetBitmap(long nIndex) const;
     425             : 
     426             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     427             :     virtual bool Create() SAL_OVERRIDE;
     428             : };
     429             : 
     430             : 
     431             : // FIXME: could add type checking too ...
     432        2819 : inline XDashListRef  XPropertyList::AsDashList() { return XDashListRef( static_cast<XDashList *> (this) ); }
     433        5768 : inline XHatchListRef XPropertyList::AsHatchList() { return XHatchListRef( static_cast<XHatchList *> (this) ); }
     434        3872 : inline XColorListRef XPropertyList::AsColorList() { return XColorListRef( static_cast<XColorList *> (this) ); }
     435        5768 : inline XBitmapListRef XPropertyList::AsBitmapList() { return XBitmapListRef( static_cast<XBitmapList *> (this) ); }
     436        2562 : inline XLineEndListRef XPropertyList::AsLineEndList() { return XLineEndListRef( static_cast<XLineEndList *> (this) ); }
     437        5768 : inline XGradientListRef XPropertyList::AsGradientList() { return XGradientListRef( static_cast<XGradientList *> (this) ); }
     438             : 
     439             : #endif // INCLUDED_SVX_XTABLE_HXX
     440             : 
     441             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10