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