LCOV - code coverage report
Current view: top level - sw/source/core/text - porlin.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 66 80.3 %
Date: 2012-08-25 Functions: 46 53 86.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 28 75.0 %

           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                 :            : #ifndef _PORLIN_HXX
      29                 :            : #define _PORLIN_HXX
      30                 :            : 
      31                 :            : #include "possiz.hxx"       // SwPosSize
      32                 :            : 
      33                 :            : #ifdef DBG_UTIL
      34                 :            : #include <libxml/xmlwriter.h>
      35                 :            : #endif
      36                 :            : 
      37                 :            : class XubString;
      38                 :            : class SwTxtSizeInfo;
      39                 :            : class SwTxtPaintInfo;
      40                 :            : class SwTxtFormatInfo;
      41                 :            : class SwPortionHandler;
      42                 :            : 
      43                 :            : // The portions output operators are virtual methods of the portion.
      44                 :            : // The CLASSIO macro implements the 'levitating' function.
      45                 :            : // In doing so we end up with both benefits: virtual output operators and general utility
      46                 :            : #ifdef DBG_UTIL
      47                 :            : #define OUTPUT_OPERATOR  virtual SvStream &operator<<( SvStream & aOs ) const;
      48                 :            : #else
      49                 :            : #define OUTPUT_OPERATOR
      50                 :            : #endif
      51                 :            : 
      52                 :            : // Portion groups
      53                 :            : #define PORGRP_TXT      0x8000
      54                 :            : #define PORGRP_EXP      0x4000
      55                 :            : #define PORGRP_FLD      0x2000
      56                 :            : #define PORGRP_HYPH     0x1000
      57                 :            : #define PORGRP_NUMBER   0x0800
      58                 :            : #define PORGRP_GLUE     0x0400
      59                 :            : #define PORGRP_FIX      0x0200
      60                 :            : #define PORGRP_TAB      0x0100
      61                 :            : #define PORGRP_NOTRECY  0x0080
      62                 :            : // Small special groups
      63                 :            : #define PORGRP_FIXMARG  0x0040
      64                 :            : //#define PORGRP_?  0x0020
      65                 :            : #define PORGRP_TABNOTLFT 0x0010
      66                 :            : #define PORGRP_TOXREF   0x0008
      67                 :            : 
      68                 :            : /*************************************************************************
      69                 :            :  *                      class SwLinePortion
      70                 :            :  *************************************************************************/
      71                 :            : 
      72                 :            : /// Base class for anything that can be part of a line in the Writer layout.
      73                 :            : class SwLinePortion: public SwPosSize
      74                 :            : {
      75                 :            : protected:
      76                 :            :     // Here we have areas with different attributes
      77                 :            :     SwLinePortion *pPortion;
      78                 :            :     // Count of chars and spaces on the line
      79                 :            :     xub_StrLen nLineLength;
      80                 :            :     KSHORT nAscent;      // Maximum ascender
      81                 :            : 
      82                 :            :     SwLinePortion();
      83                 :            : private:
      84                 :            :     MSHORT nWhichPor;       // Who's who?
      85                 :            : 
      86                 :            :     void _Truncate();
      87                 :            : 
      88                 :            : public:
      89                 :            :     inline          SwLinePortion(const SwLinePortion &rPortion);
      90                 :            :            virtual ~SwLinePortion();
      91                 :            : 
      92                 :            :     // Access methods
      93                 :     949804 :     inline SwLinePortion *GetPortion() const { return( pPortion ); }
      94                 :            :     inline SwLinePortion &operator=(const SwLinePortion &rPortion);
      95                 :            :     inline sal_Bool operator==( const SwLinePortion &rPortion ) const;
      96                 :    4272769 :     inline xub_StrLen GetLen() const { return nLineLength; }
      97                 :     228757 :     inline void SetLen( const xub_StrLen nLen ) { nLineLength = nLen; }
      98                 :      91170 :     inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
      99                 :     492424 :     inline KSHORT &GetAscent() { return nAscent; }
     100                 :     254458 :     inline KSHORT GetAscent() const { return nAscent; }
     101                 :     174949 :     inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; }
     102                 :       5203 :     inline void  PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); }
     103                 :     168107 :     inline KSHORT PrtWidth() const { return Width(); }
     104                 :      11844 :     inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); }
     105                 :        885 :     inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); }
     106                 :            : 
     107                 :            :     inline const SwPosSize &PrtSize() const { return *this; }
     108                 :            : 
     109                 :            :     // Insert methods
     110                 :            :     virtual SwLinePortion *Insert( SwLinePortion *pPortion );
     111                 :            :     virtual SwLinePortion *Append( SwLinePortion *pPortion );
     112                 :            :             SwLinePortion *Cut( SwLinePortion *pVictim );
     113                 :            :     inline  void Truncate();
     114                 :            : 
     115                 :            :     // Returns 0, if there's no payload
     116                 :            :     virtual SwLinePortion *Compress();
     117                 :            : 
     118                 :      54878 :     inline void SetWhichPor( const MSHORT nNew )    { nWhichPor = nNew; }
     119                 :        329 :     inline MSHORT GetWhichPor( ) const        { return nWhichPor; }
     120                 :            : 
     121                 :            : // Group queries
     122         [ +  + ]:     310254 :     inline sal_Bool InTxtGrp( ) const { return nWhichPor & PORGRP_TXT ? sal_True : sal_False; }
     123         [ +  + ]:         40 :     inline sal_Bool InGlueGrp( )    const { return nWhichPor & PORGRP_GLUE ? sal_True : sal_False;}
     124         [ +  + ]:     198583 :     inline sal_Bool InTabGrp( ) const { return nWhichPor & PORGRP_TAB ? sal_True : sal_False; }
     125         [ -  + ]:       7364 :     inline sal_Bool InHyphGrp( )    const { return nWhichPor & PORGRP_HYPH ? sal_True : sal_False;}
     126         [ +  + ]:     100469 :     inline sal_Bool InNumberGrp( )const { return nWhichPor & PORGRP_NUMBER ? sal_True : sal_False;}
     127         [ #  # ]:          0 :     inline sal_Bool InFixGrp( ) const { return nWhichPor & PORGRP_FIX ? sal_True : sal_False;  }
     128         [ +  + ]:     456314 :     inline sal_Bool InFldGrp( ) const { return nWhichPor & PORGRP_FLD ? sal_True : sal_False;  }
     129         [ #  # ]:          0 :     inline sal_Bool InToxRefGrp( ) const { return nWhichPor &   PORGRP_TOXREF ? sal_True : sal_False;  }
     130                 :          0 :     inline sal_Bool InToxRefOrFldGrp( ) const { return nWhichPor &
     131         [ #  # ]:          0 :                                 ( PORGRP_FLD | PORGRP_TOXREF ) ? sal_True : sal_False;  }
     132         [ +  + ]:      20374 :     inline sal_Bool InExpGrp( ) const { return nWhichPor & PORGRP_EXP ? sal_True : sal_False;  }
     133                 :            :     inline sal_Bool InTabnLftGrp( ) const
     134                 :            :         { return nWhichPor & PORGRP_TABNOTLFT ? sal_True : sal_False;  }
     135                 :     165606 :     inline sal_Bool InFixMargGrp( )const
     136         [ +  + ]:     165606 :         { return nWhichPor & PORGRP_FIXMARG ? sal_True : sal_False;  }
     137                 :     194582 :     inline sal_Bool InSpaceGrp( )const
     138 [ +  + ][ +  + ]:     194582 :         { return InTxtGrp() || IsMultiPortion();  }
     139                 :            : // Individual queries
     140                 :      49612 :     inline sal_Bool IsGrfNumPortion( )const{ return nWhichPor == POR_GRFNUM; }
     141                 :     193866 :     inline sal_Bool IsFlyCntPortion( )const{ return nWhichPor == POR_FLYCNT; }
     142                 :      26437 :     inline sal_Bool IsBlankPortion( )   const{ return nWhichPor == POR_BLANK; }
     143                 :     131591 :     inline sal_Bool IsBreakPortion( )   const{ return nWhichPor == POR_BRK; }
     144                 :        540 :     inline sal_Bool IsErgoSumPortion()const{ return nWhichPor == POR_ERGOSUM;}
     145                 :     145168 :     inline sal_Bool IsQuoVadisPortion()const{ return nWhichPor==POR_QUOVADIS;}
     146                 :            :     inline sal_Bool IsTabCntPortion( )const{ return nWhichPor==POR_TABCENTER;}
     147                 :            :     inline sal_Bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL;}
     148                 :        203 :     inline sal_Bool IsTabLeftPortion()const{ return nWhichPor == POR_TABLEFT;}
     149                 :       1618 :     inline sal_Bool IsFtnNumPortion( )const{ return nWhichPor == POR_FTNNUM; }
     150                 :     170942 :     inline sal_Bool IsFtnPortion( ) const{ return nWhichPor == POR_FTN; }
     151                 :            :     inline sal_Bool IsTmpEndPortion( )const{ return nWhichPor == POR_TMPEND; }
     152                 :     109663 :     inline sal_Bool IsDropPortion( )    const{ return nWhichPor == POR_DROP; }
     153                 :        224 :     inline sal_Bool IsLayPortion( ) const{ return nWhichPor == POR_LAY; }
     154                 :        224 :     inline sal_Bool IsParaPortion( )    const{ return nWhichPor == POR_PARA; }
     155                 :     146364 :     inline sal_Bool IsMarginPortion( )const{ return nWhichPor == POR_MARGIN; }
     156                 :     187947 :     inline sal_Bool IsFlyPortion( ) const{ return nWhichPor == POR_FLY; }
     157                 :       8620 :     inline sal_Bool IsHolePortion( )    const{ return nWhichPor == POR_HOLE; }
     158                 :          0 :     inline sal_Bool IsSoftHyphPortion()const{ return nWhichPor==POR_SOFTHYPH;}
     159                 :     186307 :     inline sal_Bool IsPostItsPortion()const{ return nWhichPor == POR_POSTITS;}
     160                 :          0 :     inline sal_Bool IsCombinedPortion()const{ return nWhichPor==POR_COMBINED;}
     161                 :         57 :     inline sal_Bool IsTextPortion( ) const{ return nWhichPor == POR_TXT; }
     162                 :            :     inline sal_Bool IsURLPortion( ) const{ return nWhichPor == POR_URL; }
     163                 :      52978 :     inline sal_Bool IsHangingPortion( ) const{ return nWhichPor == POR_HNG; }
     164                 :      60130 :     inline sal_Bool IsKernPortion( ) const{ return nWhichPor == POR_KERN; }
     165                 :      38346 :     inline sal_Bool IsArrowPortion( ) const{ return nWhichPor == POR_ARROW; }
     166                 :     536061 :     inline sal_Bool IsMultiPortion( ) const{ return nWhichPor == POR_MULTI; }
     167                 :       1252 :     inline sal_Bool IsNumberPortion( ) const{ return nWhichPor == POR_NUMBER; } // #i23726#
     168                 :          0 :     inline sal_Bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
     169                 :            : 
     170                 :            :     // Positioning
     171                 :            :     SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
     172                 :            :     SwLinePortion *FindLastPortion();
     173                 :            : 
     174                 :            :     virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
     175                 :            :     virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
     176                 :            :     void CalcTxtSize( const SwTxtSizeInfo &rInfo );
     177                 :            : 
     178                 :            :     // Output
     179                 :            :     virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
     180                 :            :     void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
     181                 :            : 
     182                 :            :     virtual sal_Bool Format( SwTxtFormatInfo &rInf );
     183                 :            :     // Is called for the line's last portion
     184                 :            :     virtual void FormatEOL( SwTxtFormatInfo &rInf );
     185                 :            :             void Move( SwTxtPaintInfo &rInf );
     186                 :            : 
     187                 :            :     // For SwTxtSlot
     188                 :            :     virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
     189                 :            : 
     190                 :            :     // For SwFldPortion, SwSoftHyphPortion
     191                 :            :     virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
     192                 :            : 
     193                 :            :     // for text- and multi-portions
     194                 :            :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
     195                 :            : 
     196                 :            :     // Accessibility: pass information about this portion to the PortionHandler
     197                 :            :     virtual void HandlePortion( SwPortionHandler& rPH ) const;
     198                 :            : 
     199                 :            :     OUTPUT_OPERATOR
     200                 :            : };
     201                 :            : 
     202                 :            : 
     203                 :            : /*************************************************************************
     204                 :            :  *                  inline - Implementations
     205                 :            :  *************************************************************************/
     206                 :            : 
     207                 :          0 : inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
     208                 :            : {
     209                 :          0 :     *(SwPosSize*)this = rPortion;
     210                 :          0 :     nLineLength = rPortion.nLineLength;
     211                 :          0 :     nAscent = rPortion.nAscent;
     212                 :          0 :     nWhichPor = rPortion.nWhichPor;
     213                 :          0 :     return *this;
     214                 :            : }
     215                 :            : 
     216                 :            : inline sal_Bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
     217                 :            : {
     218                 :            :     return( Height() == rPortion.Height() &&
     219                 :            :             Width() == rPortion.Width() &&
     220                 :            :             nLineLength == rPortion.GetLen() &&
     221                 :            :             nAscent == rPortion.GetAscent() );
     222                 :            : }
     223                 :            : 
     224                 :       3172 : inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
     225                 :            :     SwPosSize( rPortion ),
     226                 :            :     pPortion( 0 ),
     227                 :            :     nLineLength( rPortion.nLineLength ),
     228                 :            :     nAscent( rPortion.nAscent ),
     229                 :       3172 :     nWhichPor( rPortion.nWhichPor )
     230                 :            : {
     231                 :       3172 : }
     232                 :            : 
     233                 :      68075 : inline void SwLinePortion::Truncate()
     234                 :            : {
     235         [ +  + ]:      68075 :     if ( pPortion )
     236                 :       5501 :         _Truncate();
     237                 :      68075 : }
     238                 :            : 
     239                 :            : 
     240                 :            : //$ ostream
     241                 :            : #define CLASSIO( class )
     242                 :            : 
     243                 :            : CLASSIO( SwLinePortion )
     244                 :            : 
     245                 :            : #endif
     246                 :            : 
     247                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10