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
59class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwFlowFrame
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#
67 friend class SwObjectFormatterTextFrame;
68 friend class FlowFrameJoinLockGuard;
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
77 SwFrame& m_rThis;
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
107 SwTwips GetUpperSpaceAmountConsideredForPrevFrame() const;
108
114 SwTwips GetUpperSpaceAmountConsideredForPageGrid_(
115 const SwTwips _nUpperSpaceWithoutGrid ) const;
116
117protected:
118 SwFlowFrame *m_pFollow;
119 SwFlowFrame *m_pPrecede;
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; }
170 SwFlowFrame *GetFollow() { return m_pFollow; }
171 void SetFollow(SwFlowFrame *const pFollow);
172
173 const SwFlowFrame *GetPrecede() const { return m_pPrecede; }
174 SwFlowFrame *GetPrecede() { 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
208 SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const;
209
211 SwTwips CalcLowerSpace( const SwBorderAttrs* _pAttrs = nullptr ) const;
212
225 SwTwips CalcAddLowerSpaceAsLastInTableCell(
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
241inline bool SwFlowFrame::IsFwdMoveAllowed() const
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:
251 SwFlowFrame *m_pFlow;
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 {
259 m_pFlow = SwFlowFrame::CastFlowFrame(pFrame);
260 if (m_pFlow)
261 {
262 m_bOldJoinLocked = m_pFlow->IsJoinLocked();
263 m_pFlow->LockJoin();
264 }
265 else
266 {
267 m_bOldJoinLocked = false;
268 }
269 }
270
272 {
274 m_pFlow->UnlockJoin();
275 }
276};
277
278#endif
279
280/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PrepareLock(SwFlowFrame *pTab)
Definition: calcmove.cxx:208
void PrepareUnlock(SwFlowFrame *pTab)
Definition: calcmove.cxx:212
SwFlowFrame * m_pFlow
Definition: flowfrm.hxx:251
FlowFrameJoinLockGuard(SwLayoutFrame *pFrame)
Definition: flowfrm.hxx:257
Definition: doc.hxx:197
Base class of the Writer layout elements.
Definition: frame.hxx:315
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
SwFrame * GetFrame(const Point *pDocPos) const
Definition: node2lay.cxx:466
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:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
@ MoveFwd
class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwFlowFrame
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:59
void MakeFrames(SwDoc *pDoc, SwNode &rSttIdx, SwNode &rEndIdx)
Definition: frmtool.cxx:2026
void CalcContent(SwLayoutFrame *pLay, bool bNoColl=false)
Definition: fly.cxx:1550
tools::Long SwTwips
Definition: swtypes.hxx:51
void TableSplitRecalcLock(SwFlowFrame *pTab)
Definition: tabfrm.cxx:643
void TableSplitRecalcUnlock(SwFlowFrame *pTab)
Definition: tabfrm.cxx:644
void UnsetFollow(SwFlowFrame *pTab)
Definition: tblsel.cxx:2153
unsigned char sal_uInt8