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