LCOV - code coverage report
Current view: top level - sw/source/core/inc - flowfrm.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 20 20 100.0 %
Date: 2014-11-03 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             : #include "frmtool.hxx"
      24             : 
      25             : class SwPageFrm;
      26             : class SwRect;
      27             : class SwBorderAttrs;
      28             : class SwDoc;
      29             : class SwNodeIndex;
      30             : // #i44049#
      31             : class SwObjectFormatterTxtFrm;
      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 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 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             :     bool m_bLockJoin  :1; // if sal_True than joins (and thus deletes) are prohibited!
     118             :     bool m_bUndersized:1; // I am smaller than needed
     119             :     bool m_bFlyLock   :1; // stop positioning of at-character flyframes
     120             : 
     121             :     // checks if forward flow makes sense to prevent infinite moves
     122             :     inline bool IsFwdMoveAllowed();
     123             :     // #i44049# - method <CalcCntnt(..)> has to check this property.
     124             :     friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );
     125             :     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      167597 :     void LockJoin()   { m_bLockJoin = true;  }
     137      146997 :     void UnlockJoin() { m_bLockJoin = false; }
     138             : 
     139             :     bool CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bMovedBwd );
     140             :     bool MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways = 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       13892 :     const SwFrm& GetFrm() const { return m_rThis; }
     149       31164 :           SwFrm& GetFrm()       { return m_rThis; }
     150             : 
     151       32437 :     static bool IsMoveBwdJump() { return m_bMoveBwdJump; }
     152       74087 :     static void SetMoveBwdJump( bool bNew ){ m_bMoveBwdJump = bNew; }
     153             : 
     154       38682 :     inline void SetUndersized( const bool bNew ) { m_bUndersized = bNew; }
     155      547076 :     inline bool IsUndersized()  const { return m_bUndersized; }
     156             : 
     157             :     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      662469 :     bool HasFollow() const { return m_pFollow ? sal_True : sal_False; }
     163     4755484 :     bool IsFollow() const { return 0 != m_pPrecede; }
     164             :     bool IsAnFollow( const SwFlowFrm *pFlow ) const;
     165      531804 :     const SwFlowFrm *GetFollow() const { return m_pFollow; }
     166     1967561 :           SwFlowFrm *GetFollow()       { return m_pFollow; }
     167             :     void SetFollow(SwFlowFrm *const pFollow);
     168             : 
     169       71218 :     const SwFlowFrm *GetPrecede() const { return m_pPrecede; }
     170        1568 :           SwFlowFrm *GetPrecede()       { return m_pPrecede; }
     171             : 
     172      332743 :     bool IsJoinLocked() const { return m_bLockJoin; }
     173        9095 :     bool IsAnyJoinLocked() const { return m_bLockJoin || HasLockedFollow(); }
     174             : 
     175             :     bool IsPageBreak( bool bAct ) const;
     176             :     bool IsColBreak( bool bAct ) const;
     177             : 
     178             :     /** method to determine if a Keep needs to be considered (Breaks!) */
     179             :     bool IsKeep( const SwAttrSet& rAttrs, bool bBreakCheck = false ) const;
     180             : 
     181             :     bool HasLockedFollow() const;
     182             : 
     183             :     bool HasParaSpaceAtPages( 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      130215 :     void SetFlyLock( bool bNew ){ m_bFlyLock = bNew; }
     225      131023 :     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        4696 : inline bool SwFlowFrm::IsFwdMoveAllowed()
     234             : {
     235        4696 :     return m_rThis.GetIndPrev() != 0;
     236             : }
     237             : #endif
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10