Add a comment to clarify what kind of inputs the class handles
[LibreOffice.git] / sw / source / core / inc / layfrm.hxx
blobbf24ab7e928b93981523519d83dfb6647b7aaf78
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
22 #include "frame.hxx"
23 #include <swdllapi.h>
25 class SwAnchoredObject;
26 class SwContentFrame;
27 class SwFormatCol;
28 struct SwCursorMoveState;
29 class SwFrameFormat;
30 class SwBorderAttrs;
31 class SwFormatFrameSize;
32 class SwCellFrame;
34 /// A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
35 class SAL_DLLPUBLIC_RTTI SwLayoutFrame: public SwFrame
37 // The SwFrame in disguise
38 friend class SwFlowFrame;
39 friend class SwFrame;
41 // Releases the Lower while restructuring columns
42 friend SwFrame* SaveContent( SwLayoutFrame *, SwFrame * );
43 friend void RestoreContent( SwFrame *, SwLayoutFrame *, SwFrame *pSibling );
45 protected:
47 virtual void DestroyImpl() override;
48 virtual ~SwLayoutFrame() override;
50 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
51 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
53 SwFrame * m_pLower;
54 std::vector<SwAnchoredObject*> m_VertPosOrientFramesFor;
56 virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override;
57 virtual SwTwips GrowFrame(SwTwips, SwResizeLimitReason&, bool bTst, bool bInfo) override;
59 tools::Long CalcRel( const SwFormatFrameSize &rSz ) const;
61 public:
62 // --> #i28701#
64 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const;
65 void RefreshLaySubsidiary( const SwPageFrame*, const SwRect& ) const;
66 void RefreshExtraData( const SwRect & ) const;
68 /// Change size of lowers proportionally
69 void ChgLowersProp( const Size& rOldSize );
71 void AdjustColumns( const SwFormatCol *pCol, bool bAdjustAttributes );
73 void ChgColumns( const SwFormatCol &rOld, const SwFormatCol &rNew,
74 const bool bChgFootnote = false );
76 /// Paints the column separation line for the inner columns
77 void PaintColLines( const SwRect &, const SwFormatCol &,
78 const SwPageFrame * ) const;
80 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
82 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
83 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
85 virtual void Cut() override;
86 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
87 virtual void HideAndShowObjects() override;
89 /**
90 * Finds the closest Content for the SPoint
91 * Is used for Pages, Flys and Cells if GetModelPositionForViewPoint failed
93 const SwContentFrame* GetContentPos( Point &rPoint, const bool bDontLeave,
94 const bool bBodyOnly = false,
95 SwCursorMoveState *pCMS = nullptr,
96 const bool bDefaultExpand = true ) const;
98 SwLayoutFrame( SwFrameFormat*, SwFrame* );
100 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, PaintFrameMode mode = PAINT_ALL ) const override;
101 SAL_RET_MAYBENULL const SwFrame *Lower() const { return m_pLower; }
102 SAL_RET_MAYBENULL SwFrame *Lower() { return m_pLower; }
103 bool ContainsDeleteForbiddenLayFrame() const;
104 SW_DLLPUBLIC const SwContentFrame *ContainsContent() const;
105 inline SwContentFrame *ContainsContent();
106 const SwCellFrame *FirstCell() const;
107 inline SwCellFrame *FirstCell();
110 * Method <ContainsAny()> doesn't investigate content of footnotes by default.
111 * But under certain circumstances this investigation is intended.
112 * Thus, introduce new optional parameter <_bInvestigateFootnoteForSections>.
113 * It's default is <false>, still indicating that content of footnotes isn't
114 * investigated for sections.
116 const SwFrame *ContainsAny( const bool _bInvestigateFootnoteForSections = false ) const;
117 inline SwFrame *ContainsAny( const bool _bInvestigateFootnoteForSections = false );
118 bool IsAnLower( const SwFrame * ) const;
120 virtual const SwFrameFormat *GetFormat() const;
121 virtual SwFrameFormat *GetFormat();
122 void SetFrameFormat( SwFrameFormat* );
125 * Moving the Footnotes of all Lowers - starting from StartContent
127 * @returns true if at least one Footnote was moved
128 * Calls the page number update if bFootnoteNums is set
130 bool MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFrame *pOldBoss,
131 SwFootnoteBossFrame *pNewBoss, const bool bFootnoteNums );
133 // --> #i28701# - change purpose of method and its name
134 // --> #i44016# - add parameter <_bUnlockPosOfObjs> to
135 /// force an unlockposition call for the lower objects.
136 void NotifyLowerObjs( const bool _bUnlockPosOfObjs = false );
139 * Invalidates the inner Frames, whose width and/or height are
140 * calculated using percentages.
141 * Frames that are anchored to this or inner Frames, are also invalidated.
143 void InvaPercentLowers( SwTwips nDiff = 0 );
145 /// Called by Format for Frames and Areas with columns
146 void FormatWidthCols( const SwBorderAttrs &, const SwTwips nBorder,
147 const SwTwips nMinHeight );
150 * InnerHeight returns the height of the content and may be bigger or
151 * less than the PrtArea-Height of the layoutframe himself
153 SwTwips InnerHeight() const;
155 /** method to check relative position of layout frame to
156 a given layout frame.
158 refactoring of pseudo-local method <lcl_Apres(..)> in
159 <txtftn.cxx> for #104840#.
161 @param _aCheckRefLayFrame
162 constant reference of an instance of class <SwLayoutFrame> which
163 is used as the reference for the relative position check.
165 @return true, if <this> is positioned before the layout frame <p>
167 bool IsBefore( const SwLayoutFrame* _pCheckRefLayFrame ) const;
169 SW_DLLPUBLIC const SwFrame* GetLastLower() const;
170 inline SwFrame* GetLastLower();
172 virtual void PaintBreak() const;
174 void SetVertPosOrientFrameFor(SwAnchoredObject *pObj)
176 m_VertPosOrientFramesFor.push_back(pObj);
179 void ClearVertPosOrientFrameFor(SwAnchoredObject *pObj)
181 std::erase(m_VertPosOrientFramesFor, pObj);
183 void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
187 * In order to save us from duplicating implementations, we cast here
188 * a little.
190 inline SwContentFrame* SwLayoutFrame::ContainsContent()
192 return const_cast<SwContentFrame*>(static_cast<const SwLayoutFrame*>(this)->ContainsContent());
195 inline SwCellFrame* SwLayoutFrame::FirstCell()
197 return const_cast<SwCellFrame*>(static_cast<const SwLayoutFrame*>(this)->FirstCell());
200 inline SwFrame* SwLayoutFrame::ContainsAny( const bool _bInvestigateFootnoteForSections )
202 return const_cast<SwFrame*>(static_cast<const SwLayoutFrame*>(this)->ContainsAny( _bInvestigateFootnoteForSections ));
206 * These SwFrame inlines are here, so that frame.hxx does not need to include layfrm.hxx
208 inline bool SwFrame::IsColBodyFrame() const
210 return mnFrameType == SwFrameType::Body && GetUpper()->IsColumnFrame();
213 inline bool SwFrame::IsPageBodyFrame() const
215 return mnFrameType == SwFrameType::Body && GetUpper()->IsPageFrame();
218 inline SwFrame* SwLayoutFrame::GetLastLower()
220 return const_cast<SwFrame*>(static_cast<const SwLayoutFrame*>(this)->GetLastLower());
223 #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */