LCOV - code coverage report
Current view: top level - sw/source/core/inc - flowfrm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 19 100.0 %
Date: 2012-08-25 Functions: 18 18 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 6 66.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _FLOWFRM_HXX
      30                 :            : #define _FLOWFRM_HXX
      31                 :            : 
      32                 :            : class SwPageFrm;
      33                 :            : class SwRect;
      34                 :            : class SwBorderAttrs;
      35                 :            : class SwDoc;
      36                 :            : class SwNodeIndex;
      37                 :            : // #i44049#
      38                 :            : class SwObjectFormatterTxtFrm;
      39                 :            : 
      40                 :            : void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
      41                 :            : 
      42                 :            : /** Base class that provides the general functionalities for frames that are
      43                 :            :     allowed at page breaks (flow) and shall continue on the next page (can be
      44                 :            :     split), e.g. paragraphs (CntntFrm) or tables (TabFrm).
      45                 :            : 
      46                 :            :     Some parts of these functionalities are implemented in FlowFrm while the
      47                 :            :     specific ones are done in the corresponding Frm classes. The FlowFrm has to
      48                 :            :     be seen as a base class. As such it is no Frm by itself and thus no direct
      49                 :            :     instances of FlowFrm can exist.
      50                 :            : 
      51                 :            :     Actually it is not even a real Frm. The obvious implementation would be a
      52                 :            :     FlowFrm that is virtually inherited from SwFrm and that works with its own
      53                 :            :     member data. Further classes would need to inherit from FlowFrm and (via
      54                 :            :     multiple base classes since the class tree splits exactly at the branch
      55                 :            :     from SwFrm to SwCntntFrm and SwLayoutFrm) also virtually from SwFrm as
      56                 :            :     well. Unfortunately, this leads - besides problems with compilers and
      57                 :            :     debugging programs - to high additional costs, that we IMHO are not able to
      58                 :            :     afford nowadays.
      59                 :            : 
      60                 :            :     Hence, we use another technique: A FlowFrm keeps a reference to a SwFrm
      61                 :            :     - which it is actually itself - and they are friends. As a result, the
      62                 :            :     FlowFrm can work with the reference to the SwFrm instead of working with
      63                 :            :     its own this-pointer.
      64                 :            :  */
      65                 :            : class SwFlowFrm
      66                 :            : {
      67                 :            :     // PrepareMake is allowed to lock/unlock (robustness)
      68                 :            :     friend inline void PrepareLock  ( SwFlowFrm * );
      69                 :            :     friend inline void PrepareUnlock( SwFlowFrm * );
      70                 :            :     friend inline void TableSplitRecalcLock( SwFlowFrm * );
      71                 :            :     friend inline void TableSplitRecalcUnlock( SwFlowFrm * );
      72                 :            :     // #i44049#
      73                 :            :     friend class SwObjectFormatterTxtFrm;
      74                 :            : 
      75                 :            :     // TblSel is allowed to reset the follow-bit
      76                 :            :     friend inline void UnsetFollow( SwFlowFrm *pFlow );
      77                 :            : 
      78                 :            :     friend void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
      79                 :            : 
      80                 :            :     friend class SwNode2LayImpl;
      81                 :            : 
      82                 :            :     SwFrm &rThis;
      83                 :            : 
      84                 :            :     // helper methods for MoveSubTree()
      85                 :            :     static SwLayoutFrm *CutTree( SwFrm* );
      86                 :            :     static sal_Bool   PasteTree( SwFrm *, SwLayoutFrm *, SwFrm *, SwFrm* );
      87                 :            : 
      88                 :            :     /** indicates that a backward move was done over multiple pages
      89                 :            : 
      90                 :            :         Needed for the interaction of _GetPrevxxx and MoveBwd so that multiple
      91                 :            :         pages can be skipped at the same time. In addition, it is evaluated by
      92                 :            :         the MoveBwd() method in TabFrm.
      93                 :            :     */
      94                 :            :     static sal_Bool bMoveBwdJump;
      95                 :            : 
      96                 :            :     /** helper method to determine previous frame for calculation of the
      97                 :            :         upper space
      98                 :            : 
      99                 :            :         #i11860#
     100                 :            : 
     101                 :            :         @param _pProposedPrevFrm
     102                 :            :         optional input parameter - pointer to frame, which should be used
     103                 :            :         instead of the direct previous frame.
     104                 :            :     */
     105                 :            :     const SwFrm* _GetPrevFrmForUpperSpaceCalc( const SwFrm* _pProposedPrevFrm = 0L ) const;
     106                 :            : 
     107                 :            :     /** method to detemine the upper space amount, which is considered for
     108                 :            :         the previous frame
     109                 :            : 
     110                 :            :         #i11860#
     111                 :            :     */
     112                 :            :     SwTwips _GetUpperSpaceAmountConsideredForPrevFrm() const;
     113                 :            : 
     114                 :            :     /** method to detemine the upper space amount, which is considered for
     115                 :            :         the page grid
     116                 :            : 
     117                 :            :         #i11860#
     118                 :            :     */
     119                 :            :     SwTwips _GetUpperSpaceAmountConsideredForPageGrid(
     120                 :            :                                 const SwTwips _nUpperSpaceWithoutGrid ) const;
     121                 :            : 
     122                 :            : protected:
     123                 :            :     SwFlowFrm *m_pFollow;
     124                 :            :     SwFlowFrm *m_pPrecede;
     125                 :            : 
     126                 :            :     sal_Bool bLockJoin  :1; // if sal_True than joins (and thus deletes) are prohibited!
     127                 :            :     sal_Bool bUndersized:1; // I am smaller than needed
     128                 :            :     sal_Bool bFlyLock   :1; // stop positioning of at-character flyframes
     129                 :            : 
     130                 :            :     // checks if forward flow makes sense to prevent infinite moves
     131                 :            :     inline sal_Bool IsFwdMoveAllowed();
     132                 :            :     // #i44049# - method <CalcCntnt(..)> has to check this property.
     133                 :            :     friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );
     134                 :            :     sal_Bool IsKeepFwdMoveAllowed();    // like above, forward flow for Keep.
     135                 :            : 
     136                 :            :     /** method to determine overlapping of an object that requests floating
     137                 :            : 
     138                 :            :         0: no overlapping
     139                 :            :         1: objects that are anchored at the FlowFrm overlap
     140                 :            :         2: objects that are anchored somewhere else overlap
     141                 :            :         3: both types of objects overlap
     142                 :            :     */
     143                 :            :     sal_uInt8 BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect );
     144                 :            : 
     145                 :      25916 :     void LockJoin()   { bLockJoin = sal_True;  }
     146                 :      24912 :     void UnlockJoin() { bLockJoin = sal_False; }
     147                 :            : 
     148                 :            :     sal_Bool CheckMoveFwd( bool& rbMakePage, sal_Bool bKeep, sal_Bool bMovedBwd );
     149                 :            :     sal_Bool MoveFwd( sal_Bool bMakePage, sal_Bool bPageBreak, sal_Bool bMoveAlways = sal_False );
     150                 :            :     sal_Bool MoveBwd( sal_Bool &rbReformat );
     151                 :            :     virtual sal_Bool ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool bHead, sal_Bool &rReformat )=0;
     152                 :            : 
     153                 :            : public:
     154                 :            :     SwFlowFrm( SwFrm &rFrm );
     155                 :            :     virtual ~SwFlowFrm();
     156                 :            : 
     157                 :        219 :     const SwFrm *GetFrm() const { return &rThis; }
     158                 :        434 :           SwFrm *GetFrm()       { return &rThis; }
     159                 :            : 
     160                 :       2086 :     static sal_Bool IsMoveBwdJump() { return bMoveBwdJump; }
     161                 :      12929 :     static void SetMoveBwdJump( sal_Bool bNew ){ bMoveBwdJump = bNew; }
     162                 :            : 
     163                 :       3034 :     inline void SetUndersized( const sal_Bool bNew ) { bUndersized = bNew; }
     164                 :     129784 :     inline sal_Bool IsUndersized()  const { return bUndersized; }
     165                 :            : 
     166                 :            :     sal_Bool IsPrevObjMove() const;
     167                 :            : 
     168                 :            :     /** hook tree onto new parent with minimal operations and notifications */
     169                 :            :     void MoveSubTree( SwLayoutFrm* pParent, SwFrm* pSibling = 0 );
     170                 :            : 
     171         [ +  + ]:     174696 :     sal_Bool HasFollow() const { return m_pFollow ? sal_True : sal_False; }
     172                 :    1204492 :     sal_Bool IsFollow() const { return 0 != m_pPrecede; }
     173                 :            :     sal_Bool IsAnFollow( const SwFlowFrm *pFlow ) const;
     174                 :      98721 :     const SwFlowFrm *GetFollow() const { return m_pFollow; }
     175                 :     542350 :           SwFlowFrm *GetFollow()       { return m_pFollow; }
     176                 :            :     void SetFollow(SwFlowFrm *const pFollow);
     177                 :            : 
     178                 :      39861 :     const SwFlowFrm *GetPrecede() const { return m_pPrecede; }
     179                 :            :           SwFlowFrm *GetPrecede()       { return m_pPrecede; }
     180                 :            : 
     181                 :      35226 :     sal_Bool IsJoinLocked() const { return bLockJoin; }
     182 [ +  - ][ -  + ]:        299 :     sal_Bool IsAnyJoinLocked() const { return bLockJoin || HasLockedFollow(); }
     183                 :            : 
     184                 :            :     sal_Bool IsPageBreak( sal_Bool bAct ) const;
     185                 :            :     sal_Bool IsColBreak( sal_Bool bAct ) const;
     186                 :            : 
     187                 :            :     /** method to determine if a Keep needs to be considered (Breaks!) */
     188                 :            :     sal_Bool IsKeep( const SwAttrSet& rAttrs, bool bBreakCheck = false ) const;
     189                 :            : 
     190                 :            :     sal_Bool HasLockedFollow() const;
     191                 :            : 
     192                 :            :     sal_Bool HasParaSpaceAtPages( sal_Bool bSct ) const;
     193                 :            : 
     194                 :            :     /** method to determine the upper space hold by the frame
     195                 :            : 
     196                 :            :         #i11860#
     197                 :            : 
     198                 :            :         @param _bConsiderGrid
     199                 :            :         optional input parameter - consider the page grid while calculating?
     200                 :            :     */
     201                 :            :     SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = NULL,
     202                 :            :                             const SwFrm* pPr = NULL,
     203                 :            :                             const bool _bConsiderGrid = true ) const;
     204                 :            : 
     205                 :            :     /** method to determine the upper space amount, which is considered for
     206                 :            :         the previous frame and the page grid, if option 'Use former object
     207                 :            :         positioning' is OFF
     208                 :            : 
     209                 :            :         #i11860#
     210                 :            :     */
     211                 :            :     SwTwips GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() const;
     212                 :            : 
     213                 :            :     /** calculation of lower space */
     214                 :            :     SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = 0L ) const;
     215                 :            : 
     216                 :            :     /** calculation of the additional space to be considered, if flow frame
     217                 :            :         is the last inside a table cell
     218                 :            : 
     219                 :            :         #i26250
     220                 :            : 
     221                 :            :         @param _pAttrs
     222                 :            :         optional input parameter - border attributes of the flow frame.
     223                 :            :         Used for optimization, if caller has already determined the border
     224                 :            :         attributes.
     225                 :            : 
     226                 :            :         @return SwTwips
     227                 :            :     */
     228                 :            :     SwTwips CalcAddLowerSpaceAsLastInTableCell(
     229                 :            :                                     const SwBorderAttrs* _pAttrs = 0L ) const;
     230                 :            : 
     231                 :            :     void CheckKeep();
     232                 :            : 
     233                 :      22553 :     void SetFlyLock( sal_Bool bNew ){ bFlyLock = bNew; }
     234                 :      22553 :     sal_Bool IsFlyLock() const {    return bFlyLock; }
     235                 :            : 
     236                 :            :     // Casting of a Frm into a FlowFrm (if it is one, otherwise 0)
     237                 :            :     // These methods need to be customized in subclasses!
     238                 :            :     static       SwFlowFrm *CastFlowFrm( SwFrm *pFrm );
     239                 :            :     static const SwFlowFrm *CastFlowFrm( const SwFrm *pFrm );
     240                 :            : };
     241                 :            : 
     242                 :        300 : inline sal_Bool SwFlowFrm::IsFwdMoveAllowed()
     243                 :            : {
     244                 :        300 :     return rThis.GetIndPrev() != 0;
     245                 :            : }
     246                 :            : #endif
     247                 :            : 
     248                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10