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