LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/svl - style.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 24 87.5 %
Date: 2013-07-09 Functions: 17 26 65.4 %
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             : 
      20             : #ifndef _SFXSTYLE_HXX
      21             : #define _SFXSTYLE_HXX
      22             : 
      23             : #include <com/sun/star/style/XStyle.hpp>
      24             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      25             : 
      26             : #include <rtl/ref.hxx>
      27             : #include <vector>
      28             : #include <comphelper/weak.hxx>
      29             : #include <cppuhelper/implbase2.hxx>
      30             : #include "svl/svldllapi.h"
      31             : #include <rsc/rscsfx.hxx>
      32             : #include <svl/hint.hxx>
      33             : #include <svl/lstner.hxx>
      34             : #include <svl/brdcst.hxx>
      35             : #include <svl/poolitem.hxx>
      36             : #include <svl/stylesheetuser.hxx>
      37             : 
      38             : #include <svl/style.hrc>
      39             : #include <boost/shared_ptr.hpp>
      40             : 
      41             : class SfxItemSet;
      42             : class SfxItemPool;
      43             : class SfxStyleSheetBasePool;
      44             : class SvStream;
      45             : 
      46             : /*
      47             : Everyone changing instances of SfxStyleSheetBasePool or SfxStyleSheetBase
      48             : must broadcast this using <SfxStyleSheetBasePool::GetBroadcaster()> broadcasts.
      49             : The class <SfxStyleSheetHint> is used for this, it contains an Action-Id and a
      50             : pointer to the <SfxStyleSheetBase>. The actions are:
      51             : 
      52             : #define SFX_STYLESHEET_CREATED      // style is created
      53             : #define SFX_STYLESHEET_MODIFIED     // style is modified
      54             : #define SFX_STYLESHEET_CHANGED      // style is replaced
      55             : #define SFX_STYLESHEET_ERASED       // style is deleted
      56             : 
      57             : The following methods already broadcast themself
      58             : 
      59             : SfxSimpleHint(SFX_HINT_DYING) from:
      60             :    SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
      61             : 
      62             : SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) from:
      63             :    SfxStyleSheetBasePool::Make( const String& rName,
      64             :    SfxStyleFamily eFam, sal_uInt16 mask, sal_uInt16 nPos)
      65             : 
      66             : SfxStyleSheetHint( SFX_STYLESHEET_CHANGED, *pNew ) from:
      67             :    SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet )
      68             : 
      69             : SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) from:
      70             :    SfxStyleSheetBasePool::Erase( SfxStyleSheetBase* p )
      71             :    SfxStyleSheetBasePool::Clear()
      72             : */
      73             : 
      74             : class SVL_DLLPUBLIC SfxStyleSheetBase : public comphelper::OWeakTypeObject
      75             : {
      76             : private:
      77             :     friend class SfxStyleSheetBasePool;
      78             :     SVL_DLLPRIVATE static SfxStyleSheetBasePool& implGetStaticPool();
      79             : 
      80             : protected:
      81             :     SfxStyleSheetBasePool*  pPool;          // zugehoeriger Pool
      82             :     SfxStyleFamily          nFamily;        // Familie
      83             : 
      84             :     OUString                aName, aParent, aFollow;
      85             :     OUString                maDisplayName;
      86             :     OUString                aHelpFile;      // Name der Hilfedatei
      87             :     SfxItemSet*             pSet;           // ItemSet
      88             :     sal_uInt16              nMask;          // Flags
      89             : 
      90             :     sal_uLong               nHelpId;        // Hilfe-ID
      91             : 
      92             :     bool                    bMySet;         // sal_True: Set loeschen im dtor
      93             :     bool                    bHidden;
      94             : 
      95             :     SfxStyleSheetBase( const OUString&, SfxStyleSheetBasePool*, SfxStyleFamily eFam, sal_uInt16 mask );
      96             :     SfxStyleSheetBase( const SfxStyleSheetBase& );
      97             :     virtual ~SfxStyleSheetBase();
      98             :     virtual void Load( SvStream&, sal_uInt16 );
      99             :     virtual void Store( SvStream& );
     100             : 
     101             : public:
     102             :     TYPEINFO();
     103             : 
     104             :     // returns the internal name of this style
     105             :     virtual const OUString& GetName() const;
     106             : 
     107             :     // sets the internal name of this style
     108             :     virtual bool SetName( const OUString& );
     109             : 
     110             :     /** returns the display name of this style, it is used at the user interface.
     111             :         If the display name is empty, this method returns the internal name. */
     112             :     virtual OUString GetDisplayName() const;
     113             : 
     114             :     // sets the display name of this style
     115             :     virtual void SetDisplayName( const OUString& );
     116             : 
     117             :     virtual const OUString& GetParent() const;
     118             :     virtual bool SetParent( const OUString& );
     119             :     virtual const OUString& GetFollow() const;
     120             :     virtual bool SetFollow( const OUString& );
     121             :     virtual bool HasFollowSupport() const;      // Default true
     122             :     virtual bool HasParentSupport() const;      // Default true
     123             :     virtual bool HasClearParentSupport() const; // Default false
     124             :     virtual bool IsUsed() const;                // Default true
     125             :         // Default aus dem Itemset; entweder dem uebergebenen
     126             :         // oder aus dem per GetItemSet() zurueckgelieferten Set
     127             :     virtual OUString GetDescription();
     128             :     virtual OUString GetDescription( SfxMapUnit eMetric );
     129             : 
     130       36276 :     SfxStyleSheetBasePool& GetPool() { return *pPool; }
     131      267893 :     SfxStyleFamily GetFamily() const     { return nFamily; }
     132      188896 :     sal_uInt16   GetMask() const     { return nMask; }
     133           0 :     void     SetMask( sal_uInt16 mask) { nMask = mask; }
     134        1255 :     bool     IsUserDefined() const
     135        1255 :            { return ( nMask & SFXSTYLEBIT_USERDEF) != 0; }
     136             : 
     137        1107 :     virtual sal_Bool IsHidden() const { return bHidden; }
     138             :     virtual void SetHidden( sal_Bool bValue );
     139             : 
     140             :     virtual sal_uLong GetHelpId( OUString& rFile );
     141             :     virtual void   SetHelpId( const OUString& r, sal_uLong nId );
     142             : 
     143             :     virtual SfxItemSet& GetItemSet();
     144             :     virtual sal_uInt16 GetVersion() const;
     145             : };
     146             : 
     147             : //=========================================================================
     148             : 
     149             : typedef std::vector< rtl::Reference< SfxStyleSheetBase > > SfxStyles;
     150             : 
     151             : //=========================================================================
     152             : 
     153             : class SVL_DLLPUBLIC SfxStyleSheetIterator
     154             : 
     155             : /*  [Beschreibung]
     156             : 
     157             :     Klasse zum Iterieren und Suchen auf einem SfxStyleSheetBasePool.
     158             : 
     159             : */
     160             : 
     161             : {
     162             : public:
     163             :     SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase,
     164             :                           SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     165             :     virtual sal_uInt16 GetSearchMask() const;
     166             :     virtual SfxStyleFamily GetSearchFamily() const;
     167             :     virtual sal_uInt16 Count();
     168             :     virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx);
     169             :     virtual SfxStyleSheetBase* First();
     170             :     virtual SfxStyleSheetBase* Next();
     171             :     virtual SfxStyleSheetBase* Find(const OUString& rStr);
     172             :     virtual ~SfxStyleSheetIterator();
     173             : 
     174             : protected:
     175             : 
     176             :     SfxStyleSheetBasePool*  pBasePool;
     177             :     SfxStyleFamily          nSearchFamily;
     178             :     sal_uInt16              nMask;
     179             : 
     180       11727 :     bool                    SearchUsed() const { return bSearchUsed; }
     181             : 
     182             : private:
     183           0 :     sal_uInt16                  GetPos() { return nAktPosition; }
     184             :     SVL_DLLPRIVATE bool         IsTrivialSearch();
     185             :     SVL_DLLPRIVATE bool         DoesStyleMatch(SfxStyleSheetBase *pStyle);
     186             : 
     187             :     SfxStyleSheetBase*      pAktStyle;
     188             :     sal_uInt16              nAktPosition;
     189             :     bool                    bSearchUsed;
     190             : 
     191             : friend class SfxStyleSheetBasePool;
     192             : };
     193             : 
     194             : typedef ::boost::shared_ptr< SfxStyleSheetIterator > SfxStyleSheetIteratorPtr;
     195             : //=========================================================================
     196             : 
     197             : class SfxStyleSheetBasePool_Impl;
     198             : 
     199             : class SVL_DLLPUBLIC SfxStyleSheetBasePool: public SfxBroadcaster, public comphelper::OWeakTypeObject
     200             : {
     201             : friend class SfxStyleSheetIterator;
     202             : friend class SfxStyleSheetBase;
     203             : 
     204             :     SfxStyleSheetBasePool_Impl *pImp;
     205             : 
     206             : private:
     207             :     SVL_DLLPRIVATE SfxStyleSheetIterator&      GetIterator_Impl();
     208             : protected:
     209             :     OUString                    aAppName;
     210             :     SfxItemPool&                rPool;
     211             :     SfxStyles                   aStyles;
     212             :     SfxStyleFamily              nSearchFamily;
     213             :     sal_uInt16                  nMask;
     214             : 
     215             :     SfxStyleSheetBase&          Add( SfxStyleSheetBase& );
     216             :     void                        ChangeParent( const OUString&, const OUString&, bool bVirtual = true );
     217             :     virtual SfxStyleSheetBase*  Create( const OUString&, SfxStyleFamily, sal_uInt16 );
     218             :     virtual SfxStyleSheetBase*  Create( const SfxStyleSheetBase& );
     219             : 
     220             :     virtual                     ~SfxStyleSheetBasePool();
     221             : 
     222             : public:
     223             :                                 SfxStyleSheetBasePool( SfxItemPool& );
     224             :                                 SfxStyleSheetBasePool( const SfxStyleSheetBasePool& );
     225             : 
     226           0 :     const OUString&             GetAppName() const { return aAppName;   }
     227             : 
     228             :     SfxItemPool&                GetPool();
     229             :     const SfxItemPool&          GetPool() const;
     230             : 
     231             :     virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
     232             :     virtual sal_uInt16              Count();
     233             :     virtual SfxStyleSheetBase*  operator[](sal_uInt16 nIdx);
     234             : 
     235             :     virtual SfxStyleSheetBase&  Make(const OUString&,
     236             :                                      SfxStyleFamily eFam,
     237             :                                      sal_uInt16 nMask = SFXSTYLEBIT_ALL ,
     238             :                                      sal_uInt16 nPos = 0xffff);
     239             : 
     240             :     virtual void             Replace(
     241             :         SfxStyleSheetBase& rSource, SfxStyleSheetBase& rTarget );
     242             : 
     243             :     virtual void                Remove( SfxStyleSheetBase* );
     244             :     virtual void                Insert( SfxStyleSheetBase* );
     245             : 
     246             :     virtual void                Clear();
     247             : 
     248             :     SfxStyleSheetBasePool&      operator=( const SfxStyleSheetBasePool& );
     249             :     SfxStyleSheetBasePool&      operator+=( const SfxStyleSheetBasePool& );
     250             : 
     251             :     const SfxStyles&            GetStyles();
     252             :     virtual SfxStyleSheetBase*  First();
     253             :     virtual SfxStyleSheetBase*  Next();
     254             :     virtual SfxStyleSheetBase*  Find( const OUString&, SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     255             : 
     256             :     virtual bool                SetParent(SfxStyleFamily eFam,
     257             :                                           const OUString &rStyle,
     258             :                                           const OUString &rParent);
     259             : 
     260       47521 :     SfxStyleSheetBase*          Find(const OUString& rStr)
     261       47521 :                                 { return Find(rStr, nSearchFamily, nMask); }
     262             : 
     263             :     void                        SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     264             :     sal_uInt16                      GetSearchMask() const;
     265         802 :     SfxStyleFamily              GetSearchFamily() const  { return nSearchFamily; }
     266             : };
     267             : 
     268             : //=========================================================================
     269             : 
     270             : class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase,
     271             :                      public SfxListener, public SfxBroadcaster, public svl::StyleSheetUser
     272             : {
     273             : public:
     274             :                         TYPEINFO();
     275             : 
     276             :                         SfxStyleSheet( const OUString&, const SfxStyleSheetBasePool&, SfxStyleFamily, sal_uInt16 );
     277             :                         SfxStyleSheet( const SfxStyleSheet& );
     278             : 
     279             :     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     280             : 
     281             :     virtual bool        isUsedByModel() const;
     282             : 
     283             :     virtual bool        SetParent( const OUString& );
     284             : 
     285             : protected:
     286             :     SfxStyleSheet() // do not use! needed by MSVC at compile time to satisfy ImplInheritanceHelper2
     287             :         : SfxStyleSheetBase(OUString("dummy"), NULL, SFX_STYLE_FAMILY_ALL, 0)
     288             :     {
     289             :         assert(false);
     290             :     }
     291             :     virtual             ~SfxStyleSheet();
     292             : };
     293             : 
     294             : //=========================================================================
     295             : 
     296         557 : class SVL_DLLPUBLIC SfxStyleSheetPool: public SfxStyleSheetBasePool
     297             : {
     298             : protected:
     299             :     using SfxStyleSheetBasePool::Create;
     300             :     virtual SfxStyleSheetBase* Create(const OUString&, SfxStyleFamily, sal_uInt16 mask);
     301             :     virtual SfxStyleSheetBase* Create(const SfxStyleSheet &);
     302             : 
     303             : public:
     304             :     SfxStyleSheetPool( SfxItemPool const& );
     305             : 
     306             : //  virtual sal_Bool CopyTo(SfxStyleSheetPool &rDest, const String &rSourceName);
     307             : };
     308             : 
     309             : //=========================================================================
     310             : 
     311             : #define SFX_STYLESHEET_CREATED       1  // neu
     312             : #define SFX_STYLESHEET_MODIFIED      2  // ver"andert
     313             : #define SFX_STYLESHEET_CHANGED       3  // gel"oscht und neu (ausgetauscht)
     314             : #define SFX_STYLESHEET_ERASED        4  // gel"oscht
     315             : #define SFX_STYLESHEET_INDESTRUCTION 5  // wird gerade entfernt
     316             : 
     317             : #define SFX_STYLESHEETPOOL_CHANGES  1  // Aenderungen, die den Zustand
     318             :                                        // des Pools anedern, aber nicht
     319             :                                        // ueber die STYLESHEET Hints
     320             :                                        // verschickt werden sollen.
     321             : 
     322             : //========================================================================
     323             : 
     324         256 : class SVL_DLLPUBLIC SfxStyleSheetPoolHint : public SfxHint
     325             : {
     326             :     sal_uInt16 nHint;
     327             : 
     328             : public:
     329             :     TYPEINFO();
     330             : 
     331         256 :                         SfxStyleSheetPoolHint(sal_uInt16 nArgHint) :  nHint(nArgHint){}
     332             :     sal_uInt16              GetHint() const
     333             :                         { return nHint; }
     334             : };
     335             : 
     336             : //=========================================================================
     337             : 
     338       39055 : class SVL_DLLPUBLIC SfxStyleSheetHint: public SfxHint
     339             : {
     340             :     SfxStyleSheetBase*  pStyleSh;
     341             :     sal_uInt16              nHint;
     342             : 
     343             : public:
     344             :                         TYPEINFO();
     345             : 
     346             :                         SfxStyleSheetHint( sal_uInt16, SfxStyleSheetBase& );
     347       16267 :     SfxStyleSheetBase*  GetStyleSheet() const
     348       16267 :                         { return pStyleSh; }
     349        9461 :     sal_uInt16              GetHint() const
     350        9461 :                         { return nHint; }
     351             : };
     352             : 
     353         162 : class SVL_DLLPUBLIC SfxStyleSheetHintExtended: public SfxStyleSheetHint
     354             : {
     355             :     OUString            aName;
     356             : 
     357             : public:
     358             :                         TYPEINFO();
     359             : 
     360             :                         SfxStyleSheetHintExtended( sal_uInt16, const OUString& rOld,
     361             :                                                    SfxStyleSheetBase& );
     362        1862 :     const OUString&       GetOldName() { return aName; }
     363             : };
     364             : 
     365        6374 : class SVL_DLLPUBLIC SfxUnoStyleSheet : public ::cppu::ImplInheritanceHelper2< SfxStyleSheet, ::com::sun::star::style::XStyle, ::com::sun::star::lang::XUnoTunnel >
     366             : {
     367             : public:
     368             :     SfxUnoStyleSheet( const OUString& _rName, const SfxStyleSheetBasePool& _rPool, SfxStyleFamily _eFamily, sal_uInt16 _nMaske );
     369             : 
     370             :     static SfxUnoStyleSheet* getUnoStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle );
     371             : 
     372             :     // XUnoTunnel
     373             :     virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
     374             : 
     375             : private:
     376             :     SfxUnoStyleSheet(); // not implemented
     377             : 
     378             :     static const ::com::sun::star::uno::Sequence< ::sal_Int8 >& getIdentifier();
     379             : };
     380             : 
     381             : #endif
     382             : 
     383             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10