LCOV - code coverage report
Current view: top level - sw/inc - docstyle.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 10 10 100.0 %
Date: 2014-04-11 Functions: 10 10 100.0 %
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_SW_INC_DOCSTYLE_HXX
      20             : #define INCLUDED_SW_INC_DOCSTYLE_HXX
      21             : 
      22             : #include <rtl/ref.hxx>
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #include <svl/style.hxx>
      26             : #include <svl/itemset.hxx>
      27             : #include "swdllapi.h"
      28             : 
      29             : #include <vector>
      30             : 
      31             : class SwDoc;
      32             : class SwDocStyleSheetPool;
      33             : class SwPageDesc;
      34             : class SwCharFmt;
      35             : class SwTxtFmtColl;
      36             : class SwFrmFmt;
      37             : class SwNumRule;
      38             : 
      39             : /*--------------------------------------------------------------------
      40             :     Local helper class.
      41             :  --------------------------------------------------------------------*/
      42        8531 : class SwPoolFmtList : public std::vector<OUString>
      43             : {
      44             : public:
      45        8532 :     SwPoolFmtList() {}
      46             :     void Append( char cChar, const OUString& rStr );
      47             :     void Erase();
      48             : };
      49             : 
      50             : /*--------------------------------------------------------------------
      51             :     Temporary StyleSheet.
      52             :  --------------------------------------------------------------------*/
      53             : class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
      54             : {
      55             :     friend class SwDocStyleSheetPool;
      56             :     friend class SwStyleSheetIterator;
      57             : 
      58             :     SwCharFmt*          pCharFmt;
      59             :     SwTxtFmtColl*       pColl;
      60             :     SwFrmFmt*           pFrmFmt;
      61             :     const SwPageDesc*   pDesc;
      62             :     const SwNumRule*    pNumRule;
      63             : 
      64             :     SwDoc&              rDoc;
      65             :     SfxItemSet          aCoreSet;
      66             : 
      67             :     sal_Bool                bPhysical;
      68             : 
      69             :     /// Make empty shell a real StyleSheet (Core).
      70             :     SAL_DLLPRIVATE void              Create();
      71             : 
      72             :     /// Fill StyleSheet with data.
      73             :     enum FillStyleType {
      74             :         FillOnlyName,
      75             :         FillAllInfo,
      76             :         FillPhysical
      77             :     };
      78             : 
      79             :     SAL_DLLPRIVATE sal_Bool FillStyleSheet( FillStyleType eFType );
      80             : 
      81             : protected:
      82             :     virtual ~SwDocStyleSheet();
      83             : 
      84             : public:
      85             :     SwDocStyleSheet( SwDoc&                 rDoc,
      86             :                      const OUString&        rName,
      87             :                      SwDocStyleSheetPool*   pPool,
      88             :                      SfxStyleFamily         eFam,
      89             :                      sal_uInt16             nMask);
      90             : 
      91             :     SwDocStyleSheet( const SwDocStyleSheet& );
      92             : 
      93             :     void                    Reset();
      94             : 
      95      534070 :     void                    SetMask(sal_uInt16 nMsk)            { nMask = nMsk;     }
      96      466753 :     void                    SetFamily(SfxStyleFamily eFam)  { nFamily = eFam;   }
      97             : 
      98      448749 :     sal_Bool                    IsPhysical() const              { return bPhysical; }
      99             :     void                    SetPhysical(sal_Bool bPhys);
     100             : 
     101             :     virtual void            SetHidden( bool bHidden ) SAL_OVERRIDE;
     102             :     virtual bool            IsHidden( ) const SAL_OVERRIDE;
     103             :     void SetGrabBagItem(const com::sun::star::uno::Any& rVal);
     104             :     void GetGrabBagItem(com::sun::star::uno::Any& rVal) const;
     105             : 
     106             :     /** add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value sal_False,
     107             :      which indicates that the indent attributes at a paragraph style should
     108             :      be reset in case that a list style is applied to the paragraph style and
     109             :      no indent attributes are applied. */
     110             :     void                    SetItemSet( const SfxItemSet& rSet,
     111             :                                         const bool bResetIndentAttrsAtParagraphStyle = false );
     112             : 
     113             :     virtual SfxItemSet&     GetItemSet() SAL_OVERRIDE;
     114             :     /** new method for paragraph styles to merge indent attributes of applied list
     115             :      style into the given item set, if the list style indent attributes are applicable. */
     116             :     void MergeIndentAttrsOfListStyle( SfxItemSet& rSet );
     117             :     virtual const OUString& GetParent() const SAL_OVERRIDE;
     118             :     virtual const OUString& GetFollow() const SAL_OVERRIDE;
     119             : 
     120             :     virtual sal_uLong GetHelpId( OUString& rFile ) SAL_OVERRIDE;
     121             :     virtual void SetHelpId( const OUString& r, sal_uLong nId ) SAL_OVERRIDE;
     122             : 
     123             :     /** Preset the members without physical access.
     124             :      Used by StyleSheetPool. */
     125      472383 :     void                    PresetName(const OUString& rName)  { aName   = rName; }
     126             :     void                    PresetNameAndFamily(const OUString& rName);
     127      364346 :     void                    PresetParent(const OUString& rName){ aParent = rName; }
     128      282152 :     void                    PresetFollow(const OUString& rName){ aFollow = rName; }
     129             : 
     130             :     virtual bool            SetName( const OUString& rStr) SAL_OVERRIDE;
     131             :     virtual bool            SetParent( const OUString& rStr) SAL_OVERRIDE;
     132             :     virtual bool            SetFollow( const OUString& rStr) SAL_OVERRIDE;
     133             : 
     134             :     virtual bool            HasFollowSupport() const SAL_OVERRIDE;
     135             :     virtual bool            HasParentSupport() const SAL_OVERRIDE;
     136             :     virtual bool            HasClearParentSupport() const SAL_OVERRIDE;
     137             :     virtual OUString        GetDescription() SAL_OVERRIDE;
     138             :     virtual OUString        GetDescription(SfxMapUnit eUnit) SAL_OVERRIDE;
     139             : 
     140             :     SwCharFmt*              GetCharFmt();
     141             :     SwTxtFmtColl*           GetCollection();
     142             :     SwFrmFmt*               GetFrmFmt();
     143             :     const SwPageDesc*       GetPageDesc();
     144             :     const SwNumRule*        GetNumRule();
     145             :     void                    SetNumRule(const SwNumRule& rRule);
     146             : 
     147             :     virtual bool            IsUsed() const SAL_OVERRIDE;
     148             : };
     149             : 
     150             : /*--------------------------------------------------------------------
     151             :    Iterator for Pool.
     152             :  --------------------------------------------------------------------*/
     153             : 
     154             : class SwStyleSheetIterator : public SfxStyleSheetIterator, public SfxListener
     155             : {
     156             :     rtl::Reference< SwDocStyleSheet > mxIterSheet;
     157             :     rtl::Reference< SwDocStyleSheet > mxStyleSheet;
     158             :     SwPoolFmtList       aLst;
     159             :     sal_uInt16              nLastPos;
     160             :     sal_Bool                bFirstCalled;
     161             : 
     162             :     void                AppendStyleList(const ::std::vector<OUString>& rLst,
     163             :                                         sal_Bool    bUsed,
     164             :                                         sal_Bool    bTestHidden,
     165             :                                         bool        bOnlyHidden,
     166             :                                         sal_uInt16  nSection,
     167             :                                         char    cType);
     168             : 
     169             : public:
     170             :     SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
     171             :                           SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
     172             :     virtual ~SwStyleSheetIterator();
     173             : 
     174             :     virtual sal_uInt16 Count() SAL_OVERRIDE;
     175             :     virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx) SAL_OVERRIDE;
     176             :     virtual SfxStyleSheetBase* First() SAL_OVERRIDE;
     177             :     virtual SfxStyleSheetBase* Next() SAL_OVERRIDE;
     178             :     virtual SfxStyleSheetBase* Find(const OUString& rStr) SAL_OVERRIDE;
     179             : 
     180             :     virtual void Notify( SfxBroadcaster&, const SfxHint& ) SAL_OVERRIDE;
     181             : 
     182             :     void InvalidateIterator();
     183             : };
     184             : 
     185             : class SwDocStyleSheetPool : public SfxStyleSheetBasePool
     186             : {
     187             :     rtl::Reference< SwDocStyleSheet > mxStyleSheet;
     188             :     SwDoc&              rDoc;
     189             :     sal_Bool                bOrganizer : 1;     ///< Organizer
     190             : 
     191             :     virtual SfxStyleSheetBase* Create( const OUString&, SfxStyleFamily, sal_uInt16 nMask) SAL_OVERRIDE;
     192             :     virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) SAL_OVERRIDE;
     193             : 
     194             :     using SfxStyleSheetBasePool::Find;
     195             : 
     196             : public:
     197             :     SwDocStyleSheetPool( SwDoc&, sal_Bool bOrganizer = sal_False );
     198             : 
     199             :     virtual void Replace( SfxStyleSheetBase& rSource,
     200             :                           SfxStyleSheetBase& rTarget ) SAL_OVERRIDE;
     201             :     virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily,
     202             :             sal_uInt16 nMask) SAL_OVERRIDE;
     203             : 
     204             :     virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam,
     205             :                                     sal_uInt16 n=SFXSTYLEBIT_ALL ) SAL_OVERRIDE;
     206             : 
     207             :     virtual bool SetParent( SfxStyleFamily eFam, const OUString &rStyle,
     208             :                             const OUString &rParent ) SAL_OVERRIDE;
     209             : 
     210             :     virtual void Remove( SfxStyleSheetBase* pStyle) SAL_OVERRIDE;
     211             : 
     212             :     void    SetOrganizerMode( sal_Bool bMode )  { bOrganizer = bMode; }
     213       11937 :     sal_Bool    IsOrganizerMode() const         { return bOrganizer; }
     214             : 
     215             :     virtual SfxStyleSheetIteratorPtr CreateIterator( SfxStyleFamily, sal_uInt16 nMask ) SAL_OVERRIDE;
     216             : 
     217       37299 :     SwDoc& GetDoc() const { return rDoc; }
     218             : 
     219             :     void dispose();
     220             : 
     221             :     virtual void SAL_CALL acquire(  ) throw () SAL_OVERRIDE;
     222             :     virtual void SAL_CALL release(  ) throw () SAL_OVERRIDE;
     223             : 
     224             :     void InvalidateIterator();
     225             : 
     226             : protected:
     227             :     virtual ~SwDocStyleSheetPool();
     228             : 
     229             :     /// For not-so-clever compilers.
     230             : private:
     231             :     SwDocStyleSheetPool( const SwDocStyleSheetPool& );
     232             : };
     233             : 
     234             : #endif
     235             : 
     236             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10