LCOV - code coverage report
Current view: top level - sw/source/core/text - itrform2.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 28 0.0 %
Date: 2014-04-14 Functions: 0 23 0.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 SwFmtDrop;
      27             : class SwTxtAttr;
      28             : class SwNumberPortion;
      29             : class SwErgoSumPortion;
      30             : class SwExpandPortion;
      31             : class SwMultiPortion;
      32             : class SwFtnPortion;
      33             : 
      34             : class SwTxtFormatter : public SwTxtPainter
      35             : {
      36             :     const SwFmtDrop *pDropFmt;
      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             :     sal_uInt16 m_nHintEndIndex; // HACK for TryNewNoLengthPortion
      48             :     SwLinePortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion bulding)
      49             : 
      50             :     SwLinePortion *NewPortion( SwTxtFormatInfo &rInf );
      51             :     SwTxtPortion  *NewTxtPortion( SwTxtFormatInfo &rInf );
      52             :     SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf );
      53             :     SwTabPortion *NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) const;
      54             :     SwNumberPortion *NewNumberPortion( SwTxtFormatInfo &rInf ) const;
      55             :     SwDropPortion *NewDropPortion( SwTxtFormatInfo &rInf );
      56             :     SwNumberPortion *NewFtnNumPortion( SwTxtFormatInfo &rInf ) const;
      57             :     SwErgoSumPortion *NewErgoSumPortion( SwTxtFormatInfo &rInf ) const;
      58             :     SwExpandPortion *NewFldPortion( SwTxtFormatInfo &rInf,
      59             :                                     const SwTxtAttr *pHt ) const;
      60             :     SwFtnPortion *NewFtnPortion( SwTxtFormatInfo &rInf, SwTxtAttr *pHt );
      61             : 
      62             :     /**
      63             :         Sets a new portion for an object anchored as character
      64             :      */
      65             :     SwFlyCntPortion *NewFlyCntPortion( SwTxtFormatInfo &rInf,
      66             :                                        SwTxtAttr *pHt ) const;
      67             :     SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf );
      68             :     SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const;
      69             :     SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo );
      70             : 
      71             :     // The center pice of formatting
      72             :     void BuildPortions( SwTxtFormatInfo &rInf );
      73             : 
      74             :     bool BuildMultiPortion( SwTxtFormatInfo &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             :         SwTxtFly::GetFrm(const SwRect&, bool) will be needed for this.
      82             : 
      83             :         The right edge can be shortened by flys
      84             :      */
      85             :     void CalcFlyWidth( SwTxtFormatInfo &rInf );
      86             : 
      87             :     // Is overloaded by SwTxtFormatter because of UpdatePos
      88             :     void CalcAdjustLine( SwLineLayout *pCurr );
      89             : 
      90             :     // consideres line spacing attributes
      91             :     void CalcRealHeight( bool bNewLine = false );
      92             : 
      93             :     // Transfers the data to rInf
      94             :     void FeedInf( SwTxtFormatInfo &rInf ) const;
      95             : 
      96             :     // Treats underflow situations
      97             :     SwLinePortion *Underflow( SwTxtFormatInfo &rInf );
      98             : 
      99             :     // Calculates the ascent and the height from the fontmetric
     100             :     void CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor );
     101             : 
     102             :     // determines, if a optimized repaint rectange is allowed
     103             :     bool AllowRepaintOpt() const;
     104             : 
     105             :     // Is called by by FormatLine
     106             :     void FormatReset( SwTxtFormatInfo &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( SwTxtFormatInfo &rInf ) const;
     132             : 
     133             :     // Insert portion
     134             :     void InsertPortion( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) const;
     135             : 
     136             :     // Guess height for the DropPortion
     137             :     void GuessDropHeight( const MSHORT nLines );
     138             : 
     139             : public:
     140             :     // Calculate the height for the DropPortion
     141             :     void CalcDropHeight( const MSHORT 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 CtorInitTxtFormatter( SwTxtFrm *pFrm, SwTxtFormatInfo *pInf );
     155           0 :     SwTxtFormatter(SwTxtFrm *pTxtFrm, SwTxtFormatInfo *pTxtFmtInf)
     156             :         : SwTxtPainter(pTxtFrm->GetTxtNode())
     157           0 :         , bUnclipped(false)
     158             :     {
     159           0 :         CtorInitTxtFormatter( pTxtFrm, pTxtFmtInf );
     160           0 :     }
     161             :     virtual ~SwTxtFormatter();
     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 Ftn
     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           0 :     bool IsStop() const { return GetInfo().IsStop(); }
     177             : 
     178             :     // The counterpart: Continue formatting at all costs
     179           0 :     bool IsNewLine() const { return GetInfo().IsNewLine(); }
     180             : 
     181             :     // FormatQuick(); Refresh formatting information
     182           0 :     bool IsQuick() const { return GetInfo().IsQuick(); }
     183             : 
     184             :     // Create a SwLineLayout if needed, which avoids Ftn/Fly to oscillate
     185             :     void MakeDummyLine();
     186             : 
     187             :     // SwTxtIter functionality
     188             :     void Insert( SwLineLayout *pLine );
     189             : 
     190             :     // The remaining height to the page border
     191             :     KSHORT 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           0 :     const SwFmtDrop *GetDropFmt() const { return pDropFmt; }
     199           0 :     void ClearDropFmt() { pDropFmt = 0; }
     200             : 
     201           0 :     SwMultiPortion *GetMulti() const { return pMulti; }
     202             : 
     203           0 :     bool IsOnceMore() const { return bOnceMore; }
     204           0 :     void SetOnceMore( bool bNew ) { bOnceMore = bNew; }
     205             : 
     206             :     bool HasChanges() const { return bChanges; }
     207           0 :     void SetChanges()       { bChanges = true; }
     208             : 
     209           0 :     bool HasTruncLines() const { return bTruncLines; }
     210           0 :     void SetTruncLines( bool bNew ) { bTruncLines = bNew; }
     211             : 
     212           0 :     bool IsUnclipped() const { return bUnclipped; }
     213           0 :     void SetUnclipped( bool bNew ) { bUnclipped = bNew; }
     214             : 
     215           0 :     bool IsFlyInCntBase() const { return bFlyInCntBase; }
     216           0 :     void SetFlyInCntBase( bool bNew = true ) { bFlyInCntBase = bNew; }
     217             : 
     218           0 :     SwTxtFormatInfo &GetInfo()
     219           0 :         { return (SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
     220           0 :     const SwTxtFormatInfo &GetInfo() const
     221           0 :         { return (const SwTxtFormatInfo&)SwTxtIter::GetInfo(); }
     222             : 
     223           0 :     void InitCntHyph() { CntHyphens( nCntEndHyph, nCntMidHyph ); }
     224           0 :     const sal_uInt8 &CntEndHyph() const { return nCntEndHyph; }
     225           0 :     const sal_uInt8 &CntMidHyph() const { return nCntMidHyph; }
     226           0 :     sal_uInt8 &CntEndHyph() { return nCntEndHyph; }
     227           0 :     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             :     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, SwTxtFormatInfo& rInf );
     245             : };
     246             : 
     247             : #endif
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10