LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/text - itrform2.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 26 84.6 %
Date: 2012-12-27 Functions: 19 23 82.6 %
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 _ITRFORM2_HXX
      20             : #define _ITRFORM2_HXX
      21             : #include "itrpaint.hxx"
      22             : 
      23             : class SwFlyCntPortion;
      24             : class SwInterHyphInfo;
      25             : class SwDropPortion;
      26             : class SwFmtDrop;
      27             : class SwTxtAttr;
      28             : class SwNumberPortion;
      29             : class SwErgoSumPortion;
      30             : class SwExpandPortion;
      31             : class SwMultiPortion;
      32             : class SwFtnPortion;
      33             : 
      34             : 
      35             : class SwTxtFormatter : public SwTxtPainter
      36             : {
      37             :     const SwFmtDrop *pDropFmt;
      38             :     SwMultiPortion* pMulti; // during formatting a multi-portion
      39             :     sal_uInt8 nCntEndHyph;  // Counts consecutive hyphens at the line end
      40             :     sal_uInt8 nCntMidHyph;  // Counts consecutive hyphens before flies
      41             :     xub_StrLen nLeftScanIdx; // for increasing performance during
      42             :     xub_StrLen nRightScanIdx; // scanning for portion ends
      43             :     sal_Bool bOnceMore : 1; // Another round?
      44             :     sal_Bool bFlyInCntBase : 1; // Base reference that sets a character-bound frame
      45             :     sal_Bool bChanges : 1; // Flag for calculating the repaint rectangle
      46             :     sal_Bool bTruncLines : 1; // Flag for extending the repaint rect, if needed
      47             :     sal_Bool bUnclipped : 1; // Flag whether repaint is larger than the fixed line height
      48             :     sal_uInt16 m_nHintEndIndex; // HACK for TryNewNoLengthPortion
      49             :     SwLinePortion *NewPortion( SwTxtFormatInfo &rInf );
      50             :     SwTxtPortion  *NewTxtPortion( SwTxtFormatInfo &rInf );
      51             :     SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf );
      52             :     SwTabPortion *NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) const;
      53             :     SwNumberPortion *NewNumberPortion( SwTxtFormatInfo &rInf ) const;
      54             :     SwDropPortion *NewDropPortion( SwTxtFormatInfo &rInf );
      55             :     SwNumberPortion *NewFtnNumPortion( SwTxtFormatInfo &rInf ) const;
      56             :     SwErgoSumPortion *NewErgoSumPortion( SwTxtFormatInfo &rInf ) const;
      57             :     SwExpandPortion *NewFldPortion( SwTxtFormatInfo &rInf,
      58             :                                     const SwTxtAttr *pHt ) const;
      59             :     SwFtnPortion *NewFtnPortion( SwTxtFormatInfo &rInf, SwTxtAttr *pHt );
      60             : 
      61             :     /**
      62             :         Sets a new portion for an object anchored as character
      63             :      */
      64             :     SwFlyCntPortion *NewFlyCntPortion( SwTxtFormatInfo &rInf,
      65             :                                        SwTxtAttr *pHt ) const;
      66             :     SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf );
      67             :     SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const;
      68             :     SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo );
      69             : 
      70             :     // The center pice of formatting
      71             :     void BuildPortions( SwTxtFormatInfo &rInf );
      72             : 
      73             :     sal_Bool BuildMultiPortion( SwTxtFormatInfo &rInf, SwMultiPortion& rMulti );
      74             : 
      75             :     /**
      76             :         Calculation of the emulated right side.
      77             : 
      78             :         Determines the next object, that reaches into the rest of the line and
      79             :         constructs the appropriate FlyPortion.
      80             :         SwTxtFly::GetFrm(const SwRect&, sal_Bool) will be needed for this.
      81             : 
      82             :         The right edge can be shortened by flys
      83             :      */
      84             :     void CalcFlyWidth( SwTxtFormatInfo &rInf );
      85             : 
      86             :     // Is overloaded by SwTxtFormatter because of UpdatePos
      87             :     void CalcAdjustLine( SwLineLayout *pCurr );
      88             : 
      89             :     // consideres line spacing attributes
      90             :     void CalcRealHeight( sal_Bool bNewLine = sal_False );
      91             : 
      92             :     // Transfers the data to rInf
      93             :     void FeedInf( SwTxtFormatInfo &rInf ) const;
      94             : 
      95             :     // Treats underflow situations
      96             :     SwLinePortion *UnderFlow( SwTxtFormatInfo &rInf );
      97             : 
      98             :     // Calculates the ascent and the height from the fontmetric
      99             :     void CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor );
     100             : 
     101             :     // determines, if a optimized repaint rectange is allowed
     102             :     sal_Bool AllowRepaintOpt() const;
     103             : 
     104             :     // Is called by by FormatLine
     105             :     void FormatReset( SwTxtFormatInfo &rInf );
     106             : 
     107             :     /**
     108             :         The position of the portions changes with the adjustment.
     109             : 
     110             :         This method updates the reference point of the anchored as character objects,
     111             :         for example after adjustment change (right alignment, justified, etc.)
     112             :         Mainly to correct the X position.
     113             :      */
     114             :     void UpdatePos( SwLineLayout *pCurr, Point aStart, xub_StrLen nStartIdx,
     115             :             sal_Bool bAllWays = sal_False ) const;
     116             : 
     117             :     /**
     118             :         Set all anchored as character objects to the passed BaseLine
     119             :         (in Y direction).
     120             :      */
     121             :     void AlignFlyInCntBase( long nBaseLine ) const;
     122             : 
     123             :     /**
     124             :         This is called after the real height of the line has been calculated
     125             :         Therefore it is possible, that more flys from below intersect with the
     126             :         line, or that flys from above do not intersect with the line anymore.
     127             :         We check this and return true, meaning that the line has to be
     128             :         formatted again.
     129             :      */
     130             :     sal_Bool ChkFlyUnderflow( SwTxtFormatInfo &rInf ) const;
     131             : 
     132             :     // Insert portion
     133             :     void InsertPortion( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) const;
     134             : 
     135             :     // Guess height for the DropPortion
     136             :     void GuessDropHeight( const MSHORT nLines );
     137             : 
     138             : public:
     139             :     // Calculate the height for the DropPortion
     140             :     void CalcDropHeight( const MSHORT nLines );
     141             : 
     142             :     // Calculates the paragraphs bottom, takes anchored objects within it into
     143             :     // account which have a wrap setting of "wrap at 1st paragraph"
     144             :     SwTwips CalcBottomLine() const;
     145             : 
     146             :     // Takes character-bound objects into account when calculating the
     147             :     // repaint rect in lines with fixed line height
     148             :     void CalcUnclipped( SwTwips& rTop, SwTwips& rBottom );
     149             : 
     150             :     // Amongst others for DropCaps
     151             :     sal_Bool CalcOnceMore();
     152             : 
     153             :     void CtorInitTxtFormatter( SwTxtFrm *pFrm, SwTxtFormatInfo *pInf );
     154         692 :     inline SwTxtFormatter( SwTxtFrm *pTxtFrm, SwTxtFormatInfo *pTxtFmtInf ) : SwTxtPainter(pTxtFrm!=NULL?pTxtFrm->GetTxtNode():NULL)
     155         692 :            { CtorInitTxtFormatter( pTxtFrm, pTxtFmtInf ); }
     156             :     ~SwTxtFormatter();
     157             : 
     158             :     xub_StrLen FormatLine( const xub_StrLen nStart );
     159             : 
     160             :     void RecalcRealHeight();
     161             : 
     162             :     // We format a line for interactive hyphenation
     163             :     sal_Bool Hyphenate( SwInterHyphInfo &rInf );
     164             : 
     165             :     // A special method for QuoVadis texts:
     166             :     // nErgo is the page number of the ErgoSum Ftn
     167             :     // At 0 it's still unclear
     168             :     xub_StrLen FormatQuoVadis( const xub_StrLen nStart );
     169             : 
     170             :     // The emergency break: Cancel formatting, discard line
     171        2613 :     inline sal_Bool IsStop() const { return GetInfo().IsStop(); }
     172             : 
     173             :     // The counterpart: Continue formatting at all costs
     174         724 :     inline sal_Bool IsNewLine() const { return GetInfo().IsNewLine(); }
     175             : 
     176             :     // FormatQuick(); Refresh formatting information
     177        1336 :     inline sal_Bool IsQuick() const { return GetInfo().IsQuick(); }
     178             : 
     179             :     // Create a SwLineLayout if needed, which avoids Ftn/Fly to oscillate
     180             :     void MakeDummyLine();
     181             : 
     182             :     // SwTxtIter functionality
     183             :     void Insert( SwLineLayout *pLine );
     184             : 
     185             :     // The remaining height to the page border
     186             :     KSHORT GetFrmRstHeight() const;
     187             : 
     188             :     // How wide would you be without any bounds (Flys etc.)?
     189             :     SwTwips _CalcFitToContent( );
     190             : 
     191             :     SwLinePortion* MakeRestPortion(const SwLineLayout* pLine, xub_StrLen nPos);
     192             : 
     193        1317 :     inline const SwFmtDrop *GetDropFmt() const { return pDropFmt; }
     194           0 :     inline void ClearDropFmt() { pDropFmt = 0; }
     195             : 
     196        3425 :     inline SwMultiPortion *GetMulti() const { return pMulti; }
     197             : 
     198         643 :     inline sal_Bool IsOnceMore() const { return bOnceMore; }
     199           0 :     inline void       SetOnceMore( sal_Bool bNew ) { bOnceMore = bNew; }
     200             : 
     201             :     inline sal_Bool HasChanges() const { return bChanges; }
     202         724 :     inline void       SetChanges()       { bChanges = sal_True; }
     203             : 
     204           0 :     inline sal_Bool HasTruncLines() const { return bTruncLines; }
     205         643 :     inline void       SetTruncLines( sal_Bool bNew ) { bTruncLines = bNew; }
     206             : 
     207         724 :     inline sal_Bool IsUnclipped() const { return bUnclipped; }
     208        1367 :     inline void       SetUnclipped( sal_Bool bNew ) { bUnclipped = bNew; }
     209             : 
     210        1497 :     inline sal_Bool IsFlyInCntBase() const { return bFlyInCntBase; }
     211        1929 :     inline void  SetFlyInCntBase( sal_Bool bNew = sal_True ){ bFlyInCntBase = bNew; }
     212             : 
     213       26282 :     inline SwTxtFormatInfo &GetInfo()
     214       26282 :         { return (SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
     215        9430 :     inline const SwTxtFormatInfo &GetInfo() const
     216        9430 :         { return (const SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
     217             : 
     218           0 :     inline void InitCntHyph() { CntHyphens( nCntEndHyph, nCntMidHyph ); }
     219         755 :     inline const sal_uInt8 &CntEndHyph() const { return nCntEndHyph; }
     220         755 :     inline const sal_uInt8 &CntMidHyph() const { return nCntMidHyph; }
     221         755 :     inline sal_uInt8 &CntEndHyph() { return nCntEndHyph; }
     222         755 :     inline sal_uInt8 &CntMidHyph() { return nCntMidHyph; }
     223             : };
     224             : 
     225             : 
     226             : 
     227             : #endif
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10