Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / pagefrm.hxx
blobcd2f14f5e885211d858c3da2377587d32286ddfd
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_PAGEFRM_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
22 #include <viewsh.hxx>
23 #include <swdllapi.h>
24 #include "ftnboss.hxx"
25 #include "hffrm.hxx"
27 #include <SidebarWindowsTypes.hxx>
29 class SwFlyFrame;
30 class SwFlyFrameFormat;
31 class SwPageDesc;
32 class SwContentFrame;
33 struct SwPosition;
34 struct SwCursorMoveState;
35 class SwAttrSetChg;
36 namespace vcl { class Font; }
37 class SwSortedObjs;
38 class SwAnchoredObject;
40 enum class SwPageFrameInvFlags : sal_uInt8
42 NONE = 0x00,
43 InvalidatePrt = 0x01,
44 SetCompletePaint = 0x02,
45 InvalidateNextPos = 0x04,
46 PrepareHeader = 0x08,
47 PrepareFooter = 0x10,
48 CheckGrid = 0x20,
49 InvalidateGrid = 0x40,
52 namespace o3tl {
53 template<> struct typed_flags<SwPageFrameInvFlags> : is_typed_flags<SwPageFrameInvFlags, 0x007f> {};
56 /// A page of the document layout. Upper frame is expected to be an SwRootFrame
57 /// instance. At least an SwBodyFrame lower is expected.
58 class SW_DLLPUBLIC SwPageFrame final: public SwFootnoteBossFrame
60 friend class SwFrame;
62 std::unique_ptr<SwSortedObjs> m_pSortedObjs;
64 SwPageDesc *m_pDesc; //PageDesc that describes the Page
66 /// Physical page number: index into list of SwRootFrame lowers
67 sal_uInt16 m_nPhyPageNum;
69 bool m_bInvalidContent :1;
70 bool m_bInvalidLayout :1;
71 bool m_bInvalidFlyContent :1;
72 bool m_bInvalidFlyLayout :1;
73 bool m_bInvalidFlyInCnt :1;
74 bool m_bFootnotePage :1; // This Page is for document end footnotes
75 bool m_bEmptyPage :1; // This Page is an explicitly empty page
76 bool m_bEndNotePage :1; // 'Footnote page' for end notes
77 bool m_bInvalidSpelling :1; // We need online spelling
78 bool m_bInvalidSmartTags :1; // We need checking for smarttags
79 bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list
80 bool m_bInvalidWordCount :1;
81 bool m_bHasGrid :1; // Grid for Asian layout
83 static const sal_Int8 snShadowPxWidth;
85 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwPageFrameInvFlags &,
86 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
88 /// Adapt the max. footnote height in each single column
89 void SetColMaxFootnoteHeight();
91 /** determine rectangle for horizontal page shadow
93 #i9719#
95 @param _rPageRect
96 input parameter - constant instance reference of the page rectangle.
97 Generally, it's the frame area of the page, but for empty pages in print
98 preview, this parameter is useful.
100 @param _pViewShell
101 input parameter - instance of the view shell, for which the rectangle
102 has to be generated.
104 @param _orBottomShadowRect
105 output parameter - instance reference of the bottom shadow rectangle for
106 the given page rectangle
109 static void GetHorizontalShadowRect( const SwRect& _rPageRect,
110 const SwViewShell* _pViewShell,
111 OutputDevice const * pRenderContext,
112 SwRect& _orBottomShadowRect,
113 bool bPaintLeftShadow,
114 bool bPaintRightShadow,
115 bool bRightSidebar );
117 virtual void DestroyImpl() override;
118 virtual ~SwPageFrame() override;
119 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
120 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
122 /// Calculate the content height of a page (without columns).
123 size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const;
125 public:
126 SwPageFrame( SwFrameFormat*, SwFrame*, SwPageDesc* );
128 /// Make this public, so that the SwViewShell can access it when switching from browse mode
129 /// Add/remove header/footer
130 void PrepareHeader();
131 void PrepareFooter();
133 const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); }
134 SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); }
136 void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
137 void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
139 void AppendFlyToPage( SwFlyFrame *pNew );
140 void RemoveFlyFromPage( SwFlyFrame *pToRemove );
141 void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append
143 void SetPageDesc( SwPageDesc *, SwFrameFormat * );
144 SwPageDesc *GetPageDesc() { return m_pDesc; }
145 const SwPageDesc *GetPageDesc() const { return m_pDesc; }
146 SwPageDesc *FindPageDesc();
148 SwContentFrame *FindLastBodyContent();
149 inline SwContentFrame *FindFirstBodyContent();
150 inline const SwContentFrame *FindFirstBodyContent() const;
151 inline const SwContentFrame *FindLastBodyContent() const;
153 SwRect GetBoundRect(OutputDevice const * pOutputDevice) const;
155 // Specialized GetContentPos() for Field in Frames
156 void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
158 bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page
160 void UpdateFootnoteNum();
162 /// Always call after Paste
163 /// Creates the page-bound frames and formats the generic content
164 void PreparePage( bool bFootnote );
166 // Sends a Prepare() to all ContentFrames caused by a changed register template
167 void PrepareRegisterChg();
169 // Appends a fly frame - the given one or a new one - at the page frame.
170 // Needed for <Modify> and <MakeFrames>
171 // - return value not needed any more
172 // - second parameter is of type <SwFlyFrameFormat*>
173 // - third parameter only needed for assertion, but calling method assures
174 // this assertion. Thus, delete it.
175 void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat );
177 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
178 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
179 /// Get info from Client
180 virtual bool GetInfo( SfxPoolItem& ) const override;
182 virtual void Cut() override;
183 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
184 virtual void CheckDirection( bool bVert ) override;
185 void CheckGrid( bool bInvalidate );
186 void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const;
187 bool HasGrid() const { return m_bHasGrid; }
189 void PaintDecorators( ) const;
190 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
191 virtual void PaintBreak() const override;
193 /// Paint line number etc.
194 void RefreshExtraData( const SwRect & ) const;
196 /// Paint helper lines
197 void RefreshSubsidiary( const SwRect& ) const;
199 /// Foot note interface
200 bool IsFootnotePage() const { return m_bFootnotePage; }
201 bool IsEndNotePage() const { return m_bEndNotePage; }
202 void SetFootnotePage( bool b ) { m_bFootnotePage = b; }
203 void SetEndNotePage( bool b ) { m_bEndNotePage = b; }
205 sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;}
206 void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;}
208 /// Validate, invalidate and query the Page status
209 /// Layout/Content and Fly/non-Fly respectively are inspected separately
210 inline void InvalidateFlyLayout() const;
211 inline void InvalidateFlyContent() const;
212 inline void InvalidateFlyInCnt() const;
213 inline void InvalidateLayout() const;
214 inline void InvalidateContent() const;
215 inline void InvalidateSpelling() const;
216 inline void InvalidateSmartTags() const;
217 inline void InvalidateAutoCompleteWords() const;
218 inline void InvalidateWordCount() const;
219 inline void ValidateFlyLayout() const;
220 inline void ValidateFlyContent() const;
221 inline void ValidateFlyInCnt() const;
222 inline void ValidateLayout() const;
223 inline void ValidateContent() const;
224 inline void ValidateSpelling() const;
225 inline void ValidateSmartTags() const;
226 inline void ValidateAutoCompleteWords() const;
227 inline void ValidateWordCount() const;
228 inline bool IsInvalid() const;
229 inline bool IsInvalidFly() const;
230 bool IsRightShadowNeeded() const;
231 bool IsLeftShadowNeeded() const;
232 bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; }
233 bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; }
234 bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; }
235 bool IsInvalidLayout() const { return m_bInvalidLayout; }
236 bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); }
237 bool IsInvalidSpelling() const { return m_bInvalidSpelling; }
238 bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; }
239 bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; }
240 bool IsInvalidWordCount() const { return m_bInvalidWordCount; }
242 /** SwPageFrame::GetDrawBackgroundColor
244 determine the color, that is respectively will be drawn as background
245 for the page frame.
247 @return reference to an instance of class Color
249 Color GetDrawBackgroundColor() const;
251 /** paint margin area of a page
253 implement paint of margin area; margin area will be painted for a
254 view shell with a window and if the document is not in online layout.
256 @param _rOutputRect
257 input parameter - constant instance reference of the rectangle, for
258 which an output has to be generated.
260 @param _pViewShell
261 input parameter - instance of the view shell, on which the output
262 has to be generated.
264 void PaintMarginArea( const SwRect& _rOutputRect,
265 SwViewShell const * _pViewShell ) const;
267 /** paint page border and shadow
269 @param _rPageRect
270 input parameter - constant instance reference of the page rectangle.
271 Generally, it's the frame area of the page, but for empty pages in print
272 preview, this parameter is useful.
274 @param _pViewShell
275 input parameter - instance of the view shell, on which the output
276 has to be generated.
278 @param bPaintRightShadow
279 Should we paint shadow on the right or not (used in book mode)
281 @param bFullBottomShadow
282 Should we have a bottom shadow of the same size as the pages or
283 not (for right pages in book mode in a LTR environment).
285 @param bRightSidebar
286 Is the note sidebar on the right or not (used to adjust the
287 shadow with & position).
289 static void PaintBorderAndShadow( const SwRect& _rPageRect,
290 const SwViewShell* _pViewShell,
291 bool bPaintLeftShadow,
292 bool bPaintRightShadow,
293 bool bRightSidebar );
295 /** get bound rectangle of border and shadow for repaints
297 @param _rPageRect
298 input parameter - constant instance reference of the page rectangle.
299 Generally, it's the frame area of the page, but for empty pages in print
300 preview, this parameter is useful.
302 @param _pViewShell
303 input parameter - instance of the view shell, for which the rectangle
304 has to be generated.
306 @param _orBorderAndShadowBoundRect
307 output parameter - instance reference of the bounded border and shadow
308 rectangle for the given page rectangle
310 static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
311 const SwViewShell* _pViewShell,
312 OutputDevice const * pRenderContext,
313 SwRect& _orBorderAndShadowBoundRect,
314 const bool bLeftShadow,
315 const bool bRightShadow,
316 const bool bRightSidebar
319 static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
320 static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown);
322 asks the page on which side a margin should be shown, e.g for notes
323 returns true for left side, false for right side
325 sw::sidebarwindows::SidebarPosition SidebarPosition() const;
327 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
329 SwRect PrtWithoutHeaderAndFooter() const;
331 // in case this is an empty page, this function returns the 'reference' page
332 const SwPageFrame& GetFormatPage() const;
334 /// If in header or footer area, it also indicates the exact area in rControl.
335 /// Header or footer must be active, otherwise returns false.
336 bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
338 // return font used to paint the "empty page" string
339 static const vcl::Font& GetEmptyPageFont();
341 static SwTwips GetSidebarBorderWidth( const SwViewShell* );
343 /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?
344 /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
345 bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
347 const SwHeaderFrame* GetHeaderFrame() const;
348 const SwFooterFrame* GetFooterFrame() const;
350 void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
353 inline SwContentFrame *SwPageFrame::FindFirstBodyContent()
355 SwLayoutFrame *pBody = FindBodyCont();
356 return pBody ? pBody->ContainsContent() : nullptr;
358 inline const SwContentFrame *SwPageFrame::FindFirstBodyContent() const
360 const SwLayoutFrame *pBody = FindBodyCont();
361 return pBody ? pBody->ContainsContent() : nullptr;
363 inline const SwContentFrame *SwPageFrame::FindLastBodyContent() const
365 return const_cast<SwPageFrame*>(this)->FindLastBodyContent();
367 inline void SwPageFrame::InvalidateFlyLayout() const
369 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = true;
371 inline void SwPageFrame::InvalidateFlyContent() const
373 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = true;
375 inline void SwPageFrame::InvalidateFlyInCnt() const
377 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = true;
379 inline void SwPageFrame::InvalidateLayout() const
381 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = true;
383 inline void SwPageFrame::InvalidateContent() const
385 const_cast<SwPageFrame*>(this)->m_bInvalidContent = true;
387 inline void SwPageFrame::InvalidateSpelling() const
389 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = true;
392 inline void SwPageFrame::InvalidateSmartTags() const
394 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = true;
396 inline void SwPageFrame::InvalidateAutoCompleteWords() const
398 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = true;
400 inline void SwPageFrame::InvalidateWordCount() const
402 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = true;
404 inline void SwPageFrame::ValidateFlyLayout() const
406 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = false;
408 inline void SwPageFrame::ValidateFlyContent() const
410 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = false;
412 inline void SwPageFrame::ValidateFlyInCnt() const
414 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = false;
416 inline void SwPageFrame::ValidateLayout() const
418 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = false;
420 inline void SwPageFrame::ValidateContent() const
422 const_cast<SwPageFrame*>(this)->m_bInvalidContent = false;
424 inline void SwPageFrame::ValidateSpelling() const
426 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = false;
429 inline void SwPageFrame::ValidateSmartTags() const
431 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = false;
433 inline void SwPageFrame::ValidateAutoCompleteWords() const
435 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = false;
437 inline void SwPageFrame::ValidateWordCount() const
439 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = false;
442 inline bool SwPageFrame::IsInvalid() const
444 return (m_bInvalidContent || m_bInvalidLayout || m_bInvalidFlyInCnt);
446 inline bool SwPageFrame::IsInvalidFly() const
448 return m_bInvalidFlyLayout || m_bInvalidFlyContent;
452 class SwTextGridItem;
454 SwTextGridItem const* GetGridItem(SwPageFrame const*const);
456 sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
458 namespace sw { bool IsPageFrameEmpty(SwPageFrame const& rPage); }
461 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
463 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */