LCOV - code coverage report
Current view: top level - libreoffice/svl/inc/svl - style.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 10 50.0 %
Date: 2012-12-27 Functions: 5 15 33.3 %
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 <tools/string.hxx>
      33             : #include <svl/hint.hxx>
      34             : #include <svl/lstner.hxx>
      35             : #include <svl/brdcst.hxx>
      36             : #include <svl/poolitem.hxx>
      37             : 
      38             : #include <svl/style.hrc>
      39             : 
      40             : class SfxItemSet;
      41             : class SfxItemPool;
      42             : 
      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             :     UniString               aName, aParent, aFollow;
      85             :     rtl::OUString           maDisplayName;
      86             :     String                  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 UniString&, 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 UniString& GetName() const;
     106             : 
     107             :     // sets the internal name of this style
     108             :     virtual bool SetName( const UniString& );
     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 rtl::OUString GetDisplayName() const;
     113             : 
     114             :     // sets the display name of this style
     115             :     virtual void SetDisplayName( const rtl::OUString& );
     116             : 
     117             :     virtual const UniString& GetParent() const;
     118             :     virtual bool SetParent( const UniString& );
     119             :     virtual const UniString& GetFollow() const;
     120             :     virtual bool SetFollow( const UniString& );
     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 UniString GetDescription();
     128             :     virtual UniString GetDescription( SfxMapUnit eMetric );
     129             : 
     130             :     SfxStyleSheetBasePool& GetPool() { return *pPool; }
     131       46703 :     SfxStyleFamily GetFamily() const     { return nFamily; }
     132       25140 :     sal_uInt16   GetMask() const     { return nMask; }
     133             :     void     SetMask( sal_uInt16 mask) { nMask = mask; }
     134             :     bool     IsUserDefined() const
     135             :            { return ( nMask & SFXSTYLEBIT_USERDEF) != 0; }
     136             : 
     137           0 :     virtual sal_Bool IsHidden() const { return bHidden; }
     138             :     virtual void SetHidden( sal_Bool bValue );
     139             : 
     140             :     virtual sal_uLong GetHelpId( String& rFile );
     141             :     virtual void   SetHelpId( const String& 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 rtl::OUString& rStr);
     172             :     virtual ~SfxStyleSheetIterator();
     173             : 
     174             : protected:
     175             : 
     176             :     SfxStyleSheetBasePool*  pBasePool;
     177             :     SfxStyleFamily          nSearchFamily;
     178             :     sal_uInt16              nMask;
     179             : 
     180             :     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             : //=========================================================================
     195             : 
     196             : class SfxStyleSheetBasePool_Impl;
     197             : 
     198             : class SVL_DLLPUBLIC SfxStyleSheetBasePool: public SfxBroadcaster, public comphelper::OWeakTypeObject
     199             : {
     200             : friend class SfxStyleSheetIterator;
     201             : friend class SfxStyleSheetBase;
     202             : 
     203             :     SfxStyleSheetBasePool_Impl *pImp;
     204             : 
     205             : private:
     206             :     SVL_DLLPRIVATE SfxStyleSheetIterator&      GetIterator_Impl();
     207             : protected:
     208             :     String                      aAppName;
     209             :     SfxItemPool&                rPool;
     210             :     SfxStyles                   aStyles;
     211             :     SfxStyleFamily              nSearchFamily;
     212             :     sal_uInt16                      nMask;
     213             : 
     214             :     SfxStyleSheetBase&          Add( SfxStyleSheetBase& );
     215             :     void                        ChangeParent( const UniString&, const UniString&, bool bVirtual = true );
     216             :     virtual SfxStyleSheetBase*  Create( const UniString&, SfxStyleFamily, sal_uInt16 );
     217             :     virtual SfxStyleSheetBase*  Create( const SfxStyleSheetBase& );
     218             : 
     219             :     virtual                     ~SfxStyleSheetBasePool();
     220             : 
     221             : public:
     222             :                                 SfxStyleSheetBasePool( SfxItemPool& );
     223             :                                 SfxStyleSheetBasePool( const SfxStyleSheetBasePool& );
     224             : 
     225             :     const String&               GetAppName() const { return aAppName;   }
     226             : 
     227             :     SfxItemPool&                GetPool();
     228             :     const SfxItemPool&          GetPool() const;
     229             : 
     230             :     virtual SfxStyleSheetIterator* CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
     231             :     virtual sal_uInt16              Count();
     232             :     virtual SfxStyleSheetBase*  operator[](sal_uInt16 nIdx);
     233             : 
     234             :     virtual SfxStyleSheetBase&  Make(const UniString&,
     235             :                                      SfxStyleFamily eFam,
     236             :                                      sal_uInt16 nMask = SFXSTYLEBIT_ALL ,
     237             :                                      sal_uInt16 nPos = 0xffff);
     238             : 
     239             :     virtual void             Replace(
     240             :         SfxStyleSheetBase& rSource, SfxStyleSheetBase& rTarget );
     241             : 
     242             :     virtual void                Remove( SfxStyleSheetBase* );
     243             :     virtual void                Insert( SfxStyleSheetBase* );
     244             : 
     245             :     virtual void                Clear();
     246             : 
     247             :     SfxStyleSheetBasePool&      operator=( const SfxStyleSheetBasePool& );
     248             :     SfxStyleSheetBasePool&      operator+=( const SfxStyleSheetBasePool& );
     249             : 
     250             :     const SfxStyles&            GetStyles();
     251             :     virtual SfxStyleSheetBase*  First();
     252             :     virtual SfxStyleSheetBase*  Next();
     253             :     virtual SfxStyleSheetBase*  Find( const UniString&, SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     254             : 
     255             :     virtual bool                SetParent(SfxStyleFamily eFam,
     256             :                                           const UniString &rStyle,
     257             :                                           const UniString &rParent);
     258             : 
     259             :     SfxStyleSheetBase*          Find(const UniString& rStr)
     260             :                                 { return Find(rStr, nSearchFamily, nMask); }
     261             : 
     262             :     void                        SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     263             :     sal_uInt16                      GetSearchMask() const;
     264         210 :     SfxStyleFamily              GetSearchFamily() const  { return nSearchFamily; }
     265             : };
     266             : 
     267             : //=========================================================================
     268             : 
     269             : class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase,
     270             :                      public SfxListener, public SfxBroadcaster
     271             : {
     272             : public:
     273             :                         TYPEINFO();
     274             : 
     275             :                         SfxStyleSheet( const UniString&, const SfxStyleSheetBasePool&, SfxStyleFamily, sal_uInt16 );
     276             :                         SfxStyleSheet( const SfxStyleSheet& );
     277             : 
     278             :     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     279             :     virtual bool        SetParent( const UniString& );
     280             : 
     281             : protected:
     282             :     SfxStyleSheet() // do not use! needed by MSVC at compile time to satisfy ImplInheritanceHelper2
     283             :         : SfxStyleSheetBase(rtl::OUString("dummy"),
     284             :             NULL, SFX_STYLE_FAMILY_ALL, 0)
     285             :     {
     286             :         assert(false);
     287             :     }
     288             :     virtual             ~SfxStyleSheet();
     289             : };
     290             : 
     291             : //=========================================================================
     292             : 
     293           0 : class SVL_DLLPUBLIC SfxStyleSheetPool: public SfxStyleSheetBasePool
     294             : {
     295             : protected:
     296             :     using SfxStyleSheetBasePool::Create;
     297             :     virtual SfxStyleSheetBase* Create(const UniString&, SfxStyleFamily, sal_uInt16 mask);
     298             :     virtual SfxStyleSheetBase* Create(const SfxStyleSheet &);
     299             : 
     300             : public:
     301             :     SfxStyleSheetPool( SfxItemPool const& );
     302             : 
     303             : //  virtual sal_Bool CopyTo(SfxStyleSheetPool &rDest, const String &rSourceName);
     304             : };
     305             : 
     306             : //=========================================================================
     307             : 
     308             : #define SFX_STYLESHEET_CREATED       1  // neu
     309             : #define SFX_STYLESHEET_MODIFIED      2  // ver"andert
     310             : #define SFX_STYLESHEET_CHANGED       3  // gel"oscht und neu (ausgetauscht)
     311             : #define SFX_STYLESHEET_ERASED        4  // gel"oscht
     312             : #define SFX_STYLESHEET_INDESTRUCTION 5  // wird gerade entfernt
     313             : 
     314             : #define SFX_STYLESHEETPOOL_CHANGES  1  // Aenderungen, die den Zustand
     315             :                                        // des Pools anedern, aber nicht
     316             :                                        // ueber die STYLESHEET Hints
     317             :                                        // verschickt werden sollen.
     318             : 
     319             : //========================================================================
     320             : 
     321           0 : class SVL_DLLPUBLIC SfxStyleSheetPoolHint : public SfxHint
     322             : {
     323             :     sal_uInt16 nHint;
     324             : 
     325             : public:
     326             :     TYPEINFO();
     327             : 
     328             :                         SfxStyleSheetPoolHint(sal_uInt16 nArgHint) :  nHint(nArgHint){}
     329             :     sal_uInt16              GetHint() const
     330             :                         { return nHint; }
     331             : };
     332             : 
     333             : //=========================================================================
     334             : 
     335        6609 : class SVL_DLLPUBLIC SfxStyleSheetHint: public SfxHint
     336             : {
     337             :     SfxStyleSheetBase*  pStyleSh;
     338             :     sal_uInt16              nHint;
     339             : 
     340             : public:
     341             :                         TYPEINFO();
     342             : 
     343             :                         SfxStyleSheetHint( sal_uInt16, SfxStyleSheetBase& );
     344             :     SfxStyleSheetBase*  GetStyleSheet() const
     345             :                         { return pStyleSh; }
     346             :     sal_uInt16              GetHint() const
     347             :                         { return nHint; }
     348             : };
     349             : 
     350          70 : class SVL_DLLPUBLIC SfxStyleSheetHintExtended: public SfxStyleSheetHint
     351             : {
     352             :     String              aName;
     353             : 
     354             : public:
     355             :                         TYPEINFO();
     356             : 
     357             :                         SfxStyleSheetHintExtended(
     358             :                             sal_uInt16, const String& rOld,
     359             :                             SfxStyleSheetBase& );
     360             :     const String&       GetOldName() { return aName; }
     361             : };
     362             : 
     363           0 : class SVL_DLLPUBLIC SfxUnoStyleSheet : public ::cppu::ImplInheritanceHelper2< SfxStyleSheet, ::com::sun::star::style::XStyle, ::com::sun::star::lang::XUnoTunnel >
     364             : {
     365             : public:
     366             :     SfxUnoStyleSheet( const UniString& _rName, const SfxStyleSheetBasePool& _rPool, SfxStyleFamily _eFamily, sal_uInt16 _nMaske );
     367             : 
     368             :     static SfxUnoStyleSheet* getUnoStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle );
     369             : 
     370             :     // XUnoTunnel
     371             :     virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
     372             : 
     373             : private:
     374             :     SfxUnoStyleSheet(); // not implemented
     375             : 
     376             :     static const ::com::sun::star::uno::Sequence< ::sal_Int8 >& getIdentifier();
     377             : };
     378             : 
     379             : #endif
     380             : 
     381             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10