Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / frame.hxx
blob885a0d223f24ff0664ba78bc20ea44ec0a0cf7d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX
23 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
24 #include <editeng/borderline.hxx>
25 #include <svl/poolitem.hxx>
26 #include <swtypes.hxx>
27 #include <swrect.hxx>
28 #include <calbck.hxx>
29 #include <svl/SfxBroadcaster.hxx>
30 #include <o3tl/typed_flags_set.hxx>
31 #include <com/sun/star/style/TabStop.hpp>
32 #include <basegfx/matrix/b2dhommatrix.hxx>
33 #include <vcl/outdev.hxx>
35 #include <memory>
36 #include <optional>
38 namespace drawinglayer::processor2d { class BaseProcessor2D; }
40 class SwLayoutFrame;
41 class SwRootFrame;
42 class SwPageFrame;
43 class SwBodyFrame;
44 class SwFlyFrame;
45 class SwSectionFrame;
46 class SwFootnoteFrame;
47 class SwFootnoteBossFrame;
48 class SwTabFrame;
49 class SwRowFrame;
50 class SwContentFrame;
51 class SwAttrSet;
52 class Color;
53 class SwBorderAttrs;
54 class SwCache;
55 class SvxBrushItem;
56 class SvxFormatBreakItem;
57 class SwFormatPageDesc;
58 class SwSelectionList;
59 struct SwPosition;
60 struct SwCursorMoveState;
61 class SwFormat;
62 class SwPrintData;
63 class SwSortedObjs;
64 class SwAnchoredObject;
65 enum class SvxFrameDirection;
66 class IDocumentDrawModelAccess;
67 class SwTextFrame;
69 // Each FrameType is represented here as a bit.
70 // The bits must be set in a way that it can be determined with masking of
71 // which kind of FrameType an instance is _and_ from what classes it was derived.
72 // Each frame has in its base class a member that must be set by the
73 // constructors accordingly.
74 enum class SwFrameType
76 None = 0x0000,
77 Root = 0x0001,
78 Page = 0x0002,
79 Column = 0x0004,
80 Header = 0x0008,
81 Footer = 0x0010,
82 FtnCont = 0x0020,
83 Ftn = 0x0040,
84 Body = 0x0080,
85 Fly = 0x0100,
86 Section = 0x0200,
87 // UNUSED 0x0400
88 Tab = 0x0800,
89 Row = 0x1000,
90 Cell = 0x2000,
91 Txt = 0x4000,
92 NoTxt = 0x8000,
95 namespace o3tl
97 template<> struct typed_flags<SwFrameType> : is_typed_flags<SwFrameType, 0xfbff> {};
100 // for internal use some common combinations
101 #define FRM_LAYOUT SwFrameType(0x3bFF)
102 #define FRM_ALL SwFrameType(0xfbff)
103 #define FRM_CNTNT (SwFrameType::Txt | SwFrameType::NoTxt)
104 #define FRM_FTNBOSS (SwFrameType::Page | SwFrameType::Column)
105 #define FRM_ACCESSIBLE (SwFrameType::Root | SwFrameType::Page | SwFrameType::Header | SwFrameType::Footer | SwFrameType::Ftn | SwFrameType::Fly | SwFrameType::Tab | SwFrameType::Cell | SwFrameType::Txt)
106 #define FRM_NEIGHBOUR (SwFrameType::Column | SwFrameType::Cell)
107 #define FRM_NOTE_VERT (SwFrameType::FtnCont | SwFrameType::Ftn | SwFrameType::Section | SwFrameType::Tab | SwFrameType::Row | SwFrameType::Cell | SwFrameType::Txt)
108 #define FRM_HEADFOOT (SwFrameType::Header | SwFrameType::Footer)
109 #define FRM_BODYFTNC (SwFrameType::FtnCont | SwFrameType::Body)
111 // for GetNextLeaf/GetPrevLeaf.
112 enum MakePageType
114 MAKEPAGE_NONE, // do not create page/footnote
115 MAKEPAGE_APPEND, // only append page if needed
116 MAKEPAGE_INSERT, // add or append page if needed
117 MAKEPAGE_FTN, // add footnote if needed
118 MAKEPAGE_NOSECTION // Don't create section frames
121 namespace drawinglayer::attribute {
122 class SdrAllFillAttributesHelper;
123 typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
126 /// Helper class to isolate geometry-defining members of SwFrame
127 /// and to control their accesses. Moved to own class to have no
128 /// hidden accesses to 'private' members anymore.
130 /// Added most important flags about the state of this geometric
131 /// information and if it is valid or not
132 class SAL_DLLPUBLIC_RTTI SwFrameAreaDefinition
134 private:
135 friend void FriendHackInvalidateRowFrame(SwFrameAreaDefinition &);
137 // The absolute position and size of the SwFrame in the document.
138 // This values are set by the layouter implementations
139 SwRect maFrameArea;
141 // The 'inner' Frame Area defined by a SwRect relative to FrameArea:
142 // When identical to FrameArea, Pos() will be (0, 0) and Size identical.
143 SwRect maFramePrintArea;
145 // bitfield
146 bool mbFrameAreaPositionValid : 1;
147 bool mbFrameAreaSizeValid : 1;
148 bool mbFramePrintAreaValid : 1;
150 // #i65250#
151 // frame ID is now in general available - used for layout loop control
152 static sal_uInt32 snLastFrameId;
153 const sal_uInt32 mnFrameId;
155 protected:
156 // write access to mb*Valid flags
157 void setFrameAreaPositionValid(bool bNew);
158 void setFrameAreaSizeValid(bool bNew);
159 void setFramePrintAreaValid(bool bNew);
161 public:
162 SwFrameAreaDefinition();
163 virtual ~SwFrameAreaDefinition();
165 // read access to mb*Valid flags
166 bool isFrameAreaPositionValid() const { return mbFrameAreaPositionValid; }
167 bool isFrameAreaSizeValid() const { return mbFrameAreaSizeValid; }
168 bool isFramePrintAreaValid() const { return mbFramePrintAreaValid; }
170 // syntactic sugar: test whole FrameAreaDefinition
171 bool isFrameAreaDefinitionValid() const { return isFrameAreaPositionValid() && isFrameAreaSizeValid() && isFramePrintAreaValid(); }
173 // #i65250#
174 sal_uInt32 GetFrameId() const { return mnFrameId; }
176 // read accesses to FrameArea definitions - only const access allowed.
177 // Do *not* const_cast results, it is necessary to track changes. use
178 // the below offered WriteAccess helper classes instead
179 const SwRect& getFrameArea() const { return maFrameArea; }
180 const SwRect& getFramePrintArea() const { return maFramePrintArea; }
182 // helper class(es) for FrameArea manipulation. These
183 // have to be used to apply changes to FrameAreas. They hold a copy of the
184 // SwRect for manipulation. It gets written back at destruction. Thus, this
185 // mechanism depends on scope usage, take care. It prevents errors using
186 // different instances of SwFrame in get/set methods which is more safe
187 class FrameAreaWriteAccess : public SwRect
189 private:
190 SwFrameAreaDefinition& mrTarget;
192 FrameAreaWriteAccess(const FrameAreaWriteAccess&) = delete;
193 FrameAreaWriteAccess& operator=(const FrameAreaWriteAccess&) = delete;
195 public:
196 FrameAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFrameArea()), mrTarget(rTarget) {}
197 ~FrameAreaWriteAccess();
198 void setSwRect(const SwRect& rNew) { *static_cast< SwRect* >(this) = rNew; }
201 // same helper for FramePrintArea
202 class FramePrintAreaWriteAccess : public SwRect
204 private:
205 SwFrameAreaDefinition& mrTarget;
207 FramePrintAreaWriteAccess(const FramePrintAreaWriteAccess&) = delete;
208 FramePrintAreaWriteAccess& operator=(const FramePrintAreaWriteAccess&) = delete;
210 public:
211 FramePrintAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFramePrintArea()), mrTarget(rTarget) {}
212 ~FramePrintAreaWriteAccess();
213 void setSwRect(const SwRect& rNew) { *static_cast< SwRect* >(this) = rNew; }
216 // RotateFlyFrame3 - Support for Transformations
217 // Hand out the Transformations for the current FrameAreaDefinition
218 // for the FrameArea and FramePrintArea.
219 // FramePrintArea is not relative to FrameArea in this
220 // transformation representation (to make it easier to use and understand).
221 // There is no 'set' method since SwFrame is a layout object. For
222 // some cases rotation will be included (used for SwGrfNode in inner
223 // SwFrame of a SwFlyFrame)
224 virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const;
225 virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const;
227 // RotateFlyFrame3 - Support for Transformations
228 // Modify current transformations by applying given translation
229 virtual void transform_translate(const Point& rOffset);
232 /// RotateFlyFrame3: Helper class when you want to make your SwFrame derivate
233 /// transformable. It provides some tooling to do so. To use, add as member
234 /// (see e.g. SwFlyFreeFrame which uses 'std::unique_ptr< TransformableSwFrame >')
235 class TransformableSwFrame
237 private:
238 // The SwFrameAreaDefinition to work on
239 SwFrameAreaDefinition& mrSwFrameAreaDefinition;
241 // FrameAreaTransformation and FramePrintAreaTransformation
242 // !identity when needed (translate/scale is used (e.g. rotation))
243 basegfx::B2DHomMatrix maFrameAreaTransformation;
244 basegfx::B2DHomMatrix maFramePrintAreaTransformation;
246 public:
247 TransformableSwFrame(SwFrameAreaDefinition& rSwFrameAreaDefinition)
248 : mrSwFrameAreaDefinition(rSwFrameAreaDefinition),
249 maFrameAreaTransformation(),
250 maFramePrintAreaTransformation()
254 // get SwFrameArea in transformation form
255 const basegfx::B2DHomMatrix& getLocalFrameAreaTransformation() const
257 return maFrameAreaTransformation;
260 // get SwFramePrintArea in transformation form
261 const basegfx::B2DHomMatrix& getLocalFramePrintAreaTransformation() const
263 return maFramePrintAreaTransformation;
266 // Helpers to re-create the untransformed SwRect(s) originally
267 // in the SwFrameAreaDefinition, based on the current Transformations.
268 SwRect getUntransformedFrameArea() const;
269 SwRect getUntransformedFramePrintArea() const;
271 // Helper method to re-create FrameAreaTransformations based on the
272 // current FrameAreaDefinition transformed by given rotation and Center
273 void createFrameAreaTransformations(
274 double fRotation,
275 const basegfx::B2DPoint& rCenter);
277 // Tooling method to reset the SwRect(s) in the current
278 // SwFrameAreaDefinition which are already adapted to
279 // Transformation back to the untransformed state, using
280 // the getUntransformedFrame*Area calls above when needed.
281 // Only the SwRect(s) are changed back, not the transformations.
282 void restoreFrameAreas();
284 // Re-Creates the SwRect(s) as BoundAreas based on the current
285 // set Transformations.
286 void adaptFrameAreasToTransformations();
288 // Modify current definitions by applying the given transformation
289 void transform(const basegfx::B2DHomMatrix& aTransform);
292 enum class SwFrameInvFlags : sal_uInt8
294 NONE = 0x00,
295 InvalidatePrt = 0x01,
296 InvalidateSize = 0x02,
297 InvalidatePos = 0x04,
298 SetCompletePaint = 0x08,
299 NextInvalidatePos = 0x10,
300 NextSetCompletePaint = 0x20,
303 namespace o3tl {
304 template<> struct typed_flags<SwFrameInvFlags> : is_typed_flags<SwFrameInvFlags, 0x003f> {};
308 * Base class of the Writer layout elements.
310 * This includes not only fly frames, but everything down to the paragraph
311 * level: pages, headers, footers, etc. (Inside a paragraph SwLinePortion
312 * instances are used.)
314 class SW_DLLPUBLIC SwFrame : public SwFrameAreaDefinition, public SwClient, public SfxBroadcaster
316 // the hidden Frame
317 friend class SwFlowFrame;
318 friend class SwLayoutFrame;
319 friend class SwLooping;
320 friend class SwDeletionChecker; // for GetDep()
322 // voids lower during creation of a column
323 friend SwFrame *SaveContent( SwLayoutFrame *, SwFrame* pStart );
324 friend void RestoreContent( SwFrame *, SwLayoutFrame *, SwFrame *pSibling );
326 // for validating a mistakenly invalidated one in SwContentFrame::MakeAll
327 friend void ValidateSz( SwFrame *pFrame );
328 // implemented in text/txtftn.cxx, prevents Footnote oscillation
329 friend void ValidateText( SwFrame *pFrame );
331 friend void MakeNxt( SwFrame *pFrame, SwFrame *pNxt );
333 // cache for (border) attributes
334 static SwCache *spCache;
336 SwRootFrame *mpRoot;
337 SwLayoutFrame *mpUpper;
338 SwFrame *mpNext;
339 SwFrame *mpPrev;
341 // sw_redlinehide: hide these dangerous SwClient functions
342 using SwClient::GetRegisteredInNonConst;
343 using SwClient::GetRegisteredIn;
345 SwFrame *FindNext_();
346 SwFrame *FindPrev_();
348 /** method to determine next content frame in the same environment
349 for a flow frame (content frame, table frame, section frame)
351 #i27138# - adding documentation:
352 Travelling downwards through the layout to determine the next content
353 frame in the same environment. There are several environments in a
354 document, which form a closed context regarding this function. These
355 environments are:
356 - Each page header
357 - Each page footer
358 - Each unlinked fly frame
359 - Each group of linked fly frames
360 - All footnotes
361 - All document body frames
362 #i27138# - adding parameter <_bInSameFootnote>
363 Its default value is <false>. If its value is <true>, the environment
364 'All footnotes' is no longer treated. Instead each footnote is treated
365 as an own environment.
367 @param _bInSameFootnote
368 input parameter - boolean indicating, that the found next content
369 frame has to be in the same footnote frame. This parameter is only
370 relevant for flow frames in footnotes.
372 @return SwContentFrame*
373 pointer to the found next content frame. It's NULL, if none exists.
375 SwContentFrame* FindNextCnt_( const bool _bInSameFootnote );
377 /** method to determine previous content frame in the same environment
378 for a flow frame (content frame, table frame, section frame)
380 #i27138#
381 Travelling upwards through the layout to determine the previous content
382 frame in the same environment. There are several environments in a
383 document, which form a closed context regarding this function. These
384 environments are:
385 - Each page header
386 - Each page footer
387 - Each unlinked fly frame
388 - Each group of linked fly frames
389 - All footnotes
390 - All document body frames
391 #i27138# - adding parameter <_bInSameFootnote>
392 Its default value is <false>. If its value is <true>, the environment
393 'All footnotes' is no longer treated. Instead each footnote is treated
394 as an own environment.
396 The found previous content frame has to be in the same footnote frame. This is only
397 relevant for flow frames in footnotes.
399 @return SwContentFrame*
400 pointer to the found previous content frame. It's NULL, if none exists.
402 SwContentFrame* FindPrevCnt_();
404 void UpdateAttrFrame( const SfxPoolItem*, const SfxPoolItem*, SwFrameInvFlags & );
405 SwFrame* GetIndNext_();
406 void SetDirFlags( bool bVert );
408 const SwLayoutFrame* ImplGetNextLayoutLeaf( bool bFwd ) const;
410 SwPageFrame* ImplFindPageFrame();
412 protected:
413 std::unique_ptr<SwSortedObjs> m_pDrawObjs; // draw objects, can be null
414 SwFrameType mnFrameType; //Who am I?
416 bool mbInDtor : 1;
417 bool mbInvalidR2L : 1;
418 bool mbDerivedR2L : 1;
419 bool mbRightToLeft : 1;
420 bool mbInvalidVert : 1;
421 bool mbDerivedVert : 1;
422 bool mbVertical : 1;
424 bool mbVertLR : 1;
425 bool mbVertLRBT : 1;
427 bool mbValidLineNum : 1;
428 bool mbFixSize : 1;
430 // if true, frame will be painted completely even content was changed
431 // only partially. For ContentFrames a border (from Action) will exclusively
432 // painted if <mbCompletePaint> is true.
433 bool mbCompletePaint : 1;
435 bool mbRetouche : 1; // frame is responsible for retouching
437 bool mbInfInvalid : 1; // InfoFlags are invalid
438 bool mbInfBody : 1; // Frame is in document body
439 bool mbInfTab : 1; // Frame is in a table
440 bool mbInfFly : 1; // Frame is in a Fly
441 bool mbInfFootnote : 1; // Frame is in a footnote
442 bool mbInfSct : 1; // Frame is in a section
443 bool mbColLocked : 1; // lock Grow/Shrink for column-wise section
444 // or fly frames, will be set in Format
445 bool m_isInDestroy : 1;
446 int mnForbidDelete;
448 void ColLock() { mbColLocked = true; }
449 void ColUnlock() { mbColLocked = false; }
451 virtual void DestroyImpl();
452 virtual ~SwFrame() override;
454 // Only used by SwRootFrame Ctor to get 'this' into mpRoot...
455 void setRootFrame( SwRootFrame* pRoot ) { mpRoot = pRoot; }
457 SwPageFrame *InsertPage( SwPageFrame *pSibling, bool bFootnote );
458 void PrepareMake(vcl::RenderContext* pRenderContext);
459 void OptPrepareMake();
460 /// Calculates the frame area position, in case it's invalid. The frame area size and the print
461 /// area is not considered here.
462 virtual void MakePos();
463 // Format next frame of table frame to assure keeping attributes.
464 // In case of nested tables method <SwFrame::MakeAll()> is called to
465 // avoid formatting of superior table frame.
466 friend SwFrame* sw_FormatNextContentForKeep( SwTabFrame* pTabFrame );
468 virtual void MakeAll(vcl::RenderContext* pRenderContext) = 0;
469 // adjust frames of a page
470 SwTwips AdjustNeighbourhood( SwTwips nDiff, bool bTst = false );
472 // change only frame size not the size of PrtArea
473 virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) = 0;
474 virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) = 0;
476 /// use these so we can grep for SwFrame's GetRegisteredIn accesses
477 /// beware that SwTextFrame may return sw::WriterMultiListener
478 sw::BroadcastingModify* GetDep()
479 { return static_cast<sw::BroadcastingModify*>(GetRegisteredInNonConst()); }
480 const sw::BroadcastingModify* GetDep() const
481 { return static_cast<const sw::BroadcastingModify*>(GetRegisteredIn()); }
483 SwFrame( sw::BroadcastingModify*, SwFrame* );
485 void CheckDir( SvxFrameDirection nDir, bool bVert, bool bOnlyBiDi, bool bBrowse );
487 /** enumeration for the different invalidations
488 #i28701#
490 enum InvalidationType
492 INVALID_SIZE, INVALID_PRTAREA, INVALID_POS, INVALID_LINENUM, INVALID_ALL
495 /** method to determine, if an invalidation is allowed.
496 #i28701
498 virtual bool InvalidationAllowed( const InvalidationType _nInvalid ) const;
500 /** method to perform additional actions on an invalidation
502 #i28701#
503 Method has *only* to contain actions, which has to be performed on
504 *every* assignment of the corresponding flag to <false>.
506 virtual void ActionOnInvalidation( const InvalidationType _nInvalid );
508 // draw shadow and borders
509 void PaintShadow( const SwRect&, SwRect&, const SwBorderAttrs& ) const;
510 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
512 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( );
514 public:
515 virtual css::uno::Sequence< css::style::TabStop > GetTabStopInfo( SwTwips )
517 return css::uno::Sequence< css::style::TabStop >();
521 SwFrameType GetType() const { return mnFrameType; }
523 static SwCache &GetCache() { return *spCache; }
524 static SwCache *GetCachePtr() { return spCache; }
525 static void SetCache( SwCache *pNew ) { spCache = pNew; }
527 // change PrtArea size and FrameSize
528 SwTwips Shrink( SwTwips, bool bTst = false, bool bInfo = false );
529 SwTwips Grow ( SwTwips, bool bTst = false, bool bInfo = false );
531 // different methods for inserting in layout tree (for performance reasons)
533 // insert before pBehind or at the end of the chain below mpUpper
534 void InsertBefore( SwLayoutFrame* pParent, SwFrame* pBehind );
535 // insert after pBefore or at the beginning of the chain below mpUpper
536 void InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore );
537 // insert before pBehind or at the end of the chain while considering
538 // the siblings of pSct
539 bool InsertGroupBefore( SwFrame* pParent, SwFrame* pWhere, SwFrame* pSct );
540 void RemoveFromLayout();
542 // For internal use only - who ignores this will be put in a sack and has
543 // to stay there for two days
544 // Does special treatment for Get_[Next|Prev]Leaf() (for tables).
545 SwLayoutFrame *GetLeaf( MakePageType eMakePage, bool bFwd );
546 SwLayoutFrame *GetNextLeaf ( MakePageType eMakePage );
547 SwLayoutFrame *GetNextFootnoteLeaf( MakePageType eMakePage );
548 SwLayoutFrame *GetNextSctLeaf( MakePageType eMakePage );
549 SwLayoutFrame *GetNextFlyLeaf( MakePageType eMakePage );
550 SwLayoutFrame *GetNextCellLeaf();
551 SwLayoutFrame *GetPrevLeaf ();
552 SwLayoutFrame *GetPrevFootnoteLeaf( MakePageType eMakeFootnote );
553 SwLayoutFrame *GetPrevSctLeaf();
554 SwLayoutFrame *GetPrevFlyLeaf();
555 SwLayoutFrame *GetPrevCellLeaf();
556 const SwLayoutFrame *GetLeaf ( MakePageType eMakePage, bool bFwd,
557 const SwFrame *pAnch ) const;
559 bool WrongPageDesc( SwPageFrame* pNew );
561 //#i28701# - new methods to append/remove drawing objects
562 void AppendDrawObj( SwAnchoredObject& _rNewObj );
563 void RemoveDrawObj( SwAnchoredObject& _rToRemoveObj );
565 // work with chain of FlyFrames
566 void AppendFly( SwFlyFrame *pNew );
567 void RemoveFly( SwFlyFrame *pToRemove );
568 const SwSortedObjs *GetDrawObjs() const { return m_pDrawObjs.get(); }
569 SwSortedObjs *GetDrawObjs() { return m_pDrawObjs.get(); }
570 void SetDrawObjsAsDeleted( bool bDeleted ); // change tracking of objects anchored to character
571 // #i28701# - change purpose of method and adjust its name
572 void InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs = true );
574 virtual void PaintSwFrameShadowAndBorder(
575 const SwRect&,
576 const SwPageFrame* pPage,
577 const SwBorderAttrs&) const;
578 void PaintBaBo( const SwRect&, const SwPageFrame *pPage,
579 const bool bOnlyTextBackground = false) const;
580 void PaintSwFrameBackground( const SwRect&, const SwPageFrame *pPage,
581 const SwBorderAttrs &,
582 const bool bLowerMode = false,
583 const bool bLowerBorder = false,
584 const bool bOnlyTextBackground = false ) const;
585 void PaintBorderLine( const SwRect&, const SwRect&, const SwPageFrame*,
586 const Color *pColor,
587 const SvxBorderLineStyle = SvxBorderLineStyle::SOLID ) const;
589 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> CreateProcessor2D( ) const;
590 void ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DContainer& rSequence ) const;
592 // retouch, not in the area of the given Rect!
593 void Retouch( const SwPageFrame *pPage, const SwRect &rRect ) const;
595 bool GetBackgroundBrush(
596 drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
597 const SvxBrushItem*& rpBrush,
598 std::optional<Color>& rxColor,
599 SwRect &rOrigRect,
600 bool bLowerMode,
601 bool bConsiderTextBox ) const;
603 inline void SetCompletePaint() const;
604 inline void ResetCompletePaint() const;
605 bool IsCompletePaint() const { return mbCompletePaint; }
607 inline void SetRetouche() const;
608 inline void ResetRetouche() const;
609 bool IsRetouche() const { return mbRetouche; }
611 void SetInfFlags();
612 void InvalidateInfFlags() { mbInfInvalid = true; }
613 inline bool IsInDocBody() const; // use InfoFlags, determine flags
614 inline bool IsInFootnote() const; // if necessary
615 inline bool IsInTab() const;
616 inline bool IsInFly() const;
617 inline bool IsInSct() const;
619 // If frame is inside a split table row, this function returns
620 // the corresponding row frame in the follow table.
621 const SwRowFrame* IsInSplitTableRow() const;
623 // If frame is inside a follow flow row, this function returns
624 // the corresponding row frame master table
625 const SwRowFrame* IsInFollowFlowRow() const;
627 bool IsInBalancedSection() const;
629 inline bool IsVertical() const;
630 inline bool IsVertLR() const;
631 inline bool IsVertLRBT() const;
633 void SetDerivedVert( bool bNew ){ mbDerivedVert = bNew; }
634 void SetInvalidVert( bool bNew) { mbInvalidVert = bNew; }
635 inline bool IsRightToLeft() const;
636 void SetDerivedR2L( bool bNew ) { mbDerivedR2L = bNew; }
638 void CheckDirChange();
639 // returns upper left frame position for LTR and
640 // upper right frame position for Asian / RTL frames
641 Point GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const;
643 /** determine, if frame is moveable in given environment
645 method replaced 'old' method <bool IsMoveable() const>.
646 Determines, if frame is moveable in given environment. if no environment
647 is given (parameter _pLayoutFrame == 0), the movability in the actual
648 environment (<GetUpper()) is checked.
650 @param _pLayoutFrame
651 input parameter - given environment (layout frame), in which the movability
652 will be checked. If not set ( == 0 ), actual environment is taken.
654 @return boolean, indicating, if frame is moveable in given environment
656 bool IsMoveable( const SwLayoutFrame* _pLayoutFrame = nullptr ) const;
658 // Is it permitted for the (Text)Frame to add a footnote in the current
659 // environment (not e.g. for repeating table headlines)
660 bool IsFootnoteAllowed() const;
662 /// Calculates the frame area size and the print area, in case they are invalid.
663 /// The frame area position is not considered here.
664 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr );
666 virtual void CheckDirection( bool bVert );
668 void ReinitializeFrameSizeAttrFlags();
670 /// WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for
671 /// SwTextFrame, use GetBreakItem()/GetPageDescItem() instead
672 const SwAttrSet *GetAttrSet() const;
673 virtual const SvxFormatBreakItem& GetBreakItem() const;
674 virtual const SwFormatPageDesc& GetPageDescItem() const;
676 bool HasFixSize() const { return mbFixSize; }
678 // check all pages (starting from the given) and correct them if needed
679 static void CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields = true, SwPageFrame** ppPrev = nullptr);
681 // might return 0, with and without const
682 SwFrame *GetNext() { return mpNext; }
683 SwFrame *GetPrev() { return mpPrev; }
684 SwLayoutFrame *GetUpper() { return mpUpper; }
685 SwRootFrame *getRootFrame(){ return mpRoot; }
686 SwPageFrame *FindPageFrame() { return IsPageFrame() ? reinterpret_cast<SwPageFrame*>(this) : ImplFindPageFrame(); }
687 SwFrame *FindColFrame();
688 SwRowFrame *FindRowFrame();
689 SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnotes = false );
690 SwTabFrame *ImplFindTabFrame();
691 SwFootnoteFrame *ImplFindFootnoteFrame();
692 SwFlyFrame *ImplFindFlyFrame();
693 SwSectionFrame *ImplFindSctFrame();
694 const SwBodyFrame *ImplFindBodyFrame() const;
695 SwFrame *FindFooterOrHeader();
696 SwFrame *GetLower();
697 const SwFrame *GetNext() const { return mpNext; }
698 const SwFrame *GetPrev() const { return mpPrev; }
699 const SwLayoutFrame *GetUpper() const { return mpUpper; }
700 const SwRootFrame *getRootFrame() const { return mpRoot; }
701 inline SwTabFrame *FindTabFrame();
702 inline SwFootnoteFrame *FindFootnoteFrame();
703 inline SwFlyFrame *FindFlyFrame();
704 inline SwSectionFrame *FindSctFrame();
705 inline SwFrame *FindNext();
706 // #i27138# - add parameter <_bInSameFootnote>
707 SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false );
708 inline SwFrame *FindPrev();
709 inline const SwPageFrame *FindPageFrame() const;
710 inline const SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnote = false ) const;
711 inline const SwFrame *FindColFrame() const;
712 inline const SwFrame *FindFooterOrHeader() const;
713 inline const SwTabFrame *FindTabFrame() const;
714 inline const SwFootnoteFrame *FindFootnoteFrame() const;
715 inline const SwFlyFrame *FindFlyFrame() const;
716 inline const SwSectionFrame *FindSctFrame() const;
717 inline const SwBodyFrame *FindBodyFrame() const;
718 inline const SwFrame *FindNext() const;
719 // #i27138# - add parameter <_bInSameFootnote>
720 const SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false ) const;
721 inline const SwFrame *FindPrev() const;
722 const SwFrame *GetLower() const;
724 SwContentFrame* FindPrevCnt();
726 const SwContentFrame* FindPrevCnt() const;
728 // #i79774#
729 SwFrame* GetIndPrev_() const;
730 SwFrame* GetIndPrev() const
731 { return ( mpPrev || !IsInSct() ) ? mpPrev : GetIndPrev_(); }
733 SwFrame* GetIndNext()
734 { return ( mpNext || !IsInSct() ) ? mpNext : GetIndNext_(); }
735 const SwFrame* GetIndNext() const { return const_cast<SwFrame*>(this)->GetIndNext(); }
737 sal_uInt16 GetPhyPageNum() const; // page number without offset
738 sal_uInt16 GetVirtPageNum() const; // page number with offset
739 bool OnRightPage() const { return 0 != GetPhyPageNum() % 2; };
740 bool WannaRightPage() const;
741 bool OnFirstPage() const;
743 inline const SwLayoutFrame *GetPrevLayoutLeaf() const;
744 inline const SwLayoutFrame *GetNextLayoutLeaf() const;
745 inline SwLayoutFrame *GetPrevLayoutLeaf();
746 inline SwLayoutFrame *GetNextLayoutLeaf();
748 virtual void Calc(vcl::RenderContext* pRenderContext) const; // here might be "formatted"
749 inline void OptCalc() const; // here we assume (for optimization) that
750 // the predecessors are already formatted
751 Point GetRelPos() const;
753 // PaintArea is the area where content might be displayed.
754 // The margin of a page or the space between columns belongs to it.
755 SwRect GetPaintArea() const;
757 // UnionFrame is the union of Frame- and PrtArea, normally identical
758 // to the FrameArea except in case of negative Prt margins.
759 SwRect UnionFrame( bool bBorder = false ) const;
761 virtual Size ChgSize( const Size& aNewSize );
763 virtual void Cut() = 0;
764 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) = 0;
766 void ValidateLineNum() { mbValidLineNum = true; }
768 bool GetValidLineNumFlag()const { return mbValidLineNum; }
770 // Only invalidate Frame
771 // #i28701# - add call to method <ActionOnInvalidation(..)>
772 // for all invalidation methods.
773 // #i28701# - use method <InvalidationAllowed(..)> to
774 // decide, if invalidation will to be performed or not.
775 // #i26945# - no additional invalidation, if it's already
776 // invalidate.
777 void InvalidateSize_()
779 if ( isFrameAreaSizeValid() && InvalidationAllowed( INVALID_SIZE ) )
781 setFrameAreaSizeValid(false);
782 ActionOnInvalidation( INVALID_SIZE );
785 void InvalidatePrt_()
787 if ( isFramePrintAreaValid() && InvalidationAllowed( INVALID_PRTAREA ) )
789 setFramePrintAreaValid(false);
790 ActionOnInvalidation( INVALID_PRTAREA );
793 void InvalidatePos_()
795 if ( isFrameAreaPositionValid() && InvalidationAllowed( INVALID_POS ) )
797 setFrameAreaPositionValid(false);
798 ActionOnInvalidation( INVALID_POS );
801 void InvalidateLineNum_()
803 if ( mbValidLineNum && InvalidationAllowed( INVALID_LINENUM ) )
805 mbValidLineNum = false;
806 ActionOnInvalidation( INVALID_LINENUM );
809 void InvalidateAll_()
811 if ( ( isFrameAreaSizeValid() || isFramePrintAreaValid() || isFrameAreaPositionValid() ) && InvalidationAllowed( INVALID_ALL ) )
813 setFrameAreaSizeValid(false);
814 setFrameAreaPositionValid(false);
815 setFramePrintAreaValid(false);
816 ActionOnInvalidation( INVALID_ALL );
819 // also notify page at the same time
820 inline void InvalidateSize();
821 inline void InvalidatePrt();
822 inline void InvalidatePos();
823 inline void InvalidateLineNum();
824 inline void InvalidateAll();
825 void ImplInvalidateSize();
826 void ImplInvalidatePrt();
827 void ImplInvalidatePos();
828 void ImplInvalidateLineNum();
830 inline void InvalidateNextPos( bool bNoFootnote = false );
831 void ImplInvalidateNextPos( bool bNoFootnote );
833 /** method to invalidate printing area of next frame
834 #i11859#
836 void InvalidateNextPrtArea();
838 void InvalidatePage( const SwPageFrame *pPage = nullptr ) const;
840 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
842 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
843 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const;
844 virtual bool GetCharRect( SwRect &, const SwPosition&,
845 SwCursorMoveState* = nullptr, bool bAllowFarAway = true ) const;
846 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
847 SwPrintData const*const pPrintData = nullptr ) const;
849 // HACK: shortcut between frame and formatting
850 // It's your own fault if you cast void* incorrectly! In any case check
851 // the void* for 0.
852 virtual bool Prepare( const PrepareHint ePrep = PrepareHint::Clear,
853 const void *pVoid = nullptr, bool bNotify = true );
855 // true if it is the correct class, false otherwise
856 inline bool IsLayoutFrame() const;
857 inline bool IsRootFrame() const;
858 inline bool IsPageFrame() const;
859 inline bool IsColumnFrame() const;
860 inline bool IsFootnoteBossFrame() const; // footnote bosses might be PageFrames or ColumnFrames
861 inline bool IsHeaderFrame() const;
862 inline bool IsFooterFrame() const;
863 inline bool IsFootnoteContFrame() const;
864 inline bool IsFootnoteFrame() const;
865 inline bool IsBodyFrame() const;
866 inline bool IsColBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above ColumnFrame
867 inline bool IsPageBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above PageFrame
868 inline bool IsFlyFrame() const;
869 inline bool IsSctFrame() const;
870 inline bool IsTabFrame() const;
871 inline bool IsRowFrame() const;
872 inline bool IsCellFrame() const;
873 inline bool IsContentFrame() const;
874 inline bool IsTextFrame() const;
875 SwTextFrame* DynCastTextFrame();
876 const SwTextFrame* DynCastTextFrame() const;
877 SwPageFrame* DynCastPageFrame();
878 const SwPageFrame* DynCastPageFrame() const;
879 inline bool IsNoTextFrame() const;
880 // Frames where its PrtArea depends on their neighbors and that are
881 // positioned in the content flow
882 inline bool IsFlowFrame() const;
883 // Frames that are capable of retouching or that might need to retouch behind
884 // themselves
885 inline bool IsRetoucheFrame() const;
886 inline bool IsAccessibleFrame() const;
888 void PrepareCursor(); // CursorShell is allowed to call this
890 // Is the Frame (or the section containing it) protected? Same for Fly in
891 // Fly in ... and footnotes
892 bool IsProtected() const;
894 bool IsColLocked() const { return mbColLocked; }
895 virtual bool IsDeleteForbidden() const { return mnForbidDelete > 0; }
897 /// this is the only way to delete a SwFrame instance
898 static void DestroyFrame(SwFrame *const pFrame);
900 bool IsInDtor() const { return mbInDtor; }
902 // No inline cause we need the function pointers
903 tools::Long GetTopMargin() const;
904 tools::Long GetBottomMargin() const;
905 tools::Long GetLeftMargin() const;
906 tools::Long GetRightMargin() const;
907 void SetTopBottomMargins( tools::Long, tools::Long );
908 void SetLeftRightMargins( tools::Long, tools::Long );
909 void SetRightLeftMargins( tools::Long, tools::Long );
910 tools::Long GetPrtLeft() const;
911 tools::Long GetPrtBottom() const;
912 tools::Long GetPrtRight() const;
913 tools::Long GetPrtTop() const;
914 bool SetMinLeft( tools::Long );
915 bool SetMaxBottom( tools::Long );
916 bool SetMaxRight( tools::Long );
917 void MakeBelowPos( const SwFrame*, const SwFrame*, bool );
918 void MakeLeftPos( const SwFrame*, const SwFrame*, bool );
919 void MakeRightPos( const SwFrame*, const SwFrame*, bool );
920 bool IsNeighbourFrame() const
921 { return bool(GetType() & FRM_NEIGHBOUR); }
923 // NEW TABLES
924 // Some functions for covered/covering table cells. This way unnecessary
925 // includes can be avoided
926 virtual bool IsLeaveUpperAllowed() const;
927 virtual bool IsCoveredCell() const;
928 bool IsInCoveredCell() const;
930 // #i81146# new loop control
931 bool KnowsFormat( const SwFormat& rFormat ) const;
932 void RegisterToFormat( SwFormat& rFormat );
933 void ValidateThisAndAllLowers( const sal_uInt16 nStage );
935 void ForbidDelete() { ++mnForbidDelete; }
936 void AllowDelete() { assert(mnForbidDelete > 0); --mnForbidDelete; }
938 drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
939 bool supportsFullDrawingLayerFillAttributeSet() const;
941 public:
942 // if writer is NULL, dumps the layout structure as XML in layout.xml
943 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const;
944 void dumpTopMostAsXml(xmlTextWriterPtr writer = nullptr) const;
945 void dumpInfosAsXml(xmlTextWriterPtr writer) const;
946 virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const;
947 void dumpChildrenAsXml(xmlTextWriterPtr writer) const;
948 bool IsCollapse() const;
951 inline bool SwFrame::IsInDocBody() const
953 if ( mbInfInvalid )
954 const_cast<SwFrame*>(this)->SetInfFlags();
955 return mbInfBody;
957 inline bool SwFrame::IsInFootnote() const
959 if ( mbInfInvalid )
960 const_cast<SwFrame*>(this)->SetInfFlags();
961 return mbInfFootnote;
963 inline bool SwFrame::IsInTab() const
965 if ( mbInfInvalid )
966 const_cast<SwFrame*>(this)->SetInfFlags();
967 return mbInfTab;
969 inline bool SwFrame::IsInFly() const
971 if ( mbInfInvalid )
972 const_cast<SwFrame*>(this)->SetInfFlags();
973 return mbInfFly;
975 inline bool SwFrame::IsInSct() const
977 if ( mbInfInvalid )
978 const_cast<SwFrame*>(this)->SetInfFlags();
979 return mbInfSct;
981 bool SwFrame::IsVertical() const
983 if( mbInvalidVert )
984 const_cast<SwFrame*>(this)->SetDirFlags( true );
985 return mbVertical;
987 inline bool SwFrame::IsVertLR() const
989 return mbVertLR;
991 inline bool SwFrame::IsVertLRBT() const
993 return mbVertLRBT;
995 inline bool SwFrame::IsRightToLeft() const
997 if( mbInvalidR2L )
998 const_cast<SwFrame*>(this)->SetDirFlags( false );
999 return mbRightToLeft;
1002 inline void SwFrame::SetCompletePaint() const
1004 const_cast<SwFrame*>(this)->mbCompletePaint = true;
1006 inline void SwFrame::ResetCompletePaint() const
1008 const_cast<SwFrame*>(this)->mbCompletePaint = false;
1011 inline void SwFrame::SetRetouche() const
1013 const_cast<SwFrame*>(this)->mbRetouche = true;
1015 inline void SwFrame::ResetRetouche() const
1017 const_cast<SwFrame*>(this)->mbRetouche = false;
1020 inline SwLayoutFrame *SwFrame::GetNextLayoutLeaf()
1022 return const_cast<SwLayoutFrame*>(static_cast<const SwFrame*>(this)->GetNextLayoutLeaf());
1024 inline SwLayoutFrame *SwFrame::GetPrevLayoutLeaf()
1026 return const_cast<SwLayoutFrame*>(static_cast<const SwFrame*>(this)->GetPrevLayoutLeaf());
1028 inline const SwLayoutFrame *SwFrame::GetNextLayoutLeaf() const
1030 return ImplGetNextLayoutLeaf( true );
1032 inline const SwLayoutFrame *SwFrame::GetPrevLayoutLeaf() const
1034 return ImplGetNextLayoutLeaf( false );
1037 inline void SwFrame::InvalidateSize()
1039 if ( isFrameAreaSizeValid() )
1041 ImplInvalidateSize();
1044 inline void SwFrame::InvalidatePrt()
1046 if ( isFramePrintAreaValid() )
1048 ImplInvalidatePrt();
1051 inline void SwFrame::InvalidatePos()
1053 if ( isFrameAreaPositionValid() )
1055 ImplInvalidatePos();
1058 inline void SwFrame::InvalidateLineNum()
1060 if ( mbValidLineNum )
1061 ImplInvalidateLineNum();
1063 inline void SwFrame::InvalidateAll()
1065 if ( InvalidationAllowed( INVALID_ALL ) )
1067 if ( isFrameAreaDefinitionValid() )
1069 ImplInvalidatePos();
1072 setFrameAreaSizeValid(false);
1073 setFrameAreaPositionValid(false);
1074 setFramePrintAreaValid(false);
1076 // #i28701#
1077 ActionOnInvalidation( INVALID_ALL );
1080 inline void SwFrame::InvalidateNextPos( bool bNoFootnote )
1082 if ( mpNext && !mpNext->IsSctFrame() )
1083 mpNext->InvalidatePos();
1084 else
1085 ImplInvalidateNextPos( bNoFootnote );
1088 inline void SwFrame::OptCalc() const
1090 if ( !isFrameAreaPositionValid() || !isFramePrintAreaValid() || !isFrameAreaSizeValid() )
1092 const_cast<SwFrame*>(this)->OptPrepareMake();
1095 inline const SwPageFrame *SwFrame::FindPageFrame() const
1097 return const_cast<SwFrame*>(this)->FindPageFrame();
1099 inline const SwFrame *SwFrame::FindColFrame() const
1101 return const_cast<SwFrame*>(this)->FindColFrame();
1103 inline const SwFrame *SwFrame::FindFooterOrHeader() const
1105 return const_cast<SwFrame*>(this)->FindFooterOrHeader();
1107 inline SwTabFrame *SwFrame::FindTabFrame()
1109 return IsInTab() ? ImplFindTabFrame() : nullptr;
1111 inline const SwFootnoteBossFrame *SwFrame::FindFootnoteBossFrame( bool bFootnote ) const
1113 return const_cast<SwFrame*>(this)->FindFootnoteBossFrame( bFootnote );
1115 inline SwFootnoteFrame *SwFrame::FindFootnoteFrame()
1117 return IsInFootnote() ? ImplFindFootnoteFrame() : nullptr;
1119 inline SwFlyFrame *SwFrame::FindFlyFrame()
1121 return IsInFly() ? ImplFindFlyFrame() : nullptr;
1123 inline SwSectionFrame *SwFrame::FindSctFrame()
1125 return IsInSct() ? ImplFindSctFrame() : nullptr;
1128 inline const SwBodyFrame *SwFrame::FindBodyFrame() const
1130 return IsInDocBody() ? ImplFindBodyFrame() : nullptr;
1133 inline const SwTabFrame *SwFrame::FindTabFrame() const
1135 return IsInTab() ? const_cast<SwFrame*>(this)->ImplFindTabFrame() : nullptr;
1137 inline const SwFootnoteFrame *SwFrame::FindFootnoteFrame() const
1139 return IsInFootnote() ? const_cast<SwFrame*>(this)->ImplFindFootnoteFrame() : nullptr;
1141 inline const SwFlyFrame *SwFrame::FindFlyFrame() const
1143 return IsInFly() ? const_cast<SwFrame*>(this)->ImplFindFlyFrame() : nullptr;
1145 inline const SwSectionFrame *SwFrame::FindSctFrame() const
1147 return IsInSct() ? const_cast<SwFrame*>(this)->ImplFindSctFrame() : nullptr;
1149 inline SwFrame *SwFrame::FindNext()
1151 if ( mpNext )
1152 return mpNext;
1153 else
1154 return FindNext_();
1156 inline const SwFrame *SwFrame::FindNext() const
1158 if ( mpNext )
1159 return mpNext;
1160 else
1161 return const_cast<SwFrame*>(this)->FindNext_();
1163 inline SwFrame *SwFrame::FindPrev()
1165 if ( mpPrev && !mpPrev->IsSctFrame() )
1166 return mpPrev;
1167 else
1168 return FindPrev_();
1170 inline const SwFrame *SwFrame::FindPrev() const
1172 if ( mpPrev && !mpPrev->IsSctFrame() )
1173 return mpPrev;
1174 else
1175 return const_cast<SwFrame*>(this)->FindPrev_();
1178 inline bool SwFrame::IsLayoutFrame() const
1180 return bool(GetType() & FRM_LAYOUT);
1182 inline bool SwFrame::IsRootFrame() const
1184 return mnFrameType == SwFrameType::Root;
1186 inline bool SwFrame::IsPageFrame() const
1188 return mnFrameType == SwFrameType::Page;
1190 inline bool SwFrame::IsColumnFrame() const
1192 return mnFrameType == SwFrameType::Column;
1194 inline bool SwFrame::IsFootnoteBossFrame() const
1196 return bool(GetType() & FRM_FTNBOSS);
1198 inline bool SwFrame::IsHeaderFrame() const
1200 return mnFrameType == SwFrameType::Header;
1202 inline bool SwFrame::IsFooterFrame() const
1204 return mnFrameType == SwFrameType::Footer;
1206 inline bool SwFrame::IsFootnoteContFrame() const
1208 return mnFrameType == SwFrameType::FtnCont;
1210 inline bool SwFrame::IsFootnoteFrame() const
1212 return mnFrameType == SwFrameType::Ftn;
1214 inline bool SwFrame::IsBodyFrame() const
1216 return mnFrameType == SwFrameType::Body;
1218 inline bool SwFrame::IsFlyFrame() const
1220 return mnFrameType == SwFrameType::Fly;
1222 inline bool SwFrame::IsSctFrame() const
1224 return mnFrameType == SwFrameType::Section;
1226 inline bool SwFrame::IsTabFrame() const
1228 return mnFrameType == SwFrameType::Tab;
1230 inline bool SwFrame::IsRowFrame() const
1232 return mnFrameType == SwFrameType::Row;
1234 inline bool SwFrame::IsCellFrame() const
1236 return mnFrameType == SwFrameType::Cell;
1238 inline bool SwFrame::IsContentFrame() const
1240 return bool(GetType() & FRM_CNTNT);
1242 inline bool SwFrame::IsTextFrame() const
1244 return mnFrameType == SwFrameType::Txt;
1246 inline bool SwFrame::IsNoTextFrame() const
1248 return mnFrameType == SwFrameType::NoTxt;
1250 inline bool SwFrame::IsFlowFrame() const
1252 return bool(GetType() & (FRM_CNTNT|SwFrameType::Tab|SwFrameType::Section));
1254 inline bool SwFrame::IsRetoucheFrame() const
1256 return bool(GetType() & (FRM_CNTNT|SwFrameType::Tab|SwFrameType::Section|SwFrameType::Ftn));
1258 inline bool SwFrame::IsAccessibleFrame() const
1260 return bool(GetType() & FRM_ACCESSIBLE);
1263 //use this to protect a SwFrame for a given scope from getting deleted
1264 class SwFrameDeleteGuard
1266 private:
1267 SwFrame *m_pForbidFrame;
1268 public:
1269 //Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete
1270 //it in e.g. SwSectionFrame::MergeNext etc because we will need it
1271 //again after the SwFrameDeleteGuard dtor
1272 explicit SwFrameDeleteGuard(SwFrame* pFrame)
1273 : m_pForbidFrame(pFrame)
1275 if (m_pForbidFrame)
1276 m_pForbidFrame->ForbidDelete();
1279 SwFrameDeleteGuard(const SwFrameDeleteGuard&) =delete;
1281 ~SwFrameDeleteGuard()
1283 if (m_pForbidFrame)
1284 m_pForbidFrame->AllowDelete();
1287 SwFrameDeleteGuard& operator=(const SwFrameDeleteGuard&) =delete;
1290 typedef tools::Long (SwFrame::*SwFrameGet)() const;
1291 typedef bool (SwFrame::*SwFrameMax)( tools::Long );
1292 typedef void (SwFrame::*SwFrameMakePos)( const SwFrame*, const SwFrame*, bool );
1293 typedef tools::Long (*SwOperator)( tools::Long, tools::Long );
1294 typedef void (SwFrame::*SwFrameSet)( tools::Long, tools::Long );
1296 struct SwRectFnCollection
1298 SwRectGet fnGetTop;
1299 SwRectGet fnGetBottom;
1300 SwRectGet fnGetLeft;
1301 SwRectGet fnGetRight;
1302 SwRectGet fnGetWidth;
1303 SwRectGet fnGetHeight;
1304 SwRectPoint fnGetPos;
1305 SwRectSize fnGetSize;
1307 SwRectSet fnSetTop;
1308 SwRectSet fnSetBottom;
1309 SwRectSet fnSetLeft;
1310 SwRectSet fnSetRight;
1311 SwRectSet fnSetWidth;
1312 SwRectSet fnSetHeight;
1314 SwRectSet fnSubTop;
1315 SwRectSet fnAddBottom;
1316 SwRectSet fnSubLeft;
1317 SwRectSet fnAddRight;
1318 SwRectSet fnAddWidth;
1319 SwRectSet fnAddHeight;
1321 SwRectSet fnSetPosX;
1322 SwRectSet fnSetPosY;
1324 SwFrameGet fnGetTopMargin;
1325 SwFrameGet fnGetBottomMargin;
1326 SwFrameGet fnGetLeftMargin;
1327 SwFrameGet fnGetRightMargin;
1328 SwFrameSet fnSetXMargins;
1329 SwFrameSet fnSetYMargins;
1330 SwFrameGet fnGetPrtTop;
1331 SwFrameGet fnGetPrtBottom;
1332 SwFrameGet fnGetPrtLeft;
1333 SwFrameGet fnGetPrtRight;
1334 SwRectDist fnTopDist;
1335 SwRectDist fnBottomDist;
1336 SwRectDist fnLeftDist;
1337 SwRectDist fnRightDist;
1338 SwFrameMax fnSetLimit;
1339 SwRectMax fnOverStep;
1341 SwRectSetPos fnSetPos;
1342 SwFrameMakePos fnMakePos;
1343 SwOperator fnXDiff;
1344 SwOperator fnYDiff;
1345 SwOperator fnXInc;
1346 SwOperator fnYInc;
1348 SwRectSetTwice fnSetLeftAndWidth;
1349 SwRectSetTwice fnSetTopAndHeight;
1352 typedef SwRectFnCollection* SwRectFn;
1354 // This class allows to use proper methods regardless of orientation (LTR/RTL, horizontal or vertical)
1355 extern SwRectFn fnRectHori, fnRectVert, fnRectVertL2R, fnRectVertL2RB2T;
1356 class SwRectFnSet {
1357 public:
1358 explicit SwRectFnSet(const SwFrame *pFrame)
1359 : m_bVert(pFrame->IsVertical())
1360 , m_bVertL2R(pFrame->IsVertLR())
1361 , m_bVertL2RB2T(pFrame->IsVertLRBT())
1363 m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori;
1366 void Refresh(const SwFrame *pFrame)
1368 m_bVert = pFrame->IsVertical();
1369 m_bVertL2R = pFrame->IsVertLR();
1370 m_bVertL2RB2T = pFrame->IsVertLRBT();
1371 m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori;
1374 bool IsVert() const { return m_bVert; }
1375 bool IsVertL2R() const { return m_bVertL2R; }
1376 SwRectFn FnRect() const { return m_fnRect; }
1378 bool PosDiff(const SwRect &rRect1, const SwRect &rRect2) const
1380 return ((rRect1.*m_fnRect->fnGetTop)() != (rRect2.*m_fnRect->fnGetTop)()
1381 || (rRect1.*m_fnRect->fnGetLeft)() != (rRect2.*m_fnRect->fnGetLeft)());
1384 tools::Long GetTop (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetTop) (); }
1385 tools::Long GetBottom(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetBottom)(); }
1386 tools::Long GetLeft (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetLeft) (); }
1387 tools::Long GetRight (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetRight) (); }
1388 tools::Long GetWidth (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetWidth) (); }
1389 tools::Long GetHeight(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetHeight)(); }
1390 Point GetPos (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetPos) (); }
1391 Size GetSize (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetSize) (); }
1393 void SetTop (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetTop) (nNew); }
1394 void SetBottom(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetBottom)(nNew); }
1395 void SetLeft (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetLeft) (nNew); }
1396 void SetRight (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetRight) (nNew); }
1397 void SetWidth (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetWidth) (nNew); }
1398 void SetHeight(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetHeight)(nNew); }
1400 void SubTop (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSubTop) (nNew); }
1401 void AddBottom(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddBottom)(nNew); }
1402 void SubLeft (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSubLeft) (nNew); }
1403 void AddRight (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddRight) (nNew); }
1404 void AddWidth (SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddWidth) (nNew); }
1405 void AddHeight(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnAddHeight)(nNew); }
1407 void SetPosX(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetPosX)(nNew); }
1408 void SetPosY(SwRect& rRect, tools::Long nNew) const { (rRect.*m_fnRect->fnSetPosY)(nNew); }
1410 tools::Long GetTopMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetTopMargin) (); }
1411 tools::Long GetBottomMargin(const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetBottomMargin)(); }
1412 tools::Long GetLeftMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetLeftMargin) (); }
1413 tools::Long GetRightMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetRightMargin) (); }
1414 void SetXMargins(SwFrame& rFrame, tools::Long nLeft, tools::Long nRight) const { (rFrame.*m_fnRect->fnSetXMargins)(nLeft, nRight); }
1415 void SetYMargins(SwFrame& rFrame, tools::Long nTop, tools::Long nBottom) const { (rFrame.*m_fnRect->fnSetYMargins)(nTop, nBottom); }
1416 tools::Long GetPrtTop (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtTop) (); }
1417 tools::Long GetPrtBottom (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtBottom) (); }
1418 tools::Long GetPrtLeft (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtLeft) (); }
1419 tools::Long GetPrtRight (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtRight) (); }
1420 tools::Long TopDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnTopDist) (nPos); }
1421 tools::Long BottomDist(const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnBottomDist) (nPos); }
1422 tools::Long LeftDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnLeftDist) (nPos); }
1423 tools::Long RightDist (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnRightDist) (nPos); }
1424 void SetLimit (SwFrame& rFrame, tools::Long nNew) const { (rFrame.*m_fnRect->fnSetLimit) (nNew); }
1425 bool OverStep (const SwRect& rRect, tools::Long nPos) const { return (rRect.*m_fnRect->fnOverStep) (nPos); }
1427 void SetPos(SwRect& rRect, const Point& rNew) const { (rRect.*m_fnRect->fnSetPos)(rNew); }
1428 void MakePos(SwFrame& rFrame, const SwFrame* pUp, const SwFrame* pPrv, bool bNotify) const { (rFrame.*m_fnRect->fnMakePos)(pUp, pPrv, bNotify); }
1429 tools::Long XDiff(tools::Long n1, tools::Long n2) const { return (m_fnRect->fnXDiff) (n1, n2); }
1430 tools::Long YDiff(tools::Long n1, tools::Long n2) const { return (m_fnRect->fnYDiff) (n1, n2); }
1431 tools::Long XInc (tools::Long n1, tools::Long n2) const { return (m_fnRect->fnXInc) (n1, n2); }
1432 tools::Long YInc (tools::Long n1, tools::Long n2) const { return (m_fnRect->fnYInc) (n1, n2); }
1434 void SetLeftAndWidth(SwRect& rRect, tools::Long nLeft, tools::Long nWidth) const { (rRect.*m_fnRect->fnSetLeftAndWidth)(nLeft, nWidth); }
1435 void SetTopAndHeight(SwRect& rRect, tools::Long nTop, tools::Long nHeight) const { (rRect.*m_fnRect->fnSetTopAndHeight)(nTop, nHeight); }
1437 private:
1438 bool m_bVert;
1439 bool m_bVertL2R;
1440 bool m_bVertL2RB2T;
1441 SwRectFn m_fnRect;
1444 #endif
1446 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */