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

Generated by: LCOV version 1.10