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

Generated by: LCOV version 1.10