Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _PAGEFRM_HXX
29 : : #define _PAGEFRM_HXX
30 : :
31 : : #include <viewsh.hxx>
32 : : #include "ftnboss.hxx"
33 : : #include <tools/mempool.hxx>
34 : :
35 : : #include <SidebarWindowsTypes.hxx>
36 : :
37 : : class SwFlyFrm;
38 : : class SwFlyFrmFmt;
39 : : class SwPageDesc;
40 : : class SwCntntFrm;
41 : : struct SwPosition;
42 : : struct SwCrsrMoveState;
43 : : class SwAttrSetChg;
44 : : class Font;
45 : :
46 : : // #i28701# - replaced by class <SwSortedObjs>
47 : : class SwSortedObjs;
48 : : // #i28701#
49 : : class SwAnchoredObject;
50 : :
51 : : enum SwPageChg
52 : : {
53 : : CHG_NEWPAGE,
54 : : CHG_CUTPAGE,
55 : : CHG_CHGPAGE
56 : : };
57 : :
58 : : /// A page of the document layout.
59 : : class SwPageFrm: public SwFtnBossFrm
60 : : {
61 : : friend class SwFrm;
62 : :
63 : : // #i28701# - use <SwSortedObjs>
64 : : SwSortedObjs *pSortedObjs;
65 : :
66 : : SwPageDesc *pDesc; //PageDesc der die Seite beschreibt.
67 : :
68 : : sal_uInt16 nPhyPageNum; //Physikalische Seitennummer.
69 : :
70 : : sal_Bool bInvalidCntnt :1;
71 : : sal_Bool bInvalidLayout :1;
72 : : sal_Bool bInvalidFlyCntnt :1;
73 : : sal_Bool bInvalidFlyLayout :1;
74 : : sal_Bool bInvalidFlyInCnt :1;
75 : : sal_Bool bFtnPage :1; //Diese Seite ist fuer Dokumentende-Fussnoten.
76 : : sal_Bool bEmptyPage :1; //Dies ist eine explizite Leerseite
77 : : sal_Bool bEndNotePage :1; //'Fussnotenseite' fuer Endnoten
78 : : sal_Bool bInvalidSpelling :1; //Das Online-Spelling ist gefordert
79 : : sal_Bool bInvalidSmartTags :1; //checking for smarttags is needed // SMARTTAGS
80 : : sal_Bool bInvalidAutoCmplWrds :1; //Auto-Complete Wordliste aktualisieren
81 : : sal_Bool bInvalidWordCount :1;
82 : : sal_Bool bHasGrid :1; // Grid for Asian layout
83 : :
84 : : // #i28701# - boolean, indicating that layout of page frame
85 : : // is in progress.
86 : : bool mbLayoutInProgress;
87 : :
88 : : static const sal_Int8 mnShadowPxWidth;
89 : :
90 : : void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
91 : : SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
92 : :
93 : : // Anpassen der max. Fussnotenhoehen in den einzelnen Spalten
94 : : void SetColMaxFtnHeight();
95 : :
96 : : /** determine rectangle for horizontal page shadow
97 : :
98 : : #i9719#
99 : :
100 : : @param _rPageRect
101 : : input parameter - constant instance reference of the page rectangle.
102 : : Generally, it's the frame area of the page, but for empty pages in print
103 : : preview, this parameter is useful.
104 : :
105 : : @param _pViewShell
106 : : input parameter - instance of the view shell, for which the rectangle
107 : : has to be generated.
108 : :
109 : : @param _orBottomShadowRect
110 : : output parameter - instance reference of the bottom shadow rectangle for
111 : : the given page rectangle
112 : : */
113 : :
114 : : static void GetHorizontalShadowRect( const SwRect& _rPageRect,
115 : : const ViewShell* _pViewShell,
116 : : SwRect& _orBottomShadowRect,
117 : : bool bPaintLeftShadow,
118 : : bool bPaintRightShadow,
119 : : bool bRightSidebar );
120 : :
121 : : protected:
122 : : virtual void MakeAll();
123 : : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
124 : :
125 : : public:
126 [ + - ][ + - ]: 2745 : DECL_FIXEDMEMPOOL_NEWDEL(SwPageFrm)
127 : :
128 : : SwPageFrm( SwFrmFmt*, SwFrm*, SwPageDesc* );
129 : : ~SwPageFrm();
130 : :
131 : : //public, damit die ViewShell beim Umschalten vom BrowseMode darauf
132 : : //zugreifen kann.
133 : : void PrepareHeader(); //Kopf-/Fusszeilen anlegen/entfernen.
134 : : void PrepareFooter();
135 : :
136 : 119433 : const SwSortedObjs *GetSortedObjs() const { return pSortedObjs; }
137 : 77409 : SwSortedObjs *GetSortedObjs() { return pSortedObjs; }
138 : :
139 : : // #i28701# - new methods to append/remove drawing objects
140 : : void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
141 : : void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
142 : :
143 : : void AppendFlyToPage( SwFlyFrm *pNew );
144 : : void RemoveFlyFromPage( SwFlyFrm *pToRemove );
145 : : void MoveFly( SwFlyFrm *pToMove, SwPageFrm *pDest );//optimiertes Remove/Append
146 : :
147 : : void SetPageDesc( SwPageDesc *, SwFrmFmt * );
148 : 2366 : SwPageDesc *GetPageDesc() { return pDesc; }
149 : 7999 : const SwPageDesc *GetPageDesc() const { return pDesc; }
150 : : SwPageDesc *FindPageDesc();
151 : :
152 : : SwCntntFrm *FindLastBodyCntnt();
153 : : inline SwCntntFrm *FindFirstBodyCntnt();
154 : : inline const SwCntntFrm *FindFirstBodyCntnt() const;
155 : : inline const SwCntntFrm *FindLastBodyCntnt() const;
156 : :
157 : : SwRect GetBoundRect() const;
158 : :
159 : : //Spezialisiertes GetCntntPos() fuer Felder in Rahmen.
160 : : void GetCntntPosition( const Point &rPt, SwPosition &rPos ) const;
161 : :
162 : 137151 : sal_Bool IsEmptyPage() const { return bEmptyPage; } //explizite Leerseite.
163 : :
164 : : void UpdateFtnNum();
165 : :
166 : : //Immer nach dem Paste rufen. Erzeugt die Seitengeb. Rahmen und Formatiert
167 : : //generischen Inhalt.
168 : : void PreparePage( sal_Bool bFtn );
169 : :
170 : : //Schickt an alle ContentFrames ein Prepare wg. geaenderter Registervorlage
171 : : void PrepareRegisterChg();
172 : :
173 : : // #i50432# - adjust method description and synopsis.
174 : : // Appends a fly frame - the given one or a new one - at the page frame.
175 : : // Needed for <Modify> and <MakeFrms>
176 : : // - return value not needed any more
177 : : // - second parameter is of type <SwFlyFrmFmt*>
178 : : // - third parameter only needed for assertion, but calling method assures
179 : : // this assertion. Thus, delete it.
180 : : void PlaceFly( SwFlyFrm* pFly, SwFlyFrmFmt* pFmt );
181 : :
182 : : virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
183 : : SwCrsrMoveState* = 0 ) const;
184 : : // erfrage vom Client Informationen
185 : : virtual sal_Bool GetInfo( SfxPoolItem& ) const;
186 : :
187 : : virtual void Cut();
188 : : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
189 : : virtual void CheckDirection( sal_Bool bVert );
190 : : void CheckGrid( sal_Bool bInvalidate );
191 : : void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
192 : 319268 : sal_Bool HasGrid() const { return bHasGrid; }
193 : :
194 : : void PaintDecorators( ) const;
195 : : virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
196 : : virtual void PaintBreak() const;
197 : :
198 : : //Zeilennummern usw malen
199 : : void RefreshExtraData( const SwRect & ) const;
200 : :
201 : : //Hilfslinien malen.
202 : : void RefreshSubsidiary( const SwRect& ) const;
203 : :
204 : : //Fussnotenschnittstelle
205 : 13534 : sal_Bool IsFtnPage() const { return bFtnPage; }
206 : 244 : sal_Bool IsEndNotePage() const { return bEndNotePage; }
207 : 1419 : void SetFtnPage( sal_Bool b ) { bFtnPage = b; }
208 : 8 : void SetEndNotePage( sal_Bool b ) { bEndNotePage = b; }
209 : :
210 : 70705 : inline sal_uInt16 GetPhyPageNum() const { return nPhyPageNum;}
211 : 1419 : inline void SetPhyPageNum( sal_uInt16 nNum ) { nPhyPageNum = nNum;}
212 : 0 : inline void DecrPhyPageNum() { --nPhyPageNum; }
213 : 3 : inline void IncrPhyPageNum() { ++nPhyPageNum; }
214 : :
215 : : //Validieren, invalidieren und abfragen des Status der Seite.
216 : : //Layout/Cntnt und jeweils Fly/nicht Fly werden getrennt betrachtet.
217 : : inline void InvalidateFlyLayout() const;
218 : : inline void InvalidateFlyCntnt() const;
219 : : inline void InvalidateFlyInCnt() const;
220 : : inline void InvalidateLayout() const;
221 : : inline void InvalidateCntnt() const;
222 : : inline void InvalidateSpelling() const;
223 : : inline void InvalidateSmartTags() const;
224 : : inline void InvalidateAutoCompleteWords() const;
225 : : inline void InvalidateWordCount() const;
226 : : inline void ValidateFlyLayout() const;
227 : : inline void ValidateFlyCntnt() const;
228 : : inline void ValidateFlyInCnt() const;
229 : : inline void ValidateLayout() const;
230 : : inline void ValidateCntnt() const;
231 : : inline void ValidateSpelling() const;
232 : : inline void ValidateSmartTags() const; // SMARTTAGS
233 : : inline void ValidateAutoCompleteWords() const;
234 : : inline void ValidateWordCount() const;
235 : : inline sal_Bool IsInvalid() const;
236 : : inline sal_Bool IsInvalidFly() const;
237 : : sal_Bool IsRightShadowNeeded() const;
238 : : sal_Bool IsLeftShadowNeeded() const;
239 : 5829 : sal_Bool IsInvalidFlyLayout() const { return bInvalidFlyLayout; }
240 : 5829 : sal_Bool IsInvalidFlyCntnt() const { return bInvalidFlyCntnt; }
241 : 6278 : sal_Bool IsInvalidFlyInCnt() const { return bInvalidFlyInCnt; }
242 : 32311 : sal_Bool IsInvalidLayout() const { return bInvalidLayout; }
243 [ + + ][ - + ]: 20590 : sal_Bool IsInvalidCntnt() const { return (bInvalidCntnt || bInvalidFlyInCnt); }
244 : 5823 : sal_Bool IsInvalidSpelling() const { return bInvalidSpelling; }
245 : 0 : sal_Bool IsInvalidSmartTags() const { return bInvalidSmartTags; } // SMARTTAGS
246 : 4182 : sal_Bool IsInvalidAutoCompleteWords() const { return bInvalidAutoCmplWrds; }
247 : 4124 : sal_Bool IsInvalidWordCount() const { return bInvalidWordCount; }
248 : :
249 : : /** SwPageFrm::GetDrawBackgrdColor
250 : :
251 : : determine the color, that is respectively will be drawn as background
252 : : for the page frame.
253 : :
254 : : @return reference to an instance of class Color
255 : : */
256 : : const Color& GetDrawBackgrdColor() const;
257 : :
258 : : /** paint margin area of a page
259 : :
260 : : implement paint of margin area; margin area will be painted for a
261 : : view shell with a window and if the document is not in online layout.
262 : :
263 : : @param _rOutputRect
264 : : input parameter - constant instance reference of the rectangle, for
265 : : which an output has to be generated.
266 : :
267 : : @param _pViewShell
268 : : input parameter - instance of the view shell, on which the output
269 : : has to be generated.
270 : : */
271 : : void PaintMarginArea( const SwRect& _rOutputRect,
272 : : ViewShell* _pViewShell ) const;
273 : :
274 : : /** paint page border and shadow
275 : :
276 : : #i9719#
277 : : implement paint of page border and shadow
278 : :
279 : : @param _rPageRect
280 : : input parameter - constant instance reference of the page rectangle.
281 : : Generally, it's the frame area of the page, but for empty pages in print
282 : : preview, this parameter is useful.
283 : :
284 : : @param _pViewShell
285 : : input parameter - instance of the view shell, on which the output
286 : : has to be generated.
287 : :
288 : : @param bPaintRightShadow
289 : : Should we paint shadow on the right or not (used in book mode)
290 : :
291 : : @param bFullBottomShadow
292 : : Should we have a bottom shadow of the same size as the pages or
293 : : not (for right pages in book mode in a LTR environment).
294 : :
295 : : @param bRightSidebar
296 : : Is the note sidebar on the right or not (used to adjust the
297 : : shadow with & position).
298 : : */
299 : : static void PaintBorderAndShadow( const SwRect& _rPageRect,
300 : : const ViewShell* _pViewShell,
301 : : bool bPaintLeftShadow,
302 : : bool bPaintRightShadow,
303 : : bool bRightSidebar );
304 : :
305 : : /** get bound rectangle of border and shadow for repaints
306 : :
307 : : #i9719#
308 : :
309 : : @param _rPageRect
310 : : input parameter - constant instance reference of the page rectangle.
311 : : Generally, it's the frame area of the page, but for empty pages in print
312 : : preview, this parameter is useful.
313 : :
314 : : @param _pViewShell
315 : : input parameter - instance of the view shell, for which the rectangle
316 : : has to be generated.
317 : :
318 : : @param _orBorderAndShadowBoundRect
319 : : output parameter - instance reference of the bounded border and shadow
320 : : rectangle for the given page rectangle
321 : : */
322 : : static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
323 : : const ViewShell* _pViewShell,
324 : : SwRect& _orBorderAndShadowBoundRect,
325 : : const bool bLeftShadow,
326 : : const bool bRightShadow,
327 : : const bool bRightSidebar
328 : : );
329 : :
330 : : static void PaintNotesSidebar(const SwRect& _rPageRect, ViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
331 : : static void PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, ViewShell* _pViewShell, const Color aColorUp, const Color aColorDown);
332 : : /**
333 : : asks the page on which side a margin should be shown, e.g for notes
334 : : returns true for left side, false for right side
335 : : */
336 : : sw::sidebarwindows::SidebarPosition SidebarPosition() const;
337 : :
338 : : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
339 : :
340 : : inline sal_Int8 ShadowPxWidth() const
341 : : {
342 : : return mnShadowPxWidth;
343 : : }
344 : :
345 : : const SwRect PrtWithoutHeaderAndFooter() const;
346 : :
347 : : // #i28701#
348 : 559 : inline bool IsLayoutInProgress() const
349 : : {
350 : 559 : return mbLayoutInProgress;
351 : : }
352 : 9278 : inline void SetLayoutInProgress( const bool _bLayoutInProgress )
353 : : {
354 : 9278 : mbLayoutInProgress = _bLayoutInProgress;
355 : 9278 : }
356 : :
357 : : // in case this is am empty page, this function returns the 'reference' page
358 : : const SwPageFrm& GetFormatPage() const;
359 : :
360 : : /// If in header or footer area, it also indicates the exact area in rControl.
361 : : bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
362 : :
363 : : // return font used to paint the "empty page" string
364 : : static const Font& GetEmptyPageFont();
365 : :
366 : : static SwTwips GetSidebarBorderWidth( const ViewShell* );
367 : : };
368 : :
369 : 27078 : inline SwCntntFrm *SwPageFrm::FindFirstBodyCntnt()
370 : : {
371 : 27078 : SwLayoutFrm *pBody = FindBodyCont();
372 [ + - ]: 27078 : return pBody ? pBody->ContainsCntnt() : 0;
373 : : }
374 : 182 : inline const SwCntntFrm *SwPageFrm::FindFirstBodyCntnt() const
375 : : {
376 : 182 : const SwLayoutFrm *pBody = FindBodyCont();
377 [ + - ]: 182 : return pBody ? pBody->ContainsCntnt() : 0;
378 : : }
379 : 0 : inline const SwCntntFrm *SwPageFrm::FindLastBodyCntnt() const
380 : : {
381 : 0 : return ((SwPageFrm*)this)->FindLastBodyCntnt();
382 : : }
383 : 1376 : inline void SwPageFrm::InvalidateFlyLayout() const
384 : : {
385 : 1376 : ((SwPageFrm*)this)->bInvalidFlyLayout = sal_True;
386 : 1376 : }
387 : 1375 : inline void SwPageFrm::InvalidateFlyCntnt() const
388 : : {
389 : 1375 : ((SwPageFrm*)this)->bInvalidFlyCntnt = sal_True;
390 : 1375 : }
391 : 3151 : inline void SwPageFrm::InvalidateFlyInCnt() const
392 : : {
393 : 3151 : ((SwPageFrm*)this)->bInvalidFlyInCnt = sal_True;
394 : 3151 : }
395 : 11114 : inline void SwPageFrm::InvalidateLayout() const
396 : : {
397 : 11114 : ((SwPageFrm*)this)->bInvalidLayout = sal_True;
398 : 11114 : }
399 : 28074 : inline void SwPageFrm::InvalidateCntnt() const
400 : : {
401 : 28074 : ((SwPageFrm*)this)->bInvalidCntnt = sal_True;
402 : 28074 : }
403 : 13625 : inline void SwPageFrm::InvalidateSpelling() const
404 : : {
405 : 13625 : ((SwPageFrm*)this)->bInvalidSpelling = sal_True;
406 : 13625 : }
407 : : // SMARTTAGS
408 : 13625 : inline void SwPageFrm::InvalidateSmartTags() const
409 : : {
410 : 13625 : ((SwPageFrm*)this)->bInvalidSmartTags = sal_True;
411 : 13625 : }
412 : 13617 : inline void SwPageFrm::InvalidateAutoCompleteWords() const
413 : : {
414 : 13617 : ((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_True;
415 : 13617 : }
416 : 13617 : inline void SwPageFrm::InvalidateWordCount() const
417 : : {
418 : 13617 : ((SwPageFrm*)this)->bInvalidWordCount = sal_True;
419 : 13617 : }
420 : 12755 : inline void SwPageFrm::ValidateFlyLayout() const
421 : : {
422 : 12755 : ((SwPageFrm*)this)->bInvalidFlyLayout = sal_False;
423 : 12755 : }
424 : 12755 : inline void SwPageFrm::ValidateFlyCntnt() const
425 : : {
426 : 12755 : ((SwPageFrm*)this)->bInvalidFlyCntnt = sal_False;
427 : 12755 : }
428 : 5203 : inline void SwPageFrm::ValidateFlyInCnt() const
429 : : {
430 : 5203 : ((SwPageFrm*)this)->bInvalidFlyInCnt = sal_False;
431 : 5203 : }
432 : 2252 : inline void SwPageFrm::ValidateLayout() const
433 : : {
434 : 2252 : ((SwPageFrm*)this)->bInvalidLayout = sal_False;
435 : 2252 : }
436 : 5203 : inline void SwPageFrm::ValidateCntnt() const
437 : : {
438 : 5203 : ((SwPageFrm*)this)->bInvalidCntnt = sal_False;
439 : 5203 : }
440 : 11183 : inline void SwPageFrm::ValidateSpelling() const
441 : : {
442 : 11183 : ((SwPageFrm*)this)->bInvalidSpelling = sal_False;
443 : 11183 : }
444 : : // SMARTTAGS
445 : 0 : inline void SwPageFrm::ValidateSmartTags() const
446 : : {
447 : 0 : ((SwPageFrm*)this)->bInvalidSmartTags = sal_False;
448 : 0 : }
449 : 8522 : inline void SwPageFrm::ValidateAutoCompleteWords() const
450 : : {
451 : 8522 : ((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_False;
452 : 8522 : }
453 : 4180 : inline void SwPageFrm::ValidateWordCount() const
454 : : {
455 : 4180 : ((SwPageFrm*)this)->bInvalidWordCount = sal_False;
456 : 4180 : }
457 : :
458 : 82826 : inline sal_Bool SwPageFrm::IsInvalid() const
459 : : {
460 [ + + ][ + + ]: 82826 : return (bInvalidCntnt || bInvalidLayout || bInvalidFlyInCnt);
[ - + ]
461 : : }
462 : 54516 : inline sal_Bool SwPageFrm::IsInvalidFly() const
463 : : {
464 [ + + ][ + + ]: 54516 : return bInvalidFlyLayout || bInvalidFlyCntnt;
465 : : }
466 : :
467 : : #define GETGRID( pPage ) const SwTextGridItem *pGrid = NULL; \
468 : : {if( pPage && pPage->HasGrid() && GRID_NONE==(pGrid=(SwTextGridItem*)&pPage->\
469 : : GetPageDesc()->GetMaster().GetFmtAttr(RES_TEXTGRID))->GetGridType() ) \
470 : : pGrid = NULL;}
471 : :
472 : : #define GETGRIDWIDTH( pGrid , pDoc ) pDoc->IsSquaredPageMode() ? \
473 : : pGrid->GetBaseHeight(): pGrid->GetBaseWidth()
474 : :
475 : :
476 : :
477 : : #endif //_PAGEFRM_HXX
478 : :
479 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|