1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
25 class SwAnchoredObject
;
28 struct SwCursorMoveState
;
31 class SwFormatFrameSize
;
34 /// A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
35 class SW_DLLPUBLIC SwLayoutFrame
: public SwFrame
37 // The SwFrame in disguise
38 friend class SwFlowFrame
;
41 // Releases the Lower while restructuring columns
42 friend SwFrame
* SaveContent( SwLayoutFrame
*, SwFrame
* );
43 friend void RestoreContent( SwFrame
*, SwLayoutFrame
*, SwFrame
*pSibling
);
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
;
54 std::vector
<SwAnchoredObject
*> m_VertPosOrientFramesFor
;
56 virtual SwTwips
ShrinkFrame( SwTwips
, bool bTst
= false, bool bInfo
= false ) override
;
57 virtual SwTwips
GrowFrame ( SwTwips
, bool bTst
= false, bool bInfo
= false ) override
;
59 tools::Long
CalcRel( const SwFormatFrameSize
&rSz
) const;
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
;
89 * Finds the closest Content for the SPoint
90 * Is used for Pages, Flys and Cells if GetModelPositionForViewPoint failed
92 const SwContentFrame
* GetContentPos( Point
&rPoint
, const bool bDontLeave
,
93 const bool bBodyOnly
= false,
94 SwCursorMoveState
*pCMS
= nullptr,
95 const bool bDefaultExpand
= true ) const;
97 SwLayoutFrame( SwFrameFormat
*, SwFrame
* );
99 virtual void PaintSwFrame( vcl::RenderContext
& rRenderContext
, SwRect
const&,
100 SwPrintData
const*const pPrintData
= nullptr ) const override
;
101 const SwFrame
*Lower() const { return m_pLower
; }
102 SwFrame
*Lower() { return m_pLower
; }
103 bool ContainsDeleteForbiddenLayFrame() const;
104 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 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 m_VertPosOrientFramesFor
.erase(
182 std::remove(m_VertPosOrientFramesFor
.begin(),
183 m_VertPosOrientFramesFor
.end(), pObj
),
184 m_VertPosOrientFramesFor
.end());
189 * In order to save us from duplicating implementations, we cast here
192 inline SwContentFrame
* SwLayoutFrame::ContainsContent()
194 return const_cast<SwContentFrame
*>(static_cast<const SwLayoutFrame
*>(this)->ContainsContent());
197 inline SwCellFrame
* SwLayoutFrame::FirstCell()
199 return const_cast<SwCellFrame
*>(static_cast<const SwLayoutFrame
*>(this)->FirstCell());
202 inline SwFrame
* SwLayoutFrame::ContainsAny( const bool _bInvestigateFootnoteForSections
)
204 return const_cast<SwFrame
*>(static_cast<const SwLayoutFrame
*>(this)->ContainsAny( _bInvestigateFootnoteForSections
));
208 * These SwFrame inlines are here, so that frame.hxx does not need to include layfrm.hxx
210 inline bool SwFrame::IsColBodyFrame() const
212 return mnFrameType
== SwFrameType::Body
&& GetUpper()->IsColumnFrame();
215 inline bool SwFrame::IsPageBodyFrame() const
217 return mnFrameType
== SwFrameType::Body
&& GetUpper()->IsPageFrame();
220 inline SwFrame
* SwLayoutFrame::GetLastLower()
222 return const_cast<SwFrame
*>(static_cast<const SwLayoutFrame
*>(this)->GetLastLower());
225 #endif // INCLUDED_SW_SOURCE_CORE_INC_LAYFRM_HXX
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */