LCOV - code coverage report
Current view: top level - include/svx - xtable.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 44 88.6 %
Date: 2014-11-03 Functions: 34 39 87.2 %
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 reference string
      50             : extern sal_Unicode pszStandard[]; // "standard"
      51             : 
      52             : // function to convert in real RGB_Colours;
      53             : // it can't be compared with enum COL_NAME
      54             : SVX_DLLPUBLIC Color RGB_Color( ColorData nColorName );
      55             : 
      56             : 
      57             : // class XColorEntry
      58             : 
      59             : 
      60       20374 : 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        9519 :     const Color& GetColor() const
      70             :     {
      71        9519 :         return aColor;
      72             :     }
      73             : };
      74             : 
      75             : 
      76             : // class XLineEndEntry
      77             : 
      78             : 
      79         160 : 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        2938 : 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        1878 :     const XDash& GetDash() const
     108             :     {
     109        1878 :         return aDash;
     110             :     }
     111             : };
     112             : 
     113             : 
     114             : // class XHatchEntry
     115             : 
     116             : 
     117         248 : 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         764 :     const XHatch& GetHatch() const
     127             :     {
     128         764 :         return aHatch;
     129             :     }
     130             : };
     131             : 
     132             : 
     133             : // class XGradientEntry
     134             : 
     135             : 
     136        1120 : 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        1944 :     const XGradient& GetGradient() const
     146             :     {
     147        1944 :         return aGradient;
     148             :     }
     149             : };
     150             : 
     151             : 
     152             : // class XBitmapEntry
     153             : 
     154             : 
     155         200 : 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          24 :     const GraphicObject& GetGraphicObject() const
     165             :     {
     166          24 :         return maGraphicObject;
     167             :     }
     168             : };
     169             : 
     170             : 
     171             : // class XPropertyList
     172             : 
     173             : 
     174             : enum XPropertyListType {
     175             :     UNKNOWN_XPROPERTYLISTTYPE = -1,
     176             :     XCOLOR_LIST,
     177             :     XLINE_END_LIST,
     178             :     XDASH_LIST,
     179             :     XHATCH_LIST,
     180             :     XGRADIENT_LIST,
     181             :     XBITMAP_LIST,
     182             :     XPROPERTY_LIST_COUNT
     183             : };
     184             : 
     185             : typedef rtl::Reference< class XPropertyList > XPropertyListRef;
     186             : 
     187             : class XDashList ; typedef rtl::Reference< class XDashList > XDashListRef;
     188             : class XHatchList ; typedef rtl::Reference< class XHatchList > XHatchListRef;
     189             : class XColorList ; typedef rtl::Reference< class XColorList > XColorListRef;
     190             : class XBitmapList ; typedef rtl::Reference< class XBitmapList > XBitmapListRef;
     191             : class XLineEndList ; typedef rtl::Reference< class XLineEndList > XLineEndListRef;
     192             : class XGradientList ; typedef rtl::Reference< class XGradientList > XGradientListRef;
     193             : 
     194             : class SVX_DLLPUBLIC XPropertyList : public cppu::OWeakObject
     195             : {
     196             :  private:
     197             :     SAL_DLLPRIVATE void* operator new(size_t);
     198             :  protected:
     199             :     SAL_DLLPRIVATE void operator delete(void *);
     200             : protected:
     201             :     typedef ::std::vector< XPropertyEntry* > XPropertyEntryList_impl;
     202             :     typedef ::std::vector< Bitmap* > BitmapList_impl;
     203             : 
     204             :     XPropertyListType   meType;
     205             :     OUString            maName; // not persistent
     206             :     OUString            maPath;
     207             :     OUString            maReferer;
     208             : 
     209             :     XPropertyEntryList_impl maList;
     210             : 
     211             :     bool                mbListDirty;
     212             :     bool                mbEmbedInDocument;
     213             : 
     214             :     XPropertyList(XPropertyListType t, const OUString& rPath, const OUString& rReferer);
     215             : 
     216             :     virtual Bitmap CreateBitmapForUI(long nIndex) = 0;
     217             : 
     218             : public:
     219             :     virtual ~XPropertyList();
     220             : 
     221        6078 :     XPropertyListType Type() const { return meType; }
     222             :     long Count() const;
     223             : 
     224             :     void Insert(XPropertyEntry* pEntry, long nIndex = ::std::numeric_limits<long>::max());
     225             :     XPropertyEntry* Replace(XPropertyEntry* pEntry, long nIndex);
     226             :     XPropertyEntry* Remove(long nIndex);
     227             : 
     228             :     XPropertyEntry* Get(long nIndex) const;
     229             :     long GetIndex(const OUString& rName) const;
     230             :     Bitmap GetUiBitmap(long nIndex) const;
     231             : 
     232         132 :     const OUString& GetName() const { return maName; }
     233             :     void SetName(const OUString& rString);
     234             : 
     235         132 :     const OUString& GetPath() const { return maPath; }
     236           0 :     void SetPath(const OUString& rString) { maPath = rString; }
     237             : 
     238             :     bool IsDirty() const { return mbListDirty; }
     239           0 :     void SetDirty(bool bDirty = true) { mbListDirty = bDirty; }
     240             : 
     241         132 :     bool IsEmbedInDocument() const { return mbEmbedInDocument; }
     242           0 :     void SetEmbedInDocument(bool b) { mbEmbedInDocument = b; }
     243             : 
     244             :     static OUString GetDefaultExt(XPropertyListType t);
     245             :     static OUString GetDefaultExtFilter(XPropertyListType t);
     246         496 :     OUString GetDefaultExt() const { return GetDefaultExt(meType); }
     247             : 
     248             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     249             :         createInstance() = 0;
     250             :     bool Load();
     251             :     bool LoadFrom(const ::com::sun::star::uno::Reference<
     252             :                        ::com::sun::star::embed::XStorage > &xStorage,
     253             :                   const OUString &rURL, const OUString &rReferer);
     254             :     bool Save();
     255             :     bool SaveTo  (const ::com::sun::star::uno::Reference<
     256             :                        ::com::sun::star::embed::XStorage > &xStorage,
     257             :                    const OUString &rURL,
     258             :                                   OUString *pOptName);
     259             :     virtual bool Create() = 0;
     260             : 
     261             :     // Factory method for sub-classes
     262             :     static XPropertyListRef CreatePropertyList(XPropertyListType t,
     263             :                                                const OUString& rPath,
     264             :                                                const OUString& rReferer);
     265             :     // as above but initializes name as expected
     266             :     static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t,
     267             :                                                        const OUString & rUrl);
     268             : 
     269             :     // helper accessors
     270             :     static inline XDashListRef AsDashList(
     271             :         rtl::Reference<XPropertyList> const & plist);
     272             :     static inline XHatchListRef AsHatchList(
     273             :         rtl::Reference<XPropertyList> const & plist);
     274             :     static inline XColorListRef AsColorList(
     275             :         rtl::Reference<XPropertyList> const & plist);
     276             :     static inline XBitmapListRef AsBitmapList(
     277             :         rtl::Reference<XPropertyList> const & plist);
     278             :     static inline XLineEndListRef AsLineEndList(
     279             :         rtl::Reference<XPropertyList> const & plist);
     280             :     static inline XGradientListRef AsGradientList(
     281             :         rtl::Reference<XPropertyList> const & plist);
     282             : };
     283             : 
     284             : 
     285             : // class XColorList
     286             : 
     287             : 
     288        2386 : class SVX_DLLPUBLIC XColorList : public XPropertyList
     289             : {
     290             : protected:
     291             :     virtual Bitmap  CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     292             : 
     293             : public:
     294        1230 :     XColorList(const OUString& rPath, const OUString& rReferer)
     295        1230 :         : XPropertyList(XCOLOR_LIST, rPath, rReferer) {}
     296             : 
     297             :     using XPropertyList::Replace;
     298             :     using XPropertyList::Remove;
     299             : 
     300             :     XColorEntry* Replace(long nIndex, XColorEntry* pEntry);
     301             :     XColorEntry* Remove(long nIndex);
     302             :     XColorEntry* GetColor(long nIndex) const;
     303             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     304             :     virtual bool Create() SAL_OVERRIDE;
     305             : 
     306             :     static XColorListRef CreateStdColorList();
     307             :     static XColorListRef GetStdColorList(); // returns a singleton
     308             : };
     309             : 
     310             : 
     311             : // class XLineEndList
     312             : 
     313             : 
     314             : class SVX_DLLPUBLIC XLineEndList : public XPropertyList
     315             : {
     316             : protected:
     317             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     318             : 
     319             : public:
     320             :     XLineEndList(const OUString& rPath, const OUString& rReferer);
     321             :     virtual ~XLineEndList();
     322             : 
     323             :     using XPropertyList::Remove;
     324             :     XLineEndEntry* Remove(long nIndex);
     325             :     XLineEndEntry* GetLineEnd(long nIndex) const;
     326             : 
     327             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     328             :     virtual bool Create() SAL_OVERRIDE;
     329             : };
     330             : 
     331             : 
     332             : // class XDashList
     333             : 
     334             : 
     335             : class SVX_DLLPUBLIC XDashList : public XPropertyList
     336             : {
     337             : private:
     338             :     Bitmap              maBitmapSolidLine;
     339             :     OUString            maStringSolidLine;
     340             :     OUString            maStringNoLine;
     341             : 
     342             : protected:
     343             :     Bitmap ImpCreateBitmapForXDash(const XDash* pDash);
     344             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     345             : 
     346             : public:
     347             :     XDashList(const OUString& rPath, const OUString& rReferer);
     348             :     virtual ~XDashList();
     349             : 
     350             :     using XPropertyList::Replace;
     351             :     XDashEntry* Replace(XDashEntry* pEntry, long nIndex);
     352             :     using XPropertyList::Remove;
     353             :     XDashEntry* Remove(long nIndex);
     354             :     XDashEntry* GetDash(long nIndex) const;
     355             : 
     356             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     357             :     virtual bool Create() SAL_OVERRIDE;
     358             : 
     359             :     // Special call to get a bitmap for the solid line representation. It
     360             :     // creates a bitmap fitting in size and style to the ones you get by
     361             :     // using GetUiBitmap for existing entries.
     362             :     Bitmap GetBitmapForUISolidLine() const;
     363             : 
     364             :     // Special calls to get the translated strings for the UI entry for no
     365             :     // line style (XLINE_NONE) and solid line style (XLINE_SOLID) for dialogs
     366             :     OUString GetStringForUiSolidLine() const;
     367             :     OUString GetStringForUiNoLine() const;
     368             : };
     369             : 
     370             : 
     371             : // class XHatchList
     372             : 
     373             : 
     374             : class SVX_DLLPUBLIC XHatchList : public XPropertyList
     375             : {
     376             : protected:
     377             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     378             : 
     379             : public:
     380             :     XHatchList(const OUString& rPath, const OUString& rReferer);
     381             :     virtual ~XHatchList();
     382             : 
     383             :     using XPropertyList::Replace;
     384             :     XHatchEntry* Replace(XHatchEntry* pEntry, long nIndex);
     385             :     using XPropertyList::Remove;
     386             :     XHatchEntry* Remove(long nIndex);
     387             :     XHatchEntry* GetHatch(long nIndex) const;
     388             : 
     389             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     390             :     virtual bool Create() SAL_OVERRIDE;
     391             : };
     392             : 
     393             : 
     394             : // class XGradientList
     395             : 
     396             : class SVX_DLLPUBLIC XGradientList : public XPropertyList
     397             : {
     398             : protected:
     399             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     400             : 
     401             : public:
     402             :     XGradientList(const OUString& rPath, const OUString& rReferer);
     403             :     virtual ~XGradientList();
     404             : 
     405             :     using XPropertyList::Replace;
     406             :     XGradientEntry* Replace(XGradientEntry* pEntry, long nIndex);
     407             :     using XPropertyList::Remove;
     408             :     XGradientEntry* Remove(long nIndex);
     409             :     XGradientEntry* GetGradient(long nIndex) const;
     410             : 
     411             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     412             :     virtual bool Create() SAL_OVERRIDE;
     413             : };
     414             : 
     415             : 
     416             : // class XBitmapList
     417             : 
     418             : 
     419       13842 : class SVX_DLLPUBLIC XBitmapList : public XPropertyList
     420             : {
     421             : protected:
     422             :     virtual Bitmap CreateBitmapForUI(long nIndex) SAL_OVERRIDE;
     423             : 
     424             : public:
     425        6962 :     XBitmapList(const OUString& rPath, const OUString& rReferer)
     426        6962 :         : XPropertyList(XBITMAP_LIST, rPath, rReferer) {}
     427             : 
     428             :     using XPropertyList::Replace;
     429             :     using XPropertyList::Remove;
     430             :     XBitmapEntry* Remove(long nIndex);
     431             :     XBitmapEntry* GetBitmap(long nIndex) const;
     432             : 
     433             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createInstance() SAL_OVERRIDE;
     434             :     virtual bool Create() SAL_OVERRIDE;
     435             : };
     436             : 
     437             : 
     438             : // FIXME: could add type checking too ...
     439        7210 : inline XDashListRef  XPropertyList::AsDashList(
     440             :     rtl::Reference<XPropertyList> const & plist)
     441        7210 : { return XDashListRef( static_cast<XDashList *> (plist.get()) ); }
     442       10138 : inline XHatchListRef XPropertyList::AsHatchList(
     443             :     rtl::Reference<XPropertyList> const & plist)
     444       10138 : { return XHatchListRef( static_cast<XHatchList *> (plist.get()) ); }
     445       10100 : inline XColorListRef XPropertyList::AsColorList(
     446             :     rtl::Reference<XPropertyList> const & plist)
     447       10100 : { return XColorListRef( static_cast<XColorList *> (plist.get()) ); }
     448       10138 : inline XBitmapListRef XPropertyList::AsBitmapList(
     449             :     rtl::Reference<XPropertyList> const & plist)
     450       10138 : { return XBitmapListRef( static_cast<XBitmapList *> (plist.get()) ); }
     451        6764 : inline XLineEndListRef XPropertyList::AsLineEndList(
     452             :     rtl::Reference<XPropertyList> const & plist)
     453        6764 : { return XLineEndListRef( static_cast<XLineEndList *> (plist.get()) ); }
     454       10138 : inline XGradientListRef XPropertyList::AsGradientList(
     455             :     rtl::Reference<XPropertyList> const & plist)
     456       10138 : { return XGradientListRef( static_cast<XGradientList *> (plist.get()) ); }
     457             : 
     458             : #endif // INCLUDED_SVX_XTABLE_HXX
     459             : 
     460             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10