LCOV - code coverage report
Current view: top level - sw/inc - numrule.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 27 88.9 %
Date: 2012-08-25 Functions: 20 23 87.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _NUMRULE_HXX
      29                 :            : #define _NUMRULE_HXX
      30                 :            : 
      31                 :            : #include <tools/gen.hxx>
      32                 :            : #include <tools/string.hxx>
      33                 :            : #include <editeng/svxenum.hxx>
      34                 :            : #include <editeng/numitem.hxx>
      35                 :            : #include "swdllapi.h"
      36                 :            : #include <swtypes.hxx>
      37                 :            : #include <calbck.hxx>
      38                 :            : #include <hints.hxx>
      39                 :            : #include <boost/unordered_map.hpp>
      40                 :            : #include <stringhash.hxx>
      41                 :            : #include <SwNumberTreeTypes.hxx>
      42                 :            : #include <vector>
      43                 :            : 
      44                 :            : class SwTxtFmtColl;
      45                 :            : class IDocumentListsAccess;
      46                 :            : class SwNodeNum;
      47                 :            : class Font;
      48                 :            : class SvxBrushItem;
      49                 :            : class SvxNumRule;
      50                 :            : class SwCharFmt;
      51                 :            : class SwDoc;
      52                 :            : class SwFmtVertOrient;
      53                 :            : class SwTxtNode;
      54                 :            : 
      55                 :            : const sal_Unicode cBulletChar = 0x2022; // Character for lists.
      56                 :            : 
      57                 :            : class SW_DLLPUBLIC SwNumFmt : public SvxNumberFormat, public SwClient
      58                 :            : {
      59                 :            :     SwFmtVertOrient* pVertOrient;
      60                 :            : 
      61                 :            :     SW_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
      62                 :            :     SW_DLLPRIVATE virtual void NotifyGraphicArrived();
      63                 :            : 
      64                 :            :     using SvxNumberFormat::operator ==;
      65                 :            :     using SvxNumberFormat::operator !=;
      66                 :            : 
      67                 :            : protected:
      68                 :            :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
      69                 :            : 
      70                 :            : public:
      71                 :            :     SwNumFmt();
      72                 :            :     SwNumFmt( const SwNumFmt& );
      73                 :            :     SwNumFmt( const SvxNumberFormat&, SwDoc* pDoc);
      74                 :            : 
      75                 :            :     virtual ~SwNumFmt();
      76                 :            : 
      77                 :            :     SwNumFmt& operator=( const SwNumFmt& );
      78                 :            : 
      79                 :            :     sal_Bool operator==( const SwNumFmt& ) const;
      80                 :      13293 :     sal_Bool operator!=( const SwNumFmt& r ) const { return !(*this == r); }
      81                 :            : 
      82                 :      18517 :     SwCharFmt* GetCharFmt() const { return (SwCharFmt*)GetRegisteredIn(); }
      83                 :            :     void SetCharFmt( SwCharFmt* );
      84                 :            :     void ForgetCharFmt();
      85                 :            : 
      86                 :            :     virtual void            SetCharFmtName(const String& rSet);
      87                 :            :     virtual const String&   GetCharFmtName()const;
      88                 :            : 
      89                 :            :     virtual void    SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
      90                 :            : 
      91                 :            :     virtual void                SetVertOrient(sal_Int16 eSet);
      92                 :            :     virtual sal_Int16   GetVertOrient() const;
      93                 :            :     const SwFmtVertOrient*      GetGraphicOrientation() const;
      94                 :            : 
      95                 :            :     sal_Bool IsEnumeration() const; // #i22362#
      96                 :            :     sal_Bool IsItemize() const; // #i29560#
      97                 :            : };
      98                 :            : 
      99                 :            : class SwPaM;
     100                 :            : enum SwNumRuleType { OUTLINE_RULE = 0, NUM_RULE = 1, RULE_END = 2 };
     101                 :            : class SW_DLLPUBLIC SwNumRule
     102                 :            : {
     103                 :            : 
     104                 :            : public:
     105                 :            :     typedef std::vector< SwTxtNode* > tTxtNodeList;
     106                 :            :     typedef std::vector< SwTxtFmtColl* > tParagraphStyleList;
     107                 :            : 
     108                 :            :     struct Extremities
     109                 :            :     {
     110                 :            :         sal_uInt16 nPrefixChars;
     111                 :            :         sal_uInt16 nSuffixChars;
     112                 :            :     };
     113                 :            : 
     114                 :            : private:
     115                 :            :     friend void _FinitCore();
     116                 :            : 
     117                 :            :     static SwNumFmt* aBaseFmts [ RULE_END ][ MAXLEVEL ];
     118                 :            :     static sal_uInt16 aDefNumIndents[ MAXLEVEL ];
     119                 :            :     // default list level properties for position-and-space mode LABEL_ALIGNMENT
     120                 :            :     static SwNumFmt* aLabelAlignmentBaseFmts [ RULE_END ][ MAXLEVEL ];
     121                 :            :     static sal_uInt16 nRefCount;
     122                 :            :     static char* pDefOutlineName;
     123                 :            : 
     124                 :            :     SwNumFmt* aFmts[ MAXLEVEL ];
     125                 :            : 
     126                 :            :     /** container for associated text nodes */
     127                 :            :     tTxtNodeList maTxtNodeList;
     128                 :            : 
     129                 :            :     /** container for associated paragraph styles */
     130                 :            :     tParagraphStyleList maParagraphStyleList;
     131                 :            : 
     132                 :            :     /** boost::unordered_map containing "name->rule" relation */
     133                 :            :     boost::unordered_map<String, SwNumRule *, StringHash> * pNumRuleMap;
     134                 :            : 
     135                 :            :     String sName;
     136                 :            :     SwNumRuleType eRuleType;
     137                 :            :     sal_uInt16 nPoolFmtId;      // Id-for NumRules created "automatically"
     138                 :            :     sal_uInt16 nPoolHelpId;     // HelpId for this Pool-style.
     139                 :            :     sal_uInt8 nPoolHlpFileId;   // FilePos at Doc on style helps.
     140                 :            :     sal_Bool bAutoRuleFlag : 1;
     141                 :            :     sal_Bool bInvalidRuleFlag : 1;
     142                 :            :     sal_Bool bContinusNum : 1;  // Continuous numbering without levels.
     143                 :            :     sal_Bool bAbsSpaces : 1;    // Levels represent absolute indents.
     144                 :            :     bool mbCountPhantoms;
     145                 :            : 
     146                 :            :     const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode;
     147                 :            :     String msDefaultListId;
     148                 :            : 
     149                 :            : public:
     150                 :            :     // add parameter <eDefaultNumberFormatPositionAndSpaceMode>
     151                 :            :     SwNumRule( const String& rNm,
     152                 :            :                const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
     153                 :            :                SwNumRuleType = NUM_RULE,
     154                 :            :                sal_Bool bAutoFlg = sal_True );
     155                 :            : 
     156                 :            :     SwNumRule( const SwNumRule& );
     157                 :            :     ~SwNumRule();
     158                 :            : 
     159                 :            :     SwNumRule& operator=( const SwNumRule& );
     160                 :            :     sal_Bool operator==( const SwNumRule& ) const;
     161                 :        129 :     sal_Bool operator!=( const SwNumRule& r ) const { return !(*this == r); }
     162                 :            : 
     163                 :            :     const SwNumFmt* GetNumFmt( sal_uInt16 i ) const;
     164                 :            :     const SwNumFmt& Get( sal_uInt16 i ) const;
     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                 :            :     /** Returns list of associated text nodes.
     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                 :       2367 :     inline void SetDefaultListId( const String sDefaultListId )
     196                 :            :     {
     197                 :       2367 :         msDefaultListId = sDefaultListId;
     198                 :       2367 :     }
     199                 :      11042 :     inline String GetDefaultListId() const
     200                 :            :     {
     201                 :      11042 :         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                 :       4185 :     static char* GetOutlineRuleName() { return pDefOutlineName; }
     212                 :            : 
     213                 :            :     static sal_uInt16 GetNumIndent( sal_uInt8 nLvl );
     214                 :            :     static sal_uInt16 GetBullIndent( sal_uInt8 nLvl );
     215                 :            : 
     216                 :          0 :     SwNumRuleType GetRuleType() const           { return eRuleType; }
     217                 :       1369 :     void SetRuleType( SwNumRuleType eNew )      { eRuleType = eNew;
     218                 :       1369 :                                                   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                 :      59894 :     const String& GetName() const       { return sName; }
     230                 :            : 
     231                 :            :     void SetName( const String& rNm,
     232                 :            :                   IDocumentListsAccess& rDocListAccess );
     233                 :            : 
     234                 :        622 :     sal_Bool IsAutoRule() const             { return bAutoRuleFlag; }
     235                 :       2185 :     void SetAutoRule( sal_Bool bFlag )      { bAutoRuleFlag = bFlag; }
     236                 :            : 
     237                 :      39394 :     sal_Bool IsInvalidRule() const          { return bInvalidRuleFlag; }
     238                 :            :     void SetInvalidRule( sal_Bool bFlag );
     239                 :            : 
     240                 :      17478 :     sal_Bool IsContinusNum() const          { return bContinusNum; }
     241                 :       1037 :     void SetContinusNum( sal_Bool bFlag )   { bContinusNum = bFlag; }
     242                 :            : 
     243                 :       1008 :     sal_Bool IsAbsSpaces() const            { return bAbsSpaces; }
     244                 :         10 :     void SetAbsSpaces( sal_Bool bFlag )     { bAbsSpaces = bFlag; }
     245                 :            : 
     246                 :       9142 :     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                 :       3921 :     sal_uInt16 GetPoolFmtId() const         { return nPoolFmtId; }
     253                 :         10 :     void SetPoolFmtId( sal_uInt16 nId )     { nPoolFmtId = nId; }
     254                 :            : 
     255                 :            :     // Query and set Help-IDs for document styles.
     256                 :       3908 :     sal_uInt16 GetPoolHelpId() const        { return nPoolHelpId; }
     257                 :          0 :     void SetPoolHelpId( sal_uInt16 nId )    { nPoolHelpId = nId; }
     258                 :       3908 :     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