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