LCOV - code coverage report
Current view: top level - sw/source/core/text - porlin.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 64 69 92.8 %
Date: 2014-11-03 Functions: 52 57 91.2 %
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 INCLUDED_SW_SOURCE_CORE_TEXT_PORLIN_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_TEXT_PORLIN_HXX
      21             : 
      22             : #include "possiz.hxx"
      23             : #include <txttypes.hxx>
      24             : 
      25             : #ifdef DBG_UTIL
      26             : #include <libxml/xmlwriter.h>
      27             : #endif
      28             : 
      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             : #ifdef DBG_UTIL
      36             : #define OUTPUT_OPERATOR  virtual SvStream & operator<<( SvStream & aOs ) const;
      37             : #define OUTPUT_OPERATOR_OVERRIDE virtual SvStream & operator<<( SvStream & aOs ) const SAL_OVERRIDE;
      38             : #else
      39             : #define OUTPUT_OPERATOR
      40             : #define OUTPUT_OPERATOR_OVERRIDE
      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             : /// Base class for anything that can be part of a line in the Writer layout.
      60             : class SwLinePortion: public SwPosSize
      61             : {
      62             : protected:
      63             :     // Here we have areas with different attributes
      64             :     SwLinePortion *pPortion;
      65             :     // Count of chars and spaces on the line
      66             :     sal_Int32 nLineLength;
      67             :     sal_uInt16 nAscent;      // Maximum ascender
      68             : 
      69             :     SwLinePortion();
      70             : private:
      71             :     sal_uInt16 nWhichPor;       // Who's who?
      72             :     bool m_bJoinBorderWithPrev;
      73             :     bool m_bJoinBorderWithNext;
      74             : 
      75             :     void _Truncate();
      76             : 
      77             : public:
      78             :     inline          SwLinePortion(const SwLinePortion &rPortion);
      79             :            virtual ~SwLinePortion();
      80             : 
      81             :     // Access methods
      82     3834506 :     inline SwLinePortion *GetPortion() const { return( pPortion ); }
      83             :     inline SwLinePortion &operator=(const SwLinePortion &rPortion);
      84             :     inline bool operator==( const SwLinePortion &rPortion ) const;
      85     7656638 :     inline sal_Int32 GetLen() const { return nLineLength; }
      86      738943 :     inline void SetLen( const sal_Int32 nLen ) { nLineLength = nLen; }
      87      554757 :     inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
      88     1769855 :     inline sal_uInt16 &GetAscent() { return nAscent; }
      89      990479 :     inline sal_uInt16 GetAscent() const { return nAscent; }
      90      920619 :     inline void SetAscent( const sal_uInt16 nNewAsc ) { nAscent = nNewAsc; }
      91       98878 :     inline void  PrtWidth( sal_uInt16 nNewWidth ) { Width( nNewWidth ); }
      92      615558 :     inline sal_uInt16 PrtWidth() const { return Width(); }
      93      130929 :     inline void AddPrtWidth( const sal_uInt16 nNew ) { Width( Width() + nNew ); }
      94        1930 :     inline void SubPrtWidth( const sal_uInt16 nNew ) { Width( Width() - nNew ); }
      95             : 
      96             :     inline const SwPosSize &PrtSize() const { return *this; }
      97             : 
      98             :     // Insert methods
      99             :     virtual SwLinePortion *Insert( SwLinePortion *pPortion );
     100             :     virtual SwLinePortion *Append( SwLinePortion *pPortion );
     101             :             SwLinePortion *Cut( SwLinePortion *pVictim );
     102             :     inline  void Truncate();
     103             : 
     104             :     // Returns 0, if there's no payload
     105             :     virtual SwLinePortion *Compress();
     106             : 
     107      601886 :     inline void SetWhichPor( const sal_uInt16 nNew )    { nWhichPor = nNew; }
     108       64756 :     inline sal_uInt16 GetWhichPor( ) const        { return nWhichPor; }
     109             : 
     110             : // Group queries
     111     1570056 :     inline bool InTxtGrp() const { return (nWhichPor & PORGRP_TXT) != 0; }
     112        2440 :     inline bool InGlueGrp() const { return (nWhichPor & PORGRP_GLUE) != 0; }
     113      719196 :     inline bool InTabGrp() const { return (nWhichPor & PORGRP_TAB) != 0; }
     114       58060 :     inline bool InHyphGrp() const { return (nWhichPor & PORGRP_HYPH) != 0; }
     115      466625 :     inline bool InNumberGrp() const { return (nWhichPor & PORGRP_NUMBER) != 0; }
     116           0 :     inline bool InFixGrp() const { return (nWhichPor & PORGRP_FIX) != 0; }
     117     1192799 :     inline bool InFldGrp() const { return (nWhichPor & PORGRP_FLD) != 0; }
     118           0 :     inline bool InToxRefGrp() const { return (nWhichPor & PORGRP_TOXREF) != 0; }
     119           0 :     inline bool InToxRefOrFldGrp() const { return (nWhichPor & ( PORGRP_FLD | PORGRP_TOXREF )) != 0; }
     120      179454 :     inline bool InExpGrp() const { return (nWhichPor & PORGRP_EXP) != 0; }
     121             :     inline bool InTabnLftGrp() const { return (nWhichPor & PORGRP_TABNOTLFT) != 0; }
     122      529855 :     inline bool InFixMargGrp() const { return (nWhichPor & PORGRP_FIXMARG) != 0; }
     123      652243 :     inline bool InSpaceGrp() const { return InTxtGrp() || IsMultiPortion(); }
     124             : // Individual queries
     125      533796 :     inline bool IsGrfNumPortion() const { return nWhichPor == POR_GRFNUM; }
     126     1408349 :     inline bool IsFlyCntPortion() const { return nWhichPor == POR_FLYCNT; }
     127       44173 :     inline bool IsBlankPortion() const { return nWhichPor == POR_BLANK; }
     128      667478 :     inline bool IsBreakPortion() const { return nWhichPor == POR_BRK; }
     129        8898 :     inline bool IsErgoSumPortion() const { return nWhichPor == POR_ERGOSUM; }
     130      388077 :     inline bool IsQuoVadisPortion() const { return nWhichPor == POR_QUOVADIS; }
     131             :     inline bool IsTabCntPortion() const { return nWhichPor == POR_TABCENTER; }
     132             :     inline bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL; }
     133       30258 :     inline bool IsTabLeftPortion() const { return nWhichPor == POR_TABLEFT; }
     134       25400 :     inline bool IsFtnNumPortion() const { return nWhichPor == POR_FTNNUM; }
     135      451474 :     inline bool IsFtnPortion() const { return nWhichPor == POR_FTN; }
     136             :     inline bool IsTmpEndPortion() const { return nWhichPor == POR_TMPEND; }
     137      894337 :     inline bool IsDropPortion() const { return nWhichPor == POR_DROP; }
     138         216 :     inline bool IsLayPortion() const { return nWhichPor == POR_LAY; }
     139         216 :     inline bool IsParaPortion() const { return nWhichPor == POR_PARA; }
     140      331345 :     inline bool IsMarginPortion() const { return nWhichPor == POR_MARGIN; }
     141      835926 :     inline bool IsFlyPortion() const { return nWhichPor == POR_FLY; }
     142      120706 :     inline bool IsHolePortion() const { return nWhichPor == POR_HOLE; }
     143          60 :     inline bool IsSoftHyphPortion() const { return nWhichPor == POR_SOFTHYPH; }
     144      580558 :     inline bool IsPostItsPortion() const { return nWhichPor == POR_POSTITS; }
     145           0 :     inline bool IsCombinedPortion() const { return nWhichPor == POR_COMBINED; }
     146       74568 :     inline bool IsTextPortion() const { return nWhichPor == POR_TXT; }
     147             :     inline bool IsURLPortion() const { return nWhichPor == POR_URL; }
     148      350260 :     inline bool IsHangingPortion() const { return nWhichPor == POR_HNG; }
     149      221698 :     inline bool IsKernPortion() const { return nWhichPor == POR_KERN; }
     150       59100 :     inline bool IsArrowPortion() const { return nWhichPor == POR_ARROW; }
     151     1872243 :     inline bool IsMultiPortion() const { return nWhichPor == POR_MULTI; }
     152       47104 :     inline bool IsNumberPortion() const { return nWhichPor == POR_NUMBER; } // #i23726#
     153           0 :     inline bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
     154             : 
     155             :     // Positioning
     156             :     SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
     157             :     SwLinePortion *FindLastPortion();
     158             : 
     159             :     virtual sal_Int32 GetCrsrOfst( const sal_uInt16 nOfst ) const;
     160             :     virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
     161             :     void CalcTxtSize( const SwTxtSizeInfo &rInfo );
     162             : 
     163             :     // Output
     164             :     virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
     165             :     void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
     166             : 
     167             :     virtual bool Format( SwTxtFormatInfo &rInf );
     168             :     // Is called for the line's last portion
     169             :     virtual void FormatEOL( SwTxtFormatInfo &rInf );
     170             :             void Move( SwTxtPaintInfo &rInf );
     171             : 
     172             :     // For SwTxtSlot
     173             :     virtual bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const;
     174             : 
     175             :     // For SwFldPortion, SwSoftHyphPortion
     176             :     virtual sal_uInt16 GetViewWidth( const SwTxtSizeInfo &rInf ) const;
     177             : 
     178             :     // for text- and multi-portions
     179             :     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
     180             : 
     181             :     // Accessibility: pass information about this portion to the PortionHandler
     182             :     virtual void HandlePortion( SwPortionHandler& rPH ) const;
     183             : 
     184      309105 :     bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; }
     185      309131 :     bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; }
     186          94 :     void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
     187          94 :     void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
     188             : 
     189             :     OUTPUT_OPERATOR
     190             : };
     191             : 
     192          40 : inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
     193             : {
     194          40 :     *(SwPosSize*)this = rPortion;
     195          40 :     nLineLength = rPortion.nLineLength;
     196          40 :     nAscent = rPortion.nAscent;
     197          40 :     nWhichPor = rPortion.nWhichPor;
     198          40 :     m_bJoinBorderWithPrev = rPortion.m_bJoinBorderWithPrev;
     199          40 :     m_bJoinBorderWithNext = rPortion.m_bJoinBorderWithNext;
     200          40 :     return *this;
     201             : }
     202             : 
     203             : inline bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
     204             : {
     205             :     return( Height() == rPortion.Height() &&
     206             :             Width() == rPortion.Width() &&
     207             :             nLineLength == rPortion.GetLen() &&
     208             :             nAscent == rPortion.GetAscent() );
     209             : }
     210             : 
     211       25976 : inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
     212             :     SwPosSize( rPortion ),
     213             :     pPortion( 0 ),
     214             :     nLineLength( rPortion.nLineLength ),
     215             :     nAscent( rPortion.nAscent ),
     216             :     nWhichPor( rPortion.nWhichPor ),
     217             :     m_bJoinBorderWithPrev( rPortion.m_bJoinBorderWithPrev ),
     218       25976 :     m_bJoinBorderWithNext( rPortion.m_bJoinBorderWithNext )
     219             : {
     220       25976 : }
     221             : 
     222      271934 : inline void SwLinePortion::Truncate()
     223             : {
     224      271934 :     if ( pPortion )
     225       43512 :         _Truncate();
     226      271934 : }
     227             : 
     228             : #endif
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10