xref: /aoo42x/main/sw/source/core/inc/pagefrm.hxx (revision 60d78278)
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 and shadow
343 
344         OD 12.02.2003 for #i9719# and #105645#
345         implement paint of page border and shadow
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 bPaintRightShadow,
361                                       bool bRightSidebar );
362 
363     /** get bound rectangle of border and shadow for repaints
364 
365         OD 12.02.2003 for #i9719# and #105645#
366 
367         author OD
368 
369         @param _rPageRect
370         input parameter - constant instance reference of the page rectangle.
371         Generally, it's the frame area of the page, but for empty pages in print
372         preview, this parameter is useful.
373 
374         @param _pViewShell
375         input parameter - instance of the view shell, for which the rectangle
376         has to be generated.
377 
378         @param _orBorderAndShadowBoundRect
379         output parameter - instance reference of the bounded border and shadow
380         rectangle for the given page rectangle
381     */
382     static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
383                                              ViewShell*    _pViewShell,
384                                              SwRect& _orBorderAndShadowBoundRect,
385                                              const bool bRightSidebar );
386 
387     static void PaintNotesSidebar(const SwRect& _rPageRect, ViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
388     static void PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, ViewShell* _pViewShell, const Color aColorUp, const Color aColorDown);
389 	/**
390 		mod #6i193#
391 
392 		asks the page on which side a margin should be shown, e.g. for comments
393 		returns true for left side, false for right side
394 	*/
395     sw::sidebarwindows::SidebarPosition SidebarPosition() const;
396 
397 	virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
398 
399     // OD 12.02.2003 #i9719#, #105645#
400     inline sal_Int8 BorderPxWidth() const
401     {
402         return mnBorderPxWidth;
403     }
404     inline sal_Int8 ShadowPxWidth() const
405     {
406         return mnShadowPxWidth;
407     }
408 
409     // OD 22.09.2003 #110978#
410     const SwRect PrtWithoutHeaderAndFooter() const;
411 
412     // OD 2004-05-17 #i28701#
413     inline bool IsLayoutInProgress() const
414     {
415         return mbLayoutInProgress;
416     }
417     inline void SetLayoutInProgress( const bool _bLayoutInProgress )
418     {
419         mbLayoutInProgress = _bLayoutInProgress;
420     }
421 
422     // in case this is am empty page, this function returns the 'reference' page
423     const SwPageFrm& GetFormatPage() const;
424 
425     // return font used to paint the "empty page" string
426     static const Font& GetEmptyPageFont();
427 
428     static SwTwips GetSidebarBorderWidth( const ViewShell* );
429 };
430 
431 inline SwCntntFrm *SwPageFrm::FindFirstBodyCntnt()
432 {
433 	SwLayoutFrm *pBody = FindBodyCont();
434 	return pBody ? pBody->ContainsCntnt() : 0;
435 }
436 inline const SwCntntFrm *SwPageFrm::FindFirstBodyCntnt() const
437 {
438 	const SwLayoutFrm *pBody = FindBodyCont();
439 	return pBody ? pBody->ContainsCntnt() : 0;
440 }
441 inline const SwCntntFrm *SwPageFrm::FindLastBodyCntnt() const
442 {
443 	return ((SwPageFrm*)this)->FindLastBodyCntnt();
444 }
445 inline void	SwPageFrm::InvalidateFlyLayout() const
446 {
447 	((SwPageFrm*)this)->bInvalidFlyLayout = sal_True;
448 }
449 inline void	SwPageFrm::InvalidateFlyCntnt() const
450 {
451 	((SwPageFrm*)this)->bInvalidFlyCntnt = sal_True;
452 }
453 inline void SwPageFrm::InvalidateFlyInCnt() const
454 {
455 	((SwPageFrm*)this)->bInvalidFlyInCnt = sal_True;
456 }
457 inline void	SwPageFrm::InvalidateLayout() const
458 {
459 	((SwPageFrm*)this)->bInvalidLayout = sal_True;
460 }
461 inline void	SwPageFrm::InvalidateCntnt() const
462 {
463 	((SwPageFrm*)this)->bInvalidCntnt = sal_True;
464 }
465 inline void	SwPageFrm::InvalidateSpelling() const
466 {
467 	((SwPageFrm*)this)->bInvalidSpelling = sal_True;
468 }
469 // SMARTTAGS
470 inline void SwPageFrm::InvalidateSmartTags() const
471 {
472 	((SwPageFrm*)this)->bInvalidSmartTags = sal_True;
473 }
474 inline void	SwPageFrm::InvalidateAutoCompleteWords() const
475 {
476 	((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_True;
477 }
478 inline void SwPageFrm::InvalidateWordCount() const
479 {
480 	((SwPageFrm*)this)->bInvalidWordCount = sal_True;
481 }
482 inline void	SwPageFrm::ValidateFlyLayout() const
483 {
484 	((SwPageFrm*)this)->bInvalidFlyLayout = sal_False;
485 }
486 inline void	SwPageFrm::ValidateFlyCntnt() const
487 {
488 	((SwPageFrm*)this)->bInvalidFlyCntnt = sal_False;
489 }
490 inline void SwPageFrm::ValidateFlyInCnt() const
491 {
492 	((SwPageFrm*)this)->bInvalidFlyInCnt = sal_False;
493 }
494 inline void	SwPageFrm::ValidateLayout() const
495 {
496 	((SwPageFrm*)this)->bInvalidLayout = sal_False;
497 }
498 inline void	SwPageFrm::ValidateCntnt() const
499 {
500 	((SwPageFrm*)this)->bInvalidCntnt = sal_False;
501 }
502 inline void	SwPageFrm::ValidateSpelling() const
503 {
504 	((SwPageFrm*)this)->bInvalidSpelling = sal_False;
505 }
506 // SMARTTAGS
507 inline void SwPageFrm::ValidateSmartTags() const
508 {
509 	((SwPageFrm*)this)->bInvalidSmartTags = sal_False;
510 }
511 inline void SwPageFrm::ValidateAutoCompleteWords() const
512 {
513 	((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_False;
514 }
515 inline void SwPageFrm::ValidateWordCount() const
516 {
517 	((SwPageFrm*)this)->bInvalidWordCount = sal_False;
518 }
519 
520 inline sal_Bool SwPageFrm::IsInvalid() const
521 {
522 	return (bInvalidCntnt || bInvalidLayout || bInvalidFlyInCnt);
523 }
524 inline sal_Bool SwPageFrm::IsInvalidFly() const
525 {
526 	return bInvalidFlyLayout || bInvalidFlyCntnt;
527 }
528 
529 #define GETGRID( pPage ) const SwTextGridItem *pGrid = NULL; \
530  {if( pPage && pPage->HasGrid() && GRID_NONE==(pGrid=(SwTextGridItem*)&pPage->\
531      GetPageDesc()->GetMaster().GetFmtAttr(RES_TEXTGRID))->GetGridType() ) \
532     pGrid = NULL;}
533 
534 #define GETGRIDWIDTH( pGrid , pDoc ) pDoc->IsSquaredPageMode() ? \
535 	pGrid->GetBaseHeight(): pGrid->GetBaseWidth()
536 
537 
538 #endif	//_PAGEFRM_HXX
539