LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/editeng - numitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 54 74.1 %
Date: 2013-07-09 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 _SVX_NUMITEM_HXX
      20             : #define _SVX_NUMITEM_HXX
      21             : 
      22             : #include <tools/link.hxx>
      23             : #include <tools/string.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             :     sal_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             :     String          GetNumStr( sal_uLong nNo ) const;
      76             :     String          GetNumStr( sal_uLong nNo, const com::sun::star::lang::Locale& rLocale ) const;
      77             : 
      78      143070 :     void            SetNumberingType(sal_Int16 nSet) {nNumType = nSet;}
      79      623009 :     sal_Int16       GetNumberingType() const {return nNumType;}
      80             : 
      81      118280 :     void            SetShowSymbol(sal_Bool bSet) {bShowSymbol = bSet;}
      82      185738 :     sal_Bool        IsShowSymbol()const{return bShowSymbol;}
      83             : 
      84         586 :     sal_Bool        IsTxtFmt() const
      85             :                     {
      86        1148 :                         return com::sun::star::style::NumberingType::NUMBER_NONE != nNumType &&
      87        1070 :                                com::sun::star::style::NumberingType::CHAR_SPECIAL != nNumType &&
      88        1070 :                                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             :     String              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             :     SvxNumberFormat* Create(SvStream& rStream );
     166             : 
     167             :     SvxNumberFormat& operator=( const SvxNumberFormat&  );
     168             :     sal_Bool            operator==( const SvxNumberFormat&  ) const;
     169       19576 :     sal_Bool            operator!=( const SvxNumberFormat& rFmt) const {return !(*this == rFmt);}
     170             : 
     171        4453 :     void            SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
     172      180064 :     SvxAdjust       GetNumAdjust() const {return eNumAdjust;}
     173        3865 :     void            SetPrefix(const OUString& rSet) { sPrefix = rSet;}
     174      100335 :     const OUString&   GetPrefix() const { return sPrefix;}
     175       20365 :     void            SetSuffix(const OUString& rSet) { sSuffix = rSet;}
     176      100319 :     const OUString&   GetSuffix() const { return sSuffix;}
     177             : 
     178         418 :     void                    SetCharFmtName(const String& rSet){ sCharStyleName = rSet; }
     179             :     virtual const String&   GetCharFmtName()const;
     180             : 
     181             :     void            SetBulletFont(const Font* pFont);
     182        1852 :     const Font*     GetBulletFont() const {return pBulletFont;}
     183       34775 :     void            SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
     184        5258 :     sal_Unicode     GetBulletChar()const {return cBullet;}
     185        4548 :     void            SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = nSet;}
     186        1585 :     sal_uInt16          GetBulletRelSize() const { return nBulletRelSize;}
     187        7309 :     void            SetBulletColor(Color nSet){nBulletColor = nSet;}
     188        1585 :     Color           GetBulletColor()const {return nBulletColor;}
     189             : 
     190       32950 :     void            SetIncludeUpperLevels( sal_uInt8 nSet ) { nInclUpperLevels = nSet;}
     191        4765 :     sal_uInt8           GetIncludeUpperLevels()const  { return nInclUpperLevels;}
     192       35304 :     void            SetStart(sal_uInt16 nSet) {nStart = nSet;}
     193         898 :     sal_uInt16          GetStart() const {return nStart;}
     194             : 
     195             :     virtual void    SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = 0, const sal_Int16* pOrient = 0);
     196       49690 :     const SvxBrushItem*         GetBrush() const {return pGraphicBrush;}
     197             :     void            SetGraphic( const String& rName );
     198             :     virtual void        SetVertOrient(sal_Int16 eSet);
     199             :     virtual sal_Int16   GetVertOrient() const;
     200           2 :     void            SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
     201       47504 :     const Size&     GetGraphicSize() const {return aGraphicSize;}
     202             : 
     203             :     SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const;
     204             :     void SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode );
     205             : 
     206       19206 :     void            SetLSpace(short nSet) {nLSpace = nSet;}
     207             :     short           GetLSpace() const;
     208       21291 :     void            SetAbsLSpace(short nSet) {nAbsLSpace = nSet;}
     209             :     short           GetAbsLSpace() const;
     210       15261 :     void            SetFirstLineOffset(short nSet) { nFirstLineOffset = nSet;}
     211             :     short           GetFirstLineOffset() const;
     212        8998 :     void            SetCharTextDistance(short nSet) { nCharTextDistance = nSet; }
     213             :     short           GetCharTextDistance() const;
     214             : 
     215             :     void SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy );
     216             :     LabelFollowedBy GetLabelFollowedBy() const;
     217             :     void SetListtabPos( const long nListtabPos );
     218             :     long GetListtabPos() const;
     219             :     void SetFirstLineIndent( const long nFirstLineIndent );
     220             :     long GetFirstLineIndent() const;
     221             :     void SetIndentAt( const long nIndentAt );
     222             :     long GetIndentAt() const;
     223             : 
     224             :     static Size     GetGraphicSizeMM100(const Graphic* pGraphic);
     225             :     static String   CreateRomanString( sal_uLong nNo, sal_Bool bUpper );
     226             : };
     227             : 
     228             : enum SvxNumRuleType
     229             : {
     230             :     SVX_RULETYPE_NUMBERING,
     231             :     SVX_RULETYPE_OUTLINE_NUMBERING,
     232             :     SVX_RULETYPE_PRESENTATION_NUMBERING,
     233             :     SVX_RULETYPE_END
     234             : };
     235             : 
     236             : class EDITENG_DLLPUBLIC SvxNumRule
     237             : {
     238             :     sal_uInt16          nLevelCount;            // Number of supported levels
     239             :     sal_uInt32          nFeatureFlags;          // What is supported?
     240             :     SvxNumRuleType      eNumberingType;         // Type of numbering
     241             :     sal_Bool            bContinuousNumbering;   // sequential numbering
     242             : 
     243             :     SvxNumberFormat*    aFmts[SVX_MAX_NUM];
     244             :     sal_Bool            aFmtsSet[SVX_MAX_NUM]; // Flags indicating valid levels
     245             : 
     246             :     static sal_Int32    nRefCount;
     247             :     com::sun::star::lang::Locale aLocale;
     248             : public:
     249             :     SvxNumRule( sal_uLong nFeatures,
     250             :                 sal_uInt16 nLevels,
     251             :                 sal_Bool bCont,
     252             :                 SvxNumRuleType eType = SVX_RULETYPE_NUMBERING,
     253             :                 SvxNumberFormat::SvxNumPositionAndSpaceMode
     254             :                         eDefaultNumberFormatPositionAndSpaceMode
     255             :                                 = SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
     256             :     SvxNumRule(const SvxNumRule& rCopy);
     257             :     SvxNumRule(SvStream &rStream);
     258             :     virtual ~SvxNumRule();
     259             : 
     260             :     int                     operator==( const SvxNumRule& ) const;
     261           0 :     int                     operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);}
     262             : 
     263             :     SvxNumRule&             operator=( const SvxNumRule&  );
     264             : 
     265             :     SvStream&               Store(SvStream &rStream);
     266             :     SvxNumRule*             Create(SvStream &rStream);
     267             :     const SvxNumberFormat*  Get(sal_uInt16 nLevel)const;
     268             :     const SvxNumberFormat&  GetLevel(sal_uInt16 nLevel)const;
     269             :     void                    SetLevel(sal_uInt16 nLevel, const SvxNumberFormat& rFmt, sal_Bool bIsValid = sal_True);
     270             :     void                    SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt);
     271             : 
     272         218 :     sal_Bool                    IsContinuousNumbering()const
     273         218 :                                             {return bContinuousNumbering;}
     274           0 :     void                    SetContinuousNumbering(sal_Bool bSet)
     275           0 :                                             {bContinuousNumbering = bSet;}
     276             : 
     277      473647 :     sal_uInt16                  GetLevelCount() const {return nLevelCount;}
     278           0 :     sal_Bool                    IsFeatureSupported(sal_uInt32 nFeature) const
     279           0 :                                             {return 0 != (nFeatureFlags & nFeature);}
     280         186 :     sal_uInt32                  GetFeatureFlags() const {return nFeatureFlags;}
     281           0 :     void                    SetFeatureFlag( sal_uInt32 nFlag, sal_Bool bSet = sal_True ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
     282             : 
     283             :     String                  MakeNumString( const SvxNodeNum&, sal_Bool bInclStrings = sal_True ) const;
     284             : 
     285         360 :     SvxNumRuleType          GetNumRuleType() const { return eNumberingType; }
     286             :     void                    SetNumRuleType( const SvxNumRuleType& rType ) { eNumberingType = rType; }
     287             : 
     288             :     sal_Bool                    UnLinkGraphics();
     289             : };
     290             : 
     291             : class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
     292             : {
     293             :     SvxNumRule*             pNumRule;
     294             : public:
     295             :     explicit SvxNumBulletItem(SvxNumRule& rRule);
     296             :     SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich );
     297             :     SvxNumBulletItem(const SvxNumBulletItem& rCopy);
     298             :     virtual ~SvxNumBulletItem();
     299             : 
     300             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
     301             :     virtual SfxPoolItem*     Create(SvStream &rStream, sal_uInt16 nItemVersion) const;
     302             :     sal_uInt16  GetVersion( sal_uInt16 nFileVersion ) const;
     303             :     virtual SvStream&        Store(SvStream &rStream, sal_uInt16 nItemVersion ) const;
     304             :     virtual int              operator==( const SfxPoolItem& ) const;
     305             : 
     306      917996 :     SvxNumRule*             GetNumRule() const {return pNumRule;}
     307             : 
     308             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
     309             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
     310             : };
     311             : 
     312             : class SvxNodeNum
     313             : {
     314             :     sal_uInt16 nLevelVal[ SVX_MAX_NUM ];    // Numbers of all levels
     315             :     sal_uInt16 nSetValue;                   // predetermined number
     316             :     sal_uInt8 nMyLevel;                     // Current Level
     317             :     sal_Bool bStartNum;                     // Restart numbering
     318             : 
     319             : public:
     320             :     explicit inline SvxNodeNum( sal_uInt8 nLevel = SVX_NO_NUM, sal_uInt16 nSetVal = USHRT_MAX );
     321             :     inline SvxNodeNum& operator=( const SvxNodeNum& rCpy );
     322             : 
     323           0 :     sal_uInt8 GetLevel() const                  { return nMyLevel; }
     324           0 :     void SetLevel( sal_uInt8 nVal )             { nMyLevel = nVal; }
     325             : 
     326             :     sal_Bool IsStart() const                    { return bStartNum; }
     327             :     void SetStart( sal_Bool bFlag = sal_True )      { bStartNum = bFlag; }
     328             : 
     329             :     sal_uInt16 GetSetValue() const              { return nSetValue; }
     330             :     void SetSetValue( sal_uInt16 nVal )         { nSetValue = nVal; }
     331             : 
     332           0 :     const sal_uInt16* GetLevelVal() const       { return nLevelVal; }
     333           0 :           sal_uInt16* GetLevelVal()             { return nLevelVal; }
     334             : };
     335             : 
     336           0 : SvxNodeNum::SvxNodeNum( sal_uInt8 nLevel, sal_uInt16 nSetVal )
     337           0 :     : nSetValue( nSetVal ), nMyLevel( nLevel ), bStartNum( sal_False )
     338             : {
     339           0 :     memset( nLevelVal, 0, sizeof( nLevelVal ) );
     340           0 : }
     341             : 
     342             : inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy )
     343             : {
     344             :     nSetValue = rCpy.nSetValue;
     345             :     nMyLevel = rCpy.nMyLevel;
     346             :     bStartNum = rCpy.bStartNum;
     347             : 
     348             :     memcpy( nLevelVal, rCpy.nLevelVal, sizeof( nLevelVal ) );
     349             :     return *this;
     350             : }
     351             : 
     352             : SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType );
     353             : 
     354             : #endif
     355             : 
     356             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10