LCOV - code coverage report
Current view: top level - sw/source/core/text - porlin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 66 69 95.7 %
Date: 2015-06-13 12:38:46 Functions: 54 57 94.7 %
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 SwTextSizeInfo;
      30             : class SwTextPaintInfo;
      31             : class SwTextFormatInfo;
      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             : // Small special groups
      53             : #define PORGRP_FIXMARG  0x0040
      54             : //#define PORGRP_?  0x0020
      55             : #define PORGRP_TABNOTLFT 0x0010
      56             : #define PORGRP_TOXREF   0x0008
      57             : 
      58             : /// Base class for anything that can be part of a line in the Writer layout.
      59             : class SwLinePortion: public SwPosSize
      60             : {
      61             : protected:
      62             :     // Here we have areas with different attributes
      63             :     SwLinePortion *pPortion;
      64             :     // Count of chars and spaces on the line
      65             :     sal_Int32 nLineLength;
      66             :     sal_uInt16 nAscent;      // Maximum ascender
      67             : 
      68             :     SwLinePortion();
      69             : private:
      70             :     sal_uInt16 nWhichPor;       // Who's who?
      71             :     bool m_bJoinBorderWithPrev;
      72             :     bool m_bJoinBorderWithNext;
      73             : 
      74             :     void _Truncate();
      75             : 
      76             : public:
      77             :     inline          SwLinePortion(const SwLinePortion &rPortion);
      78             :            virtual ~SwLinePortion();
      79             : 
      80             :     // Access methods
      81     2284805 :     inline SwLinePortion *GetPortion() const { return pPortion; }
      82             :     inline SwLinePortion &operator=(const SwLinePortion &rPortion);
      83             :     inline bool operator==( const SwLinePortion &rPortion ) const;
      84     4277416 :     inline sal_Int32 GetLen() const { return nLineLength; }
      85      467177 :     inline void SetLen( const sal_Int32 nLen ) { nLineLength = nLen; }
      86      351531 :     inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
      87     1072962 :     inline sal_uInt16 &GetAscent() { return nAscent; }
      88      557892 :     inline sal_uInt16 GetAscent() const { return nAscent; }
      89      565734 :     inline void SetAscent( const sal_uInt16 nNewAsc ) { nAscent = nNewAsc; }
      90       57696 :     inline void  PrtWidth( sal_uInt16 nNewWidth ) { Width( nNewWidth ); }
      91      360363 :     inline sal_uInt16 PrtWidth() const { return Width(); }
      92       82056 :     inline void AddPrtWidth( const sal_uInt16 nNew ) { Width( Width() + nNew ); }
      93        1105 :     inline void SubPrtWidth( const sal_uInt16 nNew ) { Width( Width() - nNew ); }
      94             : 
      95             :     inline const SwPosSize &PrtSize() const { return *this; }
      96             : 
      97             :     // Insert methods
      98             :     virtual SwLinePortion *Insert( SwLinePortion *pPortion );
      99             :     virtual SwLinePortion *Append( SwLinePortion *pPortion );
     100             :             SwLinePortion *Cut( SwLinePortion *pVictim );
     101             :     inline  void Truncate();
     102             : 
     103             :     // Returns 0, if there's no payload
     104             :     virtual SwLinePortion *Compress();
     105             : 
     106      383227 :     inline void SetWhichPor( const sal_uInt16 nNew )    { nWhichPor = nNew; }
     107       36500 :     inline sal_uInt16 GetWhichPor( ) const        { return nWhichPor; }
     108             : 
     109             : // Group queries
     110      934544 :     inline bool InTextGrp() const { return (nWhichPor & PORGRP_TXT) != 0; }
     111        1199 :     inline bool InGlueGrp() const { return (nWhichPor & PORGRP_GLUE) != 0; }
     112      442485 :     inline bool InTabGrp() const { return (nWhichPor & PORGRP_TAB) != 0; }
     113       36693 :     inline bool InHyphGrp() const { return (nWhichPor & PORGRP_HYPH) != 0; }
     114      309630 :     inline bool InNumberGrp() const { return (nWhichPor & PORGRP_NUMBER) != 0; }
     115           0 :     inline bool InFixGrp() const { return (nWhichPor & PORGRP_FIX) != 0; }
     116      733486 :     inline bool InFieldGrp() const { return (nWhichPor & PORGRP_FLD) != 0; }
     117           2 :     inline bool InToxRefGrp() const { return (nWhichPor & PORGRP_TOXREF) != 0; }
     118           4 :     inline bool InToxRefOrFieldGrp() const { return (nWhichPor & ( PORGRP_FLD | PORGRP_TOXREF )) != 0; }
     119      118929 :     inline bool InExpGrp() const { return (nWhichPor & PORGRP_EXP) != 0; }
     120             :     inline bool InTabnLftGrp() const { return (nWhichPor & PORGRP_TABNOTLFT) != 0; }
     121      316541 :     inline bool InFixMargGrp() const { return (nWhichPor & PORGRP_FIXMARG) != 0; }
     122      370807 :     inline bool InSpaceGrp() const { return InTextGrp() || IsMultiPortion(); }
     123             : // Individual queries
     124      313477 :     inline bool IsGrfNumPortion() const { return nWhichPor == POR_GRFNUM; }
     125      837951 :     inline bool IsFlyCntPortion() const { return nWhichPor == POR_FLYCNT; }
     126       20636 :     inline bool IsBlankPortion() const { return nWhichPor == POR_BLANK; }
     127      400683 :     inline bool IsBreakPortion() const { return nWhichPor == POR_BRK; }
     128        9203 :     inline bool IsErgoSumPortion() const { return nWhichPor == POR_ERGOSUM; }
     129      233869 :     inline bool IsQuoVadisPortion() const { return nWhichPor == POR_QUOVADIS; }
     130             :     inline bool IsTabCntPortion() const { return nWhichPor == POR_TABCENTER; }
     131             :     inline bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL; }
     132       17831 :     inline bool IsTabLeftPortion() const { return nWhichPor == POR_TABLEFT; }
     133       20926 :     inline bool IsFootnoteNumPortion() const { return nWhichPor == POR_FTNNUM; }
     134      286142 :     inline bool IsFootnotePortion() const { return nWhichPor == POR_FTN; }
     135             :     inline bool IsTmpEndPortion() const { return nWhichPor == POR_TMPEND; }
     136      562954 :     inline bool IsDropPortion() const { return nWhichPor == POR_DROP; }
     137          54 :     inline bool IsLayPortion() const { return nWhichPor == POR_LAY; }
     138          54 :     inline bool IsParaPortion() const { return nWhichPor == POR_PARA; }
     139      184932 :     inline bool IsMarginPortion() const { return nWhichPor == POR_MARGIN; }
     140      519164 :     inline bool IsFlyPortion() const { return nWhichPor == POR_FLY; }
     141       67969 :     inline bool IsHolePortion() const { return nWhichPor == POR_HOLE; }
     142          30 :     inline bool IsSoftHyphPortion() const { return nWhichPor == POR_SOFTHYPH; }
     143      357637 :     inline bool IsPostItsPortion() const { return nWhichPor == POR_POSTITS; }
     144           0 :     inline bool IsCombinedPortion() const { return nWhichPor == POR_COMBINED; }
     145       42842 :     inline bool IsTextPortion() const { return nWhichPor == POR_TXT; }
     146             :     inline bool IsURLPortion() const { return nWhichPor == POR_URL; }
     147      200373 :     inline bool IsHangingPortion() const { return nWhichPor == POR_HNG; }
     148      121368 :     inline bool IsKernPortion() const { return nWhichPor == POR_KERN; }
     149       34236 :     inline bool IsArrowPortion() const { return nWhichPor == POR_ARROW; }
     150     1150319 :     inline bool IsMultiPortion() const { return nWhichPor == POR_MULTI; }
     151       29811 :     inline bool IsNumberPortion() const { return nWhichPor == POR_NUMBER; } // #i23726#
     152           0 :     inline bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
     153             : 
     154             :     // Positioning
     155             :     SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
     156             :     SwLinePortion *FindLastPortion();
     157             : 
     158             :     virtual sal_Int32 GetCrsrOfst( const sal_uInt16 nOfst ) const;
     159             :     virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const;
     160             :     void CalcTextSize( const SwTextSizeInfo &rInfo );
     161             : 
     162             :     // Output
     163             :     virtual void Paint( const SwTextPaintInfo &rInf ) const = 0;
     164             :     void PrePaint( const SwTextPaintInfo &rInf, const SwLinePortion *pLast ) const;
     165             : 
     166             :     virtual bool Format( SwTextFormatInfo &rInf );
     167             :     // Is called for the line's last portion
     168             :     virtual void FormatEOL( SwTextFormatInfo &rInf );
     169             :             void Move( SwTextPaintInfo &rInf );
     170             : 
     171             :     // For SwTextSlot
     172             :     virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const;
     173             : 
     174             :     // For SwFieldPortion, SwSoftHyphPortion
     175             :     virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const;
     176             : 
     177             :     // for text- and multi-portions
     178             :     virtual long CalcSpacing( long nSpaceAdd, const SwTextSizeInfo &rInf ) const;
     179             : 
     180             :     // Accessibility: pass information about this portion to the PortionHandler
     181             :     virtual void HandlePortion( SwPortionHandler& rPH ) const;
     182             : 
     183      173915 :     bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; }
     184      173928 :     bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; }
     185          47 :     void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
     186          47 :     void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
     187             : 
     188             :     OUTPUT_OPERATOR
     189             : };
     190             : 
     191       13670 : inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
     192             : {
     193       13670 :     *static_cast<SwPosSize*>(this) = rPortion;
     194       13670 :     nLineLength = rPortion.nLineLength;
     195       13670 :     nAscent = rPortion.nAscent;
     196       13670 :     nWhichPor = rPortion.nWhichPor;
     197       13670 :     m_bJoinBorderWithPrev = rPortion.m_bJoinBorderWithPrev;
     198       13670 :     m_bJoinBorderWithNext = rPortion.m_bJoinBorderWithNext;
     199       13670 :     return *this;
     200             : }
     201             : 
     202             : inline bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
     203             : {
     204             :     return( Height() == rPortion.Height() &&
     205             :             Width() == rPortion.Width() &&
     206             :             nLineLength == rPortion.GetLen() &&
     207             :             nAscent == rPortion.GetAscent() );
     208             : }
     209             : 
     210         570 : inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
     211             :     SwPosSize( rPortion ),
     212             :     pPortion( 0 ),
     213             :     nLineLength( rPortion.nLineLength ),
     214             :     nAscent( rPortion.nAscent ),
     215             :     nWhichPor( rPortion.nWhichPor ),
     216             :     m_bJoinBorderWithPrev( rPortion.m_bJoinBorderWithPrev ),
     217         570 :     m_bJoinBorderWithNext( rPortion.m_bJoinBorderWithNext )
     218             : {
     219         570 : }
     220             : 
     221      154800 : inline void SwLinePortion::Truncate()
     222             : {
     223      154800 :     if ( pPortion )
     224       26251 :         _Truncate();
     225      154800 : }
     226             : 
     227             : #endif
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11