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 #ifndef _PAGEFRM_HXX 24 #define _PAGEFRM_HXX 25 26 27 #include <svl/svarray.hxx> 28 29 #include "ftnboss.hxx" 30 #include <tools/mempool.hxx> 31 32 #include <SidebarWindowsTypes.hxx> 33 34 class SwFlyFrm; 35 class SwFlyFrmFmt; 36 class SwPageDesc; 37 class SwCntntFrm; 38 struct SwPosition; 39 struct SwCrsrMoveState; 40 class SdrObject; 41 class SwAttrSetChg; 42 class Font; 43 44 // OD 2004-05-07 #i28701# - replaced by class <SwSortedObjs> 45 //SV_DECL_PTRARR_SORT(SwSortDrawObjs,SdrObjectPtr,1,2); 46 class SwSortedObjs; 47 // --> OD 2004-07-02 #i28701# 48 class SwAnchoredObject; 49 // <-- 50 51 enum SwPageChg 52 { 53 CHG_NEWPAGE, 54 CHG_CUTPAGE, 55 CHG_CHGPAGE 56 }; 57 58 class SwPageFrm: public SwFtnBossFrm 59 { 60 friend class SwFrm; 61 62 // OD 2004-05-07 #i28701# - use <SwSortedObjs> 63 SwSortedObjs *pSortedObjs; 64 65 SwPageDesc *pDesc; //PageDesc der die Seite beschreibt. 66 67 sal_uInt16 nPhyPageNum; //Physikalische Seitennummer. 68 69 sal_Bool bInvalidCntnt :1; 70 sal_Bool bInvalidLayout :1; 71 sal_Bool bInvalidFlyCntnt :1; 72 sal_Bool bInvalidFlyLayout :1; 73 sal_Bool bInvalidFlyInCnt :1; 74 sal_Bool bFtnPage :1; //Diese Seite ist fuer Dokumentende-Fussnoten. 75 sal_Bool bEmptyPage :1; //Dies ist eine explizite Leerseite 76 sal_Bool bEndNotePage :1; //'Fussnotenseite' fuer Endnoten 77 sal_Bool bInvalidSpelling :1; //Das Online-Spelling ist gefordert 78 sal_Bool bInvalidSmartTags :1; //checking for smarttags is needed // SMARTTAGS 79 sal_Bool bInvalidAutoCmplWrds :1; //Auto-Complete Wordliste aktualisieren 80 sal_Bool bInvalidWordCount :1; 81 sal_Bool bHasGrid :1; // Grid for Asian layout 82 83 // OD 2004-05-17 #i28701# - boolean, indicating that layout of page frame 84 // is in progress. 85 bool mbLayoutInProgress; 86 87 // OD 12.02.2003 #i9719#, #105645# 88 static const sal_Int8 mnBorderPxWidth; 89 static const sal_Int8 mnShadowPxWidth; 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 notes 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 and shadow 342 343 OD 12.02.2003 for #i9719# and #105645# 344 implement paint of page border and shadow 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 bPaintRightShadow, 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 notes 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 538 #endif //_PAGEFRM_HXX 539