LCOV - code coverage report
Current view: top level - include/editeng - numitem.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 40 54 74.1 %
Date: 2014-04-11 Functions: 36 45 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 INCLUDED_EDITENG_NUMITEM_HXX
      20             : #define INCLUDED_EDITENG_NUMITEM_HXX
      21             : 
      22             : #include <rtl/ustring.hxx>
      23             : #include <tools/link.hxx>
      24             : #include <svl/poolitem.hxx>
      25             : #include <editeng/svxenum.hxx>
      26             : #include <tools/gen.hxx>
      27             : #include <editeng/numdef.hxx>
      28             : #include <tools/color.hxx>
      29             : #include <cppuhelper/weakref.hxx>
      30             : #include <com/sun/star/lang/Locale.hpp>
      31             : #include <com/sun/star/uno/Reference.h>
      32             : #include <com/sun/star/style/NumberingType.hpp>
      33             : #include <unotools/fontcvt.hxx>
      34             : #include <editeng/editengdllapi.h>
      35             : 
      36             : class SvxBrushItem;
      37             : class Font;
      38             : class Graphic;
      39             : class SvxNodeNum;
      40             : namespace com{namespace sun{ namespace star{
      41             :     namespace text{
      42             :         class XNumberingFormatter;
      43             :     }
      44             : }}}
      45             : 
      46             : 
      47             : //Feature-Flags (only sal_uInt16!)
      48             : #define NUM_CONTINUOUS          0x0001 // consecutive numbers possible?
      49             : #define NUM_CHAR_TEXT_DISTANCE  0x0002 // Distance Symbol<->Text?
      50             : #define NUM_CHAR_STYLE          0x0004 // Character styles?
      51             : #define NUM_BULLET_REL_SIZE     0x0008 // relative bullet size?
      52             : #define NUM_BULLET_COLOR        0x0010 // Bullet color
      53             : #define NUM_SYMBOL_ALIGNMENT    0x0040 // alignment to be shown in the options
      54             : #define NUM_NO_NUMBERS          0x0080 // Numbering are not allowed
      55             : #define NUM_ENABLE_LINKED_BMP   0x0100 // linked bitmaps are available
      56             : #define NUM_ENABLE_EMBEDDED_BMP 0x0200 // embedded bitmaps are available
      57             : 
      58             : #define SVX_NO_NUM              200 // Marker for no numbering
      59             : #define SVX_NO_NUMLEVEL         0x20
      60             : 
      61             : #define LINK_TOKEN  0x80 //indicate linked bitmaps - for use in dialog only
      62             : class EDITENG_DLLPUBLIC SvxNumberType
      63             : {
      64             :     static sal_Int32 nRefCount;
      65             :     static com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
      66             : 
      67             :     sal_Int16       nNumType;
      68             :     bool            bShowSymbol;        // Also show Symbol ?
      69             : 
      70             : public:
      71             :     explicit SvxNumberType(sal_Int16 nType = com::sun::star::style::NumberingType::ARABIC);
      72             :     SvxNumberType(const SvxNumberType& rType);
      73             :     ~SvxNumberType();
      74             : 
      75             :     OUString        GetNumStr( sal_uLong nNo ) const;
      76             :     OUString        GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
      77             : 
      78    14279693 :     void            SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
      79    28928927 :     sal_Int16       GetNumberingType() const {return nNumType;}
      80             : 
      81    14084679 :     void            SetShowSymbol(bool bSet) {bShowSymbol = bSet;}
      82    22836689 :     bool            IsShowSymbol()const{return bShowSymbol;}
      83             : 
      84        1771 :     bool            IsTxtFmt() const
      85             :                     {
      86        3471 :                         return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
      87        3336 :                                com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
      88        3336 :                                com::sun::star::style::NumberingType::BITMAP != nNumType;
      89             :                     }
      90             : };
      91             : 
      92             : class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType
      93             : {
      94             : public:
      95             :     enum SvxNumPositionAndSpaceMode
      96             :     {
      97             :         LABEL_WIDTH_AND_POSITION,
      98             :         LABEL_ALIGNMENT
      99             :     };
     100             :     enum LabelFollowedBy
     101             :     {
     102             :         LISTTAB,
     103             :         SPACE,
     104             :         NOTHING
     105             :     };
     106             : 
     107             : private:
     108             :     OUString       sPrefix;
     109             :     OUString       sSuffix;
     110             : 
     111             :     SvxAdjust           eNumAdjust;
     112             : 
     113             :     sal_uInt8           nInclUpperLevels;   // Take over numbers from the previous level.
     114             :     sal_uInt16          nStart;             // Start of counting
     115             : 
     116             :     sal_Unicode         cBullet;            // Symbol
     117             :     sal_uInt16          nBulletRelSize;     // percentage size of bullets
     118             :     Color               nBulletColor;       // Bullet color
     119             : 
     120             :     // mode indicating, if the position and spacing of the list label is
     121             :     // determined by the former attributes (nFirstLineOffset, nAbsLSpace,
     122             :     // nLSpace and nCharTextDistance) called position and spacing via label
     123             :     // width and position (LABEL_WIDTH_AND_POSITION) or by the new attributes
     124             :     // (meLabelFollowedBy, mnListtabPos, mnFirstLineIndent and mnIndentAt)
     125             :     // called position and spacing via label alignment.
     126             :     // Note 1: Attribute <eNumAdjust> is relevant for both modes.
     127             :     // Note 2: The values of the former attributes are treated as 0, if mode
     128             :     //         LABEL_ALIGNMENT is active.
     129             :     SvxNumPositionAndSpaceMode mePositionAndSpaceMode;
     130             : 
     131             :     short               nFirstLineOffset;   // First line indent
     132             :     short               nAbsLSpace;         // Distance Border<->Number
     133             :     short               nLSpace;            // relative to the previous indentation
     134             :     short               nCharTextDistance;  // Distance Number<->Text
     135             : 
     136             :     // specifies what follows the list label before the text of the first line
     137             :     // of the list item starts
     138             :     LabelFollowedBy       meLabelFollowedBy;
     139             :     // specifies an additional list tab stop position for meLabelFollowedBy = LISTTAB
     140             :     long                        mnListtabPos;
     141             :     // specifies the first line indent
     142             :     long                        mnFirstLineIndent;
     143             :     // specifies the indent before the text, e.g. in L2R-layout the left margin
     144             :     long                        mnIndentAt;
     145             : 
     146             :     SvxBrushItem*       pGraphicBrush;
     147             :     sal_Int16           eVertOrient;        // vertical alignment of a bitmap
     148             : 
     149             :     Size                aGraphicSize;       // Always! in 1/100 mm
     150             :     Font*               pBulletFont;        // Pointer to the bullet font
     151             : 
     152             :     OUString            sCharStyleName;     // Character Style
     153             : 
     154             :     DECL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void * );
     155             :     virtual void NotifyGraphicArrived();
     156             : public:
     157             :     explicit SvxNumberFormat( sal_Int16 nNumberingType,
     158             :                      SvxNumPositionAndSpaceMode ePositionAndSpaceMode = LABEL_WIDTH_AND_POSITION );
     159             :     SvxNumberFormat(const SvxNumberFormat& rFormat);
     160             :     SvxNumberFormat( SvStream & rStream );
     161             : 
     162             :     virtual ~SvxNumberFormat();
     163             : 
     164             :     SvStream&       Store(SvStream &rStream, FontToSubsFontConverter pConverter);
     165             : 
     166             :     SvxNumberFormat& operator=( const SvxNumberFormat&  );
     167             :     bool            operator==( const SvxNumberFormat&  ) const;
     168     1013249 :     bool            operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
     169             : 
     170       19200 :     void            SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
     171       20698 :     SvxAdjust       GetNumAdjust() const {return eNumAdjust;}
     172       18944 :     void            SetPrefix(const OUString& rSet) { sPrefix = rSet;}
     173       22803 :     const OUString&   GetPrefix() const { return sPrefix;}
     174       54189 :     void            SetSuffix(const OUString& rSet) { sSuffix = rSet;}
     175       21772 :     const OUString&   GetSuffix() const { return sSuffix;}
     176             : 
     177        4315 :     void                    SetCharFmtName(const OUString& rSet){ sCharStyleName = rSet; }
     178             :     virtual OUString        GetCharFmtName()const;
     179             : 
     180             :     void            SetBulletFont(const Font* pFont);
     181        5273 :     const Font*     GetBulletFont() const {return pBulletFont;}
     182       81726 :     void            SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
     183       10724 :     sal_Unicode     GetBulletChar()const {return cBullet;}
     184        7432 :     void            SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
     185        1867 :     sal_uInt16          GetBulletRelSize() const { return nBulletRelSize;}
     186        8432 :     void            SetBulletColor(Color nSet){nBulletColor = nSet;}
     187        1866 :     Color           GetBulletColor()const {return nBulletColor;}
     188             : 
     189       83876 :     void            SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
     190     1185612 :     sal_uInt8           GetIncludeUpperLevels()const  { return nInclUpperLevels;}
     191       87435 :     void            SetStart(sal_uInt16 nSet) {nStart = nSet;}
     192        3916 :     sal_uInt16          GetStart() const {return nStart;}
     193             : 
     194             :     virtual void    SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
     195     7399620 :     const SvxBrushItem*         GetBrush() const {return pGraphicBrush;}
     196             :     void            SetGraphic( const OUString& rName );
     197             :     virtual void        SetVertOrient(sal_Int16 eSet);
     198             :     virtual sal_Int16   GetVertOrient() const;
     199           2 :     void            SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
     200     5962740 :     const Size&     GetGraphicSize() const {return aGraphicSize;}
     201             : 
     202             :     SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
     203             :     void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
     204             : 
     205     1597235 :     void            SetLSpace(short nSet) {nLSpace = nSet;}
     206             :     short           GetLSpace() const;
     207     1600749 :     void            SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
     208             :     short           GetAbsLSpace() const;
     209     1591585 :     void            SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
     210             :     short           GetFirstLineOffset() const;
     211       19637 :     void            SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
     212             :     short           GetCharTextDistance() const;
     213             : 
     214             :     void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
     215             :     LabelFollowedBy GetLabelFollowedBy() const;
     216             :     void SetListtabPos( const long nListtabPos );
     217             :     long GetListtabPos() const;
     218             :     void SetFirstLineIndent( const long nFirstLineIndent );
     219             :     long GetFirstLineIndent() const;
     220             :     void SetIndentAt( const long nIndentAt );
     221             :     long GetIndentAt() const;
     222             : 
     223             :     static Size     GetGraphicSizeMM100(const Graphic* pGraphic);
     224             :     static OUString CreateRomanString( sal_uLong nNo, bool bUpper );
     225             : };
     226             : 
     227             : enum SvxNumRuleType
     228             : {
     229             :     SVX_RULETYPE_NUMBERING,
     230             :     SVX_RULETYPE_OUTLINE_NUMBERING,
     231             :     SVX_RULETYPE_PRESENTATION_NUMBERING,
     232             :     SVX_RULETYPE_END
     233             : };
     234             : 
     235             : class EDITENG_DLLPUBLIC SvxNumRule
     236             : {
     237             :     sal_uInt16          nLevelCount;            // Number of supported levels
     238             :     sal_uInt32          nFeatureFlags;          // What is supported?
     239             :     SvxNumRuleType      eNumberingType;         // Type of numbering
     240             :     bool                bContinuousNumbering;   // sequential numbering
     241             : 
     242             :     SvxNumberFormat*    aFmts[SVX_MAX_NUM];
     243             :     bool                aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
     244             : 
     245             :     static sal_Int32    nRefCount;
     246             :     com::sun::star::lang::Locale aLocale;
     247             : public:
     248             :     SvxNumRule( sal_uLong nFeatures,
     249             :                 sal_uInt16 nLevels,
     250             :                 bool bCont,
     251             :                 SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
     252             :                 SvxNumberFormat::SvxNumPositionAndSpaceMode
     253             :                         eDefaultNumberFormatPositionAndSpaceMode
     254             :                                 = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
     255             :     SvxNumRule(const SvxNumRule& rCopy);
     256             :     SvxNumRule(SvStream &rStream);
     257             :     virtual ~SvxNumRule();
     258             : 
     259             :     int                     operator==( const SvxNumRule& ) const;
     260           0 :     bool                    operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
     261             : 
     262             :     SvxNumRule&             operator=( const SvxNumRule&  );
     263             : 
     264             :     SvStream&               Store(SvStream &rStream);
     265             :     const SvxNumberFormat*  Get(sal_uInt16 nLevel)const;
     266             :     const SvxNumberFormat&  GetLevel(sal_uInt16 nLevel)const;
     267             :     void                    SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, bool bIsValid = true);
     268             :     void                    SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt);
     269             : 
     270      143686 :     bool                    IsContinuousNumbering()const
     271      143686 :                                             {return bContinuousNumbering;}
     272           0 :     void                    SetContinuousNumbering(bool bSet)
     273           0 :                                             {bContinuousNumbering = bSet;}
     274             : 
     275     1635830 :     sal_uInt16              GetLevelCount() const {return nLevelCount;}
     276           0 :     bool                    IsFeatureSupported(sal_uInt32 nFeature) const
     277           0 :                                             {return 0 != (nFeatureFlags & nFeature);}
     278         300 :     sal_uInt32              GetFeatureFlags() const {return nFeatureFlags;}
     279           0 :     void                    SetFeatureFlag( sal_uInt32 nFlag, bool bSet = true ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
     280             : 
     281             :     OUString                MakeNumString( const SvxNodeNum&, bool bInclStrings = true ) const;
     282             : 
     283        1330 :     SvxNumRuleType          GetNumRuleType() const { return eNumberingType; }
     284             :     void                    SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
     285             : 
     286             :     bool                    UnLinkGraphics();
     287             : };
     288             : 
     289             : class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
     290             : {
     291             :     SvxNumRule*             pNumRule;
     292             : public:
     293             :     explicit SvxNumBulletItem(SvxNumRule& rRule);
     294             :     SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
     295             :     SvxNumBulletItem(const SvxNumBulletItem& rCopy);
     296             :     virtual ~SvxNumBulletItem();
     297             : 
     298             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     299             :     virtual SfxPoolItem*     Create(SvStream &rStream, sal_uInt16 nItemVersion) const SAL_OVERRIDE;
     300             :     sal_uInt16  GetVersion( sal_uInt16 nFileVersion ) const SAL_OVERRIDE;
     301             :     virtual SvStream&        Store(SvStream &rStream, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
     302             :     virtual bool             operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     303             : 
     304      218999 :     SvxNumRule*             GetNumRule() const {return pNumRule;}
     305             : 
     306             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     307             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     308             : };
     309             : 
     310             : class SvxNodeNum
     311             : {
     312             :     sal_uInt16 nLevelVal[ SVX_MAX_NUM ];    // Numbers of all levels
     313             :     sal_uInt16 nSetValue;                   // predetermined number
     314             :     sal_uInt8  nMyLevel;                     // Current Level
     315             :     bool       bStartNum;                     // Restart numbering
     316             : 
     317             : public:
     318             :     explicit inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
     319             :     inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
     320             : 
     321           0 :     sal_uInt8 GetLevel() const                  { return nMyLevel; }
     322           0 :     void SetLevel( sal_uInt8 nVal )             { nMyLevel = nVal; }
     323             : 
     324             :     bool IsStart() const                        { return bStartNum; }
     325             :     void SetStart( bool bFlag = true )          { bStartNum = bFlag; }
     326             : 
     327             :     sal_uInt16 GetSetValue() const              { return nSetValue; }
     328             :     void SetSetValue( sal_uInt16 nVal )         { nSetValue = nVal; }
     329             : 
     330           0 :     const sal_uInt16* GetLevelVal() const       { return nLevelVal; }
     331           0 :           sal_uInt16* GetLevelVal()             { return nLevelVal; }
     332             : };
     333             : 
     334           0 : SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
     335           0 :     : nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( false )
     336             : {
     337           0 :     memset( nLevelVal, 0, sizeof( nLevelVal ) );
     338           0 : }
     339             : 
     340             : inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
     341             : {
     342             :     nSetValue = rCpy.nSetValue;
     343             :     nMyLevel = rCpy.nMyLevel;
     344             :     bStartNum = rCpy.bStartNum;
     345             : 
     346             :     memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
     347             :     return *this;
     348             : }
     349             : 
     350             : SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
     351             : 
     352             : #endif
     353             : 
     354             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10