1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pagefrm.hxx,v $
10 * $Revision: 1.25.144.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <svtools/svarray.hxx>
36 #include "ftnboss.hxx"
37 #include <tools/mempool.hxx>
44 struct SwCrsrMoveState
;
49 // OD 2004-05-07 #i28701# - replaced by class <SwSortedObjs>
50 //SV_DECL_PTRARR_SORT(SwSortDrawObjs,SdrObjectPtr,1,2);
52 // --> OD 2004-07-02 #i28701#
53 class SwAnchoredObject
;
63 class SwPageFrm
: public SwFtnBossFrm
67 // OD 2004-05-07 #i28701# - use <SwSortedObjs>
68 SwSortedObjs
*pSortedObjs
;
70 SwPageDesc
*pDesc
; //PageDesc der die Seite beschreibt.
72 USHORT nPhyPageNum
; //Physikalische Seitennummer.
74 BOOL bInvalidCntnt
:1;
75 BOOL bInvalidLayout
:1;
76 BOOL bInvalidFlyCntnt
:1;
77 BOOL bInvalidFlyLayout
:1;
78 BOOL bInvalidFlyInCnt
:1;
79 BOOL bFtnPage
:1; //Diese Seite ist fuer Dokumentende-Fussnoten.
80 BOOL bEmptyPage
:1; //Dies ist eine explizite Leerseite
81 BOOL bEndNotePage
:1; //'Fussnotenseite' fuer Endnoten
82 BOOL bInvalidSpelling
:1; //Das Online-Spelling ist gefordert
83 BOOL bInvalidSmartTags
:1; //checking for smarttags is needed // SMARTTAGS
84 BOOL bInvalidAutoCmplWrds
:1; //Auto-Complete Wordliste aktualisieren
85 BOOL bInvalidWordCount
:1;
86 BOOL bHasGrid
:1; // Grid for Asian layout
88 // OD 2004-05-17 #i28701# - boolean, indicating that layout of page frame
90 bool mbLayoutInProgress
;
92 // OD 12.02.2003 #i9719#, #105645#
93 static const sal_Int8 mnBorderPxWidth
;
94 static const sal_Int8 mnShadowPxWidth
;
96 void _UpdateAttr( SfxPoolItem
*, SfxPoolItem
*, BYTE
&,
97 SwAttrSetChg
*pa
= 0, SwAttrSetChg
*pb
= 0 );
99 // Anpassen der max. Fussnotenhoehen in den einzelnen Spalten
100 void SetColMaxFtnHeight();
102 /** determine rectangle for page border
104 OD 12.02.2003 for #i9719# and #105645#
109 input parameter - constant instance reference of the page rectangle.
110 Generally, it's the frame area of the page, but for empty pages in print
111 preview, this parameter is useful.
114 input parameter - instance of the view shell, for which the rectangle
118 output parameter - instance reference of the border rectangle for
119 the given page rectangle
121 static void GetBorderRect( const SwRect
& _rPageRect
,
122 ViewShell
* _pViewShell
,
123 SwRect
& _orBorderRect
,
124 bool bRightSidebar
);
126 /** determine rectangle for right page shadow
128 OD 12.02.2003 for #i9719# and #105645#
133 input parameter - constant instance reference of the page rectangle.
134 Generally, it's the frame area of the page, but for empty pages in print
135 preview, this parameter is useful.
138 input parameter - instance of the view shell, for which the rectangle
141 @param _orRightShadowRect
142 output parameter - instance reference of the right shadow rectangle for
143 the given page rectangle
145 static void GetRightShadowRect( const SwRect
& _rPageRect
,
146 ViewShell
* _pViewShell
,
147 SwRect
& _orRightShadowRect
,
148 bool bRightSidebar
);
150 /** determine rectangle for bottom page shadow
152 OD 12.02.2003 for #i9719# and #105645#
157 input parameter - constant instance reference of the page rectangle.
158 Generally, it's the frame area of the page, but for empty pages in print
159 preview, this parameter is useful.
162 input parameter - instance of the view shell, for which the rectangle
165 @param _orBottomShadowRect
166 output parameter - instance reference of the bottom shadow rectangle for
167 the given page rectangle
170 static void GetBottomShadowRect( const SwRect
& _rPageRect
,
171 ViewShell
* _pViewShell
,
172 SwRect
& _orBottomShadowRect
,
173 bool bRightSidebar
);
175 /** adds the sidebar used for notes to right and left border
176 mod 20.10.2007 for #i6193#
181 input parameter - current rect, we change borders if we want a sidebar
184 input parameter - instance of the view shell, for which the rectangle
188 input parameter - if set to true, we add in pixel
190 static void AddSidebarBorders( Rectangle
& aRect
, ViewShell
* _pViewShell
, bool bRight
, bool bPx
= false);
191 static void AddSidebarBorders( SwRect
& aRect
, ViewShell
* _pViewShell
, bool bRight
, bool bPx
= false);
194 virtual void MakeAll();
197 DECL_FIXEDMEMPOOL_NEWDEL(SwPageFrm
)
199 SwPageFrm( SwFrmFmt
*, SwPageDesc
* );
202 //public, damit die ViewShell beim Umschalten vom BrowseMode darauf
204 void PrepareHeader(); //Kopf-/Fusszeilen anlegen/entfernen.
205 void PrepareFooter();
207 const SwSortedObjs
*GetSortedObjs() const { return pSortedObjs
; }
208 SwSortedObjs
*GetSortedObjs() { return pSortedObjs
; }
210 // --> OD 2004-07-02 #i28701# - new methods to append/remove drawing objects
211 void AppendDrawObjToPage( SwAnchoredObject
& _rNewObj
);
212 void RemoveDrawObjFromPage( SwAnchoredObject
& _rToRemoveObj
);
215 void AppendFlyToPage( SwFlyFrm
*pNew
);
216 void RemoveFlyFromPage( SwFlyFrm
*pToRemove
);
217 void MoveFly( SwFlyFrm
*pToMove
, SwPageFrm
*pDest
);//optimiertes Remove/Append
219 void SetPageDesc( SwPageDesc
*, SwFrmFmt
* );
220 SwPageDesc
*GetPageDesc() { return pDesc
; }
221 const SwPageDesc
*GetPageDesc() const { return pDesc
; }
222 SwPageDesc
*FindPageDesc();
224 SwCntntFrm
*FindLastBodyCntnt();
225 inline SwCntntFrm
*FindFirstBodyCntnt();
226 inline const SwCntntFrm
*FindFirstBodyCntnt() const;
227 inline const SwCntntFrm
*FindLastBodyCntnt() const;
229 //Spezialisiertes GetCntntPos() fuer Felder in Rahmen.
230 void GetCntntPosition( const Point
&rPt
, SwPosition
&rPos
) const;
232 BOOL
IsEmptyPage() const { return bEmptyPage
; } //explizite Leerseite.
236 //Immer nach dem Paste rufen. Erzeugt die Seitengeb. Rahmen und Formatiert
237 //generischen Inhalt.
238 void PreparePage( BOOL bFtn
);
240 //Schickt an alle ContentFrames ein Prepare wg. geaenderter Registervorlage
241 void PrepareRegisterChg();
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
);
253 virtual BOOL
GetCrsrOfst( SwPosition
*, Point
&,
254 SwCrsrMoveState
* = 0 ) const;
255 virtual void Modify( SfxPoolItem
*, SfxPoolItem
* );
256 // erfrage vom Client Informationen
257 virtual BOOL
GetInfo( SfxPoolItem
& ) const;
260 virtual void Paste( SwFrm
* pParent
, SwFrm
* pSibling
= 0 );
261 virtual void CheckDirection( BOOL bVert
);
262 void CheckGrid( BOOL bInvalidate
);
263 void PaintGrid( OutputDevice
* pOut
, SwRect
&rRect
) const;
264 BOOL
HasGrid() const { return bHasGrid
; }
266 //Zeilennummern usw malen
267 void RefreshExtraData( const SwRect
& ) const;
270 void RefreshSubsidiary( const SwRect
& ) const;
272 //Fussnotenschnittstelle
273 BOOL
IsFtnPage() const { return bFtnPage
; }
274 BOOL
IsEndNotePage() const { return bEndNotePage
; }
275 void SetFtnPage( BOOL b
) { bFtnPage
= b
; }
276 void SetEndNotePage( BOOL b
) { bEndNotePage
= b
; }
278 inline USHORT
GetPhyPageNum() const { return nPhyPageNum
;}
279 inline void SetPhyPageNum( USHORT nNum
) { nPhyPageNum
= nNum
;}
280 inline void DecrPhyPageNum() { --nPhyPageNum
; }
281 inline void IncrPhyPageNum() { ++nPhyPageNum
; }
283 //Validieren, invalidieren und abfragen des Status der Seite.
284 //Layout/Cntnt und jeweils Fly/nicht Fly werden getrennt betrachtet.
285 inline void InvalidateFlyLayout() const;
286 inline void InvalidateFlyCntnt() const;
287 inline void InvalidateFlyInCnt() const;
288 inline void InvalidateLayout() const;
289 inline void InvalidateCntnt() const;
290 inline void InvalidateSpelling() const;
291 inline void InvalidateSmartTags() const;
292 inline void InvalidateAutoCompleteWords() const;
293 inline void InvalidateWordCount() const;
294 inline void ValidateFlyLayout() const;
295 inline void ValidateFlyCntnt() const;
296 inline void ValidateFlyInCnt() const;
297 inline void ValidateLayout() const;
298 inline void ValidateCntnt() const;
299 inline void ValidateSpelling() const;
300 inline void ValidateSmartTags() const; // SMARTTAGS
301 inline void ValidateAutoCompleteWords() const;
302 inline void ValidateWordCount() const;
303 inline BOOL
IsInvalid() const;
304 inline BOOL
IsInvalidFly() const;
305 BOOL
IsInvalidFlyLayout() const { return bInvalidFlyLayout
; }
306 BOOL
IsInvalidFlyCntnt() const { return bInvalidFlyCntnt
; }
307 BOOL
IsInvalidFlyInCnt() const { return bInvalidFlyInCnt
; }
308 BOOL
IsInvalidLayout() const { return bInvalidLayout
; }
309 BOOL
IsInvalidCntnt() const { return (bInvalidCntnt
|| bInvalidFlyInCnt
); }
310 BOOL
IsInvalidSpelling() const { return bInvalidSpelling
; }
311 BOOL
IsInvalidSmartTags() const { return bInvalidSmartTags
; } // SMARTTAGS
312 BOOL
IsInvalidAutoCompleteWords() const { return bInvalidAutoCmplWrds
; }
313 BOOL
IsInvalidWordCount() const { return bInvalidWordCount
; }
315 /** SwPageFrm::GetDrawBackgrdColor - for #102450#
318 determine the color, that is respectively will be drawn as background
323 @return reference to an instance of class Color
325 const Color
& GetDrawBackgrdColor() const;
327 /** paint margin area of a page
329 OD 20.11.2002 for #104598#:
330 implement paint of margin area; margin area will be painted for a
331 view shell with a window and if the document is not in online layout.
336 input parameter - constant instance reference of the rectangle, for
337 which an output has to be generated.
340 input parameter - instance of the view shell, on which the output
343 void PaintMarginArea( const SwRect
& _rOutputRect
,
344 ViewShell
* _pViewShell
) const;
346 /** paint page border and shadow
348 OD 12.02.2003 for #i9719# and #105645#
349 implement paint of page border and shadow
354 input parameter - constant instance reference of the page rectangle.
355 Generally, it's the frame area of the page, but for empty pages in print
356 preview, this parameter is useful.
359 input parameter - instance of the view shell, on which the output
362 static void PaintBorderAndShadow( const SwRect
& _rPageRect
,
363 ViewShell
* _pViewShell
,
364 bool bPaintRightShadow
,
365 bool bRightSidebar
);
367 /** get bound rectangle of border and shadow for repaints
369 OD 12.02.2003 for #i9719# and #105645#
374 input parameter - constant instance reference of the page rectangle.
375 Generally, it's the frame area of the page, but for empty pages in print
376 preview, this parameter is useful.
379 input parameter - instance of the view shell, for which the rectangle
382 @param _orBorderAndShadowBoundRect
383 output parameter - instance reference of the bounded border and shadow
384 rectangle for the given page rectangle
386 static void GetBorderAndShadowBoundRect( const SwRect
& _rPageRect
,
387 ViewShell
* _pViewShell
,
388 SwRect
& _orBorderAndShadowBoundRect
,
389 bool bRightSidebar
);
391 static void PaintNotesSidebar(const SwRect
& _rPageRect
, ViewShell
* _pViewShell
, USHORT nPageNum
, bool bRight
);
392 static void PaintNotesSidebarArrows(const Point
&aMiddleFirst
, const Point
&aMiddleSecond
, ViewShell
* _pViewShell
, const Color aColorUp
, const Color aColorDown
);
396 asks the page on which side a margin should be shown, e.g for notes
397 returns true for left side, false for right side
399 bool MarginSide() const;
401 virtual bool FillSelection( SwSelectionList
& rList
, const SwRect
& rRect
) const;
403 // OD 12.02.2003 #i9719#, #105645#
404 inline sal_Int8
BorderPxWidth() const
406 return mnBorderPxWidth
;
408 inline sal_Int8
ShadowPxWidth() const
410 return mnShadowPxWidth
;
413 // OD 22.09.2003 #110978#
414 const SwRect
PrtWithoutHeaderAndFooter() const;
416 // OD 2004-05-17 #i28701#
417 inline bool IsLayoutInProgress() const
419 return mbLayoutInProgress
;
421 inline void SetLayoutInProgress( const bool _bLayoutInProgress
)
423 mbLayoutInProgress
= _bLayoutInProgress
;
426 // in case this is am empty page, this function returns the 'reference' page
427 const SwPageFrm
& GetFormatPage() const;
429 // return font used to paint the "empty page" string
430 static const Font
& GetEmptyPageFont();
432 static SwTwips
GetSidebarBorderWidth( const ViewShell
* );
435 inline SwCntntFrm
*SwPageFrm::FindFirstBodyCntnt()
437 SwLayoutFrm
*pBody
= FindBodyCont();
438 return pBody
? pBody
->ContainsCntnt() : 0;
440 inline const SwCntntFrm
*SwPageFrm::FindFirstBodyCntnt() const
442 const SwLayoutFrm
*pBody
= FindBodyCont();
443 return pBody
? pBody
->ContainsCntnt() : 0;
445 inline const SwCntntFrm
*SwPageFrm::FindLastBodyCntnt() const
447 return ((SwPageFrm
*)this)->FindLastBodyCntnt();
449 inline void SwPageFrm::InvalidateFlyLayout() const
451 ((SwPageFrm
*)this)->bInvalidFlyLayout
= TRUE
;
453 inline void SwPageFrm::InvalidateFlyCntnt() const
455 ((SwPageFrm
*)this)->bInvalidFlyCntnt
= TRUE
;
457 inline void SwPageFrm::InvalidateFlyInCnt() const
459 ((SwPageFrm
*)this)->bInvalidFlyInCnt
= TRUE
;
461 inline void SwPageFrm::InvalidateLayout() const
463 ((SwPageFrm
*)this)->bInvalidLayout
= TRUE
;
465 inline void SwPageFrm::InvalidateCntnt() const
467 ((SwPageFrm
*)this)->bInvalidCntnt
= TRUE
;
469 inline void SwPageFrm::InvalidateSpelling() const
471 ((SwPageFrm
*)this)->bInvalidSpelling
= TRUE
;
474 inline void SwPageFrm::InvalidateSmartTags() const
476 ((SwPageFrm
*)this)->bInvalidSmartTags
= TRUE
;
478 inline void SwPageFrm::InvalidateAutoCompleteWords() const
480 ((SwPageFrm
*)this)->bInvalidAutoCmplWrds
= TRUE
;
482 inline void SwPageFrm::InvalidateWordCount() const
484 ((SwPageFrm
*)this)->bInvalidWordCount
= TRUE
;
486 inline void SwPageFrm::ValidateFlyLayout() const
488 ((SwPageFrm
*)this)->bInvalidFlyLayout
= FALSE
;
490 inline void SwPageFrm::ValidateFlyCntnt() const
492 ((SwPageFrm
*)this)->bInvalidFlyCntnt
= FALSE
;
494 inline void SwPageFrm::ValidateFlyInCnt() const
496 ((SwPageFrm
*)this)->bInvalidFlyInCnt
= FALSE
;
498 inline void SwPageFrm::ValidateLayout() const
500 ((SwPageFrm
*)this)->bInvalidLayout
= FALSE
;
502 inline void SwPageFrm::ValidateCntnt() const
504 ((SwPageFrm
*)this)->bInvalidCntnt
= FALSE
;
506 inline void SwPageFrm::ValidateSpelling() const
508 ((SwPageFrm
*)this)->bInvalidSpelling
= FALSE
;
511 inline void SwPageFrm::ValidateSmartTags() const
513 ((SwPageFrm
*)this)->bInvalidSmartTags
= FALSE
;
515 inline void SwPageFrm::ValidateAutoCompleteWords() const
517 ((SwPageFrm
*)this)->bInvalidAutoCmplWrds
= FALSE
;
519 inline void SwPageFrm::ValidateWordCount() const
521 ((SwPageFrm
*)this)->bInvalidWordCount
= FALSE
;
524 inline BOOL
SwPageFrm::IsInvalid() const
526 return (bInvalidCntnt
|| bInvalidLayout
|| bInvalidFlyInCnt
);
528 inline BOOL
SwPageFrm::IsInvalidFly() const
530 return bInvalidFlyLayout
|| bInvalidFlyCntnt
;
533 #define GETGRID( pPage ) const SwTextGridItem *pGrid = NULL; \
534 {if( pPage && pPage->HasGrid() && GRID_NONE==(pGrid=(SwTextGridItem*)&pPage->\
535 GetPageDesc()->GetMaster().GetFmtAttr(RES_TEXTGRID))->GetGridType() ) \
538 #define GETGRIDWIDTH( pGrid , pDoc ) pDoc->IsSquaredPageMode() ? \
539 pGrid->GetBaseHeight(): pGrid->GetBaseWidth()
543 #endif //_PAGEFRM_HXX