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

Generated by: LCOV version 1.10