LCOV - code coverage report
Current view: top level - sw/inc - fmtcol.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 41 82.9 %
Date: 2015-06-13 12:38:46 Functions: 19 24 79.2 %
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       42711 : class SwFormatColl : public SwFormat
      32             : {
      33             : protected:
      34        5916 :     SwFormatColl( SwAttrPool& rPool, const sal_Char* pFormatName,
      35             :                 const sal_uInt16* pWhichRanges, SwFormatColl* pDerFrom,
      36             :                 sal_uInt16 nFormatWhich )
      37        5916 :           : SwFormat( rPool, pFormatName, pWhichRanges, pDerFrom, nFormatWhich )
      38        5916 :     { SetAuto( false ); }
      39             : 
      40       36860 :     SwFormatColl( SwAttrPool& rPool, const OUString &rFormatName,
      41             :                 const sal_uInt16* pWhichRanges, SwFormatColl* pDerFrom,
      42             :                 sal_uInt16 nFormatWhich )
      43       36860 :           : SwFormat( rPool, rFormatName, pWhichRanges, pDerFrom, nFormatWhich )
      44       36860 :     { SetAuto( false ); }
      45             : 
      46             : private:
      47             :     SwFormatColl(const SwFormatColl & ) SAL_DELETED_FUNCTION;
      48             :     const SwFormatColl &operator=(const SwFormatColl &) SAL_DELETED_FUNCTION;
      49             : };
      50             : 
      51             : /// Represents the style of a paragraph.
      52       76578 : class SW_DLLPUBLIC SwTextFormatColl: public SwFormatColl
      53             : {
      54             :     friend class SwDoc;
      55             :     friend class ::sw::DocumentStylePoolManager;
      56             : 
      57             :     SwTextFormatColl(const SwTextFormatColl & rRef) SAL_DELETED_FUNCTION;
      58             : 
      59             :     bool mbStayAssignedToListLevelOfOutlineStyle;
      60             : 
      61             : protected:
      62             : 
      63             :     bool mbAssignedToOutlineStyle;
      64             : 
      65             :     SwTextFormatColl *pNextTextFormatColl;
      66             : 
      67        2958 :     SwTextFormatColl( SwAttrPool& rPool, const sal_Char* pFormatCollName,
      68             :                     SwTextFormatColl* pDerFrom = 0,
      69             :                     sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
      70             :         : SwFormatColl(rPool, pFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
      71             :         , mbStayAssignedToListLevelOfOutlineStyle(false)
      72        2958 :         , mbAssignedToOutlineStyle(false)
      73             :     {
      74        2958 :         pNextTextFormatColl = this;
      75        2958 :     }
      76             : 
      77       36860 :     SwTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
      78             :                     SwTextFormatColl* pDerFrom = 0,
      79             :                     sal_uInt16 nFormatWh = RES_TXTFMTCOLL )
      80             :         : SwFormatColl(rPool, rFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
      81             :         , mbStayAssignedToListLevelOfOutlineStyle(false)
      82       36860 :         , mbAssignedToOutlineStyle(false)
      83             :     {
      84       36860 :         pNextTextFormatColl = this;
      85       36860 :     }
      86             : 
      87             :     /// To get UL- / LR- / FontHeight-changes.
      88             :    virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
      89             : 
      90             : public:
      91             : 
      92             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
      93             : 
      94             :     inline void SetNextTextFormatColl(SwTextFormatColl& rNext);
      95      789306 :     SwTextFormatColl& GetNextTextFormatColl() const { return *pNextTextFormatColl; }
      96             : 
      97             :     bool IsAtDocNodeSet() const;
      98             : 
      99             :     void SetAttrOutlineLevel( int );
     100             :     int  GetAttrOutlineLevel() const;
     101             : 
     102             :     // Return the list level of the Outline Style - the List Style for the
     103             :     // outline numbering -
     104             :     // to which the Paragraph Style is assigned.
     105             :     int  GetAssignedOutlineStyleLevel() const;
     106             : 
     107     1384042 :     inline bool IsAssignedToListLevelOfOutlineStyle() const
     108             :     {
     109     1384042 :         return mbAssignedToOutlineStyle;
     110             :     }
     111             : 
     112             :     // If a Paragraph Style is assigned to list level N of the Outline Style,
     113             :     // then its outline level - AttrOutlineLevel - is set to N+1
     114             :     void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel);
     115             :     void DeleteAssignmentToListLevelOfOutlineStyle(const bool bResetOutlineLevel
     116             :                                                    = true);
     117             : 
     118             :     /** Override to recognize changes on the <SwNumRuleItem> and register/unregister
     119             :      the paragragh style at the corresponding <SwNumRule> instance. */
     120             :     virtual bool SetFormatAttr( const SfxPoolItem& rAttr ) SAL_OVERRIDE;
     121             :     virtual bool SetFormatAttr( const SfxItemSet& rSet ) SAL_OVERRIDE;
     122             :     virtual bool ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) SAL_OVERRIDE;
     123             : 
     124             :     /// Override <ResetAllFormatAttr()> to stay assigned to list level of outline style.
     125             :     virtual sal_uInt16 ResetAllFormatAttr() SAL_OVERRIDE;
     126             : 
     127      120204 :     inline bool StayAssignedToListLevelOfOutlineStyle() const
     128             :     {
     129      120204 :         return mbStayAssignedToListLevelOfOutlineStyle;
     130             :     }
     131             : 
     132             :     bool AreListLevelIndentsApplicable() const;
     133             : 
     134             :     void dumpAsXml(struct _xmlTextWriter* pWriter) const;
     135             : };
     136             : 
     137        5898 : class SwGrfFormatColl: public SwFormatColl
     138             : {
     139             :     friend class SwDoc;
     140             : protected:
     141        2958 :     SwGrfFormatColl( SwAttrPool& rPool, const sal_Char* pFormatCollName,
     142             :                     SwGrfFormatColl* pDerFrom = 0 )
     143             :         : SwFormatColl( rPool, pFormatCollName, aGrfFormatCollSetRange,
     144        2958 :                     pDerFrom, RES_GRFFMTCOLL )
     145        2958 :     {}
     146             : 
     147           0 :     SwGrfFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
     148             :                     SwGrfFormatColl* pDerFrom = 0 )
     149             :         : SwFormatColl( rPool, rFormatCollName, aGrfFormatCollSetRange,
     150           0 :                     pDerFrom, RES_GRFFMTCOLL )
     151           0 :     {}
     152             : 
     153             : public:
     154             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     155             : };
     156             : 
     157             : // FEATURE::CONDCOLL
     158             : /// Conditional styles.
     159             : enum Master_CollConditions
     160             : {
     161             :     PARA_IN_LIST        = 0x0001,
     162             :     PARA_IN_OUTLINE     = 0x0002,
     163             :     PARA_IN_FRAME       = 0x0004,
     164             :     PARA_IN_TABLEHEAD   = 0x0008,
     165             :     PARA_IN_TABLEBODY   = 0x0010,
     166             :     PARA_IN_SECTION     = 0x0020,
     167             :     PARA_IN_FOOTENOTE   = 0x0040,
     168             :     PARA_IN_FOOTER      = 0x0080,
     169             :     PARA_IN_HEADER      = 0x0100,
     170             :     PARA_IN_ENDNOTE     = 0x0200,
     171             : 
     172             :     USRFLD_EXPRESSION   = (int)0x8000
     173             : };
     174             : 
     175             : class SW_DLLPUBLIC SwCollCondition : public SwClient
     176             : {
     177             :     sal_uLong nCondition;
     178             :     union
     179             :     {
     180             :         sal_uLong nSubCondition;
     181             :         OUString* pFieldExpression;
     182             :     } aSubCondition;
     183             : 
     184             : public:
     185             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     186             : 
     187             :     SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
     188             :                     sal_uLong nSubCond = 0 );
     189             :     SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
     190             :                     const OUString& rSubExp );
     191             :     virtual ~SwCollCondition();
     192             : 
     193             :     /// @@@ public copy ctor, but no copy assignment?
     194             :     SwCollCondition( const SwCollCondition& rCpy );
     195             : private:
     196             :     /// @@@ public copy ctor, but no copy assignment?
     197             :     SwCollCondition & operator= (const SwCollCondition &) SAL_DELETED_FUNCTION;
     198             : public:
     199             : 
     200             :     bool operator==( const SwCollCondition& rCmp ) const;
     201             :     bool operator!=( const SwCollCondition& rCmp ) const
     202             :                             { return ! (*this == rCmp); }
     203             : 
     204           1 :     sal_uLong GetCondition() const      { return nCondition; }
     205           0 :     sal_uLong GetSubCondition() const   { return aSubCondition.nSubCondition; }
     206           0 :     const OUString* GetFieldExpression() const
     207           0 :                                     { return aSubCondition.pFieldExpression; }
     208             : 
     209             :     void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
     210           0 :     SwTextFormatColl* GetTextFormatColl() const     { return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn())); }
     211             :     void RegisterToFormat( SwFormat& );
     212             : };
     213             : 
     214        5898 : class SwFormatCollConditions : public boost::ptr_vector<SwCollCondition> {};
     215             : 
     216             : class SW_DLLPUBLIC SwConditionTextFormatColl : public SwTextFormatColl
     217             : {
     218             :     friend class SwDoc;
     219             :     friend class ::sw::DocumentStylePoolManager;
     220             : protected:
     221             :     SwFormatCollConditions aCondColls;
     222             : 
     223             :     SwConditionTextFormatColl( SwAttrPool& rPool, const sal_Char* pFormatCollName,
     224             :                             SwTextFormatColl* pDerFrom = 0 )
     225             :         : SwTextFormatColl( rPool, pFormatCollName, pDerFrom, RES_CONDTXTFMTCOLL )
     226             :     {}
     227        2952 :     SwConditionTextFormatColl( SwAttrPool& rPool, const OUString &rFormatCollName,
     228             :                             SwTextFormatColl* pDerFrom = 0 )
     229        2952 :         : SwTextFormatColl( rPool, rFormatCollName, pDerFrom, RES_CONDTXTFMTCOLL )
     230        2952 :     {}
     231             : 
     232             : public:
     233             :     TYPEINFO_OVERRIDE(); ///< Already in base class Client.
     234             : 
     235             :     virtual ~SwConditionTextFormatColl();
     236             : 
     237             :     const SwCollCondition* HasCondition( const SwCollCondition& rCond ) const;
     238         491 :     const SwFormatCollConditions& GetCondColls() const     { return aCondColls; }
     239             :     void InsertCondition( const SwCollCondition& rCond );
     240             :     bool RemoveCondition( const SwCollCondition& rCond );
     241             : 
     242             :     void SetConditions( const SwFormatCollConditions& );
     243             : };
     244             : 
     245             : // FEATURE::CONDCOLL
     246             : /// Inline implementations.
     247        9757 : inline void SwTextFormatColl::SetNextTextFormatColl( SwTextFormatColl& rNext )
     248             : {
     249        9757 :     pNextTextFormatColl = &rNext;
     250        9757 : }
     251             : #endif
     252             : 
     253             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11