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