LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/text - porlin.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 66 80.3 %
Date: 2013-07-09 Functions: 46 53 86.8 %
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 _PORLIN_HXX
      20             : #define _PORLIN_HXX
      21             : 
      22             : #include "possiz.hxx"       // SwPosSize
      23             : 
      24             : #ifdef DBG_UTIL
      25             : #include <libxml/xmlwriter.h>
      26             : #endif
      27             : 
      28             : class XubString;
      29             : class SwTxtSizeInfo;
      30             : class SwTxtPaintInfo;
      31             : class SwTxtFormatInfo;
      32             : class SwPortionHandler;
      33             : 
      34             : // The portions output operators are virtual methods of the portion.
      35             : // The CLASSIO macro implements the 'levitating' function.
      36             : // In doing so we end up with both benefits: virtual output operators and general utility
      37             : #ifdef DBG_UTIL
      38             : #define OUTPUT_OPERATOR  virtual SvStream &operator<<( SvStream & aOs ) const;
      39             : #else
      40             : #define OUTPUT_OPERATOR
      41             : #endif
      42             : 
      43             : // Portion groups
      44             : #define PORGRP_TXT      0x8000
      45             : #define PORGRP_EXP      0x4000
      46             : #define PORGRP_FLD      0x2000
      47             : #define PORGRP_HYPH     0x1000
      48             : #define PORGRP_NUMBER   0x0800
      49             : #define PORGRP_GLUE     0x0400
      50             : #define PORGRP_FIX      0x0200
      51             : #define PORGRP_TAB      0x0100
      52             : #define PORGRP_NOTRECY  0x0080
      53             : // Small special groups
      54             : #define PORGRP_FIXMARG  0x0040
      55             : //#define PORGRP_?  0x0020
      56             : #define PORGRP_TABNOTLFT 0x0010
      57             : #define PORGRP_TOXREF   0x0008
      58             : 
      59             : /*************************************************************************
      60             :  *                      class SwLinePortion
      61             :  *************************************************************************/
      62             : 
      63             : /// Base class for anything that can be part of a line in the Writer layout.
      64             : class SwLinePortion: public SwPosSize
      65             : {
      66             : protected:
      67             :     // Here we have areas with different attributes
      68             :     SwLinePortion *pPortion;
      69             :     // Count of chars and spaces on the line
      70             :     xub_StrLen nLineLength;
      71             :     KSHORT nAscent;      // Maximum ascender
      72             : 
      73             :     SwLinePortion();
      74             : private:
      75             :     MSHORT nWhichPor;       // Who's who?
      76             : 
      77             :     void _Truncate();
      78             : 
      79             : public:
      80             :     inline          SwLinePortion(const SwLinePortion &rPortion);
      81             :            virtual ~SwLinePortion();
      82             : 
      83             :     // Access methods
      84      449212 :     inline SwLinePortion *GetPortion() const { return( pPortion ); }
      85             :     inline SwLinePortion &operator=(const SwLinePortion &rPortion);
      86             :     inline bool operator==( const SwLinePortion &rPortion ) const;
      87     1895875 :     inline xub_StrLen GetLen() const { return nLineLength; }
      88      104769 :     inline void SetLen( const xub_StrLen nLen ) { nLineLength = nLen; }
      89       44431 :     inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
      90      236224 :     inline KSHORT &GetAscent() { return nAscent; }
      91      120113 :     inline KSHORT GetAscent() const { return nAscent; }
      92       81065 :     inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; }
      93        3410 :     inline void  PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); }
      94       81818 :     inline KSHORT PrtWidth() const { return Width(); }
      95        6069 :     inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); }
      96         472 :     inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); }
      97             : 
      98             :     inline const SwPosSize &PrtSize() const { return *this; }
      99             : 
     100             :     // Insert methods
     101             :     virtual SwLinePortion *Insert( SwLinePortion *pPortion );
     102             :     virtual SwLinePortion *Append( SwLinePortion *pPortion );
     103             :             SwLinePortion *Cut( SwLinePortion *pVictim );
     104             :     inline  void Truncate();
     105             : 
     106             :     // Returns 0, if there's no payload
     107             :     virtual SwLinePortion *Compress();
     108             : 
     109       33161 :     inline void SetWhichPor( const MSHORT nNew )    { nWhichPor = nNew; }
     110        1152 :     inline MSHORT GetWhichPor( ) const        { return nWhichPor; }
     111             : 
     112             : // Group queries
     113      147003 :     inline sal_Bool InTxtGrp( ) const { return nWhichPor & PORGRP_TXT ? sal_True : sal_False; }
     114          89 :     inline sal_Bool InGlueGrp( )    const { return nWhichPor & PORGRP_GLUE ? sal_True : sal_False;}
     115       98252 :     inline sal_Bool InTabGrp( ) const { return nWhichPor & PORGRP_TAB ? sal_True : sal_False; }
     116        4684 :     inline sal_Bool InHyphGrp( )    const { return nWhichPor & PORGRP_HYPH ? sal_True : sal_False;}
     117       46670 :     inline sal_Bool InNumberGrp( )const { return nWhichPor & PORGRP_NUMBER ? sal_True : sal_False;}
     118           0 :     inline sal_Bool InFixGrp( ) const { return nWhichPor & PORGRP_FIX ? sal_True : sal_False;  }
     119      215115 :     inline sal_Bool InFldGrp( ) const { return nWhichPor & PORGRP_FLD ? sal_True : sal_False;  }
     120           0 :     inline sal_Bool InToxRefGrp( ) const { return nWhichPor &   PORGRP_TOXREF ? sal_True : sal_False;  }
     121           0 :     inline sal_Bool InToxRefOrFldGrp( ) const { return nWhichPor &
     122           0 :                                 ( PORGRP_FLD | PORGRP_TOXREF ) ? sal_True : sal_False;  }
     123       10553 :     inline sal_Bool InExpGrp( ) const { return nWhichPor & PORGRP_EXP ? sal_True : sal_False;  }
     124             :     inline sal_Bool InTabnLftGrp( ) const
     125             :         { return nWhichPor & PORGRP_TABNOTLFT ? sal_True : sal_False;  }
     126       80369 :     inline sal_Bool InFixMargGrp( )const
     127       80369 :         { return nWhichPor & PORGRP_FIXMARG ? sal_True : sal_False;  }
     128       92536 :     inline sal_Bool InSpaceGrp( )const
     129       92536 :         { return InTxtGrp() || IsMultiPortion();  }
     130             : // Individual queries
     131       28331 :     inline sal_Bool IsGrfNumPortion( )const{ return nWhichPor == POR_GRFNUM; }
     132       97827 :     inline sal_Bool IsFlyCntPortion( )const{ return nWhichPor == POR_FLYCNT; }
     133       11181 :     inline sal_Bool IsBlankPortion( )   const{ return nWhichPor == POR_BLANK; }
     134       67745 :     inline sal_Bool IsBreakPortion( )   const{ return nWhichPor == POR_BRK; }
     135         326 :     inline sal_Bool IsErgoSumPortion()const{ return nWhichPor == POR_ERGOSUM;}
     136       65700 :     inline sal_Bool IsQuoVadisPortion()const{ return nWhichPor==POR_QUOVADIS;}
     137             :     inline sal_Bool IsTabCntPortion( )const{ return nWhichPor==POR_TABCENTER;}
     138             :     inline sal_Bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL;}
     139         203 :     inline sal_Bool IsTabLeftPortion()const{ return nWhichPor == POR_TABLEFT;}
     140         979 :     inline sal_Bool IsFtnNumPortion( )const{ return nWhichPor == POR_FTNNUM; }
     141       82204 :     inline sal_Bool IsFtnPortion( ) const{ return nWhichPor == POR_FTN; }
     142             :     inline sal_Bool IsTmpEndPortion( )const{ return nWhichPor == POR_TMPEND; }
     143       52136 :     inline sal_Bool IsDropPortion( )    const{ return nWhichPor == POR_DROP; }
     144         112 :     inline sal_Bool IsLayPortion( ) const{ return nWhichPor == POR_LAY; }
     145         112 :     inline sal_Bool IsParaPortion( )    const{ return nWhichPor == POR_PARA; }
     146       72772 :     inline sal_Bool IsMarginPortion( )const{ return nWhichPor == POR_MARGIN; }
     147       94899 :     inline sal_Bool IsFlyPortion( ) const{ return nWhichPor == POR_FLY; }
     148        4862 :     inline sal_Bool IsHolePortion( )    const{ return nWhichPor == POR_HOLE; }
     149           0 :     inline sal_Bool IsSoftHyphPortion()const{ return nWhichPor==POR_SOFTHYPH;}
     150       91053 :     inline sal_Bool IsPostItsPortion()const{ return nWhichPor == POR_POSTITS;}
     151           0 :     inline sal_Bool IsCombinedPortion()const{ return nWhichPor==POR_COMBINED;}
     152        1094 :     inline sal_Bool IsTextPortion( ) const{ return nWhichPor == POR_TXT; }
     153             :     inline sal_Bool IsURLPortion( ) const{ return nWhichPor == POR_URL; }
     154       23539 :     inline sal_Bool IsHangingPortion( ) const{ return nWhichPor == POR_HNG; }
     155       27203 :     inline sal_Bool IsKernPortion( ) const{ return nWhichPor == POR_KERN; }
     156       16739 :     inline sal_Bool IsArrowPortion( ) const{ return nWhichPor == POR_ARROW; }
     157      256537 :     inline sal_Bool IsMultiPortion( ) const{ return nWhichPor == POR_MULTI; }
     158        1396 :     inline sal_Bool IsNumberPortion( ) const{ return nWhichPor == POR_NUMBER; } // #i23726#
     159           0 :     inline sal_Bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
     160             : 
     161             :     // Positioning
     162             :     SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
     163             :     SwLinePortion *FindLastPortion();
     164             : 
     165             :     virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
     166             :     virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
     167             :     void CalcTxtSize( const SwTxtSizeInfo &rInfo );
     168             : 
     169             :     // Output
     170             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
     171             :     void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
     172             : 
     173             :     virtual sal_Bool Format( SwTxtFormatInfo &rInf );
     174             :     // Is called for the line's last portion
     175             :     virtual void FormatEOL( SwTxtFormatInfo &rInf );
     176             :             void Move( SwTxtPaintInfo &rInf );
     177             : 
     178             :     // For SwTxtSlot
     179             :     virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const;
     180             : 
     181             :     // For SwFldPortion, SwSoftHyphPortion
     182             :     virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
     183             : 
     184             :     // for text- and multi-portions
     185             :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
     186             : 
     187             :     // Accessibility: pass information about this portion to the PortionHandler
     188             :     virtual void HandlePortion( SwPortionHandler& rPH ) const;
     189             : 
     190             :     OUTPUT_OPERATOR
     191             : };
     192             : 
     193             : 
     194             : /*************************************************************************
     195             :  *                  inline - Implementations
     196             :  *************************************************************************/
     197             : 
     198           0 : inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
     199             : {
     200           0 :     *(SwPosSize*)this = rPortion;
     201           0 :     nLineLength = rPortion.nLineLength;
     202           0 :     nAscent = rPortion.nAscent;
     203           0 :     nWhichPor = rPortion.nWhichPor;
     204           0 :     return *this;
     205             : }
     206             : 
     207             : inline bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
     208             : {
     209             :     return( Height() == rPortion.Height() &&
     210             :             Width() == rPortion.Width() &&
     211             :             nLineLength == rPortion.GetLen() &&
     212             :             nAscent == rPortion.GetAscent() );
     213             : }
     214             : 
     215        1448 : inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
     216             :     SwPosSize( rPortion ),
     217             :     pPortion( 0 ),
     218             :     nLineLength( rPortion.nLineLength ),
     219             :     nAscent( rPortion.nAscent ),
     220        1448 :     nWhichPor( rPortion.nWhichPor )
     221             : {
     222        1448 : }
     223             : 
     224       33464 : inline void SwLinePortion::Truncate()
     225             : {
     226       33464 :     if ( pPortion )
     227        2674 :         _Truncate();
     228       33464 : }
     229             : 
     230             : 
     231             : //$ ostream
     232             : #define CLASSIO( class )
     233             : 
     234             : CLASSIO( SwLinePortion )
     235             : 
     236             : #endif
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10