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