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
29class SwPageFrame;
30class SwRect;
31class SwBorderAttrs;
32class SwDoc;
33class SwNode;
34class SwNodeIndex;
35
60{
61 // PrepareMake is allowed to lock/unlock (robustness)
62 friend inline void PrepareLock ( SwFlowFrame * );
63 friend inline void PrepareUnlock( SwFlowFrame * );
64 friend inline void TableSplitRecalcLock( SwFlowFrame * );
65 friend inline void TableSplitRecalcUnlock( SwFlowFrame * );
66 // #i44049#
69
70 // TableSel is allowed to reset the follow-bit
71 friend inline void UnsetFollow( SwFlowFrame *pFlow );
72
73 friend void MakeFrames( SwDoc *, SwNode &, SwNode & );
74
75 friend class SwNode2LayImpl;
76
78
79 // helper methods for MoveSubTree()
80 static SwLayoutFrame *CutTree( SwFrame* );
81 static bool PasteTree( SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame* );
82
89 static bool s_bMoveBwdJump;
90
100 const SwFrame* GetPrevFrameForUpperSpaceCalc_( const SwFrame* _pProposedPrevFrame = nullptr ) const;
101
108
115 const SwTwips _nUpperSpaceWithoutGrid ) const;
116
117protected:
120
121 bool m_bLockJoin :1; // if true than joins (and thus deletes) are prohibited!
122 bool m_bUndersized:1; // I am smaller than needed
123 bool m_bFlyLock :1; // stop positioning of at-character flyframes
124
125 // checks if forward flow makes sense to prevent infinite moves
126 inline bool IsFwdMoveAllowed() const;
127 // #i44049# - method <CalcContent(..)> has to check this property.
128 friend void CalcContent( SwLayoutFrame *pLay, bool bNoColl );
129 bool IsKeepFwdMoveAllowed( bool bIgnoreMyOwnKeepValue = false ); // like above, forward flow for Keep.
130
138 sal_uInt8 BwdMoveNecessary( const SwPageFrame *pPage, const SwRect &rRect );
139
140 void LockJoin() { m_bLockJoin = true; }
141 void UnlockJoin() { m_bLockJoin = false; }
142
143 bool CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue );
144 bool MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways = false );
145 bool MoveBwd( bool &rbReformat );
146 virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat )=0;
147
148public:
149 SwFlowFrame( SwFrame &rFrame );
150 virtual ~SwFlowFrame();
151
152 const SwFrame& GetFrame() const { return m_rThis; }
153 SwFrame& GetFrame() { return m_rThis; }
154
155 static bool IsMoveBwdJump() { return s_bMoveBwdJump; }
156 static void SetMoveBwdJump( bool bNew ){ s_bMoveBwdJump = bNew; }
157
158 void SetUndersized( const bool bNew ) { m_bUndersized = bNew; }
159 bool IsUndersized() const { return m_bUndersized; }
160
161 bool IsPrevObjMove() const;
162
164 void MoveSubTree( SwLayoutFrame* pParent, SwFrame* pSibling = nullptr );
165
166 bool HasFollow() const { return m_pFollow != nullptr; }
167 bool IsFollow() const { return nullptr != m_pPrecede; }
168 bool IsAnFollow( const SwFlowFrame *pFlow ) const;
169 const SwFlowFrame *GetFollow() const { return m_pFollow; }
171 void SetFollow(SwFlowFrame *const pFollow);
172
173 const SwFlowFrame *GetPrecede() const { return m_pPrecede; }
175
176 bool IsJoinLocked() const { return m_bLockJoin; }
177 bool IsAnyJoinLocked() const { return m_bLockJoin || HasLockedFollow(); }
178
179 bool IsPageBreak( bool bAct ) const;
180 bool IsColBreak( bool bAct ) const;
181
183 bool IsKeep(SvxFormatKeepItem const& rKeep,
184 SvxFormatBreakItem const& rBreak,
185 bool bBreakCheck = false ) const;
186
187 bool HasLockedFollow() const;
188
189 bool HasParaSpaceAtPages( bool bSct ) const;
190
198 SwTwips CalcUpperSpace( const SwBorderAttrs *pAttrs = nullptr,
199 const SwFrame* pPr = nullptr,
200 const bool _bConsiderGrid = true ) const;
201
209
211 SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = nullptr ) const;
212
226 const SwBorderAttrs* _pAttrs = nullptr ) const;
227
228 void CheckKeep();
229
230 void SetFlyLock( bool bNew ){ m_bFlyLock = bNew; }
231 bool IsFlyLock() const { return m_bFlyLock; }
232
233 bool ForbiddenForFootnoteCntFwd() const;
234
235 // Casting of a Frame into a FlowFrame (if it is one, otherwise 0)
236 // These methods need to be customized in subclasses!
237 static SwFlowFrame *CastFlowFrame( SwFrame *pFrame );
238 static const SwFlowFrame *CastFlowFrame( const SwFrame *pFrame );
239};
240
242{
243 return m_rThis.GetIndPrev() != nullptr;
244}
245
246//use this to protect a SwLayoutFrame for a given scope from getting merged with
247//its neighbour and thus deleted
249{
250private:
253public:
254 //JoinLock pParent for the lifetime of the Cut/Paste call, etc. to avoid
255 //SwSectionFrame::MergeNext removing the pParent we're trying to reparent
256 //into
258 {
260 if (m_pFlow)
261 {
263 m_pFlow->LockJoin();
264 }
265 else
266 {
267 m_bOldJoinLocked = false;
268 }
269 }
270
272 {
275 }
276};
277
278#endif
279
280/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFlowFrame * m_pFlow
Definition: flowfrm.hxx:251
FlowFrameJoinLockGuard(SwLayoutFrame *pFrame)
Definition: flowfrm.hxx:257
Definition: doc.hxx:194
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:60
SwTwips GetUpperSpaceAmountConsideredForPageGrid_(const SwTwips _nUpperSpaceWithoutGrid) const
method to determine the upper space amount, which is considered for the page grid
Definition: flowfrm.cxx:1646
bool IsJoinLocked() const
Definition: flowfrm.hxx:176
static void SetMoveBwdJump(bool bNew)
Definition: flowfrm.hxx:156
bool IsFlyLock() const
Definition: flowfrm.hxx:231
SwFlowFrame(SwFrame &rFrame)
Definition: flowfrm.cxx:70
void MoveSubTree(SwLayoutFrame *pParent, SwFrame *pSibling=nullptr)
hook tree onto new parent with minimal operations and notifications
Definition: flowfrm.cxx:634
friend void UnsetFollow(SwFlowFrame *pFlow)
Definition: tblsel.cxx:2153
static bool PasteTree(SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame *)
A specialized form of Paste(), which relocates a whole chain (this and the following,...
Definition: flowfrm.cxx:519
friend void PrepareUnlock(SwFlowFrame *)
Definition: calcmove.cxx:212
friend void CalcContent(SwLayoutFrame *pLay, bool bNoColl)
Definition: fly.cxx:1423
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:1206
bool IsFwdMoveAllowed() const
Definition: flowfrm.hxx:241
SwFrame & GetFrame()
Definition: flowfrm.hxx:153
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:169
bool IsAnyJoinLocked() const
Definition: flowfrm.hxx:177
sal_uInt8 BwdMoveNecessary(const SwPageFrame *pPage, const SwRect &rRect)
method to determine overlapping of an object that requests floating
Definition: flowfrm.cxx:329
static bool s_bMoveBwdJump
indicates that a backward move was done over multiple pages
Definition: flowfrm.hxx:89
bool IsPrevObjMove() const
Definition: flowfrm.cxx:1124
bool IsAnFollow(const SwFlowFrame *pFlow) const
Definition: flowfrm.cxx:726
SwFlowFrame * GetFollow()
Definition: flowfrm.hxx:170
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:1457
friend void PrepareLock(SwFlowFrame *)
Definition: calcmove.cxx:208
bool IsKeepFwdMoveAllowed(bool bIgnoreMyOwnKeepValue=false)
Definition: flowfrm.cxx:123
bool HasLockedFollow() const
Definition: flowfrm.cxx:111
void SetUndersized(const bool bNew)
Definition: flowfrm.hxx:158
SwFlowFrame * m_pPrecede
Definition: flowfrm.hxx:119
SwTwips CalcLowerSpace(const SwBorderAttrs *_pAttrs=nullptr) const
calculation of lower space
Definition: flowfrm.cxx:1754
friend void TableSplitRecalcLock(SwFlowFrame *)
Definition: tabfrm.cxx:643
void CheckKeep()
Definition: flowfrm.cxx:146
bool MoveFwd(bool bMakePage, bool bPageBreak, bool bMoveAlways=false)
Return value guarantees that a new page was not created, although false does not NECESSARILY indicate...
Definition: flowfrm.cxx:1938
bool HasFollow() const
Definition: flowfrm.hxx:166
bool HasParaSpaceAtPages(bool bSct) const
Definition: flowfrm.cxx:1310
bool m_bLockJoin
Definition: flowfrm.hxx:121
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1736
static SwLayoutFrame * CutTree(SwFrame *)
A specialized form of Cut(), which relocates a whole chain (this and the following,...
Definition: flowfrm.cxx:443
virtual ~SwFlowFrame()
Definition: flowfrm.cxx:79
const SwFrame * GetPrevFrameForUpperSpaceCalc_(const SwFrame *_pProposedPrevFrame=nullptr) const
helper method to determine previous frame for calculation of the upper space
Definition: flowfrm.cxx:1352
SwTwips GetUpperSpaceAmountConsideredForPrevFrame() const
method to determine the upper space amount, which is considered for the previous frame
Definition: flowfrm.cxx:1700
bool IsFollow() const
Definition: flowfrm.hxx:167
SwFrame & m_rThis
Definition: flowfrm.hxx:77
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:91
bool MoveBwd(bool &rbReformat)
Return value tells whether any changes have been made.
Definition: flowfrm.cxx:2143
friend void MakeFrames(SwDoc *, SwNode &, SwNode &)
Definition: frmtool.cxx:2013
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2709
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:1801
bool m_bFlyLock
Definition: flowfrm.hxx:123
const SwFrame & GetFrame() const
Definition: flowfrm.hxx:152
static bool IsMoveBwdJump()
Definition: flowfrm.hxx:155
void UnlockJoin()
Definition: flowfrm.hxx:141
const SwFlowFrame * GetPrecede() const
Definition: flowfrm.hxx:173
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:1269
friend void TableSplitRecalcUnlock(SwFlowFrame *)
Definition: tabfrm.cxx:644
bool IsUndersized() const
Definition: flowfrm.hxx:159
bool m_bUndersized
Definition: flowfrm.hxx:122
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:234
void LockJoin()
Definition: flowfrm.hxx:140
void SetFlyLock(bool bNew)
Definition: flowfrm.hxx:230
bool ForbiddenForFootnoteCntFwd() const
Definition: flowfrm.cxx:1930
SwFlowFrame * m_pFollow
Definition: flowfrm.hxx:118
SwFlowFrame * GetPrecede()
Definition: flowfrm.hxx:174
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:1846
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &rReformat)=0
Base class of the Writer layout elements.
Definition: frame.hxx:315
SwFrame * GetIndPrev() const
Definition: frame.hxx:724
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
The SwNode2LayImpl class does the actual work, the SwNode2Layout class is just the public interface.
Definition: node2lay.cxx:39
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
A page of the document layout.
Definition: pagefrm.hxx:58
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8