nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / pagefrm.hxx
bloba67b089e5efb9b5d7563424372b19acb9bbc5945
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 "ftnboss.hxx"
24 #include "hffrm.hxx"
26 #include <SidebarWindowsTypes.hxx>
28 class SwFlyFrame;
29 class SwFlyFrameFormat;
30 class SwPageDesc;
31 class SwContentFrame;
32 struct SwPosition;
33 struct SwCursorMoveState;
34 class SwAttrSetChg;
35 namespace vcl { class Font; }
36 class SwSortedObjs;
37 class SwAnchoredObject;
39 /// A page of the document layout. Upper frame is expected to be an SwRootFrame
40 /// instance. At least an SwBodyFrame lower is expected.
41 class SAL_DLLPUBLIC_RTTI SwPageFrame: public SwFootnoteBossFrame
43 friend class SwFrame;
45 std::unique_ptr<SwSortedObjs> m_pSortedObjs;
47 SwPageDesc *m_pDesc; //PageDesc that describes the Page
49 /// Physical page number: index into list of SwRootFrame lowers
50 sal_uInt16 m_nPhyPageNum;
52 bool m_bInvalidContent :1;
53 bool m_bInvalidLayout :1;
54 bool m_bInvalidFlyContent :1;
55 bool m_bInvalidFlyLayout :1;
56 bool m_bInvalidFlyInCnt :1;
57 bool m_bFootnotePage :1; // This Page is for document end footnotes
58 bool m_bEmptyPage :1; // This Page is an explicitly empty page
59 bool m_bEndNotePage :1; // 'Footnote page' for end notes
60 bool m_bInvalidSpelling :1; // We need online spelling
61 bool m_bInvalidSmartTags :1; // We need checking for smarttags
62 bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list
63 bool m_bInvalidWordCount :1;
64 bool m_bHasGrid :1; // Grid for Asian layout
66 static const sal_Int8 mnShadowPxWidth;
68 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
69 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
71 /// Adapt the max. footnote height in each single column
72 void SetColMaxFootnoteHeight();
74 /** determine rectangle for horizontal page shadow
76 #i9719#
78 @param _rPageRect
79 input parameter - constant instance reference of the page rectangle.
80 Generally, it's the frame area of the page, but for empty pages in print
81 preview, this parameter is useful.
83 @param _pViewShell
84 input parameter - instance of the view shell, for which the rectangle
85 has to be generated.
87 @param _orBottomShadowRect
88 output parameter - instance reference of the bottom shadow rectangle for
89 the given page rectangle
92 static void GetHorizontalShadowRect( const SwRect& _rPageRect,
93 const SwViewShell* _pViewShell,
94 OutputDevice const * pRenderContext,
95 SwRect& _orBottomShadowRect,
96 bool bPaintLeftShadow,
97 bool bPaintRightShadow,
98 bool bRightSidebar );
100 virtual void DestroyImpl() override;
101 virtual ~SwPageFrame() override;
103 protected:
104 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
105 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
106 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
108 /// Calculate the content height of a page (without columns).
109 size_t GetContentHeight(const tools::Long nTop, const tools::Long nBottom) const;
111 public:
112 SwPageFrame( SwFrameFormat*, SwFrame*, SwPageDesc* );
114 /// Make this public, so that the SwViewShell can access it when switching from browse mode
115 /// Add/remove header/footer
116 void PrepareHeader();
117 void PrepareFooter();
119 const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); }
120 SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); }
122 void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
123 void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
125 void AppendFlyToPage( SwFlyFrame *pNew );
126 void RemoveFlyFromPage( SwFlyFrame *pToRemove );
127 void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append
129 void SetPageDesc( SwPageDesc *, SwFrameFormat * );
130 SwPageDesc *GetPageDesc() { return m_pDesc; }
131 const SwPageDesc *GetPageDesc() const { return m_pDesc; }
132 SwPageDesc *FindPageDesc();
134 SwContentFrame *FindLastBodyContent();
135 inline SwContentFrame *FindFirstBodyContent();
136 inline const SwContentFrame *FindFirstBodyContent() const;
137 inline const SwContentFrame *FindLastBodyContent() const;
139 SwRect GetBoundRect(OutputDevice const * pOutputDevice) const;
141 // Specialized GetContentPos() for Field in Frames
142 void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
144 bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page
146 void UpdateFootnoteNum();
148 /// Always call after Paste
149 /// Creates the page-bound frames and formats the generic content
150 void PreparePage( bool bFootnote );
152 // Sends a Prepare() to all ContentFrames caused by a changed register template
153 void PrepareRegisterChg();
155 // Appends a fly frame - the given one or a new one - at the page frame.
156 // Needed for <Modify> and <MakeFrames>
157 // - return value not needed any more
158 // - second parameter is of type <SwFlyFrameFormat*>
159 // - third parameter only needed for assertion, but calling method assures
160 // this assertion. Thus, delete it.
161 void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat );
163 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
164 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
165 /// Get info from Client
166 virtual bool GetInfo( SfxPoolItem& ) const override;
168 virtual void Cut() override;
169 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
170 virtual void CheckDirection( bool bVert ) override;
171 void CheckGrid( bool bInvalidate );
172 void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const;
173 bool HasGrid() const { return m_bHasGrid; }
175 void PaintDecorators( ) const;
176 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
177 virtual void PaintBreak() const override;
179 /// Paint line number etc.
180 void RefreshExtraData( const SwRect & ) const;
182 /// Paint helper lines
183 void RefreshSubsidiary( const SwRect& ) const;
185 /// Foot note interface
186 bool IsFootnotePage() const { return m_bFootnotePage; }
187 bool IsEndNotePage() const { return m_bEndNotePage; }
188 void SetFootnotePage( bool b ) { m_bFootnotePage = b; }
189 void SetEndNotePage( bool b ) { m_bEndNotePage = b; }
191 sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;}
192 void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;}
194 /// Validate, invalidate and query the Page status
195 /// Layout/Content and Fly/non-Fly respectively are inspected separately
196 inline void InvalidateFlyLayout() const;
197 inline void InvalidateFlyContent() const;
198 inline void InvalidateFlyInCnt() const;
199 inline void InvalidateLayout() const;
200 inline void InvalidateContent() const;
201 inline void InvalidateSpelling() const;
202 inline void InvalidateSmartTags() const;
203 inline void InvalidateAutoCompleteWords() const;
204 inline void InvalidateWordCount() const;
205 inline void ValidateFlyLayout() const;
206 inline void ValidateFlyContent() const;
207 inline void ValidateFlyInCnt() const;
208 inline void ValidateLayout() const;
209 inline void ValidateContent() const;
210 inline void ValidateSpelling() const;
211 inline void ValidateSmartTags() const;
212 inline void ValidateAutoCompleteWords() const;
213 inline void ValidateWordCount() const;
214 inline bool IsInvalid() const;
215 inline bool IsInvalidFly() const;
216 bool IsRightShadowNeeded() const;
217 bool IsLeftShadowNeeded() const;
218 bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; }
219 bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; }
220 bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; }
221 bool IsInvalidLayout() const { return m_bInvalidLayout; }
222 bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); }
223 bool IsInvalidSpelling() const { return m_bInvalidSpelling; }
224 bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; }
225 bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; }
226 bool IsInvalidWordCount() const { return m_bInvalidWordCount; }
228 /** SwPageFrame::GetDrawBackgrdColor
230 determine the color, that is respectively will be drawn as background
231 for the page frame.
233 @return reference to an instance of class Color
235 Color GetDrawBackgrdColor() const;
237 /** paint margin area of a page
239 implement paint of margin area; margin area will be painted for a
240 view shell with a window and if the document is not in online layout.
242 @param _rOutputRect
243 input parameter - constant instance reference of the rectangle, for
244 which an output has to be generated.
246 @param _pViewShell
247 input parameter - instance of the view shell, on which the output
248 has to be generated.
250 void PaintMarginArea( const SwRect& _rOutputRect,
251 SwViewShell const * _pViewShell ) const;
253 /** paint page border and shadow
255 @param _rPageRect
256 input parameter - constant instance reference of the page rectangle.
257 Generally, it's the frame area of the page, but for empty pages in print
258 preview, this parameter is useful.
260 @param _pViewShell
261 input parameter - instance of the view shell, on which the output
262 has to be generated.
264 @param bPaintRightShadow
265 Should we paint shadow on the right or not (used in book mode)
267 @param bFullBottomShadow
268 Should we have a bottom shadow of the same size as the pages or
269 not (for right pages in book mode in a LTR environment).
271 @param bRightSidebar
272 Is the note sidebar on the right or not (used to adjust the
273 shadow with & position).
275 static void PaintBorderAndShadow( const SwRect& _rPageRect,
276 const SwViewShell* _pViewShell,
277 bool bPaintLeftShadow,
278 bool bPaintRightShadow,
279 bool bRightSidebar );
281 /** get bound rectangle of border and shadow for repaints
283 @param _rPageRect
284 input parameter - constant instance reference of the page rectangle.
285 Generally, it's the frame area of the page, but for empty pages in print
286 preview, this parameter is useful.
288 @param _pViewShell
289 input parameter - instance of the view shell, for which the rectangle
290 has to be generated.
292 @param _orBorderAndShadowBoundRect
293 output parameter - instance reference of the bounded border and shadow
294 rectangle for the given page rectangle
296 static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
297 const SwViewShell* _pViewShell,
298 OutputDevice const * pRenderContext,
299 SwRect& _orBorderAndShadowBoundRect,
300 const bool bLeftShadow,
301 const bool bRightShadow,
302 const bool bRightSidebar
305 static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
306 static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown);
308 asks the page on which side a margin should be shown, e.g for notes
309 returns true for left side, false for right side
311 sw::sidebarwindows::SidebarPosition SidebarPosition() const;
313 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
315 SwRect PrtWithoutHeaderAndFooter() const;
317 // in case this is an empty page, this function returns the 'reference' page
318 const SwPageFrame& GetFormatPage() const;
320 /// If in header or footer area, it also indicates the exact area in rControl.
321 /// Header or footer must be active, otherwise returns false.
322 bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
324 // return font used to paint the "empty page" string
325 static const vcl::Font& GetEmptyPageFont();
327 static SwTwips GetSidebarBorderWidth( const SwViewShell* );
329 /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?
330 /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
331 bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
333 const SwHeaderFrame* GetHeaderFrame() const;
334 const SwFooterFrame* GetFooterFrame() const;
337 inline SwContentFrame *SwPageFrame::FindFirstBodyContent()
339 SwLayoutFrame *pBody = FindBodyCont();
340 return pBody ? pBody->ContainsContent() : nullptr;
342 inline const SwContentFrame *SwPageFrame::FindFirstBodyContent() const
344 const SwLayoutFrame *pBody = FindBodyCont();
345 return pBody ? pBody->ContainsContent() : nullptr;
347 inline const SwContentFrame *SwPageFrame::FindLastBodyContent() const
349 return const_cast<SwPageFrame*>(this)->FindLastBodyContent();
351 inline void SwPageFrame::InvalidateFlyLayout() const
353 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = true;
355 inline void SwPageFrame::InvalidateFlyContent() const
357 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = true;
359 inline void SwPageFrame::InvalidateFlyInCnt() const
361 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = true;
363 inline void SwPageFrame::InvalidateLayout() const
365 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = true;
367 inline void SwPageFrame::InvalidateContent() const
369 const_cast<SwPageFrame*>(this)->m_bInvalidContent = true;
371 inline void SwPageFrame::InvalidateSpelling() const
373 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = true;
376 inline void SwPageFrame::InvalidateSmartTags() const
378 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = true;
380 inline void SwPageFrame::InvalidateAutoCompleteWords() const
382 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = true;
384 inline void SwPageFrame::InvalidateWordCount() const
386 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = true;
388 inline void SwPageFrame::ValidateFlyLayout() const
390 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = false;
392 inline void SwPageFrame::ValidateFlyContent() const
394 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = false;
396 inline void SwPageFrame::ValidateFlyInCnt() const
398 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = false;
400 inline void SwPageFrame::ValidateLayout() const
402 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = false;
404 inline void SwPageFrame::ValidateContent() const
406 const_cast<SwPageFrame*>(this)->m_bInvalidContent = false;
408 inline void SwPageFrame::ValidateSpelling() const
410 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = false;
413 inline void SwPageFrame::ValidateSmartTags() const
415 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = false;
417 inline void SwPageFrame::ValidateAutoCompleteWords() const
419 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = false;
421 inline void SwPageFrame::ValidateWordCount() const
423 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = false;
426 inline bool SwPageFrame::IsInvalid() const
428 return (m_bInvalidContent || m_bInvalidLayout || m_bInvalidFlyInCnt);
430 inline bool SwPageFrame::IsInvalidFly() const
432 return m_bInvalidFlyLayout || m_bInvalidFlyContent;
436 class SwTextGridItem;
438 SwTextGridItem const* GetGridItem(SwPageFrame const*const);
440 sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
442 namespace sw { bool IsPageFrameEmpty(SwPageFrame const& rPage); }
445 #endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */