LCOV - code coverage report
Current view: top level - editeng/source/editeng - editattr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 56 83.9 %
Date: 2012-08-25 Functions: 56 61 91.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 48 52.1 %

           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                 :            : 
      29                 :            : #ifndef _EDITATTR_HXX
      30                 :            : #define _EDITATTR_HXX
      31                 :            : 
      32                 :            : #include <editeng/eeitem.hxx>
      33                 :            : #include <svl/poolitem.hxx>
      34                 :            : 
      35                 :            : #include <boost/noncopyable.hpp>
      36                 :            : 
      37                 :            : class SvxFont;
      38                 :            : class SvxFontItem;
      39                 :            : class SvxWeightItem;
      40                 :            : class SvxPostureItem;
      41                 :            : class SvxShadowedItem;
      42                 :            : class SvxEscapementItem;
      43                 :            : class SvxContourItem;
      44                 :            : class SvxCrossedOutItem;
      45                 :            : class SvxUnderlineItem;
      46                 :            : class SvxOverlineItem;
      47                 :            : class SvxFontHeightItem;
      48                 :            : class SvxCharScaleWidthItem;
      49                 :            : class SvxColorItem;
      50                 :            : class SvxAutoKernItem;
      51                 :            : class SvxKerningItem;
      52                 :            : class SvxWordLineModeItem;
      53                 :            : class SvxFieldItem;
      54                 :            : class SvxLanguageItem;
      55                 :            : class SvxEmphasisMarkItem;
      56                 :            : class SvxCharReliefItem;
      57                 :            : class SfxVoidItem;
      58                 :            : class OutputDevice;
      59                 :            : 
      60                 :            : #define CH_FEATURE_OLD  (sal_uInt8)         0xFF
      61                 :            : #define CH_FEATURE      (sal_Unicode)   0x01
      62                 :            : 
      63                 :            : // DEF_METRIC: For my pool, the DefMetric should always appear when
      64                 :            : // GetMetric (nWhich)!
      65                 :            : // => To determine the DefMetric simply use GetMetric(0)
      66                 :            : #define DEF_METRIC  0
      67                 :            : 
      68                 :            : // -------------------------------------------------------------------------
      69                 :            : // class EditCharAttrib
      70                 :            : // -------------------------------------------------------------------------
      71                 :            : // bFeature: Attribute must not expand/shrink, length is always 1
      72                 :            : // bEdge: Attribute will not expand, if you want to expand just on the edge
      73                 :            : class EditCharAttrib : private boost::noncopyable
      74                 :            : {
      75                 :            : protected:
      76                 :            :     const SfxPoolItem*  pItem;
      77                 :            : 
      78                 :            :     sal_uInt16              nStart;
      79                 :            :     sal_uInt16              nEnd;
      80                 :            :     sal_Bool                bFeature    :1;
      81                 :            :     sal_Bool                bEdge       :1;
      82                 :            : 
      83                 :            : public:
      84                 :            :     EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
      85                 :            :     virtual ~EditCharAttrib();
      86                 :            : 
      87                 :    2668392 :     sal_uInt16          Which() const   { return pItem->Which(); }
      88                 :     523250 :     const SfxPoolItem*  GetItem() const { return pItem; }
      89                 :            : 
      90                 :    2595400 :     sal_uInt16&         GetStart()                  { return nStart; }
      91                 :    2139570 :     sal_uInt16&         GetEnd()                    { return nEnd; }
      92                 :            : 
      93                 :    1721152 :     sal_uInt16          GetStart() const            { return nStart; }
      94                 :     155654 :     sal_uInt16          GetEnd() const              { return nEnd; }
      95                 :            : 
      96                 :            :     inline sal_uInt16   GetLen() const;
      97                 :            : 
      98                 :            :     inline void     MoveForward( sal_uInt16 nDiff );
      99                 :            :     inline void     MoveBackward( sal_uInt16 nDiff );
     100                 :            : 
     101                 :            :     inline void     Expand( sal_uInt16 nDiff );
     102                 :            :     inline void     Collaps( sal_uInt16 nDiff );
     103                 :            : 
     104                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     105                 :            : 
     106                 :       4699 :     sal_Bool    IsIn( sal_uInt16 nIndex ) const
     107 [ +  - ][ +  + ]:       4699 :                 { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); }
     108                 :        253 :     sal_Bool    IsInside( sal_uInt16 nIndex ) const
     109 [ +  + ][ -  + ]:        253 :                 { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); }
     110                 :     133413 :     bool        IsEmpty() const
     111                 :     133413 :                 { return nStart == nEnd; }
     112                 :            : 
     113                 :     958600 :     bool    IsFeature() const   { return bFeature; }
     114                 :       9000 :     void    SetFeature( sal_Bool b) { bFeature = b; }
     115                 :            : 
     116                 :       3197 :     sal_Bool    IsEdge() const      { return bEdge; }
     117                 :          0 :     void    SetEdge( sal_Bool b )   { bEdge = b; }
     118                 :            : };
     119                 :            : 
     120                 :      30479 : inline sal_uInt16 EditCharAttrib::GetLen() const
     121                 :            : {
     122                 :            :     DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" );
     123                 :      30479 :     return nEnd-nStart;
     124                 :            : }
     125                 :            : 
     126                 :       1239 : inline void EditCharAttrib::MoveForward( sal_uInt16 nDiff )
     127                 :            : {
     128                 :            :     DBG_ASSERT( ((long)nEnd + nDiff) <= 0xFFFF, "EditCharAttrib: MoveForward?!" );
     129                 :       1239 :     nStart = nStart + nDiff;
     130                 :       1239 :     nEnd = nEnd + nDiff;
     131                 :       1239 : }
     132                 :            : 
     133                 :          0 : inline void EditCharAttrib::MoveBackward( sal_uInt16 nDiff )
     134                 :            : {
     135                 :            :     DBG_ASSERT( ((long)nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
     136                 :          0 :     nStart = nStart - nDiff;
     137                 :          0 :     nEnd = nEnd - nDiff;
     138                 :          0 : }
     139                 :            : 
     140                 :        948 : inline void EditCharAttrib::Expand( sal_uInt16 nDiff )
     141                 :            : {
     142                 :            :     DBG_ASSERT( ( ((long)nEnd + nDiff) <= (long)0xFFFF ), "EditCharAttrib: Expand?!" );
     143                 :            :     DBG_ASSERT( !bFeature, "Please do not expand any features!" );
     144                 :        948 :     nEnd = nEnd + nDiff;
     145                 :        948 : }
     146                 :            : 
     147                 :          0 : inline void EditCharAttrib::Collaps( sal_uInt16 nDiff )
     148                 :            : {
     149                 :            :     DBG_ASSERT( (long)nEnd - nDiff >= (long)nStart, "EditCharAttrib: Collaps?!" );
     150                 :            :     DBG_ASSERT( !bFeature, "Please do not shrink any Features!" );
     151                 :          0 :     nEnd = nEnd - nDiff;
     152                 :          0 : }
     153                 :            : 
     154                 :            : // -------------------------------------------------------------------------
     155                 :            : // class EditCharAttribFont
     156                 :            : // -------------------------------------------------------------------------
     157         [ -  + ]:      22562 : class EditCharAttribFont: public EditCharAttrib
     158                 :            : {
     159                 :            : public:
     160                 :            :     EditCharAttribFont( const SvxFontItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     161                 :            : 
     162                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     163                 :            : };
     164                 :            : 
     165                 :            : // -------------------------------------------------------------------------
     166                 :            : // class EditCharAttribWeight
     167                 :            : // -------------------------------------------------------------------------
     168         [ -  + ]:      20364 : class EditCharAttribWeight : public EditCharAttrib
     169                 :            : {
     170                 :            : public:
     171                 :            :     EditCharAttribWeight( const SvxWeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     172                 :            : 
     173                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     174                 :            : };
     175                 :            : // -------------------------------------------------------------------------
     176                 :            : // class EditCharAttribItalic
     177                 :            : // -------------------------------------------------------------------------
     178         [ -  + ]:      19526 : class EditCharAttribItalic : public EditCharAttrib
     179                 :            : {
     180                 :            : public:
     181                 :            :     EditCharAttribItalic( const SvxPostureItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     182                 :            : 
     183                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     184                 :            : };
     185                 :            : 
     186                 :            : // -------------------------------------------------------------------------
     187                 :            : // class EditCharAttribShadow
     188                 :            : // -------------------------------------------------------------------------
     189         [ -  + ]:       7222 : class EditCharAttribShadow : public EditCharAttrib
     190                 :            : {
     191                 :            : public:
     192                 :            :     EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     193                 :            : 
     194                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     195                 :            : };
     196                 :            : 
     197                 :            : // -------------------------------------------------------------------------
     198                 :            : // class EditCharAttribEscapement
     199                 :            : // -------------------------------------------------------------------------
     200         [ -  + ]:       7938 : class EditCharAttribEscapement : public EditCharAttrib
     201                 :            : {
     202                 :            : public:
     203                 :            :     EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     204                 :            : 
     205                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     206                 :            : };
     207                 :            : 
     208                 :            : // -------------------------------------------------------------------------
     209                 :            : // class EditCharAttribOutline
     210                 :            : // -------------------------------------------------------------------------
     211         [ -  + ]:       7150 : class EditCharAttribOutline : public EditCharAttrib
     212                 :            : {
     213                 :            : public:
     214                 :            :     EditCharAttribOutline( const SvxContourItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     215                 :            : 
     216                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     217                 :            : };
     218                 :            : 
     219                 :            : // -------------------------------------------------------------------------
     220                 :            : // class EditCharAttribStrikeout
     221                 :            : // -------------------------------------------------------------------------
     222         [ -  + ]:       7742 : class EditCharAttribStrikeout : public EditCharAttrib
     223                 :            : {
     224                 :            : public:
     225                 :            :     EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     226                 :            : 
     227                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     228                 :            : };
     229                 :            : 
     230                 :            : // -------------------------------------------------------------------------
     231                 :            : // class EditCharAttribUnderline
     232                 :            : // -------------------------------------------------------------------------
     233         [ -  + ]:       8092 : class EditCharAttribUnderline : public EditCharAttrib
     234                 :            : {
     235                 :            : public:
     236                 :            :     EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     237                 :            : 
     238                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     239                 :            : };
     240                 :            : 
     241                 :            : // -------------------------------------------------------------------------
     242                 :            : // class EditCharAttribOverline
     243                 :            : // -------------------------------------------------------------------------
     244         [ -  + ]:       4036 : class EditCharAttribOverline : public EditCharAttrib
     245                 :            : {
     246                 :            : public:
     247                 :            :     EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     248                 :            : 
     249                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     250                 :            : };
     251                 :            : 
     252                 :            : // -------------------------------------------------------------------------
     253                 :            : // class EditCharAttribEmphasisMark
     254                 :            : // -------------------------------------------------------------------------
     255         [ -  + ]:       5806 : class EditCharAttribEmphasisMark : public EditCharAttrib
     256                 :            : {
     257                 :            : public:
     258                 :            :     EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     259                 :            : 
     260                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     261                 :            : };
     262                 :            : 
     263                 :            : // -------------------------------------------------------------------------
     264                 :            : // class EditCharAttribRelief
     265                 :            : // -------------------------------------------------------------------------
     266         [ -  + ]:       5694 : class EditCharAttribRelief : public EditCharAttrib
     267                 :            : {
     268                 :            : public:
     269                 :            :     EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     270                 :            : 
     271                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     272                 :            : };
     273                 :            : 
     274                 :            : // -------------------------------------------------------------------------
     275                 :            : // class EditCharAttribFontHeight
     276                 :            : // -------------------------------------------------------------------------
     277         [ -  + ]:      24408 : class EditCharAttribFontHeight : public EditCharAttrib
     278                 :            : {
     279                 :            : public:
     280                 :            :     EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     281                 :            : 
     282                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     283                 :            : };
     284                 :            : 
     285                 :            : // -------------------------------------------------------------------------
     286                 :            : // class EditCharAttribFontWidth
     287                 :            : // -------------------------------------------------------------------------
     288         [ -  + ]:       5598 : class EditCharAttribFontWidth : public EditCharAttrib
     289                 :            : {
     290                 :            : public:
     291                 :            :     EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     292                 :            : 
     293                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     294                 :            : };
     295                 :            : 
     296                 :            : // -------------------------------------------------------------------------
     297                 :            : // class EditCharAttribColor
     298                 :            : // -------------------------------------------------------------------------
     299         [ -  + ]:       9704 : class EditCharAttribColor : public EditCharAttrib
     300                 :            : {
     301                 :            : public:
     302                 :            :     EditCharAttribColor( const SvxColorItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     303                 :            : 
     304                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     305                 :            : };
     306                 :            : 
     307                 :            : // -------------------------------------------------------------------------
     308                 :            : // class EditCharAttribLanguage
     309                 :            : // -------------------------------------------------------------------------
     310         [ -  + ]:      19402 : class EditCharAttribLanguage : public EditCharAttrib
     311                 :            : {
     312                 :            : public:
     313                 :            :     EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     314                 :            : 
     315                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     316                 :            : };
     317                 :            : 
     318                 :            : // -------------------------------------------------------------------------
     319                 :            : // class EditCharAttribTab
     320                 :            : // -------------------------------------------------------------------------
     321         [ #  # ]:          0 : class EditCharAttribTab : public EditCharAttrib
     322                 :            : {
     323                 :            : public:
     324                 :            :     EditCharAttribTab( const SfxVoidItem& rAttr, sal_uInt16 nPos );
     325                 :            : 
     326                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     327                 :            : };
     328                 :            : 
     329                 :            : // -------------------------------------------------------------------------
     330                 :            : // class EditCharAttribLineBreak
     331                 :            : // -------------------------------------------------------------------------
     332         [ -  + ]:         80 : class EditCharAttribLineBreak : public EditCharAttrib
     333                 :            : {
     334                 :            : public:
     335                 :            :     EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_uInt16 nPos );
     336                 :            : 
     337                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     338                 :            : };
     339                 :            : 
     340                 :            : // -------------------------------------------------------------------------
     341                 :            : // class EditCharAttribField
     342                 :            : // -------------------------------------------------------------------------
     343                 :            : class EditCharAttribField: public EditCharAttrib
     344                 :            : {
     345                 :            :     rtl::OUString   aFieldValue;
     346                 :            :     Color*          pTxtColor;
     347                 :            :     Color*          pFldColor;
     348                 :            : 
     349                 :            :     EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) const;
     350                 :            : 
     351                 :            : public:
     352                 :            :     EditCharAttribField( const SvxFieldItem& rAttr, sal_uInt16 nPos );
     353                 :            :     EditCharAttribField( const EditCharAttribField& rAttr );
     354                 :            :     ~EditCharAttribField();
     355                 :            : 
     356                 :            :     bool operator == ( const EditCharAttribField& rAttr ) const;
     357                 :       3895 :     bool operator != ( const EditCharAttribField& rAttr ) const
     358                 :       3895 :                                     { return !(operator == ( rAttr ) ); }
     359                 :            : 
     360                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     361                 :       3895 :     Color*&         GetTxtColor()           { return pTxtColor; }
     362                 :       4028 :     Color*&         GetFldColor()           { return pFldColor; }
     363                 :            : 
     364                 :            :     const rtl::OUString& GetFieldValue() const;
     365                 :            :     void SetFieldValue(const rtl::OUString& rVal);
     366                 :            : 
     367                 :            :     void Reset();
     368                 :            : };
     369                 :            : 
     370                 :            : // -------------------------------------------------------------------------
     371                 :            : // class EditCharAttribPairKerning
     372                 :            : // -------------------------------------------------------------------------
     373         [ -  + ]:       6274 : class EditCharAttribPairKerning : public EditCharAttrib
     374                 :            : {
     375                 :            : public:
     376                 :            :     EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     377                 :            : 
     378                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     379                 :            : };
     380                 :            : 
     381                 :            : // -------------------------------------------------------------------------
     382                 :            : // class EditCharAttribKerning
     383                 :            : // -------------------------------------------------------------------------
     384         [ -  + ]:       6142 : class EditCharAttribKerning : public EditCharAttrib
     385                 :            : {
     386                 :            : public:
     387                 :            :     EditCharAttribKerning( const SvxKerningItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     388                 :            : 
     389                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     390                 :            : };
     391                 :            : 
     392                 :            : // -------------------------------------------------------------------------
     393                 :            : // class EditCharAttribWordLineMode
     394                 :            : // -------------------------------------------------------------------------
     395         [ -  + ]:       6140 : class EditCharAttribWordLineMode: public EditCharAttrib
     396                 :            : {
     397                 :            : public:
     398                 :            :     EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     399                 :            : 
     400                 :            :     virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev );
     401                 :            : };
     402                 :            : 
     403                 :            : 
     404                 :            : #endif // _EDITATTR_HXX
     405                 :            : 
     406                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10