LCOV - code coverage report
Current view: top level - sw/source/core/text - itrform2.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 28 89.3 %
Date: 2015-06-13 12:38:46 Functions: 20 23 87.0 %
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_ITRFORM2_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_TEXT_ITRFORM2_HXX
      21             : #include "itrpaint.hxx"
      22             : 
      23             : class SwFlyCntPortion;
      24             : class SwInterHyphInfo;
      25             : class SwDropPortion;
      26             : class SwFormatDrop;
      27             : class SwTextAttr;
      28             : class SwNumberPortion;
      29             : class SwErgoSumPortion;
      30             : class SwExpandPortion;
      31             : class SwMultiPortion;
      32             : class SwFootnotePortion;
      33             : 
      34             : class SwTextFormatter : public SwTextPainter
      35             : {
      36             :     const SwFormatDrop *pDropFormat;
      37             :     SwMultiPortion* pMulti; // during formatting a multi-portion
      38             :     sal_uInt8 nCntEndHyph;  // Counts consecutive hyphens at the line end
      39             :     sal_uInt8 nCntMidHyph;  // Counts consecutive hyphens before flies
      40             :     sal_Int32 nLeftScanIdx; // for increasing performance during
      41             :     sal_Int32 nRightScanIdx; // scanning for portion ends
      42             :     bool bOnceMore : 1; // Another round?
      43             :     bool bFlyInCntBase : 1; // Base reference that sets a character-bound frame
      44             :     bool bChanges : 1; // Flag for calculating the repaint rectangle
      45             :     bool bTruncLines : 1; // Flag for extending the repaint rect, if needed
      46             :     bool bUnclipped : 1; // Flag whether repaint is larger than the fixed line height
      47             :     size_t m_nHintEndIndex; // HACK for TryNewNoLengthPortion
      48             :     SwLinePortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion bulding)
      49             : 
      50             :     SwLinePortion *NewPortion( SwTextFormatInfo &rInf );
      51             :     SwTextPortion  *NewTextPortion( SwTextFormatInfo &rInf );
      52             :     SwLinePortion *NewExtraPortion( SwTextFormatInfo &rInf );
      53             :     SwTabPortion *NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const;
      54             :     SwNumberPortion *NewNumberPortion( SwTextFormatInfo &rInf ) const;
      55             :     SwDropPortion *NewDropPortion( SwTextFormatInfo &rInf );
      56             :     SwNumberPortion *NewFootnoteNumPortion( SwTextFormatInfo &rInf ) const;
      57             :     SwErgoSumPortion *NewErgoSumPortion( SwTextFormatInfo &rInf ) const;
      58             :     SwExpandPortion *NewFieldPortion( SwTextFormatInfo &rInf,
      59             :                                     const SwTextAttr *pHt ) const;
      60             :     SwFootnotePortion *NewFootnotePortion( SwTextFormatInfo &rInf, SwTextAttr *pHt );
      61             : 
      62             :     /**
      63             :         Sets a new portion for an object anchored as character
      64             :      */
      65             :     SwFlyCntPortion *NewFlyCntPortion( SwTextFormatInfo &rInf,
      66             :                                        SwTextAttr *pHt ) const;
      67             :     SwLinePortion *WhichFirstPortion( SwTextFormatInfo &rInf );
      68             :     SwTextPortion *WhichTextPor( SwTextFormatInfo &rInf ) const;
      69             :     SwExpandPortion * TryNewNoLengthPortion( SwTextFormatInfo & rInfo );
      70             : 
      71             :     // The center pice of formatting
      72             :     void BuildPortions( SwTextFormatInfo &rInf );
      73             : 
      74             :     bool BuildMultiPortion( SwTextFormatInfo &rInf, SwMultiPortion& rMulti );
      75             : 
      76             :     /**
      77             :         Calculation of the emulated right side.
      78             : 
      79             :         Determines the next object, that reaches into the rest of the line and
      80             :         constructs the appropriate FlyPortion.
      81             :         SwTextFly::GetFrm(const SwRect&, bool) will be needed for this.
      82             : 
      83             :         The right edge can be shortened by flys
      84             :      */
      85             :     void CalcFlyWidth( SwTextFormatInfo &rInf );
      86             : 
      87             :     // Is overloaded by SwTextFormatter because of UpdatePos
      88             :     void CalcAdjustLine( SwLineLayout *pCurr );
      89             : 
      90             :     // considers line spacing attributes
      91             :     void CalcRealHeight( bool bNewLine = false );
      92             : 
      93             :     // Transfers the data to rInf
      94             :     void FeedInf( SwTextFormatInfo &rInf ) const;
      95             : 
      96             :     // Treats underflow situations
      97             :     SwLinePortion *Underflow( SwTextFormatInfo &rInf );
      98             : 
      99             :     // Calculates the ascent and the height from the fontmetric
     100             :     void CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor );
     101             : 
     102             :     // determines, if a optimized repaint rectange is allowed
     103             :     bool AllowRepaintOpt() const;
     104             : 
     105             :     // Is called by FormatLine
     106             :     void FormatReset( SwTextFormatInfo &rInf );
     107             : 
     108             :     /**
     109             :         The position of the portions changes with the adjustment.
     110             : 
     111             :         This method updates the reference point of the anchored as character objects,
     112             :         for example after adjustment change (right alignment, justified, etc.)
     113             :         Mainly to correct the X position.
     114             :      */
     115             :     void UpdatePos( SwLineLayout *pCurr, Point aStart, sal_Int32 nStartIdx,
     116             :             bool bAlways = false ) const;
     117             : 
     118             :     /**
     119             :         Set all anchored as character objects to the passed BaseLine
     120             :         (in Y direction).
     121             :      */
     122             :     void AlignFlyInCntBase( long nBaseLine ) const;
     123             : 
     124             :     /**
     125             :         This is called after the real height of the line has been calculated
     126             :         Therefore it is possible, that more flys from below intersect with the
     127             :         line, or that flys from above do not intersect with the line anymore.
     128             :         We check this and return true, meaning that the line has to be
     129             :         formatted again.
     130             :      */
     131             :     bool ChkFlyUnderflow( SwTextFormatInfo &rInf ) const;
     132             : 
     133             :     // Insert portion
     134             :     void InsertPortion( SwTextFormatInfo &rInf, SwLinePortion *pPor ) const;
     135             : 
     136             :     // Guess height for the DropPortion
     137             :     void GuessDropHeight( const sal_uInt16 nLines );
     138             : 
     139             : public:
     140             :     // Calculate the height for the DropPortion
     141             :     void CalcDropHeight( const sal_uInt16 nLines );
     142             : 
     143             :     // Calculates the paragraphs bottom, takes anchored objects within it into
     144             :     // account which have a wrap setting of "wrap at 1st paragraph"
     145             :     SwTwips CalcBottomLine() const;
     146             : 
     147             :     // Takes character-bound objects into account when calculating the
     148             :     // repaint rect in lines with fixed line height
     149             :     void CalcUnclipped( SwTwips& rTop, SwTwips& rBottom );
     150             : 
     151             :     // Amongst others for DropCaps
     152             :     bool CalcOnceMore();
     153             : 
     154             :     void CtorInitTextFormatter( SwTextFrm *pFrm, SwTextFormatInfo *pInf );
     155       55817 :     SwTextFormatter(SwTextFrm *pTextFrm, SwTextFormatInfo *pTextFormatInf)
     156             :         : SwTextPainter(pTextFrm->GetTextNode())
     157       55817 :         , bUnclipped(false)
     158             :     {
     159       55817 :         CtorInitTextFormatter( pTextFrm, pTextFormatInf );
     160       55817 :     }
     161             :     virtual ~SwTextFormatter();
     162             : 
     163             :     sal_Int32 FormatLine( const sal_Int32 nStart );
     164             : 
     165             :     void RecalcRealHeight();
     166             : 
     167             :     // We format a line for interactive hyphenation
     168             :     bool Hyphenate( SwInterHyphInfo &rInf );
     169             : 
     170             :     // A special method for QuoVadis texts:
     171             :     // nErgo is the page number of the ErgoSum Footnote
     172             :     // At 0 it's still unclear
     173             :     sal_Int32 FormatQuoVadis( const sal_Int32 nStart );
     174             : 
     175             :     // The emergency break: Cancel formatting, discard line
     176      216112 :     bool IsStop() const { return GetInfo().IsStop(); }
     177             : 
     178             :     // The counterpart: Continue formatting at all costs
     179       80156 :     bool IsNewLine() const { return GetInfo().IsNewLine(); }
     180             : 
     181             :     // FormatQuick(); Refresh formatting information
     182       62562 :     bool IsQuick() const { return GetInfo().IsQuick(); }
     183             : 
     184             :     // Create a SwLineLayout if needed, which avoids Footnote/Fly to oscillate
     185             :     void MakeDummyLine();
     186             : 
     187             :     // SwTextIter functionality
     188             :     void Insert( SwLineLayout *pLine );
     189             : 
     190             :     // The remaining height to the page border
     191             :     sal_uInt16 GetFrmRstHeight() const;
     192             : 
     193             :     // How wide would you be without any bounds (Flys etc.)?
     194             :     SwTwips _CalcFitToContent( );
     195             : 
     196             :     SwLinePortion* MakeRestPortion(const SwLineLayout* pLine, sal_Int32 nPos);
     197             : 
     198       94538 :     const SwFormatDrop *GetDropFormat() const { return pDropFormat; }
     199           0 :     void ClearDropFormat() { pDropFormat = 0; }
     200             : 
     201      321752 :     SwMultiPortion *GetMulti() const { return pMulti; }
     202             : 
     203       46454 :     bool IsOnceMore() const { return bOnceMore; }
     204           0 :     void SetOnceMore( bool bNew ) { bOnceMore = bNew; }
     205             : 
     206             :     bool HasChanges() const { return bChanges; }
     207       70419 :     void SetChanges()       { bChanges = true; }
     208             : 
     209           0 :     bool HasTruncLines() const { return bTruncLines; }
     210       46575 :     void SetTruncLines( bool bNew ) { bTruncLines = bNew; }
     211             : 
     212       79528 :     bool IsUnclipped() const { return bUnclipped; }
     213      126055 :     void SetUnclipped( bool bNew ) { bUnclipped = bNew; }
     214             : 
     215      177557 :     bool IsFlyInCntBase() const { return bFlyInCntBase; }
     216      140639 :     void SetFlyInCntBase( bool bNew = true ) { bFlyInCntBase = bNew; }
     217             : 
     218     2899823 :     SwTextFormatInfo &GetInfo()
     219     2899823 :         { return static_cast<SwTextFormatInfo&>(SwTextIter::GetInfo()); }
     220      699962 :     const SwTextFormatInfo &GetInfo() const
     221      699962 :         { return static_cast<const SwTextFormatInfo&>(SwTextIter::GetInfo()); }
     222             : 
     223           1 :     void InitCntHyph() { CntHyphens( nCntEndHyph, nCntMidHyph ); }
     224       84658 :     const sal_uInt8 &CntEndHyph() const { return nCntEndHyph; }
     225       84658 :     const sal_uInt8 &CntMidHyph() const { return nCntMidHyph; }
     226       84693 :     sal_uInt8 &CntEndHyph() { return nCntEndHyph; }
     227       84693 :     sal_uInt8 &CntMidHyph() { return nCntMidHyph; }
     228             : 
     229             :     /**
     230             :      * Merge border of the drop portion with modifying the font of
     231             :      * the portions' part. Removing left or right border.
     232             :      * @param   rPortion    drop portion for merge
     233             :     **/
     234             :     static void MergeCharacterBorder( SwDropPortion& rPortion );
     235             : 
     236             :     /**
     237             :      * Merge border of the line portion with setting the portion's
     238             :      * m_bJoinBorderWidthNext and m_bJoinBorderWidthPrev members and
     239             :      * changing the size (width, height and ascent) of the portion
     240             :      * to get a merged border.
     241             :      * @param   rPortion    portion for merge
     242             :      * @param   rInf        contain information
     243             :     **/
     244             :     void MergeCharacterBorder( SwLinePortion& rPortion, SwTextFormatInfo& rInf );
     245             : };
     246             : 
     247             : #endif
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11