LCOV - code coverage report
Current view: top level - sw/inc - fmtcol.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 33 41 80.5 %
Date: 2014-11-03 Functions: 18 24 75.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_FMTCOL_HXX
      20             : #define INCLUDED_SW_INC_FMTCOL_HXX
      21             : 
      22             : #include "swdllapi.h"
      23             : #include <frmatr.hxx>
      24             : #include <swtypes.hxx>
      25             : #include <boost/ptr_container/ptr_vector.hpp>
      26             : #include <rtl/ustring.hxx>
      27             : 
      28             : class SwDoc;
      29             : namespace sw{ class DocumentStylePoolManager; }
      30             : 
      31       70056 : class SwFmtColl : public SwFmt
      32             : {
      33             : protected:
      34       10104 :     SwFmtColl( SwAttrPool& rPool, const sal_Char* pFmtName,
      35             :                 const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
      36             :                 sal_uInt16 nFmtWhich )
      37       10104 :           : SwFmt( rPool, pFmtName, pWhichRanges, pDerFrom, nFmtWhich )
      38       10104 :     { SetAuto( false ); }
      39             : 
      40       60012 :     SwFmtColl( SwAttrPool& rPool, const OUString &rFmtName,
      41             :                 const sal_uInt16* pWhichRanges, SwFmtColl* pDerFrom,
      42             :                 sal_uInt16 nFmtWhich )
      43       60012 :           : SwFmt( rPool, rFmtName, pWhichRanges, pDerFrom, nFmtWhich )
      44       60012 :     { SetAuto( false ); }
      45             : 
      46             : private:
      47             : 
      48             :     /// For now don't copy and don't assign.
      49             :     SwFmtColl(const SwFmtColl & );
      50             :     const SwFmtColl &operator=(const SwFmtColl &);
      51             : };
      52             : 
      53             : /// Represents the style of a paragraph.
      54      124981 : class SW_DLLPUBLIC SwTxtFmtColl: public SwFmtColl
      55             : {
      56             :     friend class SwDoc;
      57             :     friend class ::sw::DocumentStylePoolManager;
      58             : 
      59             :     SwTxtFmtColl(const SwTxtFmtColl & rRef);
      60             : 
      61             :     bool mbStayAssignedToListLevelOfOutlineStyle;
      62             : 
      63             : protected:
      64             : 
      65             :     bool mbAssignedToOutlineStyle;
      66             : 
      67             :     SwTxtFmtColl *pNextTxtFmtColl;
      68             : 
      69        5052 :     SwTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
      70             :                     SwTxtFmtColl* pDerFrom = 0,
      71             :                     sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
      72             :         : SwFmtColl(rPool, pFmtCollName, aTxtFmtCollSetRange, pDerFrom, nFmtWh)
      73             :         , mbStayAssignedToListLevelOfOutlineStyle(false)
      74        5052 :         , mbAssignedToOutlineStyle(false)
      75             :     {
      76        5052 :         pNextTxtFmtColl = this;
      77        5052 :     }
      78             : 
      79       60012 :     SwTxtFmtColl( SwAttrPool& rPool, const OUString &rFmtCollName,
      80             :                     SwTxtFmtColl* pDerFrom = 0,
      81             :                     sal_uInt16 nFmtWh = RES_TXTFMTCOLL )
      82             :         : SwFmtColl(rPool, rFmtCollName, aTxtFmtCollSetRange, pDerFrom, nFmtWh)
      83             :         , mbStayAssignedToListLevelOfOutlineStyle(false)
      84       60012 :         , mbAssignedToOutlineStyle(false)
      85             :     {
      86       60012 :         pNextTxtFmtColl = this;
      87       60012 :     }
      88             : 
      89             :     /// To get UL- / LR- / FontHeight-changes.
      90             :    virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
      91             : 
      92             : public:
      93             : 
      94             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
      95             : 
      96             :     inline void SetNextTxtFmtColl(SwTxtFmtColl& rNext);
      97     1152388 :     SwTxtFmtColl& GetNextTxtFmtColl() const { return *pNextTxtFmtColl; }
      98             : 
      99             :     bool IsAtDocNodeSet() const;
     100             : 
     101             :     void SetAttrOutlineLevel( int );
     102             :     int  GetAttrOutlineLevel() const;
     103             : 
     104             :     // Return the list level of the Outline Style - the List Style for the
     105             :     // outline numbering -
     106             :     // to which the Paragraph Style is assigned.
     107             :     int  GetAssignedOutlineStyleLevel() const;
     108             : 
     109     2225114 :     inline bool IsAssignedToListLevelOfOutlineStyle() const
     110             :     {
     111     2225114 :         return mbAssignedToOutlineStyle;
     112             :     }
     113             : 
     114             :     // If a Paragraph Style is assigned to list level N of the Outline Style,
     115             :     // then its outline level - AttrOutlineLevel - is set to N+1
     116             :     void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
     117             :     void DeleteAssignmentToListLevelOfOutlineStyle(const bool bResetOutlineLevel
     118             :                                                    = true);
     119             : 
     120             :     /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
     121             :      the paragragh style at the corresponding <SwNumRule> instance. */
     122             :     virtual bool SetFmtAttr( const SfxPoolItem& rAttr ) SAL_OVERRIDE;
     123             :     virtual bool SetFmtAttr( const SfxItemSet& rSet ) SAL_OVERRIDE;
     124             :     virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) SAL_OVERRIDE;
     125             : 
     126             :     /// Override <ResetAllFmtAttr()> to stay assigned to list level of outline style.
     127             :     virtual sal_uInt16 ResetAllFmtAttr() SAL_OVERRIDE;
     128             : 
     129      203376 :     inline bool StayAssignedToListLevelOfOutlineStyle() const
     130             :     {
     131      203376 :         return mbStayAssignedToListLevelOfOutlineStyle;
     132             :     }
     133             : 
     134             :     bool AreListLevelIndentsApplicable() const;
     135             : 
     136             : /*
     137             :  Is the functionality of character styles at paragraph styles needed?
     138             :  If so, a second Attset for char-attributes has to be created
     139             :  in TextNode and here in TxtCollection in order to make both
     140             :  the inheritance of and the access to set attributes function correctly!
     141             : 
     142             :     virtual sal_Bool SetDerivedFrom( SwFmtColl* pDerFrom = 0 );
     143             : 
     144             :     inline SwCharFmt* GetCharFmt() const;
     145             :     inline sal_Bool IsCharFmtSet() const;
     146             :     void SetCharFmt(SwCharFmt *);
     147             :     void ResetCharFmt();
     148             :     inline sal_Bool SwTxtFmtColl::IsCharFmtSet() const
     149             :     {
     150             :         return aCharDepend.GetRegisteredIn() ? sal_True : sal_False;
     151             :     }
     152             :     inline SwCharFmt* SwTxtFmtColl::GetCharFmt() const
     153             :     {
     154             :         return (SwCharFmt*)aCharDepend.GetRegisteredIn();
     155             :     }
     156             : */
     157             : };
     158             : 
     159       10090 : class SwGrfFmtColl: public SwFmtColl
     160             : {
     161             :     friend class SwDoc;
     162             : protected:
     163        5052 :     SwGrfFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
     164             :                     SwGrfFmtColl* pDerFrom = 0 )
     165             :         : SwFmtColl( rPool, pFmtCollName, aGrfFmtCollSetRange,
     166        5052 :                     pDerFrom, RES_GRFFMTCOLL )
     167        5052 :     {}
     168             : 
     169           0 :     SwGrfFmtColl( SwAttrPool& rPool, const OUString &rFmtCollName,
     170             :                     SwGrfFmtColl* pDerFrom = 0 )
     171             :         : SwFmtColl( rPool, rFmtCollName, aGrfFmtCollSetRange,
     172           0 :                     pDerFrom, RES_GRFFMTCOLL )
     173           0 :     {}
     174             : 
     175             : public:
     176             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     177             : };
     178             : 
     179             : // FEATURE::CONDCOLL
     180             : /// Conditional styles.
     181             : enum Master_CollConditions
     182             : {
     183             :     PARA_IN_LIST        = 0x0001,
     184             :     PARA_IN_OUTLINE     = 0x0002,
     185             :     PARA_IN_FRAME       = 0x0004,
     186             :     PARA_IN_TABLEHEAD   = 0x0008,
     187             :     PARA_IN_TABLEBODY   = 0x0010,
     188             :     PARA_IN_SECTION     = 0x0020,
     189             :     PARA_IN_FOOTENOTE   = 0x0040,
     190             :     PARA_IN_FOOTER      = 0x0080,
     191             :     PARA_IN_HEADER      = 0x0100,
     192             :     PARA_IN_ENDNOTE     = 0x0200,
     193             : 
     194             :     USRFLD_EXPRESSION   = (int)0x8000
     195             : };
     196             : 
     197             : class SW_DLLPUBLIC SwCollCondition : public SwClient
     198             : {
     199             :     sal_uLong nCondition;
     200             :     union
     201             :     {
     202             :         sal_uLong nSubCondition;
     203             :         OUString* pFldExpression;
     204             :     } aSubCondition;
     205             : 
     206             : public:
     207             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     208             : 
     209             :     SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
     210             :                     sal_uLong nSubCond = 0 );
     211             :     SwCollCondition( SwTxtFmtColl* pColl, sal_uLong nMasterCond,
     212             :                     const OUString& rSubExp );
     213             :     virtual ~SwCollCondition();
     214             : 
     215             :     /// @@@ public copy ctor, but no copy assignment?
     216             :     SwCollCondition( const SwCollCondition& rCpy );
     217             : private:
     218             :     /// @@@ public copy ctor, but no copy assignment?
     219             :     SwCollCondition & operator= (const SwCollCondition &);
     220             : public:
     221             : 
     222             :     bool operator==( const SwCollCondition& rCmp ) const;
     223             :     bool operator!=( const SwCollCondition& rCmp ) const
     224             :                             { return ! (*this == rCmp); }
     225             : 
     226           0 :     sal_uLong GetCondition() const      { return nCondition; }
     227           0 :     sal_uLong GetSubCondition() const   { return aSubCondition.nSubCondition; }
     228           0 :     const OUString* GetFldExpression() const
     229           0 :                                     { return aSubCondition.pFldExpression; }
     230             : 
     231             :     void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
     232           0 :     SwTxtFmtColl* GetTxtFmtColl() const     { return (SwTxtFmtColl*)GetRegisteredIn(); }
     233             :     void RegisterToFormat( SwFmt& );
     234             : };
     235             : 
     236       10087 : class SwFmtCollConditions : public boost::ptr_vector<SwCollCondition> {};
     237             : 
     238             : class SW_DLLPUBLIC SwConditionTxtFmtColl : public SwTxtFmtColl
     239             : {
     240             :     friend class SwDoc;
     241             :     friend class ::sw::DocumentStylePoolManager;
     242             : protected:
     243             :     SwFmtCollConditions aCondColls;
     244             : 
     245             :     SwConditionTxtFmtColl( SwAttrPool& rPool, const sal_Char* pFmtCollName,
     246             :                             SwTxtFmtColl* pDerFrom = 0 )
     247             :         : SwTxtFmtColl( rPool, pFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
     248             :     {}
     249        5046 :     SwConditionTxtFmtColl( SwAttrPool& rPool, const OUString &rFmtCollName,
     250             :                             SwTxtFmtColl* pDerFrom = 0 )
     251        5046 :         : SwTxtFmtColl( rPool, rFmtCollName, pDerFrom, RES_CONDTXTFMTCOLL )
     252        5046 :     {}
     253             : 
     254             : public:
     255             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     256             : 
     257             :     virtual ~SwConditionTxtFmtColl();
     258             : 
     259             :     const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
     260         510 :     const SwFmtCollConditions& GetCondColls() const     { return aCondColls; }
     261             :     void InsertCondition( const SwCollCondition& rCond );
     262             :     bool RemoveCondition( const SwCollCondition& rCond );
     263             : 
     264             :     void SetConditions( const SwFmtCollConditions& );
     265             : };
     266             : 
     267             : // FEATURE::CONDCOLL
     268             : /// Inline implementations.
     269       13900 : inline void SwTxtFmtColl::SetNextTxtFmtColl( SwTxtFmtColl& rNext )
     270             : {
     271       13900 :     pNextTxtFmtColl = &rNext;
     272       13900 : }
     273             : #endif
     274             : 
     275             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10