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

Generated by: LCOV version 1.10