LCOV - code coverage report
Current view: top level - sw/source/core/inc - txtfrm.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 92 100 92.0 %
Date: 2014-11-03 Functions: 55 58 94.8 %
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_INC_TXTFRM_HXX
      20             : #define INCLUDED_SW_SOURCE_CORE_INC_TXTFRM_HXX
      21             : 
      22             : #include <com/sun/star/uno/Sequence.hxx>
      23             : #include <tools/mempool.hxx>
      24             : #include "cntfrm.hxx"
      25             : #include "ndtxt.hxx"
      26             : 
      27             : class SwCharRange;
      28             : class SwTxtNode;
      29             : class SwTxtFormatter;
      30             : class SwTxtFormatInfo;
      31             : class SwParaPortion;
      32             : class WidowsAndOrphans;
      33             : class SwBodyFrm;
      34             : class SwTxtFtn;
      35             : class SwInterHyphInfo;      // Hyphenate()
      36             : class SwCache;
      37             : class SwBorderAttrs;
      38             : class SwFrmFmt;
      39             : class OutputDevice;
      40             : class SwTestFormat;
      41             : struct SwCrsrMoveState;
      42             : struct SwFillData;
      43             : class SwPortionHandler;
      44             : class SwScriptInfo;
      45             : class SwViewOption;
      46             : class SwWrongList;
      47             : 
      48             : #define NON_PRINTING_CHARACTER_COLOR RGB_COLORDATA(0x26, 0x8b, 0xd2)
      49             : 
      50             : /// Represents the visualization of a paragraph.
      51             : class SwTxtFrm: public SwCntntFrm
      52             : {
      53             :     friend class SwTxtIter;
      54             :     friend class SwTestFormat;
      55             :     friend class WidowsAndOrphans;
      56             :     friend class SwTxtFrmLocker; // May Lock()/Unlock()
      57             :     friend bool sw_ChangeOffset( SwTxtFrm* pFrm, sal_Int32 nNew );
      58             : 
      59             :     static SwCache *pTxtCache;  // Pointer to the Line Cache
      60             :     static long nMinPrtLine;    // This Line must not be underrun when printing
      61             :                                 // Hack for table cells stretching multiple pages
      62             : 
      63             :     sal_uLong  nAllLines        :24; // Line count for the Paint (including nThisLines)
      64             :     sal_uLong  nThisLines       :8; // Count of Lines of the Frame
      65             : 
      66             :     // The x position for flys anchored at this paragraph.
      67             :     // These values are calculated in SwTxtFrm::CalcBaseOfstForFly()
      68             :     SwTwips mnFlyAnchorOfst;
      69             :     // The x position for wrap-through flys anchored at this paragraph.
      70             :     SwTwips mnFlyAnchorOfstNoWrap;
      71             :     SwTwips mnFtnLine;
      72             :     // OD 2004-03-17 #i11860# - re-factoring of #i11859#
      73             :     // member for height of last line (value needed for proportional line spacing)
      74             :     SwTwips mnHeightOfLastLine;
      75             :     // member for the additional first line offset, which is caused by the list
      76             :     // label alignment for list level position and space mode LABEL_ALIGNMENT.
      77             :     // This additional first line offset is used for the text formatting.
      78             :     // It is NOT used for the determination of printing area.
      79             :     SwTwips mnAdditionalFirstLineOffset;
      80             : 
      81             :     sal_Int32 nOfst; // Is the offset in the Cntnt (character count)
      82             : 
      83             :     sal_uInt16 nCacheIdx; // Index into the cache, USHRT_MAX if there's definitely no fitting object in the cache
      84             : 
      85             :     // Separates the Master and creates a Follow or adjusts the data in the Follow
      86             :     void _AdjustFollow( SwTxtFormatter &rLine, const sal_Int32 nOffset,
      87             :                                const sal_Int32 nStrEnd, const sal_uInt8 nMode );
      88             :     inline void AdjustFollow( SwTxtFormatter &rLine, const sal_Int32 nOffset,
      89             :                               const sal_Int32 nStrEnd, const sal_uInt8 nMode );
      90             : 
      91             :     // Iterates all Lines and sets the line spacing using the attribute
      92             :     void CalcLineSpace();
      93             : 
      94             :     // Only called in Format
      95             :     void AdjustFrm( const SwTwips nChgHeight, bool bHasToFit = false );
      96             : 
      97             :     // Evaluates the Preps in Format()
      98             :     bool CalcPreps();
      99             :     void PrepWidows( const sal_uInt16 nNeed, bool bNotify = true );
     100             :     void _InvalidateRange( const SwCharRange &, const long = 0);
     101             :     inline void InvalidateRange( const SwCharRange &, const long = 0);
     102             : 
     103             :     // WidowsAndOrphans, AdjustFrm, AdjustFollow
     104             :     void FormatAdjust( SwTxtFormatter &rLine, WidowsAndOrphans &rFrmBreak,
     105             :                        const sal_Int32 nStrLen, const bool bDummy );
     106             : 
     107             :     bool bLocked        : 1;        // In the Format?
     108             :     bool bWidow         : 1;        // Are we a Widow?
     109             :     bool bJustWidow     : 1;        // Did we just request to be a Widow?
     110             :     bool bEmpty         : 1;        // Are we an empty paragraph?
     111             :     bool bInFtnConnect  : 1;        // Is in Connect at the moment
     112             :     bool bFtn           : 1;        // Has at least one footnote
     113             :     bool bRepaint       : 1;        // TxtFrm: Repaint is ready to be fetched
     114             :     bool bBlinkPor      : 1;        // Contains Blink Portions
     115             :     bool bFieldFollow   : 1;        // Start with Field rest of the Master
     116             :     bool bHasAnimation  : 1;        // Contains animated SwGrfNumPortion
     117             :     bool bIsSwapped     : 1;        // during text formatting we swap the
     118             :                                     // width and height for vertical formatting
     119             :     // OD 14.03.2003 #i11760# - flag to control, if follow is formatted in
     120             :     // method <CalcFollow(..)>.
     121             :     // E.g., avoid formatting of follow, if method <SwLayoutFrm::FormatWidthCols(..)>
     122             :     // is running.
     123             :     bool mbFollowFormatAllowed : 1;
     124             : 
     125             :     void ResetPreps();
     126      126901 :     inline void Lock() { bLocked = true; }
     127      126901 :     inline void Unlock() { bLocked = false; }
     128       28191 :     inline void SetWidow( const bool bNew ) { bWidow = bNew; }
     129          34 :     inline void SetJustWidow( const bool bNew ) { bJustWidow = bNew; }
     130      121267 :     inline void SetEmpty( const bool bNew ) { bEmpty = bNew; }
     131        1898 :     inline void SetFieldFollow( const bool bNew ) { bFieldFollow = bNew; }
     132             : 
     133             :     bool IsIdxInside( const sal_Int32 nPos, const sal_Int32 nLen ) const;
     134             : 
     135             :     // Changes the Frame or not (cf. FlyCnt)
     136             :     bool _GetCrsrOfst(SwPosition *pPos, const Point &rPoint,
     137             :                       const bool bChgFrm, SwCrsrMoveState* = 0 ) const;
     138             :     void FillCrsrPos( SwFillData &rFill ) const;
     139             : 
     140             :     // Format exactly one Line
     141             :     bool FormatLine( SwTxtFormatter &rLine, const bool bPrev );
     142             : 
     143             :     // In order to safe stack space, we split this method:
     144             :     // _Format calls _Format with parameters
     145             :     void _Format( SwParaPortion *pPara );
     146             :     void _Format( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf,
     147             :                   const bool bAdjust = false );
     148             :     void FormatOnceMore( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf );
     149             : 
     150             :     // Formats the Follow and ensures disposing on orphans
     151             :     bool CalcFollow(  const sal_Int32 nTxtOfst );
     152             : 
     153             :     // Corrects the position from which we need to format
     154             :     sal_Int32 FindBrk(const OUString &rTxt, const sal_Int32 nStart,
     155             :                                        const sal_Int32 nEnd) const;
     156             : 
     157             :     // inline branch
     158             :     SwTwips _GetFtnFrmHeight() const;
     159             : 
     160             :     // Outsourced to CalcPreps
     161             :     bool CalcPrepFtnAdjust();
     162             : 
     163             :     // For Ftn and WidOrp: Forced validation
     164             :     void ValidateFrm();
     165             :     void ValidateBodyFrm();
     166             : 
     167             :     bool _GetDropRect( SwRect &rRect ) const;
     168             : 
     169             :     void SetPara( SwParaPortion *pNew, bool bDelete = true );
     170             : 
     171             :     bool _IsFtnNumFrm() const;
     172             : 
     173             :     // Refresh formatting information
     174             :     bool FormatQuick( bool bForceQuickFormat );
     175             : 
     176             :     // Opt: Format empty paragraphs
     177             :     bool FormatEmpty();
     178             :     SwTwips EmptyHeight() const;
     179             : 
     180             :     // Opt: Paint empty paragraphs
     181             :     bool PaintEmpty( const SwRect &, bool bCheck ) const;
     182             : 
     183             :     void ChgThisLines(); // Must always be called if the Line count could have changed
     184             : 
     185             :     // required for 'new' relative anchor position
     186             :     void CalcBaseOfstForFly();
     187             : 
     188             :     /** method to determine height of last line, needed for proportional line spacing
     189             : 
     190             :         OD 2004-03-17 #i11860#
     191             :         OD 2005-05-20 #i47162# - introduce new optional parameter <_bUseFont>
     192             :         in order to force the usage of the former algorithm to determine the
     193             :         height of the last line, which uses the font.
     194             : 
     195             :         @param _bUseFont
     196             :         optional input parameter - boolean indicating, if the font has to be
     197             :         used to determine the height of the last line. default value: false
     198             :     */
     199             :     void _CalcHeightOfLastLine( const bool _bUseFont = false );
     200             : 
     201             :     // ST2
     202             :     SwWrongList* _SmartTagScan ( const OUString& aTxtToScan, SwWrongList *pSmartTagList,
     203             :                                  sal_Int32 nBegin,sal_Int32 nEnd,
     204             :                                  sal_Int32 nInsertPos, sal_Int32 nActPos,
     205             :                                  sal_Int32 &nChgStart, sal_Int32 &nChgEnd,
     206             :                                  sal_Int32 &nInvStart, sal_Int32 &nInvEnd);
     207             : protected:
     208             :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
     209             : 
     210             : public:
     211             : 
     212             :     com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >  GetTabStopInfo( SwTwips CurrentPos ) SAL_OVERRIDE;
     213             : 
     214             :     /**
     215             :      * This is public, as it needs to be called by some methods in order to save the Prepare
     216             :      * USE WITH CAUTION!
     217             :      */
     218             :     void Init();
     219             : 
     220             :     /// Is called by FormatSpelling()
     221             :     SwRect _AutoSpell( const SwCntntNode*, const SwViewOption&, sal_Int32 );
     222             : 
     223             :     /// Is called by FormatSpelling()
     224             :     SwRect SmartTagScan( SwCntntNode* , sal_Int32 );
     225             : 
     226             :     /// Is called by CollectAutoCmplWords()
     227             :     void CollectAutoCmplWrds( SwCntntNode* , sal_Int32 );
     228             : 
     229             :     /**
     230             :      * Returns the screen position of rPos. The values are relative to the upper
     231             :      * left position of the page frame.
     232             :      * Additional information can be obtained by passing an SwCrsrMoveState object.
     233             :      * Returns false if rPos > number of character is string
     234             :      */
     235             :     virtual bool GetCharRect( SwRect& rRect, const SwPosition& rPos,
     236             :                                 SwCrsrMoveState* pCMS = 0 ) const SAL_OVERRIDE;
     237             : 
     238             :     /// A slimmer version of GetCharRect for autopositioning Frames
     239             :     bool GetAutoPos( SwRect &, const SwPosition& ) const;
     240             : 
     241             :     /**
     242             :      * Determine top of line for given position in the text frame
     243             :      *
     244             :      * OD 11.11.2003 #i22341#
     245             :      * Assumption: given position exists in the text frame or in a follow of it
     246             :      * OD 2004-02-02 - adjustment
     247             :      * Top of first paragraph line is the top of the paragraph.
     248             :      * OD 2004-03-18 #i11860# - Consider upper space amount considered for
     249             :      * previous frame and the page grid.
     250             :      *
     251             :      * @param _onTopOfLine
     252             :      * output parameter - top of line, if the given position is found in the
     253             :      * text frame.
     254             :      *
     255             :      * @param _rPos
     256             :      * input parameter - reference to the position in the text frame
     257             :      *
     258             :      * @return boolean indicating, if the top of line for the given position
     259             :      * has been determined or not.
     260             :      */
     261             :     bool GetTopOfLine( SwTwips& _onTopOfLine,
     262             :                        const SwPosition& _rPos ) const;
     263             : 
     264             :     virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
     265             : 
     266             :     /**
     267             :      * In nOffset returns the offset of the char within the set
     268             :      * text buffer, which is closest to the position provided by
     269             :      * aPoint within the layout's SSize.
     270             :      *
     271             :      * @returns false if the SPoint is outside of the SSize else
     272             :      *          returns true
     273             :      */
     274             :     virtual bool GetCrsrOfst( SwPosition *, Point&,
     275             :                                   SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
     276             : 
     277             :     /**
     278             :      * Makes sure that the Frame is not switched (e.g. switched for a
     279             :      * character-bound Frame)
     280             :      */
     281           0 :     inline bool GetKeyCrsrOfst(SwPosition *pPos, const Point &rPoint ) const
     282           0 :             { return _GetCrsrOfst( pPos, rPoint, false ); }
     283             : 
     284             :     void   PaintExtraData( const SwRect & rRect ) const; /// Page number etc.
     285             :     SwRect Paint();
     286             :     virtual void Paint( SwRect const&,
     287             :                         SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
     288             :     virtual bool GetInfo( SfxPoolItem & ) const SAL_OVERRIDE;
     289             : 
     290             :     /**
     291             :      * Layout oriented cursor travelling:
     292             :      * Left border, right border, previous Line, following Line,
     293             :      * same horizontal position
     294             :      */
     295             :     virtual bool LeftMargin(SwPaM *) const SAL_OVERRIDE;
     296             :     virtual bool RightMargin(SwPaM *, bool bAPI = false) const SAL_OVERRIDE;
     297             : 
     298             :     virtual bool UnitUp(SwPaM *, const SwTwips nOffset = 0,
     299             :                             bool bSetInReadOnly = false ) const SAL_OVERRIDE;
     300             :     virtual bool UnitDown(SwPaM *, const SwTwips nOffset = 0,
     301             :                             bool bSetInReadOnly = false ) const SAL_OVERRIDE;
     302             :     bool _UnitUp(SwPaM *, const SwTwips nOffset = 0,
     303             :                             bool bSetInReadOnly = false ) const;
     304             :     bool _UnitDown(SwPaM *, const SwTwips nOffset = 0,
     305             :                             bool bSetInReadOnly = false ) const;
     306             : 
     307             :     /**
     308             :      * Prepares the cursor position for a visual cursor move (BiDi).
     309             :      * The behaviour is different for insert and overwrite cursors
     310             :      */
     311             :     void PrepareVisualMove( sal_Int32& nPos, sal_uInt8& nCrsrLevel,
     312             :                             bool& bRight, bool bInsertCrsr );
     313             : 
     314             :     /// Methods to manage the FollowFrame
     315             :     SwCntntFrm *SplitFrm( const sal_Int32 nTxtPos );
     316             :     SwCntntFrm *JoinFrm();
     317      969585 :     inline sal_Int32  GetOfst() const { return nOfst; }
     318             :            void        _SetOfst( const sal_Int32 nNewOfst );
     319             :     inline void        SetOfst ( const sal_Int32 nNewOfst );
     320        8909 :     inline void        ManipOfst ( const sal_Int32 nNewOfst ){ nOfst = nNewOfst; }
     321             :            SwTxtFrm   *GetFrmAtPos ( const SwPosition &rPos);
     322             :     inline const SwTxtFrm *GetFrmAtPos ( const SwPosition &rPos) const;
     323             :     SwTxtFrm&   GetFrmAtOfst( const sal_Int32 nOfst );
     324             :     /// If there's a Follow and we don't contain text ourselves
     325      103785 :     inline bool IsEmptyMaster() const
     326      103785 :         { return GetFollow() && !GetFollow()->GetOfst(); }
     327             : 
     328             :     /// Returns the text portion we want to edit (for inline see underneath)
     329             :     const OUString& GetTxt() const;
     330     7083338 :     inline SwTxtNode *GetTxtNode()
     331     7083338 :         { return static_cast< SwTxtNode* >( SwCntntFrm::GetNode()); }
     332     4047066 :     inline const SwTxtNode *GetTxtNode() const
     333     4047066 :         { return static_cast< const SwTxtNode* >( SwCntntFrm::GetNode()); }
     334             : 
     335             :     SwTxtFrm(SwTxtNode * const, SwFrm* );
     336             :     virtual ~SwTxtFrm();
     337             : 
     338             :     /**
     339             :      * SwCntntFrm: the shortcut for the Frames
     340             :      * If the void* casts wrongly, it's its own fault!
     341             :      * The void* must be checked for 0 in any case!
     342             :      */
     343             :     virtual void Prepare( const PrepareHint ePrep = PREP_CLEAR,
     344             :                           const void *pVoid = 0, bool bNotify = true ) SAL_OVERRIDE;
     345             : 
     346             :     /**
     347             :      * nMaxHeight is the required height
     348             :      * bSplit indicates, that the paragraph has to be split
     349             :      * bTst indicates, that we are currently doing a test formatting
     350             :      */
     351             :     virtual bool WouldFit( SwTwips &nMaxHeight, bool &bSplit, bool bTst ) SAL_OVERRIDE;
     352             : 
     353             :     /**
     354             :      * The WouldFit equivalent for temporarily rewired TextFrames
     355             :      * nMaxHeight returns the required size here too and bSplit
     356             :      * determines whether the paragraph needs to be split.
     357             :      * We pass the potential predecessor for the distance calculation
     358             :      */
     359             :     bool TestFormat( const SwFrm* pPrv, SwTwips &nMaxHeight, bool &bSplit );
     360             : 
     361             :     /**
     362             :      * We format a Line for interactive hyphenation
     363             :      * @return found
     364             :      */
     365             :     bool Hyphenate( SwInterHyphInfo &rInf );
     366             : 
     367             :     /// Test grow
     368             :     inline SwTwips GrowTst( const SwTwips nGrow );
     369             : 
     370             :     SwParaPortion *GetPara();
     371             :     inline const SwParaPortion *GetPara() const;
     372             :     inline bool HasPara() const;
     373             :     bool _HasPara() const;
     374             : 
     375             :     // If there are any hanging punctuation portions in the margin
     376             :     // the offset will be returned.
     377             :     SwTwips HangingMargin() const;
     378             : 
     379             :     // RTTI
     380             :     TYPEINFO_OVERRIDE();
     381      127876 :     DECL_FIXEDMEMPOOL_NEWDEL(SwTxtFrm)
     382             : 
     383             :     // Locking
     384      956949 :     inline bool IsLocked()      const { return bLocked;     }
     385             : 
     386       84913 :     inline bool IsWidow()       const { return bWidow;      }
     387         152 :     inline bool IsJustWidow()   const { return bJustWidow;  }
     388      670696 :     inline bool IsEmpty()       const { return bEmpty;      }
     389      207298 :     inline bool HasFtn()        const { return bFtn;        }
     390         912 :     inline bool IsInFtnConnect()const { return bInFtnConnect;}
     391        4505 :     inline bool IsFieldFollow() const { return bFieldFollow;}
     392             : 
     393             :     inline void SetRepaint() const;
     394             :     inline void ResetRepaint() const;
     395       12362 :     inline bool HasRepaint() const { return bRepaint; }
     396             :     inline void SetBlinkPor() const;
     397             :     inline void ResetBlinkPor() const;
     398       33988 :     inline bool HasBlinkPor() const { return bBlinkPor; }
     399           0 :     inline void SetAnimation() const
     400           0 :         { ( (SwTxtFrm*)this )->bHasAnimation = true; }
     401        2800 :     inline bool HasAnimation() const { return bHasAnimation; }
     402             : 
     403          68 :     inline bool IsSwapped() const { return bIsSwapped; }
     404             : 
     405             :     /// Does the Frm have a local footnote (in this Frm or Follow)?
     406             : #ifdef DBG_UTIL
     407             :     void CalcFtnFlag( sal_Int32 nStop = COMPLETE_STRING ); //For testing SplitFrm
     408             : #else
     409             :     void CalcFtnFlag();
     410             : #endif
     411             : 
     412             :     /// Hidden
     413             :     bool IsHiddenNow() const;       // bHidden && pOut == pPrt
     414             :     void HideHidden();              // Remove appendage if Hidden
     415             :     void HideFootnotes( sal_Int32 nStart, sal_Int32 nEnd );
     416             : 
     417             :     /**
     418             :      * Hides respectively shows objects, which are anchored at paragraph,
     419             :      * at/as a character of the paragraph, corresponding to the paragraph and
     420             :      * paragraph portion visibility.
     421             :      */
     422             :     void HideAndShowObjects();
     423             : 
     424             :     /// Ftn
     425             :     void RemoveFtn( const sal_Int32 nStart = 0,
     426             :                     const sal_Int32 nLen = COMPLETE_STRING );
     427             :     inline SwTwips GetFtnFrmHeight() const;
     428             :     SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn );
     429             :     inline const SwTxtFrm *FindFtnRef( const SwTxtFtn *pFtn ) const
     430             :     { return FindFtnRef( pFtn ); }
     431             :     void ConnectFtn( SwTxtFtn *pFtn, const SwTwips nDeadLine );
     432             : 
     433             :     /**
     434             :      * If we're a Ftn that grows towards its reference ...
     435             :      * public, because it's needed by SwCntntFrm::MakeAll
     436             :      */
     437             :     SwTwips GetFtnLine( const SwTxtFtn *pFtn ) const;
     438             : 
     439             :     /**
     440             :      * Returns the left and the right margin document coordinates
     441             :      * (taking the paragraph attributes into account)
     442             :      */
     443             :     inline SwTwips GetLeftMargin() const;
     444             :     inline SwTwips GetRightMargin() const;
     445             : 
     446             :     virtual void Format( const SwBorderAttrs *pAttrs = 0 ) SAL_OVERRIDE;
     447             :     virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
     448             : 
     449             :     /// Returns the sum of line height in pLine
     450             :     sal_uInt16 GetParHeight() const;
     451             : 
     452             :     /// Returns the remaining height
     453             :     inline SwTwips GetRstHeight() const;
     454             : 
     455             :     inline       SwTxtFrm *GetFollow();
     456             :     inline const SwTxtFrm *GetFollow() const;
     457             : 
     458             :     /// Find the page number of ErgoSum and QuoVadis
     459             :     SwTxtFrm *FindQuoVadisFrm();
     460             : 
     461             :     /**
     462             :      * Makes up for formatting if the Idle Handler has struck
     463             :      *
     464             :      * #i29062# GetFormatted() can trigger a full formatting
     465             :      * of the paragraph, causing other layout frames to become invalid. This
     466             :      * has to be avoided during painting. Therefore we need to pass the
     467             :      * information that we are currently in the paint process.
     468             :      */
     469             :     SwTxtFrm* GetFormatted( bool bForceQuickFormat = false );
     470             : 
     471             :     /// Will be moved soon
     472        1204 :     inline void SetFtn( const bool bNew ) { bFtn = bNew; }
     473             : 
     474             :     /// Respect the Follows
     475             :     inline bool IsInside( const sal_Int32 nPos ) const;
     476             : 
     477             :     const SwBodyFrm   *FindBodyFrm()   const;
     478             : 
     479             :     /// DropCaps and selections
     480        1772 :     inline bool GetDropRect( SwRect &rRect ) const
     481        1772 :     { return HasPara() && _GetDropRect( rRect ); }
     482             : 
     483     2236754 :     static SwCache *GetTxtCache() { return pTxtCache; }
     484          90 :     static void     SetTxtCache( SwCache *pNew ) { pTxtCache = pNew; }
     485             : 
     486       21832 :     static long GetMinPrtLine() { return nMinPrtLine; }
     487             :     static void SetMinPrtLine( long nNew ) { nMinPrtLine = nNew; }
     488             : 
     489     3786411 :     inline sal_uInt16 GetCacheIdx() const { return nCacheIdx; }
     490       76273 :     inline void   SetCacheIdx( const sal_uInt16 nNew ) { nCacheIdx = nNew; }
     491             : 
     492             :     /// Removes the Line information from the Cache
     493             :     void ClearPara();
     494             : 
     495             :     /// Am I a FtnFrm, with a number at the start of the paragraph?
     496      100912 :     inline bool IsFtnNumFrm() const
     497      100912 :     { return IsInFtn() && !GetIndPrev() && _IsFtnNumFrm(); }
     498             : 
     499             :     /**
     500             :      * Simulates a formatting as if there were not right margin or Flys or other
     501             :      * obstacles and returns the width
     502             :      */
     503             :     SwTwips CalcFitToContent();
     504             : 
     505             :     /**
     506             :      * Simulate format for a list item paragraph, whose list level attributes
     507             :      * are in LABEL_ALIGNMENT mode, in order to determine additional first
     508             :      * line offset for the real text formatting due to the value of label
     509             :      * adjustment attribute of the list level.
     510             :      */
     511             :     void CalcAdditionalFirstLineOffset();
     512             : 
     513      290257 :     inline SwTwips GetAdditionalFirstLineOffset() const
     514             :     {
     515      290257 :         return mnAdditionalFirstLineOffset;
     516             :     }
     517             : 
     518             :     /**
     519             :      * Returns the additional line spacing for the next paragraph
     520             :      * @param _bNoPropLineSpacing: control, whether the value of a
     521             :      *        proportional line spacing is returned or not
     522             :      */
     523             :     long GetLineSpace( const bool _bNoPropLineSpacing = false ) const;
     524             : 
     525             :     /// Returns the first line height
     526             :     sal_uInt16 FirstLineHeight() const;
     527             : 
     528             :     /// Rewires FlyInCntFrm, if nEnd > Index >= nStart
     529             :     void MoveFlyInCnt( SwTxtFrm *pNew, sal_Int32 nStart, sal_Int32 nEnd );
     530             : 
     531             :     /// Calculates the position of FlyInCntFrms
     532             :     sal_Int32 CalcFlyPos( SwFrmFmt* pSearch );
     533             : 
     534             :     /// Determines the start position and step size of the register
     535             :     bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
     536             : 
     537             :     /// Determines the line count
     538             :     sal_uInt16 GetLineCount( sal_Int32 nPos );
     539             : 
     540             :     /// For displaying the line numbers
     541      142244 :     sal_uLong GetAllLines()  const { return nAllLines; }
     542       44582 :     sal_uLong GetThisLines() const { return nThisLines;}
     543             :     void RecalcAllLines();
     544             : 
     545             :     /// Stops the animations within numberings
     546             :     void StopAnimation( OutputDevice *pOut );
     547             : 
     548             :     /// Visit all portions for Accessibility
     549             :     void VisitPortions( SwPortionHandler& rPH ) const;
     550             : 
     551             :     /// Returns the script info stored at the paraportion
     552             :     const SwScriptInfo* GetScriptInfo() const;
     553             : 
     554             :     /// Swaps width and height of the text frame
     555             :     void SwapWidthAndHeight();
     556             : 
     557             :     /**
     558             :      * Calculates the coordinates of a rectangle when switching from
     559             :      * horizontal to vertical layout
     560             :      */
     561             :     void SwitchHorizontalToVertical( SwRect& rRect ) const;
     562             : 
     563             :     /**
     564             :      * Calculates the coordinates of a point when switching from
     565             :      * horizontal to vertical layout
     566             :      */
     567             :     void SwitchHorizontalToVertical( Point& rPoint ) const;
     568             : 
     569             :     /**
     570             :      * Calculates the a limit value when switching from
     571             :      * horizontal to vertical layout
     572             :      */
     573             :     long SwitchHorizontalToVertical( long nLimit ) const;
     574             : 
     575             :     /**
     576             :      * Calculates the coordinates of a rectangle when switching from
     577             :      * vertical to horizontal layout
     578             :      */
     579             :     void SwitchVerticalToHorizontal( SwRect& rRect ) const;
     580             : 
     581             :     /**
     582             :      * Calculates the coordinates of a point when switching from
     583             :      * vertical to horizontal layout
     584             :      */
     585             :     void SwitchVerticalToHorizontal( Point& rPoint ) const;
     586             : 
     587             :     /**
     588             :      * Calculates the a limit value when switching from
     589             :      * vertical to horizontal layout
     590             :      */
     591             :     long SwitchVerticalToHorizontal( long nLimit ) const;
     592             : 
     593             :     /**
     594             :      * Calculates the coordinates of a rectangle when switching from
     595             :      * LTR to RTL layout
     596             :      */
     597             :     void SwitchLTRtoRTL( SwRect& rRect ) const;
     598             : 
     599             :     /**
     600             :      * Calculates the coordinates of a point when switching from
     601             :      * LTR to RTL layout
     602             :      */
     603             :     void SwitchLTRtoRTL( Point& rPoint ) const;
     604             : 
     605             :     /**
     606             :      * Calculates the coordinates of a rectangle when switching from
     607             :      * RTL to LTR layout
     608             :      */
     609          74 :     inline void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); }
     610             : 
     611             :     /**
     612             :      * Calculates the coordinates of a point when switching from
     613             :      * RTL to LTR layout
     614             :      */
     615           0 :     inline void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); };
     616             : 
     617        3250 :     inline bool FollowFormatAllowed() const
     618             :     {
     619        3250 :         return mbFollowFormatAllowed;
     620             :     }
     621             : 
     622       12412 :     inline void AllowFollowFormat()
     623             :     {
     624       12412 :         mbFollowFormatAllowed = true;
     625       12412 :     }
     626             : 
     627        1882 :     inline void ForbidFollowFormat()
     628             :     {
     629        1882 :         mbFollowFormatAllowed = false;
     630        1882 :     }
     631             : 
     632      533538 :     SwTwips GetBaseOfstForFly( bool bIgnoreFlysAnchoredAtThisFrame ) const
     633             :     {
     634             :         return ( bIgnoreFlysAnchoredAtThisFrame ?
     635             :                  mnFlyAnchorOfst :
     636      533538 :                  mnFlyAnchorOfstNoWrap );
     637             :     }
     638             : 
     639       56108 :     inline SwTwips GetHeightOfLastLine() const
     640             :     {
     641       56108 :         return mnHeightOfLastLine;
     642             :     }
     643             : 
     644             :     static void repaintTextFrames( const SwTxtNode& rNode );
     645             : 
     646             :     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const SAL_OVERRIDE;
     647             : };
     648             : 
     649             : class SwTxtFrmLocker
     650             : {
     651             : private:
     652             :     SwTxtFrm * const pFrm;
     653             : public:
     654      128139 :     inline SwTxtFrmLocker( SwTxtFrm *pTxtFrm )
     655      128139 :         : pFrm( pTxtFrm->IsLocked() ? 0 : pTxtFrm )
     656      128139 :     { if( pFrm ) pFrm->Lock(); }
     657      128139 :     inline ~SwTxtFrmLocker() { if( pFrm ) pFrm->Unlock(); }
     658             : };
     659             : 
     660      238451 : inline const SwParaPortion *SwTxtFrm::GetPara() const
     661             : {
     662      238451 :     return ((SwTxtFrm*)this)->GetPara();
     663             : }
     664             : 
     665     1055693 : inline bool SwTxtFrm::HasPara() const
     666             : {
     667     1055693 :     return nCacheIdx!=USHRT_MAX && _HasPara();
     668             : }
     669             : 
     670             : /// 9104: Frm().Height() - Prt().Height(), see widorp.cxx and 7455, 6114, 7908
     671             : inline SwTwips SwTxtFrm::GetRstHeight() const
     672             : {
     673             :     return !GetUpper() ? 0 : ((const SwFrm*)GetUpper())->Frm().Top()
     674             :                            + ((const SwFrm*)GetUpper())->Prt().Top()
     675             :                            + ((const SwFrm*)GetUpper())->Prt().Height()
     676             :                            - Frm().Top() - (Frm().Height() - Prt().Height());
     677             : }
     678             : 
     679             : inline SwTwips SwTxtFrm::GetLeftMargin() const
     680             : {
     681             :     return Frm().Left() + Prt().Left();
     682             : }
     683             : inline SwTwips SwTxtFrm::GetRightMargin() const
     684             : {
     685             :     return Frm().Left() + Prt().Left() + Prt().Width();
     686             : }
     687       11435 : inline SwTwips SwTxtFrm::GrowTst( const SwTwips nGrow )
     688             : {
     689       11435 :     return Grow( nGrow, true );
     690             : }
     691             : 
     692           2 : inline bool SwTxtFrm::IsInside( const sal_Int32 nPos ) const
     693             : {
     694           2 :     bool bRet = true;
     695           2 :     if( nPos < GetOfst() )
     696           0 :         bRet = false;
     697             :     else
     698             :     {
     699           2 :         const SwTxtFrm *pFoll = GetFollow();
     700           2 :         if( pFoll && nPos >= pFoll->GetOfst() )
     701           0 :             bRet = false;
     702             :     }
     703           2 :     return bRet;
     704             : }
     705             : 
     706         510 : inline SwTwips SwTxtFrm::GetFtnFrmHeight() const
     707             : {
     708         510 :     if(  !IsFollow() && IsInFtn() && HasPara() )
     709         510 :         return _GetFtnFrmHeight();
     710             :     else
     711           0 :         return 0;
     712             : }
     713             : 
     714      152793 : inline const SwTxtFrm *SwTxtFrm::GetFollow() const
     715             : {
     716      152793 :     return (const SwTxtFrm*)SwCntntFrm::GetFollow();
     717             : }
     718     1036683 : inline SwTxtFrm *SwTxtFrm::GetFollow()
     719             : {
     720     1036683 :     return (SwTxtFrm*)SwCntntFrm::GetFollow();
     721             : }
     722             : 
     723             : inline const SwTxtFrm *SwTxtFrm::GetFrmAtPos( const SwPosition &rPos) const
     724             : {
     725             :     return ((SwTxtFrm*)this)->GetFrmAtPos( rPos );
     726             : }
     727             : 
     728             : inline void SwTxtFrm::AdjustFollow( SwTxtFormatter &rLine,
     729             :     const sal_Int32 nOffset, const sal_Int32 nStrEnd, const sal_uInt8 nMode )
     730             : {
     731             :     if ( HasFollow() )
     732             :         _AdjustFollow( rLine, nOffset, nStrEnd, nMode );
     733             : }
     734             : 
     735          52 : inline void SwTxtFrm::SetOfst( const sal_Int32 nNewOfst )
     736             : {
     737          52 :     if ( nOfst != nNewOfst )
     738          52 :         _SetOfst( nNewOfst );
     739          52 : }
     740             : 
     741       82613 : inline void SwTxtFrm::SetRepaint() const
     742             : {
     743       82613 :     ((SwTxtFrm*)this)->bRepaint = true;
     744       82613 : }
     745       41695 : inline void SwTxtFrm::ResetRepaint() const
     746             : {
     747       41695 :     ((SwTxtFrm*)this)->bRepaint = false;
     748       41695 : }
     749             : 
     750         216 : inline void SwTxtFrm::SetBlinkPor() const
     751             : {
     752         216 :     ((SwTxtFrm*)this)->bBlinkPor = true;
     753         216 : }
     754       31840 : inline void SwTxtFrm::ResetBlinkPor() const
     755             : {
     756       31840 :     ((SwTxtFrm*)this)->bBlinkPor = false;
     757       31840 : }
     758             : 
     759             : #define SWAP_IF_SWAPPED( pFrm )\
     760             :     bool bUndoSwap = false;   \
     761             :     if ( pFrm->IsVertical() && pFrm->IsSwapped() )\
     762             :     {                                 \
     763             :         bUndoSwap = true;         \
     764             :         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
     765             :     }
     766             : 
     767             : #define SWAP_IF_NOT_SWAPPED( pFrm )\
     768             :     bool bUndoSwap = false;     \
     769             :     if ( pFrm->IsVertical() && ! pFrm->IsSwapped() )\
     770             :     {                                   \
     771             :         bUndoSwap = true;           \
     772             :         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();         \
     773             :     }
     774             : 
     775             : #define UNDO_SWAP( pFrm )\
     776             :     if ( bUndoSwap )\
     777             :         ((SwTxtFrm*)pFrm)->SwapWidthAndHeight();
     778             : 
     779             : /**
     780             :  * Helper class which can be used instead of the macros if a function
     781             :  * has too many returns
     782             :  */
     783             : class SwFrmSwapper
     784             : {
     785             :     const SwTxtFrm* pFrm;
     786             :     bool bUndo;
     787             : public:
     788             :     SwFrmSwapper( const SwTxtFrm* pFrm, bool bSwapIfNotSwapped );
     789             :     ~SwFrmSwapper();
     790             : };
     791             : 
     792             : class SwLayoutModeModifier
     793             : {
     794             :     const OutputDevice& rOut;
     795             :     ComplexTextLayoutMode nOldLayoutMode;
     796             : public:
     797             :     SwLayoutModeModifier( const OutputDevice& rOutp );
     798             :     ~SwLayoutModeModifier();
     799             :     void Modify( bool bChgToRTL );
     800             :     void SetAuto();
     801             : };
     802             : 
     803             : class SwDigitModeModifier
     804             : {
     805             :     const OutputDevice& rOut;
     806             :     LanguageType nOldLanguageType;
     807             : public:
     808             :     SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
     809             :     ~SwDigitModeModifier();
     810             : };
     811             : 
     812             : #endif
     813             : 
     814             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10