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 );
91 /// Adapt the max. footnote height in each single column
92 void SetColMaxFootnoteHeight();
94 /** determine rectangle for horizontal page shadow
99 input parameter - constant instance reference of the page rectangle.
100 Generally, it's the frame area of the page, but for empty pages in print
101 preview, this parameter is useful.
104 input parameter - instance of the view shell, for which the rectangle
107 @param _orBottomShadowRect
108 output parameter - instance reference of the bottom shadow rectangle for
109 the given page rectangle
112 static void GetHorizontalShadowRect( const SwRect
& _rPageRect
,
113 const SwViewShell
* _pViewShell
,
114 OutputDevice
const * pRenderContext
,
115 SwRect
& _orBottomShadowRect
,
116 bool bPaintLeftShadow
,
117 bool bPaintRightShadow
,
118 bool bRightSidebar
);
120 virtual void DestroyImpl() override
;
121 virtual ~SwPageFrame() override
;
122 virtual void MakeAll(vcl::RenderContext
* pRenderContext
) override
;
123 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
125 /// Calculate the content height of a page (without columns).
126 size_t GetContentHeight(const tools::Long nTop
, const tools::Long nBottom
) const;
128 std::vector
<basegfx::B2DPolygon
> GetSubsidiaryLinesPolygons(const SwViewShell
& rViewShell
) const;
131 SwPageFrame( SwFrameFormat
*, SwFrame
*, SwPageDesc
* );
133 /// Make this public, so that the SwViewShell can access it when switching from browse mode
134 /// Add/remove header/footer
135 void PrepareHeader();
136 void PrepareFooter();
138 const SwSortedObjs
*GetSortedObjs() const { return m_pSortedObjs
.get(); }
139 SwSortedObjs
*GetSortedObjs() { return m_pSortedObjs
.get(); }
141 void AppendDrawObjToPage( SwAnchoredObject
& _rNewObj
);
142 void RemoveDrawObjFromPage( SwAnchoredObject
& _rToRemoveObj
);
144 void AppendFlyToPage( SwFlyFrame
*pNew
);
145 void RemoveFlyFromPage( SwFlyFrame
*pToRemove
);
146 void MoveFly( SwFlyFrame
*pToMove
, SwPageFrame
*pDest
); // Optimized Remove/Append
148 void SetPageDesc( SwPageDesc
*, SwFrameFormat
* );
149 SwPageDesc
*GetPageDesc() { return m_pDesc
; }
150 const SwPageDesc
*GetPageDesc() const { return m_pDesc
; }
151 SwPageDesc
*FindPageDesc();
153 SwContentFrame
*FindLastBodyContent();
154 inline SwContentFrame
*FindFirstBodyContent();
155 inline const SwContentFrame
*FindFirstBodyContent() const;
156 inline const SwContentFrame
*FindLastBodyContent() const;
158 SwRect
GetBoundRect(OutputDevice
const * pOutputDevice
) const;
160 // Specialized GetContentPos() for Field in Frames
161 void GetContentPosition( const Point
&rPt
, SwPosition
&rPos
) const;
163 bool IsEmptyPage() const { return m_bEmptyPage
; } // Explicitly empty page
165 void UpdateFootnoteNum();
167 /// Always call after Paste
168 /// Creates the page-bound frames and formats the generic content
169 void PreparePage( bool bFootnote
);
171 // Sends a Prepare() to all ContentFrames caused by a changed register template
172 void PrepareRegisterChg();
174 // Appends a fly frame - the given one or a new one - at the page frame.
175 // Needed for <Modify> and <MakeFrames>
176 // - return value not needed any more
177 // - second parameter is of type <SwFlyFrameFormat*>
178 // - third parameter only needed for assertion, but calling method assures
179 // this assertion. Thus, delete it.
180 void PlaceFly( SwFlyFrame
* pFly
, SwFlyFrameFormat
* pFormat
);
182 virtual bool GetModelPositionForViewPoint( SwPosition
*, Point
&,
183 SwCursorMoveState
* = nullptr, bool bTestBackground
= false ) const override
;
184 virtual void Cut() override
;
185 virtual void Paste( SwFrame
* pParent
, SwFrame
* pSibling
= nullptr ) override
;
186 virtual void CheckDirection( bool bVert
) override
;
187 void CheckGrid( bool bInvalidate
);
188 void PaintGrid( OutputDevice
const * pOut
, SwRect
const &rRect
) const;
189 bool HasGrid() const { return m_bHasGrid
; }
191 void PaintDecorators( ) const;
192 virtual void PaintSubsidiaryLines( const SwPageFrame
*, const SwRect
& ) const override
;
193 void AddSubsidiaryLinesBounds(const SwViewShell
& rShell
, RectangleVector
& rRects
) const;
194 virtual void PaintBreak() const override
;
196 /// Paint line number etc.
197 void RefreshExtraData( const SwRect
& ) const;
199 /// Paint helper lines
200 void RefreshSubsidiary( const SwRect
& ) const;
202 /// Foot note interface
203 bool IsFootnotePage() const { return m_bFootnotePage
; }
204 bool IsEndNotePage() const { return m_bEndNotePage
; }
205 void SetFootnotePage( bool b
) { m_bFootnotePage
= b
; }
206 void SetEndNotePage( bool b
) { m_bEndNotePage
= b
; }
207 SwSectionFrame
* GetEndNoteSection();
209 sal_uInt16
GetPhyPageNum() const { return m_nPhyPageNum
;}
210 void SetPhyPageNum( sal_uInt16 nNum
) { m_nPhyPageNum
= nNum
;}
212 /// Validate, invalidate and query the Page status
213 /// Layout/Content and Fly/non-Fly respectively are inspected separately
214 inline void InvalidateFlyLayout() const;
215 inline void InvalidateFlyContent() const;
216 inline void InvalidateFlyInCnt() const;
217 inline void InvalidateLayout() const;
218 inline void InvalidateContent() const;
219 inline void InvalidateSpelling() const;
220 inline void InvalidateSmartTags() const;
221 inline void InvalidateAutoCompleteWords() const;
222 inline void InvalidateWordCount() const;
223 inline void ValidateFlyLayout() const;
224 inline void ValidateFlyContent() const;
225 inline void ValidateFlyInCnt() const;
226 inline void ValidateLayout() const;
227 inline void ValidateContent() const;
228 inline void ValidateSpelling() const;
229 inline void ValidateSmartTags() const;
230 inline void ValidateAutoCompleteWords() const;
231 inline void ValidateWordCount() const;
232 inline bool IsInvalid() const;
233 inline bool IsInvalidFly() const;
234 bool IsRightShadowNeeded() const;
235 bool IsLeftShadowNeeded() const;
236 bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout
; }
237 bool IsInvalidFlyContent() const { return m_bInvalidFlyContent
; }
238 bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt
; }
239 bool IsInvalidLayout() const { return m_bInvalidLayout
; }
240 bool IsInvalidContent() const { return (m_bInvalidContent
|| m_bInvalidFlyInCnt
); }
241 bool IsInvalidSpelling() const { return m_bInvalidSpelling
; }
242 bool IsInvalidSmartTags() const { return m_bInvalidSmartTags
; }
243 bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds
; }
244 bool IsInvalidWordCount() const { return m_bInvalidWordCount
; }
246 /** SwPageFrame::GetDrawBackgroundColor
248 determine the color, that is respectively will be drawn as background
251 @return reference to an instance of class Color
253 Color
GetDrawBackgroundColor() const;
255 /** paint margin area of a page
257 implement paint of margin area; margin area will be painted for a
258 view shell with a window and if the document is not in online layout.
261 input parameter - constant instance reference of the rectangle, for
262 which an output has to be generated.
265 input parameter - instance of the view shell, on which the output
268 void PaintMarginArea( const SwRect
& _rOutputRect
,
269 SwViewShell
const * _pViewShell
) const;
271 /** paint page border and shadow
274 input parameter - constant instance reference of the page rectangle.
275 Generally, it's the frame area of the page, but for empty pages in print
276 preview, this parameter is useful.
279 input parameter - instance of the view shell, on which the output
282 @param bPaintRightShadow
283 Should we paint shadow on the right or not (used in book mode)
285 @param bFullBottomShadow
286 Should we have a bottom shadow of the same size as the pages or
287 not (for right pages in book mode in a LTR environment).
290 Is the note sidebar on the right or not (used to adjust the
291 shadow with & position).
293 static void PaintBorderAndShadow( const SwRect
& _rPageRect
,
294 const SwViewShell
* _pViewShell
,
295 bool bPaintLeftShadow
,
296 bool bPaintRightShadow
,
297 bool bRightSidebar
);
299 /** get bound rectangle of border and shadow for repaints
302 input parameter - constant instance reference of the page rectangle.
303 Generally, it's the frame area of the page, but for empty pages in print
304 preview, this parameter is useful.
307 input parameter - instance of the view shell, for which the rectangle
310 @param _orBorderAndShadowBoundRect
311 output parameter - instance reference of the bounded border and shadow
312 rectangle for the given page rectangle
314 static void GetBorderAndShadowBoundRect( const SwRect
& _rPageRect
,
315 const SwViewShell
* _pViewShell
,
316 OutputDevice
const * pRenderContext
,
317 SwRect
& _orBorderAndShadowBoundRect
,
318 const bool bLeftShadow
,
319 const bool bRightShadow
,
320 const bool bRightSidebar
323 static void PaintNotesSidebar(const SwRect
& _rPageRect
, SwViewShell
* _pViewShell
, sal_uInt16 nPageNum
, bool bRight
);
324 static void PaintNotesSidebarArrows(const Point
&rMiddleFirst
, const Point
&rMiddleSecond
, SwViewShell
const * _pViewShell
, const Color
& rColorUp
, const Color
& rColorDown
);
326 asks the page on which side a margin should be shown, e.g for notes
327 returns true for left side, false for right side
329 sw::sidebarwindows::SidebarPosition
SidebarPosition() const;
331 virtual bool FillSelection( SwSelectionList
& rList
, const SwRect
& rRect
) const override
;
333 SwRect
PrtWithoutHeaderAndFooter() const;
335 // in case this is an empty page, this function returns the 'reference' page
336 const SwPageFrame
& GetFormatPage() const;
338 /// If in header or footer area, it also indicates the exact area in rControl.
339 /// Header or footer must be active, otherwise returns false.
340 bool IsOverHeaderFooterArea( const Point
& rPt
, FrameControlType
&rControl
) const;
342 // return font used to paint the "empty page" string
343 static const vcl::Font
& GetEmptyPageFont();
345 static SwTwips
GetSidebarBorderWidth( const SwViewShell
* );
347 /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?
348 /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
349 bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff
);
351 const SwHeaderFrame
* GetHeaderFrame() const;
352 const SwFooterFrame
* GetFooterFrame() const;
354 void UpdateVirtPageNumInfo(sw::VirtPageNumHint
& rHint
, const SwFrame
* pFrame
) const;
356 void dumpAsXml(xmlTextWriterPtr writer
= nullptr) const override
;
359 inline SwContentFrame
*SwPageFrame::FindFirstBodyContent()
361 SwLayoutFrame
*pBody
= FindBodyCont();
362 return pBody
? pBody
->ContainsContent() : nullptr;
364 inline const SwContentFrame
*SwPageFrame::FindFirstBodyContent() const
366 const SwLayoutFrame
*pBody
= FindBodyCont();
367 return pBody
? pBody
->ContainsContent() : nullptr;
369 inline const SwContentFrame
*SwPageFrame::FindLastBodyContent() const
371 return const_cast<SwPageFrame
*>(this)->FindLastBodyContent();
373 inline void SwPageFrame::InvalidateFlyLayout() const
375 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyLayout
= true;
377 inline void SwPageFrame::InvalidateFlyContent() const
379 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyContent
= true;
381 inline void SwPageFrame::InvalidateFlyInCnt() const
383 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyInCnt
= true;
385 inline void SwPageFrame::InvalidateLayout() const
387 const_cast<SwPageFrame
*>(this)->m_bInvalidLayout
= true;
389 inline void SwPageFrame::InvalidateContent() const
391 const_cast<SwPageFrame
*>(this)->m_bInvalidContent
= true;
393 inline void SwPageFrame::InvalidateSpelling() const
395 const_cast<SwPageFrame
*>(this)->m_bInvalidSpelling
= true;
398 inline void SwPageFrame::InvalidateSmartTags() const
400 const_cast<SwPageFrame
*>(this)->m_bInvalidSmartTags
= true;
402 inline void SwPageFrame::InvalidateAutoCompleteWords() const
404 const_cast<SwPageFrame
*>(this)->m_bInvalidAutoCmplWrds
= true;
406 inline void SwPageFrame::InvalidateWordCount() const
408 const_cast<SwPageFrame
*>(this)->m_bInvalidWordCount
= true;
410 inline void SwPageFrame::ValidateFlyLayout() const
412 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyLayout
= false;
414 inline void SwPageFrame::ValidateFlyContent() const
416 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyContent
= false;
418 inline void SwPageFrame::ValidateFlyInCnt() const
420 const_cast<SwPageFrame
*>(this)->m_bInvalidFlyInCnt
= false;
422 inline void SwPageFrame::ValidateLayout() const
424 const_cast<SwPageFrame
*>(this)->m_bInvalidLayout
= false;
426 inline void SwPageFrame::ValidateContent() const
428 const_cast<SwPageFrame
*>(this)->m_bInvalidContent
= false;
430 inline void SwPageFrame::ValidateSpelling() const
432 const_cast<SwPageFrame
*>(this)->m_bInvalidSpelling
= false;
435 inline void SwPageFrame::ValidateSmartTags() const
437 const_cast<SwPageFrame
*>(this)->m_bInvalidSmartTags
= false;
439 inline void SwPageFrame::ValidateAutoCompleteWords() const
441 const_cast<SwPageFrame
*>(this)->m_bInvalidAutoCmplWrds
= false;
443 inline void SwPageFrame::ValidateWordCount() const
445 const_cast<SwPageFrame
*>(this)->m_bInvalidWordCount
= false;
448 inline bool SwPageFrame::IsInvalid() const
450 return (m_bInvalidContent
|| m_bInvalidLayout
|| m_bInvalidFlyInCnt
);
452 inline bool SwPageFrame::IsInvalidFly() const
454 return m_bInvalidFlyLayout
|| m_bInvalidFlyContent
;
458 class SwTextGridItem
;
460 SwTextGridItem
const* GetGridItem(SwPageFrame
const*const);
462 sal_uInt16
GetGridWidth(SwTextGridItem
const&, SwDoc
const&);
464 namespace sw
{ bool IsPageFrameEmpty(SwPageFrame
const& rPage
); }
467 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
469 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */