LCOV - code coverage report
Current view: top level - sw/source/core/inc - flowfrm.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 20 20 100.0 %
Date: 2014-04-11 Functions: 19 19 100.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             : 
      20             : #ifndef INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX
      21             : #define INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX
      22             : 
      23             : class SwPageFrm;
      24             : class SwRect;
      25             : class SwBorderAttrs;
      26             : class SwDoc;
      27             : class SwNodeIndex;
      28             : // #i44049#
      29             : class SwObjectFormatterTxtFrm;
      30             : 
      31             : void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
      32             : 
      33             : /** Base class that provides the general functionalities for frames that are
      34             :     allowed at page breaks (flow) and shall continue on the next page (can be
      35             :     split), e.g. paragraphs (CntntFrm) or tables (TabFrm).
      36             : 
      37             :     Some parts of these functionalities are implemented in FlowFrm while the
      38             :     specific ones are done in the corresponding Frm classes. The FlowFrm has to
      39             :     be seen as a base class. As such it is no Frm by itself and thus no direct
      40             :     instances of FlowFrm can exist.
      41             : 
      42             :     Actually it is not even a real Frm. The obvious implementation would be a
      43             :     FlowFrm that is virtually inherited from SwFrm and that works with its own
      44             :     member data. Further classes would need to inherit from FlowFrm and (via
      45             :     multiple base classes since the class tree splits exactly at the branch
      46             :     from SwFrm to SwCntntFrm and SwLayoutFrm) also virtually from SwFrm as
      47             :     well. Unfortunately, this leads - besides problems with compilers and
      48             :     debugging programs - to high additional costs, that we IMHO are not able to
      49             :     afford nowadays.
      50             : 
      51             :     Hence, we use another technique: A FlowFrm keeps a reference to a SwFrm
      52             :     - which it is actually itself - and they are friends. As a result, the
      53             :     FlowFrm can work with the reference to the SwFrm instead of working with
      54             :     its own this-pointer.
      55             :  */
      56             : class SwFlowFrm
      57             : {
      58             :     // PrepareMake is allowed to lock/unlock (robustness)
      59             :     friend inline void PrepareLock  ( SwFlowFrm * );
      60             :     friend inline void PrepareUnlock( SwFlowFrm * );
      61             :     friend inline void TableSplitRecalcLock( SwFlowFrm * );
      62             :     friend inline void TableSplitRecalcUnlock( SwFlowFrm * );
      63             :     // #i44049#
      64             :     friend class SwObjectFormatterTxtFrm;
      65             : 
      66             :     // TblSel is allowed to reset the follow-bit
      67             :     friend inline void UnsetFollow( SwFlowFrm *pFlow );
      68             : 
      69             :     friend void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
      70             : 
      71             :     friend class SwNode2LayImpl;
      72             : 
      73             :     SwFrm& m_rThis;
      74             : 
      75             :     // helper methods for MoveSubTree()
      76             :     static SwLayoutFrm *CutTree( SwFrm* );
      77             :     static sal_Bool   PasteTree( SwFrm *, SwLayoutFrm *, SwFrm *, SwFrm* );
      78             : 
      79             :     /** indicates that a backward move was done over multiple pages
      80             : 
      81             :         Needed for the interaction of _GetPrevxxx and MoveBwd so that multiple
      82             :         pages can be skipped at the same time. In addition, it is evaluated by
      83             :         the MoveBwd() method in TabFrm.
      84             :     */
      85             :     static sal_Bool m_bMoveBwdJump;
      86             : 
      87             :     /** helper method to determine previous frame for calculation of the
      88             :         upper space
      89             : 
      90             :         #i11860#
      91             : 
      92             :         @param _pProposedPrevFrm
      93             :         optional input parameter - pointer to frame, which should be used
      94             :         instead of the direct previous frame.
      95             :     */
      96             :     const SwFrm* _GetPrevFrmForUpperSpaceCalc( const SwFrm* _pProposedPrevFrm = 0L ) const;
      97             : 
      98             :     /** method to detemine the upper space amount, which is considered for
      99             :         the previous frame
     100             : 
     101             :         #i11860#
     102             :     */
     103             :     SwTwips _GetUpperSpaceAmountConsideredForPrevFrm() const;
     104             : 
     105             :     /** method to detemine the upper space amount, which is considered for
     106             :         the page grid
     107             : 
     108             :         #i11860#
     109             :     */
     110             :     SwTwips _GetUpperSpaceAmountConsideredForPageGrid(
     111             :                                 const SwTwips _nUpperSpaceWithoutGrid ) const;
     112             : 
     113             : protected:
     114             :     SwFlowFrm *m_pFollow;
     115             :     SwFlowFrm *m_pPrecede;
     116             : 
     117             :     sal_Bool m_bLockJoin  :1; // if sal_True than joins (and thus deletes) are prohibited!
     118             :     sal_Bool m_bUndersized:1; // I am smaller than needed
     119             :     sal_Bool m_bFlyLock   :1; // stop positioning of at-character flyframes
     120             : 
     121             :     // checks if forward flow makes sense to prevent infinite moves
     122             :     inline sal_Bool IsFwdMoveAllowed();
     123             :     // #i44049# - method <CalcCntnt(..)> has to check this property.
     124             :     friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );
     125             :     sal_Bool IsKeepFwdMoveAllowed();    // like above, forward flow for Keep.
     126             : 
     127             :     /** method to determine overlapping of an object that requests floating
     128             : 
     129             :         0: no overlapping
     130             :         1: objects that are anchored at the FlowFrm overlap
     131             :         2: objects that are anchored somewhere else overlap
     132             :         3: both types of objects overlap
     133             :     */
     134             :     sal_uInt8 BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect );
     135             : 
     136       63781 :     void LockJoin()   { m_bLockJoin = sal_True;  }
     137       54157 :     void UnlockJoin() { m_bLockJoin = sal_False; }
     138             : 
     139             :     sal_Bool CheckMoveFwd( bool& rbMakePage, sal_Bool bKeep, sal_Bool bMovedBwd );
     140             :     sal_Bool MoveFwd( sal_Bool bMakePage, sal_Bool bPageBreak, sal_Bool bMoveAlways = sal_False );
     141             :     bool MoveBwd( bool &rbReformat );
     142             :     virtual bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, bool bHead, bool &rReformat )=0;
     143             : 
     144             : public:
     145             :     SwFlowFrm( SwFrm &rFrm );
     146             :     virtual ~SwFlowFrm();
     147             : 
     148        4768 :     const SwFrm *GetFrm() const { return &m_rThis; }
     149       14993 :           SwFrm *GetFrm()       { return &m_rThis; }
     150             : 
     151       11417 :     static sal_Bool IsMoveBwdJump() { return m_bMoveBwdJump; }
     152       23202 :     static void SetMoveBwdJump( sal_Bool bNew ){ m_bMoveBwdJump = bNew; }
     153             : 
     154       12881 :     inline void SetUndersized( const sal_Bool bNew ) { m_bUndersized = bNew; }
     155      195326 :     inline sal_Bool IsUndersized()  const { return m_bUndersized; }
     156             : 
     157             :     sal_Bool IsPrevObjMove() const;
     158             : 
     159             :     /** hook tree onto new parent with minimal operations and notifications */
     160             :     void MoveSubTree( SwLayoutFrm* pParent, SwFrm* pSibling = 0 );
     161             : 
     162      232418 :     sal_Bool HasFollow() const { return m_pFollow ? sal_True : sal_False; }
     163     1777693 :     sal_Bool IsFollow() const { return 0 != m_pPrecede; }
     164             :     sal_Bool IsAnFollow( const SwFlowFrm *pFlow ) const;
     165      210359 :     const SwFlowFrm *GetFollow() const { return m_pFollow; }
     166      820727 :           SwFlowFrm *GetFollow()       { return m_pFollow; }
     167             :     void SetFollow(SwFlowFrm *const pFollow);
     168             : 
     169       28640 :     const SwFlowFrm *GetPrecede() const { return m_pPrecede; }
     170         629 :           SwFlowFrm *GetPrecede()       { return m_pPrecede; }
     171             : 
     172      129543 :     sal_Bool IsJoinLocked() const { return m_bLockJoin; }
     173        2080 :     sal_Bool IsAnyJoinLocked() const { return m_bLockJoin || HasLockedFollow(); }
     174             : 
     175             :     sal_Bool IsPageBreak( sal_Bool bAct ) const;
     176             :     sal_Bool IsColBreak( sal_Bool bAct ) const;
     177             : 
     178             :     /** method to determine if a Keep needs to be considered (Breaks!) */
     179             :     sal_Bool IsKeep( const SwAttrSet& rAttrs, bool bBreakCheck = false ) const;
     180             : 
     181             :     sal_Bool HasLockedFollow() const;
     182             : 
     183             :     sal_Bool HasParaSpaceAtPages( sal_Bool bSct ) const;
     184             : 
     185             :     /** method to determine the upper space hold by the frame
     186             : 
     187             :         #i11860#
     188             : 
     189             :         @param _bConsiderGrid
     190             :         optional input parameter - consider the page grid while calculating?
     191             :     */
     192             :     SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = NULL,
     193             :                             const SwFrm* pPr = NULL,
     194             :                             const bool _bConsiderGrid = true ) const;
     195             : 
     196             :     /** method to determine the upper space amount, which is considered for
     197             :         the previous frame and the page grid, if option 'Use former object
     198             :         positioning' is OFF
     199             : 
     200             :         #i11860#
     201             :     */
     202             :     SwTwips GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() const;
     203             : 
     204             :     /** calculation of lower space */
     205             :     SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = 0L ) const;
     206             : 
     207             :     /** calculation of the additional space to be considered, if flow frame
     208             :         is the last inside a table cell
     209             : 
     210             :         #i26250
     211             : 
     212             :         @param _pAttrs
     213             :         optional input parameter - border attributes of the flow frame.
     214             :         Used for optimization, if caller has already determined the border
     215             :         attributes.
     216             : 
     217             :         @return SwTwips
     218             :     */
     219             :     SwTwips CalcAddLowerSpaceAsLastInTableCell(
     220             :                                     const SwBorderAttrs* _pAttrs = 0L ) const;
     221             : 
     222             :     void CheckKeep();
     223             : 
     224       47446 :     void SetFlyLock( sal_Bool bNew ){ m_bFlyLock = bNew; }
     225       47848 :     sal_Bool IsFlyLock() const {    return m_bFlyLock; }
     226             : 
     227             :     // Casting of a Frm into a FlowFrm (if it is one, otherwise 0)
     228             :     // These methods need to be customized in subclasses!
     229             :     static       SwFlowFrm *CastFlowFrm( SwFrm *pFrm );
     230             :     static const SwFlowFrm *CastFlowFrm( const SwFrm *pFrm );
     231             : };
     232             : 
     233        1700 : inline sal_Bool SwFlowFrm::IsFwdMoveAllowed()
     234             : {
     235        1700 :     return m_rThis.GetIndPrev() != 0;
     236             : }
     237             : #endif
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10