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