LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - numrule.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 29 82.8 %
Date: 2012-12-27 Functions: 20 25 80.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 _NUMRULE_HXX
      20             : #define _NUMRULE_HXX
      21             : 
      22             : #include <tools/gen.hxx>
      23             : #include <tools/string.hxx>
      24             : #include <editeng/svxenum.hxx>
      25             : #include <editeng/numitem.hxx>
      26             : #include "swdllapi.h"
      27             : #include <swtypes.hxx>
      28             : #include <calbck.hxx>
      29             : #include <hints.hxx>
      30             : #include <boost/unordered_map.hpp>
      31             : #include <stringhash.hxx>
      32             : #include <SwNumberTreeTypes.hxx>
      33             : #include <vector>
      34             : 
      35             : class SwTxtFmtColl;
      36             : class IDocumentListsAccess;
      37             : class SwNodeNum;
      38             : class Font;
      39             : class SvxBrushItem;
      40             : class SvxNumRule;
      41             : class SwCharFmt;
      42             : class SwDoc;
      43             : class SwFmtVertOrient;
      44             : class SwTxtNode;
      45             : 
      46             : const sal_Unicode cBulletChar = 0x2022; ///< Character for lists.
      47             : 
      48             : class SW_DLLPUBLIC SwNumFmt : public SvxNumberFormat, public SwClient
      49             : {
      50             :     SwFmtVertOrient* pVertOrient;
      51             : 
      52             :     SW_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
      53             :     SW_DLLPRIVATE virtual void NotifyGraphicArrived();
      54             : 
      55             :     using SvxNumberFormat::operator ==;
      56             :     using SvxNumberFormat::operator !=;
      57             : 
      58             : protected:
      59             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
      60             : 
      61             : public:
      62             :     SwNumFmt();
      63             :     SwNumFmt( const SwNumFmt& );
      64             :     SwNumFmt( const SvxNumberFormat&, SwDoc* pDoc);
      65             : 
      66             :     virtual ~SwNumFmt();
      67             : 
      68             :     SwNumFmt& operator=( const SwNumFmt& );
      69             : 
      70             :     sal_Bool operator==( const SwNumFmt& ) const;
      71        4585 :     sal_Bool operator!=( const SwNumFmt& r ) const { return !(*this == r); }
      72             : 
      73        6244 :     SwCharFmt* GetCharFmt() const { return (SwCharFmt*)GetRegisteredIn(); }
      74             :     void SetCharFmt( SwCharFmt* );
      75             : 
      76             :     virtual void            SetCharFmtName(const String& rSet);
      77             :     virtual const String&   GetCharFmtName()const;
      78             : 
      79             :     virtual void    SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
      80             : 
      81             :     virtual void                SetVertOrient(sal_Int16 eSet);
      82             :     virtual sal_Int16   GetVertOrient() const;
      83             :     const SwFmtVertOrient*      GetGraphicOrientation() const;
      84             : 
      85             :     sal_Bool IsEnumeration() const; // #i22362#
      86             :     sal_Bool IsItemize() const; // #i29560#
      87             : };
      88             : 
      89             : class SwPaM;
      90             : enum SwNumRuleType { OUTLINE_RULE = 0, NUM_RULE = 1, RULE_END = 2 };
      91             : class SW_DLLPUBLIC SwNumRule
      92             : {
      93             : 
      94             : public:
      95             :     typedef std::vector< SwTxtNode* > tTxtNodeList;
      96             :     typedef std::vector< SwTxtFmtColl* > tParagraphStyleList;
      97             : 
      98             :     struct Extremities
      99             :     {
     100             :         sal_uInt16 nPrefixChars;
     101             :         sal_uInt16 nSuffixChars;
     102             :     };
     103             : 
     104             : private:
     105             :     friend void _FinitCore();
     106             : 
     107             :     static SwNumFmt* aBaseFmts [ RULE_END ][ MAXLEVEL ];
     108             :     static sal_uInt16 aDefNumIndents[ MAXLEVEL ];
     109             :     /// default list level properties for position-and-space mode LABEL_ALIGNMENT
     110             :     static SwNumFmt* aLabelAlignmentBaseFmts [ RULE_END ][ MAXLEVEL ];
     111             :     static sal_uInt16 nRefCount;
     112             :     static char* pDefOutlineName;
     113             : 
     114             :     SwNumFmt* aFmts[ MAXLEVEL ];
     115             : 
     116             :     /** container for associated text nodes */
     117             :     tTxtNodeList maTxtNodeList;
     118             : 
     119             :     /** container for associated paragraph styles */
     120             :     tParagraphStyleList maParagraphStyleList;
     121             : 
     122             :     /** boost::unordered_map containing "name->rule" relation */
     123             :     boost::unordered_map<String, SwNumRule *, StringHash> * pNumRuleMap;
     124             : 
     125             :     String sName;
     126             :     SwNumRuleType eRuleType;
     127             :     sal_uInt16 nPoolFmtId;      ///< Id-for NumRules created "automatically"
     128             :     sal_uInt16 nPoolHelpId;     ///< HelpId for this Pool-style.
     129             :     sal_uInt8 nPoolHlpFileId;   ///< FilePos at Doc on style helps.
     130             :     sal_Bool bAutoRuleFlag : 1;
     131             :     sal_Bool bInvalidRuleFlag : 1;
     132             :     sal_Bool bContinusNum : 1;  ///< Continuous numbering without levels.
     133             :     sal_Bool bAbsSpaces : 1;    ///< Levels represent absolute indents.
     134             :     sal_Bool bHidden : 1;       ///< Is the numering rule to be hidden in the UI?
     135             :     bool mbCountPhantoms;
     136             : 
     137             :     const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode;
     138             :     String msDefaultListId;
     139             : 
     140             : public:
     141             :     /// add parameter <eDefaultNumberFormatPositionAndSpaceMode>
     142             :     SwNumRule( const String& rNm,
     143             :                const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
     144             :                SwNumRuleType = NUM_RULE,
     145             :                sal_Bool bAutoFlg = sal_True );
     146             : 
     147             :     SwNumRule( const SwNumRule& );
     148             :     ~SwNumRule();
     149             : 
     150             :     SwNumRule& operator=( const SwNumRule& );
     151             :     sal_Bool operator==( const SwNumRule& ) const;
     152          29 :     sal_Bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
     153             : 
     154             :     const SwNumFmt* GetNumFmt( sal_uInt16 i ) const;
     155             :     const SwNumFmt& Get( sal_uInt16 i ) const;
     156             : 
     157           3 :     sal_Bool IsHidden( ) const { return bHidden; }
     158           8 :     void SetHidden( sal_Bool bValue ) { bHidden = bValue; }
     159             : 
     160             :     void Set( sal_uInt16 i, const SwNumFmt* );
     161             :     void Set( sal_uInt16 i, const SwNumFmt& );
     162             :     String MakeNumString( const SwNodeNum&, sal_Bool bInclStrings = sal_True,
     163             :                             sal_Bool bOnlyArabic = sal_False ) const;
     164             :     /** - add optional parameter <_nRestrictToThisLevel> in order to
     165             :          restrict returned string to this level. */
     166             :     String MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
     167             :                           const sal_Bool bInclStrings = sal_True,
     168             :                           const sal_Bool bOnlyArabic = sal_False,
     169             :                           const unsigned int _nRestrictToThisLevel = MAXLEVEL,
     170             :                           Extremities* pExtremities = 0 ) const;
     171             :     String MakeRefNumString( const SwNodeNum& rNodeNum,
     172             :                              const bool bInclSuperiorNumLabels = false,
     173             :                              const sal_uInt8 nRestrictInclToThisLevel = 0 ) const;
     174             : 
     175             :     /**
     176             : 
     177             :        @return list of associated text nodes
     178             :     */
     179             :     void GetTxtNodeList( SwNumRule::tTxtNodeList& rTxtNodeList ) const;
     180             :     SwNumRule::tTxtNodeList::size_type GetTxtNodeListSize() const;
     181             : 
     182             :     void AddTxtNode( SwTxtNode& rTxtNode );
     183             :     void RemoveTxtNode( SwTxtNode& rTxtNode );
     184             : 
     185             :     SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const;
     186             :     void AddParagraphStyle( SwTxtFmtColl& rTxtFmtColl );
     187             :     void RemoveParagraphStyle( SwTxtFmtColl& rTxtFmtColl );
     188             : 
     189         591 :     inline void SetDefaultListId( const String sDefaultListId )
     190             :     {
     191         591 :         msDefaultListId = sDefaultListId;
     192         591 :     }
     193        3467 :     inline String GetDefaultListId() const
     194             :     {
     195        3467 :         return msDefaultListId;
     196             :     }
     197             :     /**
     198             :        Register this rule in a "name->numrule" map.
     199             : 
     200             :        @param pNumRuleMap      map to register in
     201             :      */
     202             :     void SetNumRuleMap(
     203             :                 boost::unordered_map<String, SwNumRule *, StringHash>* pNumRuleMap );
     204             : 
     205        1059 :     static char* GetOutlineRuleName() { return pDefOutlineName; }
     206             : 
     207             :     static sal_uInt16 GetNumIndent( sal_uInt8 nLvl );
     208             :     static sal_uInt16 GetBullIndent( sal_uInt8 nLvl );
     209             : 
     210           0 :     SwNumRuleType GetRuleType() const           { return eRuleType; }
     211         364 :     void SetRuleType( SwNumRuleType eNew )      { eRuleType = eNew;
     212         364 :                                                   bInvalidRuleFlag = sal_True; }
     213             : 
     214             :     /** A kind of copy-constructor to make sure the num formats are
     215             :        attached to the correctCharFormats of a document!!
     216             :        (Copies the NumFormats and returns itself). */
     217             :     SwNumRule& CopyNumRule( SwDoc*, const SwNumRule& );
     218             : 
     219             :     /** Tests whether the CharFormats are from the given doc
     220             :        and copies them if appropriate. */
     221             :     void CheckCharFmts( SwDoc* pDoc );
     222             : 
     223       20343 :     const String& GetName() const       { return sName; }
     224             : 
     225             :     void SetName( const String& rNm,
     226             :                   IDocumentListsAccess& rDocListAccess );
     227             : 
     228         226 :     sal_Bool IsAutoRule() const             { return bAutoRuleFlag; }
     229         672 :     void SetAutoRule( sal_Bool bFlag )      { bAutoRuleFlag = bFlag; }
     230             : 
     231        3283 :     sal_Bool IsInvalidRule() const          { return bInvalidRuleFlag; }
     232             :     void SetInvalidRule( sal_Bool bFlag );
     233             : 
     234        5512 :     sal_Bool IsContinusNum() const          { return bContinusNum; }
     235         413 :     void SetContinusNum( sal_Bool bFlag )   { bContinusNum = bFlag; }
     236             : 
     237           0 :     sal_Bool IsAbsSpaces() const            { return bAbsSpaces; }
     238           0 :     void SetAbsSpaces( sal_Bool bFlag )     { bAbsSpaces = bFlag; }
     239             : 
     240        2959 :     sal_Bool IsOutlineRule() const { return eRuleType == OUTLINE_RULE; }
     241             : 
     242             :     bool IsCountPhantoms() const;
     243             :     void SetCountPhantoms(bool bCountPhantoms);
     244             : 
     245             :     /// Query and set PoolFormat IDs.
     246        1311 :     sal_uInt16 GetPoolFmtId() const         { return nPoolFmtId; }
     247           2 :     void SetPoolFmtId( sal_uInt16 nId )     { nPoolFmtId = nId; }
     248             : 
     249             :     /// Query and set Help-IDs for document styles.
     250        1308 :     sal_uInt16 GetPoolHelpId() const        { return nPoolHelpId; }
     251           0 :     void SetPoolHelpId( sal_uInt16 nId )    { nPoolHelpId = nId; }
     252        1308 :     sal_uInt8 GetPoolHlpFileId() const      { return nPoolHlpFileId; }
     253           0 :     void SetPoolHlpFileId( sal_uInt8 nId )  { nPoolHlpFileId = nId; }
     254             : 
     255             :     void        SetSvxRule(const SvxNumRule&, SwDoc* pDoc);
     256             :     SvxNumRule  MakeSvxNumRule() const;
     257             : 
     258             :     /// change indent of all list levels by given difference
     259             :     void ChangeIndent( const short nDiff );
     260             :     /// set indent of certain list level to given value
     261             :     void SetIndent( const short nNewIndent,
     262             :                     const sal_uInt16 nListLevel );
     263             :     /** set indent of first list level to given value and change other list level's
     264             :        indents accordingly */
     265             :     void SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent );
     266             : 
     267             :     void Validate();
     268             : };
     269             : 
     270             : /// namespace for static functions and methods for numbering and bullets
     271             : namespace numfunc
     272             : {
     273             :     /** retrieve font family name used for the default bullet list characters
     274             : 
     275             :         @author OD
     276             :     */
     277             :     const String& GetDefBulletFontname();
     278             : 
     279             :     /** determine if default bullet font is user defined
     280             : 
     281             :         The default bullet font is user defined, if it is given in the user configuration
     282             : 
     283             :         @author OD
     284             :     */
     285             :     bool IsDefBulletFontUserDefined();
     286             : 
     287             :     /** retrieve font used for the default bullet list characters
     288             : 
     289             :         @author OD
     290             :     */
     291             :     SW_DLLPUBLIC const Font& GetDefBulletFont();
     292             : 
     293             :     /** retrieve unicode of character used for the default bullet list for the given list level
     294             : 
     295             :         @author OD
     296             :     */
     297             :     sal_Unicode GetBulletChar( sal_uInt8 nLevel );
     298             : 
     299             :     /** configuration, if at first position of the first list item the <TAB>-key
     300             :         increased the indent of the complete list or only demotes this list item.
     301             :         The same for <SHIFT-TAB>-key at the same position for decreasing the
     302             :         indent of the complete list or only promotes this list item.
     303             : 
     304             :         @author OD
     305             :     */
     306             :     sal_Bool ChangeIndentOnTabAtFirstPosOfFirstListItem();
     307             : 
     308             :     /**
     309             :         @author OD
     310             :     */
     311             :     SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode();
     312             : }
     313             : 
     314             : #endif  // _NUMRULE_HXX
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10