LibreOffice Module sw (master)  1
flowfrm.hxx
Go to the documentation of this file.
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 "frame.hxx"
24 #include "layfrm.hxx"
25 #include <swtypes.hxx>
26 
27 class SvxFormatKeepItem;
28 class SvxFormatBreakItem;
29 class SwPageFrame;
30 class SwRect;
31 class SwBorderAttrs;
32 class SwDoc;
33 class SwNodeIndex;
34 
59 {
60  // PrepareMake is allowed to lock/unlock (robustness)
61  friend inline void PrepareLock ( SwFlowFrame * );
62  friend inline void PrepareUnlock( SwFlowFrame * );
63  friend inline void TableSplitRecalcLock( SwFlowFrame * );
64  friend inline void TableSplitRecalcUnlock( SwFlowFrame * );
65  // #i44049#
67  friend class FlowFrameJoinLockGuard;
68 
69  // TableSel is allowed to reset the follow-bit
70  friend inline void UnsetFollow( SwFlowFrame *pFlow );
71 
72  friend void MakeFrames( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
73 
74  friend class SwNode2LayImpl;
75 
77 
78  // helper methods for MoveSubTree()
79  static SwLayoutFrame *CutTree( SwFrame* );
80  static bool PasteTree( SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame* );
81 
88  static bool m_bMoveBwdJump;
89 
99  const SwFrame* GetPrevFrameForUpperSpaceCalc_( const SwFrame* _pProposedPrevFrame = nullptr ) const;
100 
107 
114  const SwTwips _nUpperSpaceWithoutGrid ) const;
115 
116 protected:
119 
120  bool m_bLockJoin :1; // if true than joins (and thus deletes) are prohibited!
121  bool m_bUndersized:1; // I am smaller than needed
122  bool m_bFlyLock :1; // stop positioning of at-character flyframes
123 
124  // checks if forward flow makes sense to prevent infinite moves
125  inline bool IsFwdMoveAllowed();
126  // #i44049# - method <CalcContent(..)> has to check this property.
127  friend void CalcContent( SwLayoutFrame *pLay, bool bNoColl );
128  bool IsKeepFwdMoveAllowed( bool bIgnoreMyOwnKeepValue = false ); // like above, forward flow for Keep.
129 
137  sal_uInt8 BwdMoveNecessary( const SwPageFrame *pPage, const SwRect &rRect );
138 
139  void LockJoin() { m_bLockJoin = true; }
140  void UnlockJoin() { m_bLockJoin = false; }
141 
142  bool CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue );
143  bool MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways = false );
144  bool MoveBwd( bool &rbReformat );
145  virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool bHead, bool &rReformat )=0;
146 
147 public:
148  SwFlowFrame( SwFrame &rFrame );
149  virtual ~SwFlowFrame();
150 
151  const SwFrame& GetFrame() const { return m_rThis; }
152  SwFrame& GetFrame() { return m_rThis; }
153 
154  static bool IsMoveBwdJump() { return m_bMoveBwdJump; }
155  static void SetMoveBwdJump( bool bNew ){ m_bMoveBwdJump = bNew; }
156 
157  void SetUndersized( const bool bNew ) { m_bUndersized = bNew; }
158  bool IsUndersized() const { return m_bUndersized; }
159 
160  bool IsPrevObjMove() const;
161 
163  void MoveSubTree( SwLayoutFrame* pParent, SwFrame* pSibling = nullptr );
164 
165  bool HasFollow() const { return m_pFollow != nullptr; }
166  bool IsFollow() const { return nullptr != m_pPrecede; }
167  bool IsAnFollow( const SwFlowFrame *pFlow ) const;
168  const SwFlowFrame *GetFollow() const { return m_pFollow; }
170  void SetFollow(SwFlowFrame *const pFollow);
171 
172  const SwFlowFrame *GetPrecede() const { return m_pPrecede; }
174 
175  bool IsJoinLocked() const { return m_bLockJoin; }
176  bool IsAnyJoinLocked() const { return m_bLockJoin || HasLockedFollow(); }
177 
178  bool IsPageBreak( bool bAct ) const;
179  bool IsColBreak( bool bAct ) const;
180 
182  bool IsKeep(SvxFormatKeepItem const& rKeep,
183  SvxFormatBreakItem const& rBreak,
184  bool bBreakCheck = false ) const;
185 
186  bool HasLockedFollow() const;
187 
188  bool HasParaSpaceAtPages( bool bSct ) const;
189 
197  SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = nullptr,
198  const SwFrame* pPr = nullptr,
199  const bool _bConsiderGrid = true ) const;
200 
208 
210  SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = nullptr ) const;
211 
225  const SwBorderAttrs* _pAttrs = nullptr ) const;
226 
227  void CheckKeep();
228 
229  void SetFlyLock( bool bNew ){ m_bFlyLock = bNew; }
230  bool IsFlyLock() const { return m_bFlyLock; }
231 
232  bool ForbiddenForFootnoteCntFwd() const;
233 
234  // Casting of a Frame into a FlowFrame (if it is one, otherwise 0)
235  // These methods need to be customized in subclasses!
236  static SwFlowFrame *CastFlowFrame( SwFrame *pFrame );
237  static const SwFlowFrame *CastFlowFrame( const SwFrame *pFrame );
238 };
239 
241 {
242  return m_rThis.GetIndPrev() != nullptr;
243 }
244 
245 //use this to protect a SwLayoutFrame for a given scope from getting merged with
246 //its neighbour and thus deleted
248 {
249 private:
252 public:
253  //JoinLock pParent for the lifetime of the Cut/Paste call, etc. to avoid
254  //SwSectionFrame::MergeNext removing the pParent we're trying to reparent
255  //into
257  {
258  m_pFlow = SwFlowFrame::CastFlowFrame(pFrame);
259  if (m_pFlow)
260  {
261  m_bOldJoinLocked = m_pFlow->IsJoinLocked();
262  m_pFlow->LockJoin();
263  }
264  else
265  {
266  m_bOldJoinLocked = false;
267  }
268  }
269 
271  {
272  if (m_pFlow && !m_bOldJoinLocked)
273  m_pFlow->UnlockJoin();
274  }
275 };
276 
277 #endif
278 
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsKeepFwdMoveAllowed(bool bIgnoreMyOwnKeepValue=false)
Definition: flowfrm.cxx:121
Base class of the Writer layout elements.
Definition: frame.hxx:295
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
bool IsFollow() const
Definition: flowfrm.hxx:166
bool IsAnyJoinLocked() const
Definition: flowfrm.hxx:176
SwFlowFrame * GetPrecede()
Definition: flowfrm.hxx:173
static void SetMoveBwdJump(bool bNew)
Definition: flowfrm.hxx:155
bool MoveFwd(bool bMakePage, bool bPageBreak, bool bMoveAlways=false)
Return value tells us whether the Frame has changed the page.
Definition: flowfrm.cxx:1833
bool IsKeep(SvxFormatKeepItem const &rKeep, SvxFormatBreakItem const &rBreak, bool bBreakCheck=false) const
method to determine if a Keep needs to be considered (Breaks!)
Definition: flowfrm.cxx:176
bool IsPrevObjMove() const
Definition: flowfrm.cxx:1065
void SetFlyLock(bool bNew)
Definition: flowfrm.hxx:229
friend void TableSplitRecalcLock(SwFlowFrame *)
Definition: tabfrm.cxx:630
Definition: doc.hxx:185
static bool m_bMoveBwdJump
indicates that a backward move was done over multiple pages
Definition: flowfrm.hxx:88
bool HasFollow() const
Definition: flowfrm.hxx:165
SwTwips GetUpperSpaceAmountConsideredForPageGrid_(const SwTwips _nUpperSpaceWithoutGrid) const
method to determine the upper space amount, which is considered for the page grid ...
Definition: flowfrm.cxx:1556
SwTwips CalcLowerSpace(const SwBorderAttrs *_pAttrs=nullptr) const
calculation of lower space
Definition: flowfrm.cxx:1666
bool MoveBwd(bool &rbReformat)
Return value tells whether the Frame should change the page.
Definition: flowfrm.cxx:2036
long SwTwips
Definition: swtypes.hxx:49
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
bool IsFlyLock() const
Definition: flowfrm.hxx:230
const SwFrame * GetPrevFrameForUpperSpaceCalc_(const SwFrame *_pProposedPrevFrame=nullptr) const
helper method to determine previous frame for calculation of the upper space
Definition: flowfrm.cxx:1282
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2601
SwFrame & m_rThis
Definition: flowfrm.hxx:76
SwTwips CalcUpperSpace(const SwBorderAttrs *pAttrs=nullptr, const SwFrame *pPr=nullptr, const bool _bConsiderGrid=true) const
method to determine the upper space hold by the frame
Definition: flowfrm.cxx:1388
FlowFrameJoinLockGuard(SwLayoutFrame *pFrame)
Definition: flowfrm.hxx:256
SwFlowFrame * m_pFollow
Definition: flowfrm.hxx:117
bool m_bUndersized
Definition: flowfrm.hxx:121
bool IsFwdMoveAllowed()
Definition: flowfrm.hxx:240
bool IsPageBreak(bool bAct) const
|* If there's a hard page break before the Frame AND there's a |* predecessor on the same page...
Definition: flowfrm.cxx:1136
const SwFrame & GetFrame() const
Definition: flowfrm.hxx:151
void SetUndersized(const bool bNew)
Definition: flowfrm.hxx:157
friend void PrepareLock(SwFlowFrame *)
Definition: calcmove.cxx:203
SwFrame * GetIndPrev() const
Definition: frame.hxx:702
bool HasParaSpaceAtPages(bool bSct) const
Definition: flowfrm.cxx:1240
SwTwips CalcAddLowerSpaceAsLastInTableCell(const SwBorderAttrs *_pAttrs=nullptr) const
calculation of the additional space to be considered, if flow frame is the last inside a table cell ...
Definition: flowfrm.cxx:1706
bool IsJoinLocked() const
Definition: flowfrm.hxx:175
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:89
static bool PasteTree(SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame *)
A specialized form of Paste(), which relocates a whole chain (this and the following, in particular).
Definition: flowfrm.cxx:461
bool IsUndersized() const
Definition: flowfrm.hxx:158
void LockJoin()
Definition: flowfrm.hxx:139
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1646
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool bHead, bool &rReformat)=0
bool HasLockedFollow() const
Definition: flowfrm.cxx:109
SwFlowFrame * m_pPrecede
Definition: flowfrm.hxx:118
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual ~SwFlowFrame()
Definition: flowfrm.cxx:77
friend void MakeFrames(SwDoc *, const SwNodeIndex &, const SwNodeIndex &)
Definition: frmtool.cxx:1770
A page of the document layout.
Definition: pagefrm.hxx:40
sal_uInt8 BwdMoveNecessary(const SwPageFrame *pPage, const SwRect &rRect)
method to determine overlapping of an object that requests floating
Definition: flowfrm.cxx:270
bool CheckMoveFwd(bool &rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue)
Moves the Frame forward if it seems necessary regarding the current conditions and attributes...
Definition: flowfrm.cxx:1743
bool m_bLockJoin
Definition: flowfrm.hxx:120
const SwFlowFrame * GetPrecede() const
Definition: flowfrm.hxx:172
SwFlowFrame * GetFollow()
Definition: flowfrm.hxx:169
void MoveSubTree(SwLayoutFrame *pParent, SwFrame *pSibling=nullptr)
hook tree onto new parent with minimal operations and notifications
Definition: flowfrm.cxx:574
void CheckKeep()
Definition: flowfrm.cxx:144
void UnlockJoin()
Definition: flowfrm.hxx:140
unsigned char sal_uInt8
friend void CalcContent(SwLayoutFrame *pLay, bool bNoColl)
Definition: fly.cxx:1368
bool ForbiddenForFootnoteCntFwd() const
Definition: flowfrm.cxx:1827
SwTwips GetUpperSpaceAmountConsideredForPrevFrame() const
method to determine the upper space amount, which is considered for the previous frame ...
Definition: flowfrm.cxx:1610
The SwNode2LayImpl class does the actual work, the SwNode2Layout class is just the public interface...
Definition: node2lay.cxx:37
static SwLayoutFrame * CutTree(SwFrame *)
A specialized form of Cut(), which relocates a whole chain (this and the following, in particular).
Definition: flowfrm.cxx:385
friend void UnsetFollow(SwFlowFrame *pFlow)
Definition: tblsel.cxx:2155
bool IsColBreak(bool bAct) const
|* If there's a hard column break before the Frame AND there is |* a predecessor in the same column...
Definition: flowfrm.cxx:1199
bool m_bFlyLock
Definition: flowfrm.hxx:122
bool IsAnFollow(const SwFlowFrame *pFlow) const
Definition: flowfrm.cxx:667
SwFlowFrame * m_pFlow
Definition: flowfrm.hxx:250
SwFrame & GetFrame()
Definition: flowfrm.hxx:152
SwFlowFrame(SwFrame &rFrame)
Definition: flowfrm.cxx:68
friend void PrepareUnlock(SwFlowFrame *)
Definition: calcmove.cxx:207
friend void TableSplitRecalcUnlock(SwFlowFrame *)
Definition: tabfrm.cxx:631
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
static bool IsMoveBwdJump()
Definition: flowfrm.hxx:154