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_PAGEFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
24 #include "ftnboss.hxx"
27 #include <SidebarWindowsTypes.hxx>
30 class SwFlyFrameFormat
;
34 struct SwCursorMoveState
;
36 namespace vcl
{ class Font
; }
38 class SwAnchoredObject
;
40 class VirtPageNumHint
;
43 enum class SwPageFrameInvFlags
: sal_uInt8
47 SetCompletePaint
= 0x02,
48 InvalidateNextPos
= 0x04,
52 InvalidateGrid
= 0x40,
56 template<> struct typed_flags
<SwPageFrameInvFlags
> : is_typed_flags
<SwPageFrameInvFlags
, 0x007f> {};
59 /// A page of the document layout. Upper frame is expected to be an SwRootFrame
60 /// instance. At least an SwBodyFrame lower is expected.
61 class SW_DLLPUBLIC SwPageFrame final
: public SwFootnoteBossFrame
65 std::unique_ptr
<SwSortedObjs
> m_pSortedObjs
;
67 SwPageDesc
*m_pDesc
; //PageDesc that describes the Page
69 /// Physical page number: index into list of SwRootFrame lowers
70 sal_uInt16 m_nPhyPageNum
;
72 bool m_bInvalidContent
:1;
73 bool m_bInvalidLayout
:1;
74 bool m_bInvalidFlyContent
:1;
75 bool m_bInvalidFlyLayout
:1;
76 bool m_bInvalidFlyInCnt
:1;
77 bool m_bFootnotePage
:1; // This Page is for document end footnotes
78 bool m_bEmptyPage
:1; // This Page is an explicitly empty page
79 bool m_bEndNotePage
:1; // 'Footnote page' for end notes
80 bool m_bInvalidSpelling
:1; // We need online spelling
81 bool m_bInvalidSmartTags
:1; // We need checking for smarttags
82 bool m_bInvalidAutoCmplWrds
:1; // Update auto complete word list
83 bool m_bInvalidWordCount
:1;
84 bool m_bHasGrid
:1; // Grid for Asian layout
86 static const sal_Int8 snShadowPxWidth
;
88 void UpdateAttr_( const SfxPoolItem
*, const SfxPoolItem
*, SwPageFrameInvFlags
&,
89 SwAttrSetChg
*pa
= nullptr, SwAttrSetChg
*pb
= nullptr );
90 void UpdateAttrForFormatChange( SwFormat
* pOldFormat
, SwFormat
* pNewFormat
, SwPageFrameInvFlags
& );
92 /// Adapt the max. footnote height in each single column
93 void SetColMaxFootnoteHeight();
95 /** determine rectangle for horizontal page shadow
100 input parameter - constant instance reference of the page rectangle.
101 Generally, it's the frame area of the page, but for empty pages in print
102 preview, this parameter is useful.
105 input parameter - instance of the view shell, for which the rectangle
108 @param _orBottomShadowRect
109 output parameter - instance reference of the bottom shadow rectangle for
110 the given page rectangle
113 static void GetHorizontalShadowRect( const SwRect
& _rPageRect
,
114 const SwViewShell
* _pViewShell
,
115 OutputDevice
const * pRenderContext
,
116 SwRect
& _orBottomShadowRect
,
117 bool bPaintLeftShadow
,
118 bool bPaintRightShadow
,
119 bool bRightSidebar
);
121 virtual void DestroyImpl() override
;
122 virtual ~SwPageFrame() override
;
123 virtual void MakeAll(vcl::RenderContext
* pRenderContext
) override
;
124 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
126 /// Calculate the content height of a page (without columns).
127 size_t GetContentHeight(const tools::Long nTop
, const tools::Long nBottom
) const;
129 std::vector
<basegfx::B2DPolygon
> GetSubsidiaryLinesPolygons(const SwViewShell
& rViewShell
) const;
132 SwPageFrame( SwFrameFormat
*, SwFrame
*, SwPageDesc
* );
134 /// Make this public, so that the SwViewShell can access it when switching from browse mode
135 /// Add/remove header/footer
136 void PrepareHeader();
137 void PrepareFooter();
139 const SwSortedObjs
*GetSortedObjs() const { return m_pSortedObjs
.get(); }
140 SwSortedObjs
*GetSortedObjs() { return m_pSortedObjs
.get(); }
142 void AppendDrawObjToPage( SwAnchoredObject
& _rNewObj
);
143 void RemoveDrawObjFromPage( SwAnchoredObject
& _rToRemoveObj
);
145 void AppendFlyToPage( SwFlyFrame
*pNew
);
146 void RemoveFlyFromPage( SwFlyFrame
*pToRemove
);
147 void MoveFly( SwFlyFrame
*pToMove
, SwPageFrame
*pDest
); // Optimized Remove/Append
149 void SetPageDesc( SwPageDesc
*, SwFrameFormat
* );
150 SwPageDesc
*GetPageDesc() { return m_pDesc
; }
151 const SwPageDesc
*GetPageDesc() const { return m_pDesc
; }
152 SwPageDesc
*FindPageDesc();
154 SwContentFrame
*FindLastBodyContent();
155 inline SwContentFrame
*FindFirstBodyContent();
156 inline const SwContentFrame
*FindFirstBodyContent() const;
157 inline const SwContentFrame
*FindLastBodyContent() const;
159 SwRect
GetBoundRect(OutputDevice
const * pOutputDevice
) const;
161 // Specialized GetContentPos() for Field in Frames
162 void GetContentPosition( const Point
&rPt
, SwPosition
&rPos
) const;
164 bool IsEmptyPage() const { return m_bEmptyPage
; } // Explicitly empty page
166 void UpdateFootnoteNum();
168 /// Always call after Paste
169 /// Creates the page-bound frames and formats the generic content
170 void PreparePage( bool bFootnote
);
172 // Sends a Prepare() to all ContentFrames caused by a changed register template
173 void PrepareRegisterChg();
175 // Appends a fly frame - the given one or a new one - at the page frame.
176 // Needed for <Modify> and <MakeFrames>
177 // - return value not needed any more
178 // - second parameter is of type <SwFlyFrameFormat*>
179 // - third parameter only needed for assertion, but calling method assures
180 // this assertion. Thus, delete it.
181 void PlaceFly( SwFlyFrame
* pFly
, SwFlyFrameFormat
* pFormat
);
183 virtual bool GetModelPositionForViewPoint( SwPosition
*, Point
&,
184 SwCursorMoveState
* = nullptr, bool bTestBackground
= false ) const override
;
185 virtual void Cut() override
;
186 virtual void Paste( SwFrame
* pParent
, SwFrame
* pSibling
= nullptr ) override
;
187 virtual void CheckDirection( bool bVert
) override
;
188 void CheckGrid( bool bInvalidate
);
189 void PaintGrid( OutputDevice
const * pOut
, SwRect
const &rRect
) const;
190 bool HasGrid() const { return m_bHasGrid
; }
192 void PaintDecorators( ) const;
193 virtual void PaintSubsidiaryLines( const SwPageFrame
*, const SwRect
& ) const override
;
194 void AddSubsidiaryLinesBounds(const SwViewShell
& rShell
, RectangleVector
& rRects
) const;
195 virtual void PaintBreak() const override
;
197 /// Paint line number etc.
198 void RefreshExtraData( const SwRect
& ) const;
200 /// Paint helper lines
201 void RefreshSubsidiary( const SwRect
& ) const;
203 /// Foot note interface
204 bool IsFootnotePage() const { return m_bFootnotePage
; }
205 bool IsEndNotePage() const { return m_bEndNotePage
; }
206 void SetFootnotePage( bool b
) { m_bFootnotePage
= b
; }
207 void SetEndNotePage( bool b
) { m_bEndNotePage
= b
; }
208 SwSectionFrame
* GetEndNoteSection();
210 sal_uInt16
GetPhyPageNum() const { return m_nPhyPageNum
;}
211 void SetPhyPageNum( sal_uInt16 nNum
) { m_nPhyPageNum
= nNum
;}
213 /// Validate, invalidate and query the Page status
214 /// Layout/Content and Fly/non-Fly respectively are inspected separately
215 inline void InvalidateFlyLayout() const;
216 inline void InvalidateFlyContent() const;
217 inline void InvalidateFlyInCnt() const;
218 inline void InvalidateLayout() const;
219 inline void InvalidateContent() const;
220 inline void InvalidateSpelling() const;
221 inline void InvalidateSmartTags() const;
222 inline void InvalidateAutoCompleteWords() const;
223 inline void InvalidateWordCount() const;
224 inline void ValidateFlyLayout() const;
225 inline void ValidateFlyContent() const;
226 inline void ValidateFlyInCnt() const;
227 inline void ValidateLayout() const;
228 inline void ValidateContent() const;
229 inline void ValidateSpelling() const;
230 inline void ValidateSmartTags() const;
231 inline void ValidateAutoCompleteWords() const;
232 inline void ValidateWordCount() const;
233 inline bool IsInvalid() const;
234 inline bool IsInvalidFly() const;
235 bool IsRightShadowNeeded() const;
236 bool IsLeftShadowNeeded() const;
237 bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout
; }
238 bool IsInvalidFlyContent() const { return m_bInvalidFlyContent
; }
239 bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt
; }
240 bool IsInvalidLayout() const { return m_bInvalidLayout
; }
241 bool IsInvalidContent() const { return (m_bInvalidContent
|| m_bInvalidFlyInCnt
); }
242 bool IsInvalidSpelling() const { return m_bInvalidSpelling
; }
243 bool IsInvalidSmartTags() const { return m_bInvalidSmartTags
; }
244 bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds
; }
245 bool IsInvalidWordCount() const { return m_bInvalidWordCount
; }
247 /** SwPageFrame::GetDrawBackgroundColor
249 determine the color, that is respectively will be drawn as background
252 @return reference to an instance of class Color
254 Color
GetDrawBackgroundColor() const;
256 /** paint margin area of a page
258 implement paint of margin area; margin area will be painted for a
259 view shell with a window and if the document is not in online layout.
262 input parameter - constant instance reference of the rectangle, for
263 which an output has to be generated.
266 input parameter - instance of the view shell, on which the output
269 void PaintMarginArea( const SwRect
& _rOutputRect
,
270 SwViewShell
const * _pViewShell
) const;
272 /** paint page border and shadow
275 input parameter - constant instance reference of the page rectangle.
276 Generally, it's the frame area of the page, but for empty pages in print
277 preview, this parameter is useful.
280 input parameter - instance of the view shell, on which the output
283 @param bPaintRightShadow
284 Should we paint shadow on the right or not (used in book mode)
286 @param bFullBottomShadow
287 Should we have a bottom shadow of the same size as the pages or
288 not (for right pages in book mode in a LTR environment).
291 Is the note sidebar on the right or not (used to adjust the
292 shadow with & position).
294 static void PaintBorderAndShadow( const SwRect
& _rPageRect
,
295 const SwViewShell
* _pViewShell
,
296 bool bPaintLeftShadow
,
297 bool bPaintRightShadow
,
298 bool bRightSidebar
);
300 /** get bound rectangle of border and shadow for repaints
303 input parameter - constant instance reference of the page rectangle.
304 Generally, it's the frame area of the page, but for empty pages in print
305 preview, this parameter is useful.
308 input parameter - instance of the view shell, for which the rectangle
311 @param _orBorderAndShadowBoundRect
312 output parameter - instance reference of the bounded border and shadow
313 rectangle for the given page rectangle
315 static void GetBorderAndShadowBoundRect( const SwRect
& _rPageRect
,
316 const SwViewShell
* _pViewShell
,
317 OutputDevice
const * pRenderContext
,
318 SwRect
& _orBorderAndShadowBoundRect
,
319 const bool bLeftShadow
,
320 const bool bRightShadow
,
321 const bool bRightSidebar
324 static void PaintNotesSidebar(const SwRect
& _rPageRect
, SwViewShell
* _pViewShell
, sal_uInt16 nPageNum
, bool bRight
);
325 static void PaintNotesSidebarArrows(const Point
&rMiddleFirst
, const Point
&rMiddleSecond
, SwViewShell
const * _pViewShell
, const Color
& rColorUp
, const Color
& rColorDown
);
327 asks the page on which side a margin should be shown, e.g for notes
328 returns true for left side, false for right side
330 sw::sidebarwindows::SidebarPosition
SidebarPosition() const;
332 virtual bool FillSelection( SwSelectionList
& rList
, const SwRect
& rRect
) const override
;
334 SwRect
PrtWithoutHeaderAndFooter() const;
336 // in case this is an empty page, this function returns the 'reference' page
337 const SwPageFrame
& GetFormatPage() const;
339 /// If in header or footer area, it also indicates the exact area in rControl.
340 /// Header or footer must be active, otherwise returns false.
341 bool IsOverHeaderFooterArea( const Point
& rPt
, FrameControlType
&rControl
) const;
343 // return font used to paint the "empty page" string
344 static const vcl::Font
& GetEmptyPageFont();
346 static SwTwips
GetSidebarBorderWidth( const SwViewShell
* );
348 /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?
349 /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
350 bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff
);
352 const SwHeaderFrame
* GetHeaderFrame() const;
353 const SwFooterFrame
* GetFooterFrame() const;
355 void UpdateVirtPageNumInfo(sw::VirtPageNumHint
& rHint
, const SwFrame
* pFrame
) const;
357 void dumpAsXml(xmlTextWriterPtr writer
= nullptr) const override
;
360 inline SwContentFrame
*SwPageFrame::FindFirstBodyContent()
362 SwLayoutFrame
*pBody
= FindBodyCont();
363 return pBody
? pBody
->ContainsContent() : nullptr;
365 inline const SwContentFrame
*SwPageFrame::FindFirstBodyContent() const
367 const SwLayoutFrame
*pBody
= FindBodyCont();
368 return pBody
? pBody
->ContainsContent() : nullptr;
370 inline const SwContentFrame
*SwPageFrame::FindLastBodyContent() const
372 return const_cast<SwPageFrame
*>(this)->FindLastBodyContent();
374 inline void SwPageFrame::InvalidateFlyLayout() const
376 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyLayout
= true;
378 inline void SwPageFrame::InvalidateFlyContent() const
380 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyContent
= true;
382 inline void SwPageFrame::InvalidateFlyInCnt() const
384 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyInCnt
= true;
386 inline void SwPageFrame::InvalidateLayout() const
388 const_cast<SwPageFrame
*>(this)->m_bInvalidLayout
= true;
390 inline void SwPageFrame::InvalidateContent() const
392 const_cast<SwPageFrame
*>(this)->m_bInvalidContent
= true;
394 inline void SwPageFrame::InvalidateSpelling() const
396 const_cast<SwPageFrame
*>(this)->m_bInvalidSpelling
= true;
399 inline void SwPageFrame::InvalidateSmartTags() const
401 const_cast<SwPageFrame
*>(this)->m_bInvalidSmartTags
= true;
403 inline void SwPageFrame::InvalidateAutoCompleteWords() const
405 const_cast<SwPageFrame
*>(this)->m_bInvalidAutoCmplWrds
= true;
407 inline void SwPageFrame::InvalidateWordCount() const
409 const_cast<SwPageFrame
*>(this)->m_bInvalidWordCount
= true;
411 inline void SwPageFrame::ValidateFlyLayout() const
413 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyLayout
= false;
415 inline void SwPageFrame::ValidateFlyContent() const
417 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyContent
= false;
419 inline void SwPageFrame::ValidateFlyInCnt() const
421 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyInCnt
= false;
423 inline void SwPageFrame::ValidateLayout() const
425 const_cast<SwPageFrame
*>(this)->m_bInvalidLayout
= false;
427 inline void SwPageFrame::ValidateContent() const
429 const_cast<SwPageFrame
*>(this)->m_bInvalidContent
= false;
431 inline void SwPageFrame::ValidateSpelling() const
433 const_cast<SwPageFrame
*>(this)->m_bInvalidSpelling
= false;
436 inline void SwPageFrame::ValidateSmartTags() const
438 const_cast<SwPageFrame
*>(this)->m_bInvalidSmartTags
= false;
440 inline void SwPageFrame::ValidateAutoCompleteWords() const
442 const_cast<SwPageFrame
*>(this)->m_bInvalidAutoCmplWrds
= false;
444 inline void SwPageFrame::ValidateWordCount() const
446 const_cast<SwPageFrame
*>(this)->m_bInvalidWordCount
= false;
449 inline bool SwPageFrame::IsInvalid() const
451 return (m_bInvalidContent
|| m_bInvalidLayout
|| m_bInvalidFlyInCnt
);
453 inline bool SwPageFrame::IsInvalidFly() const
455 return m_bInvalidFlyLayout
|| m_bInvalidFlyContent
;
459 class SwTextGridItem
;
461 SwTextGridItem
const* GetGridItem(SwPageFrame
const*const);
463 sal_uInt16
GetGridWidth(SwTextGridItem
const&, SwDoc
const&);
465 namespace sw
{ bool IsPageFrameEmpty(SwPageFrame
const& rPage
); }
468 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */