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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <sfx2/objface.hxx> 28 #include <vcl/timer.hxx> 29 #include <vcl/field.hxx> 30 #include <vcl/fixed.hxx> 31 #include <vcl/help.hxx> 32 #include <vcl/cmdevt.hxx> 33 #include <vcl/button.hxx> 34 #include <svl/whiter.hxx> 35 #include <svl/stritem.hxx> 36 #include <svl/eitem.hxx> 37 #include <sfx2/printer.hxx> 38 #include <sfx2/progress.hxx> 39 #include <sfx2/app.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <sfx2/request.hxx> 42 #include <sfx2/dispatch.hxx> 43 #include <vcl/msgbox.hxx> 44 #include <svx/stddlg.hxx> 45 #include <editeng/paperinf.hxx> 46 #include <svl/srchitem.hxx> 47 #include <svx/svdview.hxx> 48 #include <svx/dlgutil.hxx> 49 #include <svx/zoomslideritem.hxx> 50 #include <svx/svxids.hrc> 51 52 #include <swwait.hxx> 53 #include <globdoc.hxx> 54 #include <wdocsh.hxx> 55 #include <pvprtdat.hxx> 56 #include <swmodule.hxx> 57 #include <modcfg.hxx> 58 #include <wrtsh.hxx> 59 #include <docsh.hxx> 60 #include <viewopt.hxx> 61 #include <doc.hxx> 62 #include <pview.hxx> 63 #include <view.hxx> 64 #include <textsh.hxx> 65 #include <scroll.hxx> 66 #include <prtopt.hxx> 67 #include <docstat.hxx> 68 #include <usrpref.hxx> 69 #include <viewfunc.hxx> 70 71 #include <helpid.h> 72 #include <cmdid.h> 73 #include <globals.hrc> 74 #include <popup.hrc> 75 #include <pview.hrc> 76 77 #define SwPagePreView 78 #include <sfx2/msg.hxx> 79 #include <swslots.hxx> 80 // OD 12.12.2002 #103492# 81 #include <pagepreviewlayout.hxx> 82 83 #include <svx/svxdlg.hxx> 84 #include <svx/dialogs.hrc> 85 #include <vos/mutex.hxx> 86 87 88 using namespace ::com::sun::star; 89 90 SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreView, "PrintPreview") 91 { 92 SFX_VIEW_REGISTRATION(SwDocShell); 93 SFX_VIEW_REGISTRATION(SwWebDocShell); 94 SFX_VIEW_REGISTRATION(SwGlobalDocShell); 95 } 96 97 SFX_IMPL_INTERFACE(SwPagePreView, SfxViewShell, SW_RES(RID_PVIEW_TOOLBOX)) 98 { 99 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU)); 100 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD| 101 SFX_VISIBILITY_CLIENT|SFX_VISIBILITY_FULLSCREEN| 102 SFX_VISIBILITY_READONLYDOC, 103 SW_RES(RID_PVIEW_TOOLBOX)); 104 } 105 106 107 TYPEINIT1(SwPagePreView,SfxViewShell) 108 109 #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS ) 110 111 #define MIN_PREVIEW_ZOOM 25 112 #define MAX_PREVIEW_ZOOM 600 113 /* */ 114 /* -----------------26.11.2002 10:41----------------- 115 * 116 * --------------------------------------------------*/ 117 sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, sal_Bool bZoomIn) 118 { 119 static sal_uInt16 aZoomArr[] = 120 { 121 25, 50, 75, 100, 150, 200, 400, 600 122 }; 123 const sal_uInt16 nZoomArrSize = sizeof(aZoomArr)/sizeof(sal_uInt16); 124 if(bZoomIn) 125 for(int i = nZoomArrSize - 1; i >= 0; --i) 126 { 127 if(nCurrentZoom > aZoomArr[i] || !i) 128 return aZoomArr[i]; 129 } 130 else 131 for(int i = 0; i < nZoomArrSize; ++i) 132 { 133 if(nCurrentZoom < aZoomArr[i]) 134 return aZoomArr[i]; 135 } 136 return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM; 137 }; 138 /* -----------------02.12.2002 09:11----------------- 139 * 140 * --------------------------------------------------*/ 141 void lcl_InvalidateZoomSlots(SfxBindings& rBindings) 142 { 143 static sal_uInt16 __READONLY_DATA aInval[] = 144 { 145 SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM, 146 0 147 }; 148 rBindings.Invalidate( aInval ); 149 } 150 /*-------------------------------------------------------------------- 151 Beschreibung: 152 --------------------------------------------------------------------*/ 153 154 // erstmal der Zoom-Dialog 155 156 class SwPreViewZoomDlg : public SvxStandardDialog 157 { 158 FixedText aRowLbl; 159 NumericField aRowEdit; 160 FixedText aColLbl; 161 NumericField aColEdit; 162 163 OKButton aOkBtn; 164 CancelButton aCancelBtn; 165 HelpButton aHelpBtn; 166 167 virtual void Apply(); 168 169 public: 170 SwPreViewZoomDlg( SwPagePreViewWin& rParent ); 171 ~SwPreViewZoomDlg(); 172 }; 173 174 /*-------------------------------------------------------------------- 175 Beschreibung: 176 --------------------------------------------------------------------*/ 177 178 179 SwPreViewZoomDlg::SwPreViewZoomDlg( SwPagePreViewWin& rParent ) : 180 SvxStandardDialog( &rParent, SW_RES(DLG_PAGEPREVIEW_ZOOM) ), 181 aRowLbl(this,SW_RES(FT_ROW)), 182 aRowEdit(this,SW_RES(ED_ROW)), 183 aColLbl(this,SW_RES(FT_COL)), 184 aColEdit(this,SW_RES(ED_COL)), 185 aOkBtn(this,SW_RES(BT_OK)), 186 aCancelBtn(this,SW_RES(BT_CANCEL)), 187 aHelpBtn(this,SW_RES(BT_HELP)) 188 { 189 FreeResource(); 190 191 aRowEdit.SetValue( rParent.GetRow() ); 192 aColEdit.SetValue( rParent.GetCol() ); 193 } 194 195 /*-------------------------------------------------------------------- 196 Beschreibung: 197 --------------------------------------------------------------------*/ 198 199 SwPreViewZoomDlg::~SwPreViewZoomDlg() {} 200 201 202 void SwPreViewZoomDlg::Apply() 203 { 204 ((SwPagePreViewWin*)GetParent())->CalcWish( 205 sal_uInt8(aRowEdit.GetValue()), 206 sal_uInt8(aColEdit.GetValue()) ); 207 } 208 209 /*-------------------------------------------------------------------- 210 Beschreibung: 211 --------------------------------------------------------------------*/ 212 213 // alles fuers SwPagePreViewWin 214 215 216 SwPagePreViewWin::SwPagePreViewWin( Window *pParent, SwPagePreView& rPView ) 217 : Window( pParent, WinBits( WB_CLIPCHILDREN) ), 218 mpViewShell( 0 ), 219 mrView( rPView ), 220 mbCalcScaleForPreviewLayout( true ), 221 maPaintedPreviewDocRect( Rectangle(0,0,0,0) ) 222 { 223 SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611# 224 SetHelpId(HID_PAGEPREVIEW); 225 SetFillColor( GetBackground().GetColor() ); 226 SetLineColor( GetBackground().GetColor()); 227 SetMapMode( MapMode(MAP_TWIP) ); 228 229 const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(sal_False); 230 mnRow = pUsrPref->GetPagePrevRow(); // 1 Zeile 231 mnCol = pUsrPref->GetPagePrevCol(); // 1 Spalte 232 // OD 24.03.2003 #108282# - member <mnVirtPage> no longer exists. 233 mnSttPage = USHRT_MAX; 234 } 235 236 /*-------------------------------------------------------------------- 237 Beschreibung: 238 --------------------------------------------------------------------*/ 239 240 241 SwPagePreViewWin::~SwPagePreViewWin() 242 { 243 // Remove to the deconstruction of SwPagePreView. 244 //if( mpViewShell) 245 // delete mpViewShell; 246 } 247 248 /*-------------------------------------------------------------------- 249 Beschreibung: 250 --------------------------------------------------------------------*/ 251 252 253 void SwPagePreViewWin::Paint( const Rectangle& rRect ) 254 { 255 if( !mpViewShell || !mpViewShell->GetLayout() ) 256 return; 257 258 if( USHRT_MAX == mnSttPage ) // wurde noch nie berechnet ? (Init-Phase!) 259 { 260 // das ist die Size, auf die ich mich immer beziehe 261 if( !maPxWinSize.Height() || !maPxWinSize.Width() ) 262 maPxWinSize = GetOutputSizePixel(); 263 264 Rectangle aRect( LogicToPixel( rRect )); 265 mpPgPrevwLayout->Prepare( 1, Point(0,0), maPxWinSize, 266 mnSttPage, maPaintedPreviewDocRect ); 267 SetSelectedPage( 1 ); 268 mpPgPrevwLayout->Paint( PixelToLogic( aRect ) ); 269 SetPagePreview(mnRow, mnCol); 270 } 271 else 272 { 273 MapMode aMM( GetMapMode() ); 274 aMM.SetScaleX( maScale ); 275 aMM.SetScaleY( maScale ); 276 SetMapMode( aMM ); 277 mpPgPrevwLayout->Paint( rRect ); 278 } 279 } 280 281 /*-------------------------------------------------------------------- 282 Beschreibung: 283 --------------------------------------------------------------------*/ 284 void SwPagePreViewWin::CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol ) 285 { 286 if( !mpViewShell || !mpViewShell->GetLayout() ) 287 return; 288 289 sal_uInt16 nOldCol = mnCol; 290 // OD 02.12.2002 #103492# - update <mnRow> and <mnCol>. 291 mnRow = nNewRow; 292 mnCol = nNewCol; 293 sal_uInt16 nPages = mnRow * mnCol, 294 nLastSttPg = mrView.GetPageCount()+1 > nPages 295 ? mrView.GetPageCount()+1 - nPages : 0; 296 if( mnSttPage > nLastSttPg ) 297 mnSttPage = nLastSttPg; 298 299 mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true ); 300 mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize, 301 mnSttPage, maPaintedPreviewDocRect ); 302 SetSelectedPage( mnSttPage ); 303 SetPagePreview(mnRow, mnCol); 304 maScale = GetMapMode().GetScaleX(); 305 306 // falls an der Spaltigkeit gedreht wurde, so muss der Sonderfall 307 // Einspaltig beachtet und ggfs. der Scrollbar korrigiert werden 308 if( (1 == nOldCol) ^ (1 == mnCol) ) 309 mrView.ScrollDocSzChg(); 310 311 // Sortierung muss eingehalten werden!! 312 // OD 24.03.2003 #108282# - additional invalidate page status. 313 static sal_uInt16 __READONLY_DATA aInval[] = 314 { 315 SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, 316 FN_PREVIEW_ZOOM, 317 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN, 318 FN_STAT_PAGE, FN_STAT_ZOOM, 319 FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES, 320 0 321 }; 322 SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings(); 323 rBindings.Invalidate( aInval ); 324 rBindings.Update( FN_SHOW_TWO_PAGES ); 325 rBindings.Update( FN_SHOW_MULTIPLE_PAGES ); 326 // OD 18.12.2002 #103492# - adjust scrollbars 327 mrView.ScrollViewSzChg(); 328 } 329 /*-------------------------------------------------------------------- 330 Beschreibung:, mnSttPage is Absolute 331 --------------------------------------------------------------------*/ 332 333 334 int SwPagePreViewWin::MovePage( int eMoveMode ) 335 { 336 // soviele Seiten hoch 337 sal_uInt16 nPages = mnRow * mnCol; 338 sal_uInt16 nNewSttPage = mnSttPage; 339 // OD 04.12.2002 #103492# 340 sal_uInt16 nPageCount = mrView.GetPageCount(); 341 sal_uInt16 nDefSttPg = GetDefSttPage(); 342 // OD 06.12.2002 #103492# 343 bool bPaintPageAtFirstCol = true; 344 345 switch( eMoveMode ) 346 { 347 case MV_PAGE_UP: 348 { 349 const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage ); 350 const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ? 351 mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) : 352 nDefSttPg; 353 nNewSttPage = nNewAbsSttPage; 354 355 const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() ); 356 const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ? 357 nRelSelPage - nPages : 358 1; 359 SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) ); 360 361 break; 362 } 363 case MV_PAGE_DOWN: 364 { 365 const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage ); 366 const sal_uInt16 nNewAbsSttPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages ); 367 nNewSttPage = nNewAbsSttPage < nPageCount ? nNewAbsSttPage : nPageCount; 368 369 const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() ); 370 const sal_uInt16 nNewAbsSelPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages ); 371 SetSelectedPage( nNewAbsSelPage < nPageCount ? nNewAbsSelPage : nPageCount ); 372 373 break; 374 } 375 case MV_DOC_STT: 376 nNewSttPage = nDefSttPg; 377 SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) ); 378 break; 379 case MV_DOC_END: 380 // OD 03.12.2002 #103492# - correct calculation of new start page. 381 nNewSttPage = nPageCount; 382 SetSelectedPage( nPageCount ); 383 break; 384 // OD 12.12.2002 #103492# - add new move mode 385 case MV_SELPAGE: 386 // <nNewSttPage> and <SelectedPage()> are already set. 387 // OD 20.02.2003 #107369# - not start at first column, only if the 388 // complete preview layout columns doesn't fit into window. 389 if ( !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() ) 390 bPaintPageAtFirstCol = false; 391 break; 392 case MV_SCROLL: 393 // OD 17.01.2003 #103492# - check, if paint page at first column 394 // has to be avoided 395 if ( !mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() || 396 !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() ) 397 bPaintPageAtFirstCol = false; 398 break; 399 case MV_NEWWINSIZE: 400 // OD 18.12.2002 #103492# - nothing special to do. 401 break; 402 case MV_CALC: 403 // OD 18.12.2002 #103492# - re-init page preview layout. 404 mpPgPrevwLayout->ReInit(); 405 406 // OD 03.12.2002 #103492# - correct calculation of new start page. 407 if( nNewSttPage > nPageCount ) 408 nNewSttPage = nPageCount; 409 410 // OD 18.12.2002 #103492# - correct selected page number 411 if( SelectedPage() > nPageCount ) 412 SetSelectedPage( nNewSttPage ? nNewSttPage : 1 ); 413 } 414 415 mpPgPrevwLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize, 416 nNewSttPage, 417 maPaintedPreviewDocRect, bPaintPageAtFirstCol ); 418 if( nNewSttPage == mnSttPage && 419 eMoveMode != MV_SELPAGE ) 420 return sal_False; 421 422 SetPagePreview(mnRow, mnCol); 423 mnSttPage = nNewSttPage; 424 425 // OD 24.03.2003 #108282# - additional invalidate page status. 426 static sal_uInt16 __READONLY_DATA aInval[] = 427 { 428 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN, 429 FN_STAT_PAGE, 0 430 }; 431 432 SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings(); 433 rBindings.Invalidate( aInval ); 434 435 return sal_True; 436 } 437 438 /*-------------------------------------------------------------------- 439 Beschreibung: 440 --------------------------------------------------------------------*/ 441 442 443 void SwPagePreViewWin::SetWinSize( const Size& rNewSize ) 444 { 445 // die Size wollen wir aber immer in Pixel-Einheiten haben 446 maPxWinSize = LogicToPixel( rNewSize ); 447 448 if( USHRT_MAX == mnSttPage ) 449 { 450 mnSttPage = GetDefSttPage(); 451 SetSelectedPage( GetDefSttPage() ); 452 } 453 454 if ( mbCalcScaleForPreviewLayout ) 455 { 456 mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true ); 457 maScale = GetMapMode().GetScaleX(); 458 } 459 mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize, 460 mnSttPage, maPaintedPreviewDocRect ); 461 if ( mbCalcScaleForPreviewLayout ) 462 { 463 SetSelectedPage( mnSttPage ); 464 mbCalcScaleForPreviewLayout = false; 465 } 466 SetPagePreview(mnRow, mnCol); 467 maScale = GetMapMode().GetScaleX(); 468 } 469 470 471 /*-------------------------------------------------------------------- 472 Beschreibung: 473 --------------------------------------------------------------------*/ 474 475 476 void SwPagePreViewWin::GetStatusStr( String& rStr, sal_uInt16 nPageCnt ) const 477 { 478 // OD 24.03.2003 #108282# - show physical and virtual page number of 479 // selected page, if it's visible. 480 sal_uInt16 nPageNum; 481 if ( mpPgPrevwLayout->IsPageVisible( mpPgPrevwLayout->SelectedPage() ) ) 482 { 483 nPageNum = mpPgPrevwLayout->SelectedPage(); 484 } 485 else 486 { 487 nPageNum = mnSttPage > 1 ? mnSttPage : 1; 488 } 489 sal_uInt16 nVirtPageNum = mpPgPrevwLayout->GetVirtPageNumByPageNum( nPageNum ); 490 if( nVirtPageNum && nVirtPageNum != nPageNum ) 491 { 492 rStr += String::CreateFromInt32( nVirtPageNum ); 493 rStr += ' '; 494 } 495 rStr += String::CreateFromInt32( nPageNum ); 496 rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / ")); 497 rStr += String::CreateFromInt32( nPageCnt ); 498 } 499 500 /*-------------------------------------------------------------------- 501 Beschreibung: 502 --------------------------------------------------------------------*/ 503 504 505 void SwPagePreViewWin::KeyInput( const KeyEvent &rKEvt ) 506 { 507 const KeyCode& rKeyCode = rKEvt.GetKeyCode(); 508 sal_uInt16 nKey = rKeyCode.GetCode(); 509 sal_Bool bHandled = sal_False; 510 if(!rKeyCode.GetModifier()) 511 { 512 sal_uInt16 nSlot = 0; 513 switch(nKey) 514 { 515 case KEY_ADD : nSlot = SID_ZOOM_OUT; break; 516 case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break; 517 case KEY_SUBTRACT : nSlot = SID_ZOOM_IN; break; 518 } 519 if(nSlot) 520 { 521 bHandled = sal_True; 522 mrView.GetViewFrame()->GetDispatcher()->Execute( 523 nSlot, SFX_CALLMODE_ASYNCHRON ); 524 } 525 } 526 if( !bHandled && !mrView.KeyInput( rKEvt ) ) 527 Window::KeyInput( rKEvt ); 528 } 529 530 /****************************************************************************** 531 * Beschreibung: 532 ******************************************************************************/ 533 534 void SwPagePreViewWin::Command( const CommandEvent& rCEvt ) 535 { 536 sal_Bool bCallBase = sal_True; 537 switch( rCEvt.GetCommand() ) 538 { 539 case COMMAND_CONTEXTMENU: 540 mrView.GetViewFrame()->GetDispatcher()->ExecutePopup(); 541 bCallBase = sal_False; 542 break; 543 544 case COMMAND_WHEEL: 545 case COMMAND_STARTAUTOSCROLL: 546 case COMMAND_AUTOSCROLL: 547 { 548 const CommandWheelData* pData = rCEvt.GetWheelData(); 549 if( pData ) 550 { 551 const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL, 552 pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel()); 553 const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew); 554 bCallBase = !mrView.HandleWheelCommands( aEvent ); 555 } 556 else 557 bCallBase = !mrView.HandleWheelCommands( rCEvt ); 558 } 559 break; 560 default: 561 // OD 17.12.2002 #103492# - delete assertion 562 ; 563 } 564 565 if( bCallBase ) 566 Window::Command( rCEvt ); 567 } 568 569 void SwPagePreViewWin::MouseButtonDown( const MouseEvent& rMEvt ) 570 { 571 // OD 17.12.2002 #103492# - consider single-click to set selected page 572 if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) ) 573 { 574 Point aPrevwPos( PixelToLogic( rMEvt.GetPosPixel() ) ); 575 Point aDocPos; 576 bool bPosInEmptyPage; 577 sal_uInt16 nNewSelectedPage; 578 bool bIsDocPos = 579 mpPgPrevwLayout->IsPrevwPosInDocPrevwPage( aPrevwPos, 580 aDocPos, bPosInEmptyPage, nNewSelectedPage ); 581 if ( bIsDocPos && rMEvt.GetClicks() == 2 ) 582 { 583 // close page preview, set new cursor position and switch to 584 // normal view. 585 String sNewCrsrPos( String::CreateFromInt32( aDocPos.X() )); 586 ((( sNewCrsrPos += ';' ) 587 += String::CreateFromInt32( aDocPos.Y() )) ) 588 += ';'; 589 mrView.SetNewCrsrPos( sNewCrsrPos ); 590 591 SfxViewFrame *pTmpFrm = mrView.GetViewFrame(); 592 pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0, 593 SFX_CALLMODE_ASYNCHRON ); 594 } 595 else if ( bIsDocPos || bPosInEmptyPage ) 596 // OD 2004-03-04 #i20684# - add missing parenthesis 597 { 598 // show clicked page as the selected one 599 mpPgPrevwLayout->MarkNewSelectedPage( nNewSelectedPage ); 600 GetViewShell()->ShowPreViewSelection( nNewSelectedPage ); 601 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar. 602 if ( mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() ) 603 { 604 mrView.SetVScrollbarThumbPos( nNewSelectedPage ); 605 } 606 // OD 24.03.2003 #108282# - invalidate page status. 607 static sal_uInt16 __READONLY_DATA aInval[] = 608 { 609 FN_STAT_PAGE, 0 610 }; 611 SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings(); 612 rBindings.Invalidate( aInval ); 613 } 614 } 615 } 616 617 /****************************************************************************** 618 * Beschreibung: Userprefs bzw Viewoptions setzen 619 ******************************************************************************/ 620 621 622 void SwPagePreViewWin::SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol ) 623 { 624 SwMasterUsrPref *pOpt = (SwMasterUsrPref *)SW_MOD()->GetUsrPref(sal_False); 625 626 if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol()) 627 { 628 pOpt->SetPagePrevRow( nRow ); 629 pOpt->SetPagePrevCol( nCol ); 630 pOpt->SetModified(); 631 632 //Scrollbar updaten! 633 mrView.ScrollViewSzChg(); 634 } 635 } 636 637 /** get selected page in document preview 638 639 OD 13.12.2002 #103492# 640 641 @author OD 642 */ 643 sal_uInt16 SwPagePreViewWin::SelectedPage() const 644 { 645 return mpPgPrevwLayout->SelectedPage(); 646 } 647 648 /** set selected page number in document preview 649 650 OD 13.12.2002 #103492# 651 652 @author OD 653 */ 654 void SwPagePreViewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum ) 655 { 656 mpPgPrevwLayout->SetSelectedPage( _nSelectedPageNum ); 657 } 658 659 /** method to enable/disable book preview 660 661 OD 2004-03-05 #i18143# 662 663 @author OD 664 */ 665 bool SwPagePreViewWin::SetBookPreviewMode( const bool _bBookPreview ) 666 { 667 return mpPgPrevwLayout->SetBookPreviewMode( _bBookPreview, 668 mnSttPage, 669 maPaintedPreviewDocRect ); 670 } 671 672 void SwPagePreViewWin::DataChanged( const DataChangedEvent& rDCEvt ) 673 { 674 Window::DataChanged( rDCEvt ); 675 676 switch( rDCEvt.GetType() ) 677 { 678 case DATACHANGED_SETTINGS: 679 // ScrollBars neu anordnen bzw. Resize ausloesen, da sich 680 // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im 681 // Resize-Handler aber auch die Groesse der ScrollBars aus 682 // den Settings abgefragt werden. 683 if( rDCEvt.GetFlags() & SETTINGS_STYLE ) 684 mrView.InvalidateBorder(); //Scrollbarbreiten 685 //#106746# zoom has to be disabled if Accessibility support is switched on 686 lcl_InvalidateZoomSlots(mrView.GetViewFrame()->GetBindings()); 687 break; 688 689 case DATACHANGED_PRINTER: 690 case DATACHANGED_DISPLAY: 691 case DATACHANGED_FONTS: 692 case DATACHANGED_FONTSUBSTITUTION: 693 mrView.GetDocShell()->UpdateFontList(); //Fontwechsel 694 if ( mpViewShell->GetWin() ) 695 mpViewShell->GetWin()->Invalidate(); 696 break; 697 } 698 } 699 700 /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN 701 702 OD 04.03.2003 #107369# 703 704 @author OD 705 */ 706 void SwPagePreView::_ExecPgUpAndPgDown( const bool _bPgUp, 707 SfxRequest* _pReq ) 708 { 709 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout(); 710 // check, if top/bottom of preview is *not* already visible. 711 if( pPagePrevwLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 ) 712 { 713 if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() && 714 pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() ) 715 { 716 const int eMvMode = _bPgUp ? 717 SwPagePreViewWin::MV_PAGE_UP : 718 SwPagePreViewWin::MV_PAGE_DOWN; 719 if ( ChgPage( eMvMode, sal_True ) ) 720 pViewWin->Invalidate(); 721 } 722 else 723 { 724 SwTwips nScrollAmount; 725 sal_uInt16 nNewSelectedPageNum = 0; 726 const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol(); 727 if( _bPgUp ) 728 { 729 if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() ) 730 { 731 nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( -1 ); 732 if ( (pViewWin->SelectedPage() - nVisPages) > 0 ) 733 nNewSelectedPageNum = pViewWin->SelectedPage() - nVisPages; 734 else 735 nNewSelectedPageNum = 1; 736 } 737 else 738 nScrollAmount = - Min( pViewWin->GetOutputSize().Height(), 739 pViewWin->GetPaintedPreviewDocRect().Top() ); 740 } 741 else 742 { 743 if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() ) 744 { 745 nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( 1 ); 746 if ( (pViewWin->SelectedPage() + nVisPages) <= mnPageCount ) 747 nNewSelectedPageNum = pViewWin->SelectedPage() + nVisPages; 748 else 749 nNewSelectedPageNum = mnPageCount; 750 } 751 else 752 nScrollAmount = Min( pViewWin->GetOutputSize().Height(), 753 ( pPagePrevwLay->GetPrevwDocSize().Height() - 754 pViewWin->GetPaintedPreviewDocRect().Bottom() ) ); 755 } 756 pViewWin->Scroll( 0, nScrollAmount ); 757 if ( nNewSelectedPageNum != 0 ) 758 { 759 pViewWin->SetSelectedPage( nNewSelectedPageNum ); 760 } 761 ScrollViewSzChg(); 762 // OD 24.03.2003 #108282# - additional invalidate page status. 763 static sal_uInt16 __READONLY_DATA aInval[] = 764 { 765 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN, 766 FN_STAT_PAGE, 0 767 }; 768 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 769 rBindings.Invalidate( aInval ); 770 pViewWin->Invalidate(); 771 } 772 } 773 774 if ( _pReq ) 775 _pReq->Done(); 776 } 777 778 /*-------------------------------------------------------------------- 779 Beschreibung: 780 --------------------------------------------------------------------*/ 781 // dann mal alles fuer die SwPagePreView 782 void SwPagePreView::Execute( SfxRequest &rReq ) 783 { 784 int eMvMode; 785 sal_uInt8 nRow = 1; 786 sal_Bool bRetVal = sal_False; 787 bool bRefresh = true; 788 789 switch(rReq.GetSlot()) 790 { 791 case FN_REFRESH_VIEW: 792 case FN_STAT_PAGE: 793 case FN_STAT_ZOOM: 794 break; 795 796 case FN_SHOW_MULTIPLE_PAGES: 797 { 798 const SfxItemSet *pArgs = rReq.GetArgs(); 799 if( pArgs && pArgs->Count() >= 2 ) 800 { 801 sal_uInt8 nCols = (sal_uInt8)((SfxUInt16Item &)pArgs->Get( 802 SID_ATTR_TABLE_COLUMN)).GetValue(); 803 sal_uInt8 nRows = (sal_uInt8)((SfxUInt16Item &)pArgs->Get( 804 SID_ATTR_TABLE_ROW)).GetValue(); 805 pViewWin->CalcWish( nRows, nCols ); 806 807 } 808 else 809 SwPreViewZoomDlg( *pViewWin ).Execute(); 810 811 } 812 break; 813 case FN_SHOW_BOOKVIEW: 814 { 815 const SfxItemSet* pArgs = rReq.GetArgs(); 816 const SfxPoolItem* pItem; 817 bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview(); 818 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, sal_False, &pItem ) ) 819 { 820 bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue(); 821 ( ( SwViewOption* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview ); 822 // cast is not gentleman like, but it's common use in writer and in this case 823 } 824 if ( pViewWin->SetBookPreviewMode( bBookPreview ) ) 825 { 826 // book preview mode changed. Thus, adjust scrollbars and 827 // invalidate corresponding states. 828 ScrollViewSzChg(); 829 static sal_uInt16 __READONLY_DATA aInval[] = 830 { 831 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN, 832 FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0 833 }; 834 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 835 rBindings.Invalidate( aInval ); 836 pViewWin->Invalidate(); 837 } 838 839 } 840 break; 841 case FN_SHOW_TWO_PAGES: 842 pViewWin->CalcWish( nRow, 2 ); 843 break; 844 845 case FN_PREVIEW_ZOOM: 846 case SID_ATTR_ZOOM: 847 { 848 const SfxItemSet *pArgs = rReq.GetArgs(); 849 const SfxPoolItem* pItem; 850 AbstractSvxZoomDialog *pDlg = 0; 851 if(!pArgs) 852 { 853 SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); 854 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 855 SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(), 856 pVOpt->GetZoom() ); 857 aZoom.SetValueSet( 858 SVX_ZOOM_ENABLE_50| 859 SVX_ZOOM_ENABLE_75| 860 SVX_ZOOM_ENABLE_100| 861 SVX_ZOOM_ENABLE_150| 862 SVX_ZOOM_ENABLE_200| 863 SVX_ZOOM_ENABLE_WHOLEPAGE); 864 aCoreSet.Put( aZoom ); 865 866 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 867 if(pFact) 868 { 869 pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet); 870 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 871 } 872 873 pDlg->SetLimits( MINZOOM, MAXZOOM ); 874 875 if( pDlg->Execute() != RET_CANCEL ) 876 pArgs = pDlg->GetOutputItemSet(); 877 } 878 if( pArgs ) 879 { 880 enum SvxZoomType eType = SVX_ZOOM_PERCENT; 881 sal_uInt16 nZoomFactor = USHRT_MAX; 882 if(SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem)) 883 { 884 eType = ((const SvxZoomItem *)pItem)->GetType(); 885 nZoomFactor = ((const SvxZoomItem *)pItem)->GetValue(); 886 } 887 else if(SFX_ITEM_SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, sal_True, &pItem)) 888 nZoomFactor = ((const SfxUInt16Item *)pItem)->GetValue(); 889 if(USHRT_MAX != nZoomFactor) 890 SetZoom(eType, nZoomFactor); 891 } 892 delete pDlg; 893 } 894 break; 895 case SID_ATTR_ZOOMSLIDER : 896 { 897 const SfxItemSet *pArgs = rReq.GetArgs(); 898 const SfxPoolItem* pItem; 899 900 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem ) ) 901 { 902 const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue(); 903 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom ); 904 } 905 } 906 break; 907 case SID_ZOOM_IN: 908 case SID_ZOOM_OUT: 909 { 910 enum SvxZoomType eType = SVX_ZOOM_PERCENT; 911 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 912 SetZoom(eType, 913 lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot())); 914 } 915 break; 916 case FN_CHAR_LEFT: 917 case FN_CHAR_RIGHT: 918 case FN_LINE_UP: 919 case FN_LINE_DOWN: 920 { 921 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout(); 922 sal_uInt16 nNewSelectedPage; 923 sal_uInt16 nNewStartPage; 924 Point aNewStartPos; 925 sal_Int16 nHoriMove = 0; 926 sal_Int16 nVertMove = 0; 927 switch(rReq.GetSlot()) 928 { 929 case FN_CHAR_LEFT: nHoriMove = -1; break; 930 case FN_CHAR_RIGHT: nHoriMove = 1; break; 931 case FN_LINE_UP: nVertMove = -1; break; 932 case FN_LINE_DOWN: nVertMove = 1; break; 933 } 934 pPagePrevwLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove, 935 nNewSelectedPage, nNewStartPage, aNewStartPos ); 936 if ( pViewWin->SelectedPage() != nNewSelectedPage ) 937 { 938 if ( pPagePrevwLay->IsPageVisible( nNewSelectedPage ) ) 939 { 940 pPagePrevwLay->MarkNewSelectedPage( nNewSelectedPage ); 941 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar. 942 SetVScrollbarThumbPos( nNewSelectedPage ); 943 bRefresh = false; 944 } 945 else 946 { 947 pViewWin->SetSelectedPage( nNewSelectedPage ); 948 pViewWin->SetSttPage( nNewStartPage ); 949 int nRet = ChgPage( SwPagePreViewWin::MV_SELPAGE, sal_True ); 950 bRefresh = 0 != nRet; 951 } 952 GetViewShell()->ShowPreViewSelection( nNewSelectedPage ); 953 // OD 24.03.2003 #108282# - invalidate page status. 954 static sal_uInt16 __READONLY_DATA aInval[] = 955 { 956 FN_STAT_PAGE, 0 957 }; 958 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 959 rBindings.Invalidate( aInval ); 960 rReq.Done(); 961 } 962 else 963 { 964 bRefresh = false; 965 } 966 break; 967 } 968 case FN_PAGEUP: 969 case FN_PAGEDOWN: 970 { 971 _ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq ); 972 break; 973 } 974 case FN_START_OF_LINE: 975 case FN_START_OF_DOCUMENT: 976 pViewWin->SetSelectedPage( 1 ); 977 eMvMode = SwPagePreViewWin::MV_DOC_STT; bRetVal = sal_True; goto MOVEPAGE; 978 case FN_END_OF_LINE: 979 case FN_END_OF_DOCUMENT: 980 pViewWin->SetSelectedPage( mnPageCount ); 981 eMvMode = SwPagePreViewWin::MV_DOC_END; bRetVal = sal_True; goto MOVEPAGE; 982 MOVEPAGE: 983 { 984 int nRet = ChgPage( eMvMode, sal_True ); 985 // return value fuer Basic 986 if(bRetVal) 987 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), nRet == 0)); 988 989 bRefresh = 0 != nRet; 990 rReq.Done(); 991 } 992 break; 993 994 case FN_PRINT_PAGEPREVIEW: 995 { 996 const SwPagePreViewPrtData* pPPVPD = pViewWin->GetViewShell()->GetDoc()->GetPreViewPrtData(); 997 // die Sache mit der Orientation 998 if(pPPVPD) 999 { 1000 SfxPrinter* pPrinter = GetPrinter( sal_True ); 1001 if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE) 1002 != pPPVPD->GetLandscape()) 1003 pPrinter->SetOrientation(pPPVPD->GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT); 1004 } 1005 ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False ); 1006 bNormalPrint = sal_False; 1007 sal_uInt16 nPrtSlot = SID_PRINTDOC; 1008 rReq.SetSlot( nPrtSlot ); 1009 SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() ); 1010 rReq.SetSlot( FN_PRINT_PAGEPREVIEW ); 1011 return; 1012 } 1013 case SID_PRINTDOCDIRECT: 1014 case SID_PRINTDOC: 1015 ::SetAppPrintOptions( pViewWin->GetViewShell(), sal_False ); 1016 bNormalPrint = sal_True; 1017 SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() ); 1018 return; 1019 case FN_CLOSE_PAGEPREVIEW: 1020 case SID_PRINTPREVIEW: 1021 // print preview is now always in the same frame as the tab view 1022 // -> always switch this frame back to normal view 1023 // (ScTabViewShell ctor reads stored view data) 1024 GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, 0, 0, SFX_CALLMODE_ASYNCHRON ); 1025 break; 1026 case FN_INSERT_BREAK: 1027 { 1028 sal_uInt16 nSelPage = pViewWin->SelectedPage(); 1029 //if a dummy page is selected (e.g. a non-existing right/left page) 1030 //the direct neighbor is used 1031 if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage )) 1032 nSelPage +=2; 1033 SetNewPage( nSelPage ); 1034 SfxViewFrame *pTmpFrm = GetViewFrame(); 1035 pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0, 1036 SFX_CALLMODE_ASYNCHRON ); 1037 } 1038 break; 1039 default: 1040 ASSERT(!this, falscher Dispatcher); 1041 return; 1042 } 1043 1044 if( bRefresh ) 1045 pViewWin->Invalidate(); 1046 } 1047 1048 /*-------------------------------------------------------------------- 1049 Beschreibung: 1050 --------------------------------------------------------------------*/ 1051 1052 1053 void SwPagePreView::GetState( SfxItemSet& rSet ) 1054 { 1055 SfxWhichIter aIter(rSet); 1056 sal_uInt8 nRow = 1; 1057 sal_uInt16 nWhich = aIter.FirstWhich(); 1058 ASSERT(nWhich, leeres Set); 1059 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout(); 1060 //#106746# zoom has to be disabled if Accessibility support is switched on 1061 // MT 2010/01, see #110498# 1062 sal_Bool bZoomEnabled = sal_True; // !Application::GetSettings().GetMiscSettings().GetEnableATToolSupport(); 1063 1064 while(nWhich) 1065 { 1066 switch(nWhich) 1067 { 1068 case SID_BROWSER_MODE: 1069 case FN_PRINT_LAYOUT: 1070 rSet.DisableItem(nWhich); 1071 break; 1072 case FN_START_OF_DOCUMENT: 1073 { 1074 if ( pPagePrevwLay->IsPageVisible( 1 ) ) 1075 rSet.DisableItem(nWhich); 1076 break; 1077 } 1078 case FN_END_OF_DOCUMENT: 1079 { 1080 if ( pPagePrevwLay->IsPageVisible( mnPageCount ) ) 1081 rSet.DisableItem(nWhich); 1082 break; 1083 } 1084 case FN_PAGEUP: 1085 { 1086 if( pPagePrevwLay->GetWinPagesScrollAmount( -1 ) == 0 ) 1087 rSet.DisableItem(nWhich); 1088 break; 1089 } 1090 case FN_PAGEDOWN: 1091 { 1092 if( pPagePrevwLay->GetWinPagesScrollAmount( 1 ) == 0 ) 1093 rSet.DisableItem(nWhich); 1094 break; 1095 } 1096 1097 case FN_STAT_PAGE: 1098 { 1099 String aStr( sPageStr ); 1100 pViewWin->GetStatusStr( aStr, mnPageCount ); 1101 rSet.Put( SfxStringItem( nWhich, aStr) ); 1102 } 1103 break; 1104 1105 case SID_ATTR_ZOOM: 1106 case FN_STAT_ZOOM: 1107 { 1108 if(bZoomEnabled) 1109 { 1110 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 1111 SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(), 1112 pVOpt->GetZoom()); 1113 aZoom.SetValueSet( 1114 SVX_ZOOM_ENABLE_50| 1115 SVX_ZOOM_ENABLE_75| 1116 SVX_ZOOM_ENABLE_100| 1117 SVX_ZOOM_ENABLE_150| 1118 SVX_ZOOM_ENABLE_200); 1119 rSet.Put( aZoom ); 1120 } 1121 else 1122 rSet.DisableItem(nWhich); 1123 } 1124 break; 1125 case SID_ATTR_ZOOMSLIDER : 1126 { 1127 if(bZoomEnabled) 1128 { 1129 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 1130 const sal_uInt16 nCurrentZoom = pVOpt->GetZoom(); 1131 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM ); 1132 aZoomSliderItem.AddSnappingPoint( 100 ); 1133 rSet.Put( aZoomSliderItem ); 1134 } 1135 else 1136 rSet.DisableItem(nWhich); 1137 } 1138 break; 1139 case FN_PREVIEW_ZOOM: 1140 { 1141 if(bZoomEnabled) 1142 { 1143 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 1144 rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom())); 1145 } 1146 else 1147 rSet.DisableItem(nWhich); 1148 } 1149 break; 1150 case SID_ZOOM_IN: 1151 case SID_ZOOM_OUT: 1152 { 1153 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions(); 1154 if(!bZoomEnabled || (SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)|| 1155 (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM)) 1156 { 1157 rSet.DisableItem(nWhich); 1158 } 1159 } 1160 break; 1161 case FN_SHOW_MULTIPLE_PAGES: 1162 //should never be disabled 1163 break; 1164 case FN_SHOW_BOOKVIEW: 1165 { 1166 sal_Bool b = GetViewShell()->GetViewOptions()->IsPagePrevBookview(); 1167 rSet.Put(SfxBoolItem(nWhich, b)); 1168 } 1169 break; 1170 1171 case FN_SHOW_TWO_PAGES: 1172 if( 2 == pViewWin->GetCol() && nRow == pViewWin->GetRow() ) 1173 rSet.DisableItem( nWhich ); 1174 break; 1175 1176 case FN_PRINT_PAGEPREVIEW: 1177 // hat den gleichen Status wie das normale Drucken 1178 { 1179 const SfxPoolItem* pItem; 1180 SfxItemSet aSet( *rSet.GetPool(), SID_PRINTDOC, SID_PRINTDOC ); 1181 GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet ); 1182 if( SFX_ITEM_DISABLED == aSet.GetItemState( SID_PRINTDOC, 1183 sal_False, &pItem )) 1184 rSet.DisableItem( nWhich ); 1185 else if( SFX_ITEM_SET == aSet.GetItemState( SID_PRINTDOC, 1186 sal_False, &pItem )) 1187 { 1188 ((SfxPoolItem*)pItem)->SetWhich( FN_PRINT_PAGEPREVIEW ); 1189 rSet.Put( *pItem ); 1190 } 1191 } 1192 break; 1193 1194 case SID_PRINTPREVIEW: 1195 rSet.Put( SfxBoolItem( nWhich, sal_True ) ); 1196 break; 1197 1198 case SID_PRINTDOC: 1199 case SID_PRINTDOCDIRECT: 1200 GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet ); 1201 break; 1202 } 1203 nWhich = aIter.NextWhich(); 1204 } 1205 } 1206 1207 /*-------------------------------------------------------------------- 1208 Beschreibung: 1209 --------------------------------------------------------------------*/ 1210 1211 1212 void SwPagePreView::StateUndo(SfxItemSet& rSet) 1213 { 1214 SfxWhichIter aIter(rSet); 1215 sal_uInt16 nWhich = aIter.FirstWhich(); 1216 1217 while (nWhich) 1218 { 1219 rSet.DisableItem(nWhich); 1220 nWhich = aIter.NextWhich(); 1221 } 1222 } 1223 1224 /*-------------------------------------------------------------------- 1225 Beschreibung: 1226 --------------------------------------------------------------------*/ 1227 1228 1229 void SwPagePreView::Init(const SwViewOption * pPrefs) 1230 { 1231 if ( GetViewShell()->HasDrawView() ) 1232 GetViewShell()->GetDrawView()->SetAnimationEnabled( sal_False ); 1233 1234 bNormalPrint = sal_True; 1235 1236 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte 1237 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase 1238 // nicht in der SFX-Verwaltung bekannt ist. 1239 1240 if( !pPrefs ) 1241 pPrefs = SW_MOD()->GetUsrPref(sal_False); 1242 1243 // die Felder aktualisieren 1244 // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen. 1245 // In den Methoden wird auf die akt. Shell abgefragt! 1246 SwEditShell* pESh = (SwEditShell*)GetViewShell(); 1247 sal_Bool bIsModified = pESh->IsModified(); 1248 1249 1250 SwViewOption aOpt( *pPrefs ); 1251 aOpt.SetPagePreview(sal_True); 1252 aOpt.SetTab( sal_False ); 1253 aOpt.SetBlank( sal_False ); 1254 aOpt.SetHardBlank( sal_False ); 1255 aOpt.SetParagraph( sal_False ); 1256 aOpt.SetLineBreak( sal_False ); 1257 aOpt.SetPageBreak( sal_False ); 1258 aOpt.SetColumnBreak( sal_False ); 1259 aOpt.SetSoftHyph( sal_False ); 1260 aOpt.SetFldName( sal_False ); 1261 aOpt.SetPostIts( sal_False ); 1262 aOpt.SetShowHiddenChar( sal_False ); 1263 aOpt.SetShowHiddenField( sal_False ); 1264 aOpt.SetShowHiddenPara( sal_False ); 1265 aOpt.SetViewHRuler( sal_False ); 1266 aOpt.SetViewVRuler( sal_False ); 1267 aOpt.SetGraphic( sal_True ); 1268 aOpt.SetTable( sal_True ); 1269 aOpt.SetSnap( sal_False ); 1270 aOpt.SetGridVisible( sal_False ); 1271 1272 GetViewShell()->ApplyViewOptions( aOpt ); 1273 GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions()); 1274 1275 // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print 1276 SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false); 1277 GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions ); 1278 1279 GetViewShell()->CalcLayout(); 1280 DocSzChgd( GetViewShell()->GetDocSize() ); 1281 1282 if( !bIsModified ) 1283 pESh->ResetModified(); 1284 1285 pVScrollbar->ExtendedShow(pPrefs->IsViewVScrollBar()); 1286 pHScrollbar->ExtendedShow(pPrefs->IsViewHScrollBar()); 1287 pScrollFill->Show(pPrefs->IsViewVScrollBar() && pPrefs->IsViewHScrollBar()); 1288 } 1289 1290 1291 /*-------------------------------------------------------------------- 1292 Beschreibung: 1293 --------------------------------------------------------------------*/ 1294 1295 1296 SwPagePreView::SwPagePreView(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): 1297 SfxViewShell( pViewFrame, SWVIEWFLAGS ), 1298 pViewWin( new SwPagePreViewWin(&(GetViewFrame())->GetWindow(), *this ) ), 1299 nNewPage(USHRT_MAX), 1300 pHScrollbar(0), 1301 pVScrollbar(0), 1302 pPageUpBtn(0), 1303 pPageDownBtn(0), 1304 pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(), 1305 pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )), 1306 mnPageCount( 0 ), 1307 // OD 09.01.2003 #106334# 1308 mbResetFormDesignMode( false ), 1309 mbFormDesignModeToReset( false ) 1310 { 1311 SetName(String::CreateFromAscii("PageView" )); 1312 SetWindow( pViewWin ); 1313 SetHelpId(SW_PAGEPREVIEW); 1314 _CreateScrollbar( sal_True ); 1315 _CreateScrollbar( sal_False ); 1316 1317 SfxObjectShell* pObjShell = pViewFrame->GetObjectShell(); 1318 if ( !pOldSh ) 1319 { 1320 //Gibt es schon eine Sicht auf das Dokument? 1321 SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell ); 1322 if ( pF == pViewFrame ) 1323 pF = SfxViewFrame::GetNext( *pF, pObjShell ); 1324 if ( pF ) 1325 pOldSh = pF->GetViewShell(); 1326 } 1327 1328 ViewShell *pVS, *pNew; 1329 1330 if( pOldSh && pOldSh->IsA( TYPE( SwPagePreView ) ) ) 1331 pVS = ((SwPagePreView*)pOldSh)->GetViewShell(); 1332 else 1333 { 1334 if( pOldSh && pOldSh->IsA( TYPE( SwView ) ) ) 1335 { 1336 pVS = ((SwView*)pOldSh)->GetWrtShellPtr(); 1337 // save the current ViewData of the previous SwView 1338 pOldSh->WriteUserData( sSwViewData, sal_False ); 1339 } 1340 else 1341 pVS = GetDocShell()->GetWrtShell(); 1342 if( pVS ) 1343 { 1344 // setze die akt. Seite als die erste 1345 sal_uInt16 nPhysPg, nVirtPg; 1346 ((SwCrsrShell*)pVS)->GetPageNum( nPhysPg, nVirtPg, /*sal_False*/sal_True, sal_False ); 1347 if( 1 != pViewWin->GetCol() && 1 == nPhysPg ) 1348 --nPhysPg; 1349 pViewWin->SetSttPage( nPhysPg ); 1350 } 1351 } 1352 1353 // OD 09.01.2003 #106334# - for form shell remember design mode of draw view 1354 // of previous view shell 1355 if ( pVS && pVS->HasDrawView() ) 1356 { 1357 mbResetFormDesignMode = true; 1358 mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode(); 1359 } 1360 1361 if( pVS ) 1362 pNew = new ViewShell( *pVS, pViewWin, 0, VSHELLFLAG_ISPREVIEW ); 1363 else 1364 pNew = new ViewShell( 1365 *((SwDocShell*)pViewFrame->GetObjectShell())->GetDoc(), 1366 pViewWin, 0, 0, VSHELLFLAG_ISPREVIEW ); 1367 1368 pViewWin->SetViewShell( pNew ); 1369 pNew->SetSfxViewShell( this ); 1370 Init(); 1371 } 1372 1373 1374 /*-------------------------------------------------------------------- 1375 Beschreibung: 1376 --------------------------------------------------------------------*/ 1377 1378 1379 SwPagePreView::~SwPagePreView() 1380 { 1381 SetWindow( 0 ); 1382 ViewShell* pVShell = pViewWin->GetViewShell(); 1383 pVShell->SetWin(0); 1384 //pViewWin->Hide(); 1385 if( pVShell) 1386 delete pVShell; 1387 delete pViewWin; 1388 //pViewWin->Hide(); 1389 1390 delete pScrollFill; 1391 delete pHScrollbar; 1392 delete pVScrollbar; 1393 delete pPageUpBtn; 1394 delete pPageDownBtn; 1395 1396 /* SfxObjectShell* pDocSh = GetDocShell(); 1397 for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocSh ); 1398 pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) ) 1399 if( pFrame != GetViewFrame() ) 1400 { 1401 // es gibt noch eine weitere Sicht auf unser Dokument, also 1402 // aktiviere dieses 1403 pFrame->GetFrame().Appear(); 1404 break; 1405 } 1406 */} 1407 1408 /*-------------------------------------------------------------------- 1409 Beschreibung: 1410 --------------------------------------------------------------------*/ 1411 1412 1413 SwDocShell* SwPagePreView::GetDocShell() 1414 { 1415 return PTR_CAST(SwDocShell, GetViewFrame()->GetObjectShell()); 1416 } 1417 1418 /*-------------------------------------------------------------------- 1419 Beschreibung: 1420 --------------------------------------------------------------------*/ 1421 1422 1423 int SwPagePreView::_CreateScrollbar( sal_Bool bHori ) 1424 { 1425 Window *pMDI = &GetViewFrame()->GetWindow(); 1426 SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar; 1427 1428 ASSERT( !*ppScrollbar, "vorher abpruefen!" ) 1429 1430 if( !bHori ) 1431 { 1432 1433 pPageUpBtn = new ImageButton(pMDI, SW_RES( BTN_PAGEUP ) ); 1434 pPageUpBtn->SetHelpId(GetStaticInterface()->GetSlot(FN_PAGEUP)->GetCommand()); 1435 pPageDownBtn = new ImageButton(pMDI, SW_RES( BTN_PAGEDOWN ) ); 1436 pPageDownBtn->SetHelpId(GetStaticInterface()->GetSlot(FN_PAGEDOWN)->GetCommand()); 1437 Link aLk( LINK( this, SwPagePreView, BtnPage ) ); 1438 pPageUpBtn->SetClickHdl( aLk ); 1439 pPageDownBtn->SetClickHdl( aLk ); 1440 pPageUpBtn->Show(); 1441 pPageDownBtn->Show(); 1442 } 1443 1444 *ppScrollbar = new SwScrollbar( pMDI, bHori ); 1445 1446 ScrollDocSzChg(); 1447 (*ppScrollbar)->EnableDrag( sal_True ); 1448 (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreView, EndScrollHdl )); 1449 1450 1451 (*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreView, ScrollHdl )); 1452 1453 InvalidateBorder(); 1454 (*ppScrollbar)->ExtendedShow(); 1455 return 1; 1456 } 1457 1458 /*-------------------------------------------------------------------- 1459 Beschreibung: 1460 --------------------------------------------------------------------*/ 1461 1462 1463 1464 /*-------------------------------------------------------------------- 1465 Beschreibung: 1466 --------------------------------------------------------------------*/ 1467 1468 /* 1469 * Button-Handler 1470 */ 1471 IMPL_LINK_INLINE_START( SwPagePreView, BtnPage, Button *, pButton ) 1472 { 1473 // OD 04.03.2003 #107369# - use new helper method to perform page up 1474 // respectively page down. 1475 _ExecPgUpAndPgDown( pButton == pPageUpBtn ); 1476 return 0; 1477 } 1478 IMPL_LINK_INLINE_END( SwPagePreView, BtnPage, Button *, pButton ) 1479 1480 /*-------------------------------------------------------------------- 1481 Beschreibung: 1482 --------------------------------------------------------------------*/ 1483 1484 1485 int SwPagePreView::ChgPage( int eMvMode, int bUpdateScrollbar ) 1486 { 1487 Rectangle aPixVisArea( pViewWin->LogicToPixel( aVisArea ) ); 1488 int bChg = pViewWin->MovePage( eMvMode ) || 1489 eMvMode == SwPagePreViewWin::MV_CALC || 1490 eMvMode == SwPagePreViewWin::MV_NEWWINSIZE; 1491 aVisArea = pViewWin->PixelToLogic( aPixVisArea ); 1492 1493 if( bChg ) 1494 { 1495 // Statusleiste updaten 1496 String aStr( sPageStr ); 1497 pViewWin->GetStatusStr( aStr, mnPageCount ); 1498 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 1499 1500 if( bUpdateScrollbar ) 1501 { 1502 ScrollViewSzChg(); 1503 1504 static sal_uInt16 __READONLY_DATA aInval[] = 1505 { 1506 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, 1507 FN_PAGEUP, FN_PAGEDOWN, 0 1508 }; 1509 rBindings.Invalidate( aInval ); 1510 } 1511 rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) ); 1512 } 1513 return bChg; 1514 } 1515 1516 1517 /* */ 1518 /*-------------------------------------------------------------------- 1519 Beschreibung: 1520 --------------------------------------------------------------------*/ 1521 1522 1523 // ab hier alles aus der SwView uebernommen 1524 1525 1526 void SwPagePreView::CalcAndSetBorderPixel( SvBorder &rToFill, sal_Bool /*bInner*/ ) 1527 { 1528 // const long nAdd = bInner ? 0 : ScrollBar::GetWindowOverlapPixel(); 1529 const StyleSettings &rSet = pViewWin->GetSettings().GetStyleSettings(); 1530 const long nTmp = rSet.GetScrollBarSize();// - nAdd; 1531 if ( pVScrollbar->IsVisible( sal_False )) 1532 rToFill.Right() = nTmp; 1533 if ( pHScrollbar->IsVisible( sal_False ) ) 1534 rToFill.Bottom() = nTmp; 1535 SetBorderPixel( rToFill ); 1536 } 1537 1538 /*-------------------------------------------------------------------- 1539 Beschreibung: 1540 --------------------------------------------------------------------*/ 1541 1542 1543 void SwPagePreView::InnerResizePixel( const Point &rOfst, const Size &rSize ) 1544 { 1545 SvBorder aBorder; 1546 CalcAndSetBorderPixel( aBorder, sal_True ); 1547 Rectangle aRect( rOfst, rSize ); 1548 aRect += aBorder; 1549 ViewResizePixel( *pViewWin, aRect.TopLeft(), aRect.GetSize(), 1550 pViewWin->GetOutputSizePixel(), 1551 sal_True, 1552 *pVScrollbar, *pHScrollbar, pPageUpBtn, pPageDownBtn, 0, 1553 *pScrollFill ); 1554 1555 //EditWin niemals einstellen! 1556 //VisArea niemals einstellen! 1557 } 1558 1559 /*-------------------------------------------------------------------- 1560 Beschreibung: 1561 --------------------------------------------------------------------*/ 1562 1563 1564 void SwPagePreView::OuterResizePixel( const Point &rOfst, const Size &rSize ) 1565 { 1566 SvBorder aBorder; 1567 CalcAndSetBorderPixel( aBorder, sal_False ); 1568 ViewResizePixel( *pViewWin, rOfst, rSize, pViewWin->GetOutputSizePixel(), 1569 sal_False, *pVScrollbar, 1570 *pHScrollbar, pPageUpBtn, pPageDownBtn, 0, *pScrollFill ); 1571 1572 //EditWin niemals einstellen! 1573 1574 Size aTmpSize( pViewWin->GetOutputSizePixel() ); 1575 Point aBottomRight( pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) ); 1576 SetVisArea( Rectangle( Point(), aBottomRight ) ); 1577 1578 //Aufruf der DocSzChgd-Methode der Scrollbars ist noetig, da vom maximalen 1579 //Scrollrange immer die halbe Hoehe der VisArea abgezogen wird. 1580 if ( pVScrollbar && 1581 aTmpSize.Width() > 0 && aTmpSize.Height() > 0 ) 1582 { 1583 ScrollDocSzChg(); 1584 } 1585 } 1586 1587 /*-------------------------------------------------------------------- 1588 Beschreibung: 1589 --------------------------------------------------------------------*/ 1590 1591 1592 void SwPagePreView::SetVisArea( const Rectangle &rRect, sal_Bool bUpdateScrollbar ) 1593 { 1594 const Point aTopLeft(AlignToPixel(rRect.TopLeft())); 1595 const Point aBottomRight(AlignToPixel(rRect.BottomRight())); 1596 Rectangle aLR(aTopLeft,aBottomRight); 1597 1598 if(aLR == aVisArea) 1599 return; 1600 // keine negative Position, keine neg. Groesse 1601 1602 if(aLR.Top() < 0) 1603 { 1604 aLR.Bottom() += Abs(aLR.Top()); 1605 aLR.Top() = 0; 1606 } 1607 1608 if(aLR.Left() < 0) 1609 { 1610 aLR.Right() += Abs(aLR.Left()); 1611 aLR.Left() = 0; 1612 } 1613 if(aLR.Right() < 0) aLR.Right() = 0; 1614 if(aLR.Bottom() < 0) aLR.Bottom() = 0; 1615 if(aLR == aVisArea || 1616 // JP 29.10.97: Bug 45173 - Leeres Rechteck nicht beachten 1617 ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) ) 1618 return; 1619 1620 if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() ) 1621 return; 1622 1623 //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird 1624 //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten 1625 //umgerechnet werden. 1626 //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft, 1627 //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden 1628 //lediglich (in Dokumentkoordinaten) vorgemerkt. 1629 if( GetViewShell()->ActionPend() ) 1630 pViewWin->Update(); 1631 1632 // setze am View-Win die aktuelle Size 1633 aVisArea = aLR; 1634 pViewWin->SetWinSize( aLR.GetSize() ); 1635 // OD 18.12.2002 #103492# - use new mode 1636 ChgPage( SwPagePreViewWin::MV_NEWWINSIZE, bUpdateScrollbar ); 1637 1638 pViewWin->Invalidate(); 1639 } 1640 1641 /*-------------------------------------------------------------------- 1642 Beschreibung: 1643 --------------------------------------------------------------------*/ 1644 1645 1646 IMPL_LINK( SwPagePreView, ScrollHdl, SwScrollbar *, pScrollbar ) 1647 { 1648 if(!GetViewShell()) 1649 return 0; 1650 if( !pScrollbar->IsHoriScroll() && 1651 pScrollbar->GetType() == SCROLL_DRAG && 1652 Help::IsQuickHelpEnabled() && 1653 GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow()) 1654 { 1655 // wieviele Seiten scrollen ?? 1656 String sStateStr(sPageStr); 1657 sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos(); 1658 if( 1 == pViewWin->GetCol() || !nThmbPos ) 1659 ++nThmbPos; 1660 sStateStr += String::CreateFromInt32( nThmbPos ); 1661 Point aPos = pScrollbar->GetParent()->OutputToScreenPixel( 1662 pScrollbar->GetPosPixel()); 1663 aPos.Y() = pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y(); 1664 Size aSize = pScrollbar->GetSizePixel(); 1665 Rectangle aRect; 1666 aRect.Left() = aPos.X() -8; 1667 aRect.Right() = aRect.Left(); 1668 aRect.Top() = aPos.Y(); 1669 aRect.Bottom() = aRect.Top(); 1670 1671 Help::ShowQuickHelp(pScrollbar, aRect, sStateStr, 1672 QUICKHELP_RIGHT|QUICKHELP_VCENTER); 1673 1674 } 1675 else 1676 EndScrollHdl( pScrollbar ); 1677 return 0; 1678 } 1679 1680 /*-------------------------------------------------------------------- 1681 Beschreibung: 1682 --------------------------------------------------------------------*/ 1683 1684 1685 IMPL_LINK( SwPagePreView, EndScrollHdl, SwScrollbar *, pScrollbar ) 1686 { 1687 if(!GetViewShell()) 1688 return 0; 1689 1690 // OD 04.03.2003 #107369# - boolean to avoid unnecessary invalidation of the window. 1691 bool bInvalidateWin = true; 1692 1693 if( !pScrollbar->IsHoriScroll() ) // scroll vertically 1694 { 1695 if ( Help::IsQuickHelpEnabled() ) 1696 Help::ShowQuickHelp(pScrollbar, Rectangle(), aEmptyStr, 0); 1697 if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() ) 1698 { 1699 // wieviele Seiten scrollen ?? 1700 sal_uInt16 nThmbPos = (sal_uInt16)pScrollbar->GetThumbPos(); 1701 // OD 05.12.2002 #103492# - adjust to new preview functionality 1702 if( nThmbPos != pViewWin->SelectedPage() ) 1703 { 1704 // OD 17.01.2003 #103492# - consider case that page <nThmbPos> 1705 // is already visible 1706 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout(); 1707 if ( pPagePrevwLay->IsPageVisible( nThmbPos ) ) 1708 { 1709 pPagePrevwLay->MarkNewSelectedPage( nThmbPos ); 1710 // OD 04.03.2003 #107369# - invalidation of window is unnecessary 1711 bInvalidateWin = false; 1712 } 1713 else 1714 { 1715 // OD 17.01.2003 #103492# - consider whether layout columns 1716 // fit or not. 1717 if ( !pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() ) 1718 { 1719 pViewWin->SetSttPage( nThmbPos ); 1720 pViewWin->SetSelectedPage( nThmbPos ); 1721 ChgPage( SwPagePreViewWin::MV_SCROLL, sal_False ); 1722 // OD 20.01.2003 #103492# - update scrollbars 1723 ScrollViewSzChg(); 1724 } 1725 else 1726 { 1727 // OD 04.03.2003 #107369# - correct scroll amount 1728 const sal_Int16 nPageDiff = nThmbPos - pViewWin->SelectedPage(); 1729 const sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol(); 1730 sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages; 1731 if ( nPageDiff % nVisPages ) 1732 { 1733 // decrease/increase number of preview pages to scroll 1734 nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll; 1735 } 1736 pViewWin->SetSelectedPage( nThmbPos ); 1737 pViewWin->Scroll( 0, pPagePrevwLay->GetWinPagesScrollAmount( nWinPagesToScroll ) ); 1738 } 1739 } 1740 // OD 17.01.2003 #103492# - update accessibility 1741 GetViewShell()->ShowPreViewSelection( nThmbPos ); 1742 } 1743 else 1744 { 1745 // OD 04.03.2003 #107369# - invalidation of window is unnecessary 1746 bInvalidateWin = false; 1747 } 1748 } 1749 else 1750 { 1751 long nThmbPos = pScrollbar->GetThumbPos(); 1752 pViewWin->Scroll(0, nThmbPos - pViewWin->GetPaintedPreviewDocRect().Top()); 1753 } 1754 } 1755 else 1756 { 1757 long nThmbPos = pScrollbar->GetThumbPos(); 1758 pViewWin->Scroll(nThmbPos - pViewWin->GetPaintedPreviewDocRect().Left(), 0); 1759 } 1760 // OD 24.03.2003 #108282# - additional invalidate page status. 1761 static sal_uInt16 __READONLY_DATA aInval[] = 1762 { 1763 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN, 1764 FN_STAT_PAGE, 0 1765 }; 1766 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 1767 rBindings.Invalidate( aInval ); 1768 // OD 04.03.2003 #107369# - control invalidation of window 1769 if ( bInvalidateWin ) 1770 { 1771 pViewWin->Invalidate(); 1772 } 1773 return 0; 1774 } 1775 /*-------------------------------------------------------------------- 1776 Beschreibung: 1777 --------------------------------------------------------------------*/ 1778 1779 1780 Point SwPagePreView::AlignToPixel(const Point &rPt) const 1781 { 1782 return pViewWin->PixelToLogic( pViewWin->LogicToPixel( rPt ) ); 1783 } 1784 1785 /*-------------------------------------------------------------------- 1786 Beschreibung: 1787 --------------------------------------------------------------------*/ 1788 1789 1790 void SwPagePreView::DocSzChgd( const Size &rSz ) 1791 { 1792 if( aDocSz == rSz ) 1793 return; 1794 1795 aDocSz = rSz; 1796 1797 // --> OD 2009-08-20 #i96726# 1798 // Due to the multiple page layout it is needed to trigger recalculation 1799 // of the page preview layout, even if the count of pages is not changing. 1800 mnPageCount = GetViewShell()->GetNumPages(); 1801 1802 if( aVisArea.GetWidth() ) 1803 { 1804 ChgPage( SwPagePreViewWin::MV_CALC, sal_True ); 1805 ScrollDocSzChg(); 1806 1807 pViewWin->Invalidate(); 1808 } 1809 // <-- 1810 } 1811 1812 /*-------------------------------------------------------------------- 1813 Beschreibung: 1814 --------------------------------------------------------------------*/ 1815 1816 1817 void SwPagePreView::ScrollViewSzChg() 1818 { 1819 if(!GetViewShell()) 1820 return ; 1821 if(pVScrollbar) 1822 { 1823 if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow()) 1824 { 1825 //vertical scrolling by row 1826 // OD 04.12.2002 #103492# - adjust to new preview functionality 1827 sal_uInt16 nVisPages = pViewWin->GetRow() * pViewWin->GetCol(); 1828 pVScrollbar->SetVisibleSize( nVisPages ); 1829 // OD 19.02.2003 #107369# - set selected page as scroll bar position, 1830 // if it is visible. 1831 SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout(); 1832 if ( pPagePrevwLay->IsPageVisible( pViewWin->SelectedPage() ) ) 1833 { 1834 pVScrollbar->SetThumbPos( pViewWin->SelectedPage() ); 1835 } 1836 else 1837 { 1838 pVScrollbar->SetThumbPos( pViewWin->GetSttPage() ); 1839 } 1840 pVScrollbar->SetLineSize( pViewWin->GetCol() ); 1841 pVScrollbar->SetPageSize( nVisPages ); 1842 // calculate and set scrollbar range 1843 Range aScrollbarRange( 1, mnPageCount ); 1844 // increase range by one, because left-top-corner is left blank. 1845 ++aScrollbarRange.Max(); 1846 // OD 17.01.2003 #103492# - increase range in order to access all pages 1847 aScrollbarRange.Max() += ( nVisPages - 1 ); 1848 pVScrollbar->SetRange( aScrollbarRange ); 1849 } 1850 else //vertical scrolling by pixel 1851 { 1852 const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect(); 1853 const Size& rPreviewSize = 1854 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize(); 1855 pVScrollbar->SetRangeMax(rPreviewSize.Height()) ; 1856 long nVisHeight = rDocRect.GetHeight(); 1857 pVScrollbar->SetVisibleSize( nVisHeight ); 1858 pVScrollbar->SetThumbPos( rDocRect.Top() ); 1859 pVScrollbar->SetLineSize( nVisHeight / 10 ); 1860 pVScrollbar->SetPageSize( nVisHeight / 2 ); 1861 } 1862 } 1863 if(pHScrollbar) 1864 { 1865 const Rectangle& rDocRect = pViewWin->GetPaintedPreviewDocRect(); 1866 const Size& rPreviewSize = 1867 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize(); 1868 long nVisWidth = 0; 1869 long nThumb = 0; 1870 Range aRange(0,0); 1871 1872 if(rDocRect.GetWidth() < rPreviewSize.Width()) 1873 { 1874 nVisWidth = rDocRect.GetWidth(); 1875 nThumb = rDocRect.Left(); 1876 aRange = Range(0, rPreviewSize.Width()); 1877 } 1878 pHScrollbar->SetRange( aRange ); 1879 pHScrollbar->SetVisibleSize( nVisWidth ); 1880 pHScrollbar->SetThumbPos( nThumb ); 1881 pHScrollbar->SetLineSize( nVisWidth / 10 ); 1882 pHScrollbar->SetPageSize( nVisWidth / 2 ); 1883 } 1884 } 1885 1886 /*-------------------------------------------------------------------- 1887 Beschreibung: 1888 --------------------------------------------------------------------*/ 1889 1890 1891 void SwPagePreView::ScrollDocSzChg() 1892 { 1893 ScrollViewSzChg(); 1894 } 1895 1896 1897 /* */ 1898 /*-------------------------------------------------------------------- 1899 Beschreibung: 1900 --------------------------------------------------------------------*/ 1901 1902 1903 // alles zum Thema Drucken 1904 1905 SfxPrinter* SwPagePreView::GetPrinter( sal_Bool bCreate ) 1906 { 1907 return pViewWin->GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate ); 1908 } 1909 1910 /*-------------------------------------------------------------------- 1911 Beschreibung: 1912 --------------------------------------------------------------------*/ 1913 1914 1915 sal_uInt16 SwPagePreView::SetPrinter( SfxPrinter *pNew, sal_uInt16 nDiffFlags, bool ) 1916 { 1917 ViewShell &rSh = *GetViewShell(); 1918 SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false ); 1919 if ( pOld && pOld->IsPrinting() ) 1920 return SFX_PRINTERROR_BUSY; 1921 1922 SwEditShell &rESh = (SwEditShell&)rSh; //Buh... 1923 if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags ) 1924 { 1925 rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true ); 1926 if( nDiffFlags & SFX_PRINTER_PRINTER ) 1927 rESh.SetModified(); 1928 } 1929 if ( ( nDiffFlags & SFX_PRINTER_OPTIONS ) == SFX_PRINTER_OPTIONS ) 1930 ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, sal_False ); 1931 1932 const sal_Bool bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? sal_True : sal_False; 1933 const sal_Bool bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? sal_True : sal_False; 1934 if ( bChgOri || bChgSize ) 1935 { 1936 rESh.StartAllAction(); 1937 if ( bChgOri ) 1938 rSh.ChgAllPageOrientation( sal_uInt16(pNew->GetOrientation()) ); 1939 if ( bChgSize ) 1940 { 1941 Size aSz( SvxPaperInfo::GetPaperSize( pNew ) ); 1942 rSh.ChgAllPageSize( aSz ); 1943 } 1944 if( !bNormalPrint ) 1945 pViewWin->CalcWish( pViewWin->GetRow(), pViewWin->GetCol() ); 1946 rESh.SetModified(); 1947 rESh.EndAllAction(); 1948 1949 static sal_uInt16 __READONLY_DATA aInval[] = 1950 { 1951 SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE, 1952 SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0 1953 }; 1954 #ifdef DBG_UTIL 1955 { 1956 const sal_uInt16* pPtr = aInval + 1; 1957 do { 1958 ASSERT( *(pPtr - 1) < *pPtr, "falsche Sortierung!" ); 1959 } while( *++pPtr ); 1960 } 1961 #endif 1962 1963 GetViewFrame()->GetBindings().Invalidate(aInval); 1964 } 1965 1966 return 0; 1967 } 1968 1969 /*-------------------------------------------------------------------- 1970 Beschreibung: 1971 --------------------------------------------------------------------*/ 1972 1973 1974 SfxTabPage* SwPagePreView::CreatePrintOptionsPage( Window *pParent, 1975 const SfxItemSet &rOptions ) 1976 { 1977 return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint ); 1978 } 1979 1980 /*-------------------------------------------------------------------- 1981 Beschreibung: 1982 --------------------------------------------------------------------*/ 1983 1984 1985 // OD 18.12.2002 #103492# - no longer needed ?? 1986 Size SwPagePreView::GetOptimalSizePixel() const 1987 { 1988 ASSERT( false, "overloaded virtual method <SwPagePreView::GetOptimalSizePixel()> needed ??" ) 1989 return Size( -1, -1 ); 1990 /* 1991 //JP 09.06.99: was wird hier errechnet ????? 1992 // ALT: 1993 // SfxApplicationWindow* pWin = SFX_APPWINDOW ; 1994 // Rectangle aRect = pWin->GetClientAreaPixel(); 1995 1996 Window& rWin = GetViewFrame()->GetWindow(); 1997 Rectangle aRect( Point(0, 0), rWin.GetOutputSizePixel() ); 1998 Size aMaxSize( aRect.GetWidth(), aRect.GetHeight() ); 1999 Size aInSize = rWin.GetOutputSizePixel(); 2000 Size aOutSize = rWin.GetSizePixel(); 2001 sal_uInt16 nXBorder = sal_uInt16(aOutSize.Width() - aInSize.Width()); 2002 sal_uInt16 nYBorder = sal_uInt16(aOutSize.Height() - aInSize.Height()); 2003 aMaxSize.Width() -= nXBorder; 2004 //'auf Verdacht' etwas vom Border abziehen (Menue) 2005 nYBorder -= (nYBorder - nXBorder) / 2; 2006 aMaxSize.Height() -= nYBorder; 2007 //mit der max. moeglichen Outputsize guenstigstes Verhaeltnis ausrechnen 2008 pViewWin->GetOptimalSize(aMaxSize); 2009 // Border wieder dazuzaehlen 2010 aMaxSize.Height() += nYBorder; 2011 aMaxSize.Width() += nXBorder; 2012 return aMaxSize; 2013 */ 2014 } 2015 2016 /*-------------------------------------------------------------------- 2017 Beschreibung: 2018 --------------------------------------------------------------------*/ 2019 2020 // OD 12.12.2002 #103492# 2021 void SwPagePreViewWin::SetViewShell( ViewShell* pShell ) 2022 { 2023 mpViewShell = pShell; 2024 if ( mpViewShell && mpViewShell->IsPreView() ) 2025 { 2026 mpPgPrevwLayout = mpViewShell->PagePreviewLayout(); 2027 } 2028 } 2029 2030 void SwPagePreViewWin::RepaintCoreRect( const SwRect& rRect ) 2031 { 2032 // OD 2004-03-04 #i24183# 2033 if ( mpPgPrevwLayout->PreviewLayoutValid() ) 2034 { 2035 mpPgPrevwLayout->Repaint( Rectangle( rRect.Pos(), rRect.SSize() ) ); 2036 } 2037 } 2038 2039 /** method to adjust preview to a new zoom factor 2040 2041 OD 02.12.2002 #103492# 2042 OD 24.09.2003 #i19975# - also consider zoom type - adding parameter <_eZoomType> 2043 */ 2044 void SwPagePreViewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor, 2045 const SvxZoomType _eZoomType ) 2046 { 2047 // OD 24.09.2003 #i19975# - consider zoom type 2048 if ( _eZoomType == SVX_ZOOM_WHOLEPAGE ) 2049 { 2050 mnRow = 1; 2051 mnCol = 1; 2052 mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true ); 2053 mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize, 2054 mnSttPage, maPaintedPreviewDocRect ); 2055 SetSelectedPage( mnSttPage ); 2056 SetPagePreview(mnRow, mnCol); 2057 maScale = GetMapMode().GetScaleX(); 2058 } 2059 else if ( _nZoomFactor != 0 ) 2060 { 2061 // calculate new scaling and set mapping mode appropriately. 2062 Fraction aNewScale( _nZoomFactor, 100 ); 2063 MapMode aNewMapMode = GetMapMode(); 2064 aNewMapMode.SetScaleX( aNewScale ); 2065 aNewMapMode.SetScaleY( aNewScale ); 2066 SetMapMode( aNewMapMode ); 2067 2068 // calculate new start position for preview paint 2069 Size aNewWinSize = PixelToLogic( maPxWinSize ); 2070 Point aNewPaintStartPos = 2071 mpPgPrevwLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize ); 2072 2073 // remember new scaling and prepare preview paint 2074 // Note: paint of preview will be performed by a corresponding invalidate 2075 // due to property changes. 2076 maScale = aNewScale; 2077 mpPgPrevwLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize, 2078 mnSttPage, maPaintedPreviewDocRect ); 2079 } 2080 2081 } 2082 /* -----------------04.12.2002 10:46----------------- 2083 * pixel scrolling - horizontally always or vertically 2084 * when less than the desired number of rows fits into 2085 * the view 2086 * --------------------------------------------------*/ 2087 void SwPagePreViewWin::Scroll(long nXMove, long nYMove, sal_uInt16 /*nFlags*/) 2088 { 2089 maPaintedPreviewDocRect.Move(nXMove, nYMove); 2090 mpPgPrevwLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(), 2091 maPxWinSize, mnSttPage, 2092 maPaintedPreviewDocRect ); 2093 2094 } 2095 2096 sal_Bool SwPagePreView::HandleWheelCommands( const CommandEvent& rCEvt ) 2097 { 2098 sal_Bool bOk = sal_False; 2099 const CommandWheelData* pWData = rCEvt.GetWheelData(); 2100 if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() ) 2101 { 2102 //IAccessibility2 Implementation 2009-----, only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here 2103 //if(!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport()) 2104 if ( !Application::IsAccessibilityEnabled() ) 2105 { 2106 sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom(); 2107 const sal_uInt16 nOffset = 10; 2108 if( 0L > pWData->GetDelta() ) 2109 { 2110 nFactor -= nOffset; 2111 if(nFactor < MIN_PREVIEW_ZOOM) 2112 nFactor = MIN_PREVIEW_ZOOM; 2113 } 2114 else 2115 { 2116 nFactor += nOffset; 2117 if(nFactor > MAX_PREVIEW_ZOOM) 2118 nFactor = MAX_PREVIEW_ZOOM; 2119 } 2120 SetZoom(SVX_ZOOM_PERCENT, nFactor); 2121 } 2122 bOk = sal_True; 2123 } 2124 else 2125 bOk = pViewWin->HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar ); 2126 return bOk; 2127 } 2128 2129 2130 uno::Reference< ::com::sun::star::accessibility::XAccessible > 2131 SwPagePreViewWin::CreateAccessible() 2132 { 2133 vos::OGuard aGuard(Application::GetSolarMutex()); // this should have 2134 // happened already!!! 2135 2136 DBG_ASSERT( GetViewShell() != NULL, "We need a view shell" ); 2137 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible( sal_False ); 2138 if (xAcc.is()) 2139 { 2140 return xAcc; 2141 } 2142 if (mpViewShell) 2143 { 2144 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview(); 2145 SetAccessible(xAccPreview); 2146 } 2147 return GetAccessible( sal_False ); 2148 } 2149 // MT: Removed Windows::SwitchView() introduced with IA2 CWS. 2150 // There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism 2151 void SwPagePreViewWin::SwitchView() 2152 { 2153 #ifdef ACCESSIBLE_LAYOUT 2154 if (!Application::IsAccessibilityEnabled()) 2155 { 2156 return ; 2157 } 2158 if (mpViewShell) 2159 { 2160 mpViewShell->InvalidateAccessibleFocus(); 2161 } 2162 #endif 2163 } 2164 2165 /* -----------------------------06.05.2002 13:18------------------------------ 2166 2167 ---------------------------------------------------------------------------*/ 2168 void SwPagePreView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions) 2169 { 2170 GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions); 2171 } 2172 /* -----------------------------2002/06/26 14:30------------------------------ 2173 2174 ---------------------------------------------------------------------------*/ 2175 void SwPagePreView::ShowHScrollbar(sal_Bool bShow) 2176 { 2177 pHScrollbar->Show(bShow); 2178 InvalidateBorder(); 2179 } 2180 2181 /* -----------------------------2002/06/26 14:30------------------------------ 2182 2183 ---------------------------------------------------------------------------*/ 2184 void SwPagePreView::ShowVScrollbar(sal_Bool bShow) 2185 { 2186 pVScrollbar->Show(bShow); 2187 InvalidateBorder(); 2188 } 2189 2190 /* -----------------25.11.2002 16:36----------------- 2191 * 2192 * --------------------------------------------------*/ 2193 void SwPagePreView::SetZoom(SvxZoomType eType, sal_uInt16 nFactor) 2194 { 2195 ViewShell& rSh = *GetViewShell(); 2196 SwViewOption aOpt(*rSh.GetViewOptions()); 2197 // OD 16.12.2002 #103492# - perform action only on changes of zoom or zoom type. 2198 if ( aOpt.GetZoom() != nFactor || 2199 aOpt.GetZoomType() != eType ) 2200 { 2201 aOpt.SetZoom(nFactor); 2202 aOpt.SetZoomType(eType); 2203 rSh.ApplyViewOptions( aOpt ); 2204 lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings()); 2205 // OD 02.12.2002 #103492# 2206 // OD 24.09.2003 #i19975# - also consider zoom type 2207 pViewWin->AdjustPreviewToNewZoom( nFactor, eType ); 2208 ScrollViewSzChg(); 2209 } 2210 } 2211 2212 /** adjust position of vertical scrollbar 2213 2214 OD 19.02.2003 #107369 2215 2216 @author OD 2217 */ 2218 void SwPagePreView::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos ) 2219 { 2220 if ( pVScrollbar ) 2221 { 2222 pVScrollbar->SetThumbPos( _nNewThumbPos ); 2223 } 2224 } 2225