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

Generated by: LCOV version 1.10