LibreOffice Module sw (master)  1
pview.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sfx2/objface.hxx>
21 #include <vcl/help.hxx>
22 #include <vcl/commandevent.hxx>
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/syswin.hxx>
26 #include <vcl/weld.hxx>
27 
28 #include <rtl/ustrbuf.hxx>
29 #include <svl/whiter.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/eitem.hxx>
32 #include <sfx2/printer.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <sfx2/request.hxx>
35 #include <sfx2/dispatch.hxx>
36 #include <editeng/paperinf.hxx>
37 #include <svx/svdview.hxx>
38 #include <svx/zoomslideritem.hxx>
39 #include <tools/svborder.hxx>
40 
41 #include <globdoc.hxx>
42 #include <wdocsh.hxx>
43 #include <pvprtdat.hxx>
44 #include <swmodule.hxx>
45 #include <wrtsh.hxx>
46 #include <docsh.hxx>
47 #include <viewopt.hxx>
48 #include <doc.hxx>
50 #include <pview.hxx>
51 #include <view.hxx>
52 #include <scroll.hxx>
53 #include <prtopt.hxx>
54 #include <usrpref.hxx>
55 #include "viewfunc.hxx"
56 
57 #include <helpids.h>
58 #include <cmdid.h>
59 #include <strings.hrc>
60 
61 #define ShellClass_SwPagePreview
62 #include <sfx2/msg.hxx>
63 #include <swslots.hxx>
64 #include <pagepreviewlayout.hxx>
65 
66 #include <svx/svxdlg.hxx>
67 
68 #include <memory>
69 #include <vcl/EnumContext.hxx>
70 #include <vcl/notebookbar.hxx>
71 
72 using namespace ::com::sun::star;
74 {
78 }
79 
81 
82 void SwPagePreview::InitInterface_Impl()
83 {
84  GetStaticInterface()->RegisterPopupMenu("preview");
85  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
86  SfxVisibilityFlags::Standard|SfxVisibilityFlags::Client|SfxVisibilityFlags::FullScreen|SfxVisibilityFlags::ReadonlyDoc,
87  ToolbarId::PView_Toolbox);
88 }
89 
90 
91 #define SWVIEWFLAGS SfxViewShellFlags::HAS_PRINTOPTIONS
92 
93 #define MIN_PREVIEW_ZOOM 25
94 #define MAX_PREVIEW_ZOOM 600
95 
96 static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, bool bZoomIn)
97 {
98  static const sal_uInt16 aZoomArr[] =
99  {
100  25, 50, 75, 100, 150, 200, 400, 600
101  };
102  const int nZoomArrSize = static_cast<int>(SAL_N_ELEMENTS(aZoomArr));
103  if (bZoomIn)
104  {
105  for(int i = nZoomArrSize - 1; i >= 0; --i)
106  {
107  if(nCurrentZoom > aZoomArr[i] || !i)
108  return aZoomArr[i];
109  }
110  }
111  else
112  {
113  for(sal_uInt16 i : aZoomArr)
114  {
115  if(nCurrentZoom < i)
116  return i;
117  }
118  }
119  return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
120 };
121 
122 static void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
123 {
124  static sal_uInt16 const aInval[] =
125  {
126  SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
127  0
128  };
129  rBindings.Invalidate( aInval );
130 }
131 
132 namespace {
133 
134 // At first the zoom dialog
135 class SwPreviewZoomDlg : public weld::GenericDialogController
136 {
138  std::unique_ptr<weld::SpinButton> m_xRowEdit;
139  std::unique_ptr<weld::SpinButton> m_xColEdit;
140 
141 public:
142  SwPreviewZoomDlg(SwPagePreviewWin& rParent)
143  : GenericDialogController(rParent.GetFrameWeld(), "modules/swriter/ui/previewzoomdialog.ui", "PreviewZoomDialog")
144  , m_rParent(rParent)
145  , m_xRowEdit(m_xBuilder->weld_spin_button("rows"))
146  , m_xColEdit(m_xBuilder->weld_spin_button("cols"))
147  {
148  m_xRowEdit->set_value(rParent.GetRow());
149  m_xColEdit->set_value(rParent.GetCol());
150  }
151 
152  void execute()
153  {
154  if (run() == RET_OK)
155  {
156  m_rParent.CalcWish(sal_uInt8(m_xRowEdit->get_value()), sal_uInt8(m_xColEdit->get_value()));
157  }
158  }
159 };
160 
161 }
162 
163 // all for SwPagePreviewWin
165  : Window(pParent, WinBits(WB_CLIPCHILDREN))
166  , mpViewShell(nullptr)
167  , mrView(rPView)
168  , mbCalcScaleForPreviewLayout(true)
169  , maPaintedPreviewDocRect(tools::Rectangle(0,0,0,0))
170  , mpPgPreviewLayout(nullptr)
171 {
172  SetOutDevViewType( OutDevViewType::PrintPreview );
174  SetFillColor( GetBackground().GetColor() );
175  SetLineColor( GetBackground().GetColor());
176  SetMapMode( MapMode(MapUnit::MapTwip) );
177 
178  const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(false);
179  mnRow = pUsrPref->GetPagePrevRow(); // 1 row
180  mnCol = pUsrPref->GetPagePrevCol(); // 1 column
182 }
183 
185 {
186 }
187 
189 {
190  if (!mpViewShell || !mpViewShell->GetLayout())
191  return;
192 
193  if (USHRT_MAX == mnSttPage) // was never calculated ? (Init-Phase!)
194  {
195  // This is the size to which I always relate.
196  if (!maPxWinSize.Height() || !maPxWinSize.Width())
198 
199  tools::Rectangle aRect(rRenderContext.LogicToPixel(rRect));
202  SetSelectedPage(1);
203  mpPgPreviewLayout->Paint(rRenderContext, rRenderContext.PixelToLogic(aRect));
205  }
206  else
207  {
208  MapMode aMM(rRenderContext.GetMapMode());
209  aMM.SetScaleX(maScale);
210  aMM.SetScaleY(maScale);
211  rRenderContext.SetMapMode(aMM);
213  mpPgPreviewLayout->Paint(rRenderContext, rRect);
215  }
216 }
217 
219 {
220  if( !mpViewShell || !mpViewShell->GetLayout() )
221  return;
222 
223  const sal_uInt8 nOldCol = mnCol;
224  mnRow = nNewRow;
225  mnCol = nNewCol;
226  const sal_uInt16 nPages = mnRow * mnCol;
227  const sal_uInt16 nLastSttPg = mrView.GetPageCount()+1 > nPages
228  ? mrView.GetPageCount()+1 - nPages : 0;
229  if( mnSttPage > nLastSttPg )
230  mnSttPage = nLastSttPg;
231 
236  SetPagePreview(mnRow, mnCol);
238 
239  // If changes have taken place at the columns, the special case "single column"
240  // must be considered and corrected if necessary.
241  if( (1 == nOldCol) != (1 == mnCol) )
243 
244  // Order must be maintained!
245  // additional invalidate page status.
246  static sal_uInt16 aInval[] =
247  {
248  SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
250  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
253  0
254  };
255  SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
256  rBindings.Invalidate( aInval );
257  rBindings.Update( FN_SHOW_TWO_PAGES );
258  rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
259  // adjust scrollbars
261 }
262 
263 // mnSttPage is Absolute
264 bool SwPagePreviewWin::MovePage( int eMoveMode )
265 {
266  // number of pages up
267  const sal_uInt16 nPages = mnRow * mnCol;
268  sal_uInt16 nNewSttPage = mnSttPage;
269  const sal_uInt16 nPageCount = mrView.GetPageCount();
270  const sal_uInt16 nDefSttPg = GetDefSttPage();
271  bool bPaintPageAtFirstCol = true;
272 
273  switch( eMoveMode )
274  {
275  case MV_PAGE_UP:
276  {
277  const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
278  const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
279  mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
280  nDefSttPg;
281  nNewSttPage = nNewAbsSttPage;
282 
283  const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
284  const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
285  nRelSelPage - nPages :
286  1;
288 
289  break;
290  }
291  case MV_PAGE_DOWN:
292  {
293  const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
294  const sal_uInt16 nNewAbsSttPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
295  nNewSttPage = std::min(nNewAbsSttPage, nPageCount);
296 
297  const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
298  const sal_uInt16 nNewAbsSelPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
299  SetSelectedPage( std::min(nNewAbsSelPage, nPageCount) );
300 
301  break;
302  }
303  case MV_DOC_STT:
304  nNewSttPage = nDefSttPg;
305  SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
306  break;
307  case MV_DOC_END:
308  // correct calculation of new start page.
309  nNewSttPage = nPageCount;
310  SetSelectedPage( nPageCount );
311  break;
312 
313  case MV_SELPAGE:
314  // <nNewSttPage> and <SelectedPage()> are already set.
315  // not start at first column, only if the
316  // complete preview layout columns doesn't fit into window.
318  bPaintPageAtFirstCol = false;
319  break;
320  case MV_SCROLL:
321  // check, if paint page at first column
322  // has to be avoided
325  bPaintPageAtFirstCol = false;
326  break;
327  case MV_NEWWINSIZE:
328  // nothing special to do.
329  break;
330  case MV_CALC:
331  // re-init page preview layout.
333 
334  // correct calculation of new start page.
335  if( nNewSttPage > nPageCount )
336  nNewSttPage = nPageCount;
337 
338  // correct selected page number
339  if( SelectedPage() > nPageCount )
340  SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
341  }
342 
343  mpPgPreviewLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
344  nNewSttPage,
345  maPaintedPreviewDocRect, bPaintPageAtFirstCol );
346  if( nNewSttPage == mnSttPage &&
347  eMoveMode != MV_SELPAGE )
348  return false;
349 
350  SetPagePreview(mnRow, mnCol);
351  mnSttPage = nNewSttPage;
352 
353  // additional invalidate page status.
354  static sal_uInt16 aInval[] =
355  {
356  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
357  FN_STAT_PAGE, 0
358  };
359 
360  SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
361  rBindings.Invalidate( aInval );
362 
363  return true;
364 }
365 
366 void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
367 {
368  // We always want the size as pixel units.
369  maPxWinSize = LogicToPixel( rNewSize );
370 
371  if( USHRT_MAX == mnSttPage )
372  {
375  }
376 
378  {
381  }
385  {
388  }
391 }
392 
393 OUString SwPagePreviewWin::GetStatusStr( sal_uInt16 nPageCnt ) const
394 {
395  // show physical and virtual page number of
396  // selected page, if it's visible.
397  const sal_uInt16 nPageNum = mpPgPreviewLayout->IsPageVisible( mpPgPreviewLayout->SelectedPage() )
398  ? mpPgPreviewLayout->SelectedPage() : std::max<sal_uInt16>(mnSttPage, 1);
399 
400  OUStringBuffer aStatusStr;
401  const sal_uInt16 nVirtPageNum = mpPgPreviewLayout->GetVirtPageNumByPageNum( nPageNum );
402  if( nVirtPageNum && nVirtPageNum != nPageNum )
403  {
404  aStatusStr.append( OUString::number(nVirtPageNum) ).append( " " );
405  }
406  aStatusStr.append( OUString::number(nPageNum) ).append( " / " ).append( OUString::number(nPageCnt) );
407  return aStatusStr.makeStringAndClear();
408 }
409 
411 {
412  const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
413  bool bHandled = false;
414  if(!rKeyCode.GetModifier())
415  {
416  sal_uInt16 nSlot = 0;
417  switch(rKeyCode.GetCode())
418  {
419  case KEY_ADD : nSlot = SID_ZOOM_OUT; break;
420  case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
421  case KEY_SUBTRACT : nSlot = SID_ZOOM_IN; break;
422  }
423  if(nSlot)
424  {
425  bHandled = true;
427  nSlot, SfxCallMode::ASYNCHRON );
428  }
429  }
430  if( !bHandled && !mrView.KeyInput( rKEvt ) )
431  Window::KeyInput( rKEvt );
432 }
433 
435 {
436  bool bCallBase = true;
437  switch( rCEvt.GetCommand() )
438  {
439  case CommandEventId::ContextMenu:
441  bCallBase = false;
442  break;
443 
444  case CommandEventId::Wheel:
445  case CommandEventId::StartAutoScroll:
446  case CommandEventId::AutoScroll:
447  {
448  const CommandWheelData* pData = rCEvt.GetWheelData();
449  if( pData )
450  {
451  const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
452  pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
453  const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
454  bCallBase = !mrView.HandleWheelCommands( aEvent );
455  }
456  else
457  bCallBase = !mrView.HandleWheelCommands( rCEvt );
458  }
459  break;
460  default:
461  ;
462  }
463 
464  if( bCallBase )
465  Window::Command( rCEvt );
466 }
467 
469 {
470  // consider single-click to set selected page
471  if( MOUSE_LEFT != ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
472  return;
473 
474  Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) );
475  Point aDocPos;
476  bool bPosInEmptyPage;
477  sal_uInt16 nNewSelectedPage;
478  bool bIsDocPos =
480  aDocPos, bPosInEmptyPage, nNewSelectedPage );
481  if ( bIsDocPos && rMEvt.GetClicks() == 2 )
482  {
483  // close page preview, set new cursor position and switch to
484  // normal view.
485  OUString sNewCursorPos = OUString::number( aDocPos.X() ) + ";" +
486  OUString::number( aDocPos.Y() ) + ";";
487  mrView.SetNewCursorPos( sNewCursorPos );
488 
489  SfxViewFrame *pTmpFrame = mrView.GetViewFrame();
490  pTmpFrame->GetBindings().Execute( SID_VIEWSHELL0, nullptr,
491  SfxCallMode::ASYNCHRON );
492  }
493  else if ( bIsDocPos || bPosInEmptyPage )
494  {
495  // show clicked page as the selected one
496  mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage );
497  GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
498  // adjust position at vertical scrollbar.
500  {
501  mrView.SetVScrollbarThumbPos( nNewSelectedPage );
502  }
503  // invalidate page status.
504  static sal_uInt16 aInval[] =
505  {
506  FN_STAT_PAGE, 0
507  };
508  SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
509  rBindings.Invalidate( aInval );
510  }
511 }
512 
513 // Set user prefs or view options
514 
516 {
517  SwMasterUsrPref *pOpt = const_cast<SwMasterUsrPref *>(SW_MOD()->GetUsrPref(false));
518 
519  if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
520  {
521  pOpt->SetPagePrevRow( nRow );
522  pOpt->SetPagePrevCol( nCol );
523  pOpt->SetModified();
524 
525  // Update scrollbar!
527  }
528 }
529 
532 {
534 }
535 
537 void SwPagePreviewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
538 {
539  mpPgPreviewLayout->SetSelectedPage( _nSelectedPageNum );
540 }
541 
543 bool SwPagePreviewWin::SetBookPreviewMode( const bool _bBookPreview )
544 {
545  return mpPgPreviewLayout->SetBookPreviewMode( _bBookPreview,
546  mnSttPage,
548 }
549 
551 {
552  Window::DataChanged( rDCEvt );
553 
554  switch( rDCEvt.GetType() )
555  {
556  case DataChangedEventType::SETTINGS:
557  // Rearrange the scrollbars or trigger resize, because the
558  // size of the scrollbars may have be changed. Also the
559  // size of the scrollbars has to be retrieved from the settings
560  // out of the resize handler.
561  if( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
562  mrView.InvalidateBorder(); // Scrollbar widths
563  // zoom has to be disabled if Accessibility support is switched on
565  break;
566 
567  case DataChangedEventType::PRINTER:
568  case DataChangedEventType::DISPLAY:
569  case DataChangedEventType::FONTS:
570  case DataChangedEventType::FONTSUBSTITUTION:
571  mrView.GetDocShell()->UpdateFontList(); // Font change
573  if ( mpViewShell->GetWin() )
575  break;
576  default: break;
577  }
578 }
579 
581 void SwPagePreview::ExecPgUpAndPgDown( const bool _bPgUp,
582  SfxRequest* _pReq )
583 {
584  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
585  // check, if top/bottom of preview is *not* already visible.
586  if( pPagePreviewLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
587  {
588  if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() &&
589  pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
590  {
591  const int eMvMode = _bPgUp ?
594  if ( ChgPage( eMvMode ) )
596  }
597  else
598  {
599  SwTwips nScrollAmount;
600  sal_uInt16 nNewSelectedPageNum = 0;
601  const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
602  if( _bPgUp )
603  {
604  if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
605  {
606  nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( -1 );
607  if ( (m_pViewWin->SelectedPage() - nVisPages) > 0 )
608  nNewSelectedPageNum = m_pViewWin->SelectedPage() - nVisPages;
609  else
610  nNewSelectedPageNum = 1;
611  }
612  else
613  nScrollAmount = - std::min( m_pViewWin->GetOutputSize().Height(),
615  }
616  else
617  {
618  if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
619  {
620  nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( 1 );
621  if ( (m_pViewWin->SelectedPage() + nVisPages) <= mnPageCount )
622  nNewSelectedPageNum = m_pViewWin->SelectedPage() + nVisPages;
623  else
624  nNewSelectedPageNum = mnPageCount;
625  }
626  else
627  nScrollAmount = std::min( m_pViewWin->GetOutputSize().Height(),
628  ( pPagePreviewLay->GetPreviewDocSize().Height() -
630  }
631  m_pViewWin->Scroll( 0, nScrollAmount );
632  if ( nNewSelectedPageNum != 0 )
633  {
634  m_pViewWin->SetSelectedPage( nNewSelectedPageNum );
635  }
636  ScrollViewSzChg();
637  // additional invalidate page status.
638  static sal_uInt16 aInval[] =
639  {
640  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
641  FN_STAT_PAGE, 0
642  };
643  SfxBindings& rBindings = GetViewFrame()->GetBindings();
644  rBindings.Invalidate( aInval );
646  }
647  }
648 
649  if ( _pReq )
650  _pReq->Done();
651 }
652 
653 // Then all for the SwPagePreview
655 {
656  int eMvMode = SwPagePreviewWin::MV_DOC_END;
657  sal_uInt8 nRow = 1;
658  bool bRefresh = true;
659 
660  switch(rReq.GetSlot())
661  {
662  case FN_REFRESH_VIEW:
663  case FN_STAT_PAGE:
664  case FN_STAT_ZOOM:
665  break;
666 
668  {
669  const SfxItemSet *pArgs = rReq.GetArgs();
670  if( pArgs && pArgs->Count() >= 2 )
671  {
672  sal_uInt8 nCols = static_cast<sal_uInt8>(pArgs->Get(SID_ATTR_TABLE_COLUMN).GetValue());
673  sal_uInt8 nRows = static_cast<sal_uInt8>(pArgs->Get(SID_ATTR_TABLE_ROW).GetValue());
674  m_pViewWin->CalcWish( nRows, nCols );
675 
676  }
677  else
678  {
679  SwPreviewZoomDlg aDlg(*m_pViewWin);
680  aDlg.execute();
681  }
682  }
683  break;
684  case FN_SHOW_BOOKVIEW:
685  {
686  const SfxItemSet* pArgs = rReq.GetArgs();
687  const SfxPoolItem* pItem;
688  bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
689  if( pArgs && SfxItemState::SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, false, &pItem ) )
690  {
691  bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue();
692  const_cast<SwViewOption*>(GetViewShell()->GetViewOptions())->SetPagePrevBookview( bBookPreview );
693  // cast is not gentleman like, but it's common use in writer and in this case
694  }
695  if ( m_pViewWin->SetBookPreviewMode( bBookPreview ) )
696  {
697  // book preview mode changed. Thus, adjust scrollbars and
698  // invalidate corresponding states.
699  ScrollViewSzChg();
700  static sal_uInt16 aInval[] =
701  {
702  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
704  };
705  SfxBindings& rBindings = GetViewFrame()->GetBindings();
706  rBindings.Invalidate( aInval );
708  }
709 
710  }
711  break;
712  case FN_SHOW_TWO_PAGES:
713  m_pViewWin->CalcWish( nRow, 2 );
714  break;
715 
716  case FN_SHOW_SINGLE_PAGE:
717  m_pViewWin->CalcWish( nRow, 1 );
718  break;
719 
720  case FN_PREVIEW_ZOOM:
721  case SID_ATTR_ZOOM:
722  {
723  const SfxItemSet *pArgs = rReq.GetArgs();
724  const SfxPoolItem* pItem;
726  if(!pArgs)
727  {
729  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
730  SvxZoomItem aZoom( pVOpt->GetZoomType(), pVOpt->GetZoom() );
731  aZoom.SetValueSet(
732  SvxZoomEnableFlags::N50|
733  SvxZoomEnableFlags::N75|
734  SvxZoomEnableFlags::N100|
735  SvxZoomEnableFlags::N150|
736  SvxZoomEnableFlags::N200|
737  SvxZoomEnableFlags::WHOLEPAGE);
738  aCoreSet.Put( aZoom );
739 
742  pDlg->SetLimits( MINZOOM, MAXZOOM );
743 
744  if( pDlg->Execute() != RET_CANCEL )
745  pArgs = pDlg->GetOutputItemSet();
746  }
747  if( pArgs )
748  {
749  SvxZoomType eType = SvxZoomType::PERCENT;
750  sal_uInt16 nZoomFactor = USHRT_MAX;
751  if(SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOM, true, &pItem))
752  {
753  eType = static_cast<const SvxZoomItem *>(pItem)->GetType();
754  nZoomFactor = static_cast<const SvxZoomItem *>(pItem)->GetValue();
755  }
756  else if(SfxItemState::SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, true, &pItem))
757  nZoomFactor = static_cast<const SfxUInt16Item *>(pItem)->GetValue();
758  if(USHRT_MAX != nZoomFactor)
759  SetZoom(eType, nZoomFactor);
760  }
761  }
762  break;
763  case SID_ATTR_ZOOMSLIDER :
764  {
765  const SfxItemSet *pArgs = rReq.GetArgs();
766  const SfxPoolItem* pItem;
767 
768  if ( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ) )
769  {
770  const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
771  SetZoom( SvxZoomType::PERCENT, nCurrentZoom );
772  }
773  }
774  break;
775  case SID_ZOOM_IN:
776  case SID_ZOOM_OUT:
777  {
778  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
779  SetZoom(SvxZoomType::PERCENT,
780  lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
781  }
782  break;
783  case FN_CHAR_LEFT:
784  case FN_CHAR_RIGHT:
785  case FN_LINE_UP:
786  case FN_LINE_DOWN:
787  {
788  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
789  sal_uInt16 nNewSelectedPage;
790  sal_uInt16 nNewStartPage;
791  Point aNewStartPos;
792  sal_Int16 nHoriMove = 0;
793  sal_Int16 nVertMove = 0;
794  switch(rReq.GetSlot())
795  {
796  case FN_CHAR_LEFT: nHoriMove = -1; break;
797  case FN_CHAR_RIGHT: nHoriMove = 1; break;
798  case FN_LINE_UP: nVertMove = -1; break;
799  case FN_LINE_DOWN: nVertMove = 1; break;
800  }
801  pPagePreviewLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
802  nNewSelectedPage, nNewStartPage, aNewStartPos );
803  if ( m_pViewWin->SelectedPage() != nNewSelectedPage )
804  {
805  if ( pPagePreviewLay->IsPageVisible( nNewSelectedPage ) )
806  {
807  pPagePreviewLay->MarkNewSelectedPage( nNewSelectedPage );
808  // adjust position at vertical scrollbar.
809  SetVScrollbarThumbPos( nNewSelectedPage );
810  bRefresh = false;
811  }
812  else
813  {
814  m_pViewWin->SetSelectedPage( nNewSelectedPage );
815  m_pViewWin->SetSttPage( nNewStartPage );
817  }
818  GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
819  // invalidate page status.
820  static sal_uInt16 aInval[] =
821  {
822  FN_STAT_PAGE, 0
823  };
824  SfxBindings& rBindings = GetViewFrame()->GetBindings();
825  rBindings.Invalidate( aInval );
826  rReq.Done();
827  }
828  else
829  {
830  bRefresh = false;
831  }
832  break;
833  }
834  case FN_PAGEUP:
835  case FN_PAGEDOWN:
836  {
837  ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
838  break;
839  }
841  {
842  const SfxItemSet *pArgs = rReq.GetArgs();
843  if( pArgs && pArgs->Count())
844  {
845  sal_uInt16 nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue();
846 
847  if( nPageNum > 0 && nPageNum <= mnPageCount )
848  {
849  m_pViewWin->SetSttPage( nPageNum);
850  m_pViewWin->SetSelectedPage( nPageNum );
852  ScrollViewSzChg();
853  }
854  }
855  }
856  break;
857  case FN_START_OF_LINE:
860  [[fallthrough]];
861  case FN_END_OF_LINE:
862  case FN_END_OF_DOCUMENT:
864  {
865  bool bRet = ChgPage( eMvMode );
866  // return value for Basic
867  rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
868 
869  bRefresh = bRet;
870  rReq.Done();
871  }
872  break;
873 
875  {
877  // The thing with the orientation
878  if(pPPVPD)
879  {
880  SfxPrinter* pPrinter = GetPrinter( true );
881  if((pPrinter->GetOrientation() == Orientation::Landscape)
882  != pPPVPD->GetLandscape())
883  pPrinter->SetOrientation(pPPVPD->GetLandscape() ? Orientation::Landscape : Orientation::Portrait);
884  }
886  m_bNormalPrint = false;
887  rReq.SetSlot( SID_PRINTDOC );
890  return;
891  }
892  case SID_PRINTDOCDIRECT:
893  case SID_PRINTDOC:
895  m_bNormalPrint = true;
897  return;
899  case SID_PRINTPREVIEW:
900  // print preview is now always in the same frame as the tab view
901  // -> always switch this frame back to normal view
902  // (ScTabViewShell ctor reads stored view data)
903  GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::ASYNCHRON );
904  break;
905  case FN_INSERT_BREAK:
906  {
907  sal_uInt16 nSelPage = m_pViewWin->SelectedPage();
908  //if a dummy page is selected (e.g. a non-existing right/left page)
909  //the direct neighbor is used
910  if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
911  nSelPage +=2;
912  m_nNewPage = nSelPage;
913  SfxViewFrame *pTmpFrame = GetViewFrame();
914  pTmpFrame->GetBindings().Execute( SID_VIEWSHELL0, nullptr,
915  SfxCallMode::ASYNCHRON );
916  }
917  break;
918  default:
919  OSL_ENSURE(false, "wrong dispatcher");
920  return;
921  }
922 
923  if( bRefresh )
925 }
926 
928 {
929  SfxWhichIter aIter(rSet);
930  sal_uInt16 nWhich = aIter.FirstWhich();
931  OSL_ENSURE(nWhich, "empty set");
932  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
933 
934  while(nWhich)
935  {
936  switch(nWhich)
937  {
938  case SID_BROWSER_MODE:
939  case FN_PRINT_LAYOUT:
940  rSet.DisableItem(nWhich);
941  break;
943  {
944  if ( pPagePreviewLay->IsPageVisible( 1 ) )
945  rSet.DisableItem(nWhich);
946  break;
947  }
948  case FN_END_OF_DOCUMENT:
949  {
950  if ( pPagePreviewLay->IsPageVisible( mnPageCount ) )
951  rSet.DisableItem(nWhich);
952  break;
953  }
954  case FN_PAGEUP:
955  {
956  if( pPagePreviewLay->GetWinPagesScrollAmount( -1 ) == 0 )
957  rSet.DisableItem(nWhich);
958  break;
959  }
960  case FN_PAGEDOWN:
961  {
962  if( pPagePreviewLay->GetWinPagesScrollAmount( 1 ) == 0 )
963  rSet.DisableItem(nWhich);
964  break;
965  }
966 
967  case FN_STAT_PAGE:
968  {
970  rSet.Put( SfxStringItem( nWhich, aStr) );
971  }
972  break;
973 
974  case SID_ATTR_ZOOM:
975  case FN_STAT_ZOOM:
976  {
977  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
978  SvxZoomItem aZoom(pVOpt->GetZoomType(), pVOpt->GetZoom());
979  aZoom.SetValueSet(
980  SvxZoomEnableFlags::N50|
981  SvxZoomEnableFlags::N75|
982  SvxZoomEnableFlags::N100|
983  SvxZoomEnableFlags::N150|
984  SvxZoomEnableFlags::N200);
985  rSet.Put( aZoom );
986  }
987  break;
988  case SID_ATTR_ZOOMSLIDER :
989  {
990  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
991  const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
992  SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
993  aZoomSliderItem.AddSnappingPoint( 100 );
994  rSet.Put( aZoomSliderItem );
995  }
996  break;
997  case FN_PREVIEW_ZOOM:
998  {
999  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1000  rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
1001  }
1002  break;
1003  case SID_ZOOM_IN:
1004  case SID_ZOOM_OUT:
1005  {
1006  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1007  if((SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
1008  (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
1009  {
1010  rSet.DisableItem(nWhich);
1011  }
1012  }
1013  break;
1015  // should never be disabled
1016  break;
1017  case FN_SHOW_BOOKVIEW:
1018  {
1020  rSet.Put(SfxBoolItem(nWhich, b));
1021  }
1022  break;
1023 
1024  case FN_SHOW_TWO_PAGES:
1025  if( 2 == m_pViewWin->GetCol() && 1 == m_pViewWin->GetRow() )
1026  rSet.DisableItem( nWhich );
1027  break;
1028 
1029  case FN_PRINT_PAGEPREVIEW:
1030  // has the same status like the normal printing
1031  {
1032  const SfxPoolItem* pItem;
1034  GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
1035  if( SfxItemState::DISABLED == aSet.GetItemState( SID_PRINTDOC,
1036  false, &pItem ))
1037  rSet.DisableItem( nWhich );
1038  else if( SfxItemState::SET == aSet.GetItemState( SID_PRINTDOC,
1039  false, &pItem ))
1040  {
1041  const_cast<SfxPoolItem*>(pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
1042  rSet.Put( *pItem );
1043  }
1044  }
1045  break;
1046 
1047  case SID_PRINTPREVIEW:
1048  rSet.Put( SfxBoolItem( nWhich, true ) );
1049  break;
1050 
1051  case SID_PRINTDOC:
1052  case SID_PRINTDOCDIRECT:
1053  GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
1054  break;
1055  }
1056  nWhich = aIter.NextWhich();
1057  }
1058 }
1059 
1061 {
1062  SfxWhichIter aIter(rSet);
1063  sal_uInt16 nWhich = aIter.FirstWhich();
1064 
1065  while (nWhich)
1066  {
1067  rSet.DisableItem(nWhich);
1068  nWhich = aIter.NextWhich();
1069  }
1070 }
1071 
1073 {
1074  if ( GetViewShell()->HasDrawView() )
1076 
1077  m_bNormalPrint = true;
1078 
1079  // Check and process the DocSize. The shell could not be found via
1080  // the handler, because the shell is unknown to the SFX management
1081  // within the CTOR phase.
1082 
1083  const SwViewOption * pPrefs = SW_MOD()->GetUsrPref(false);
1084 
1087 
1088  // Update the fields
1089  // ATTENTION: Do cast the EditShell up, to use the SS.
1090  // At the methods the current shell will be queried!
1091  SwEditShell* pESh = dynamic_cast<SwEditShell*>(GetViewShell());
1092  bool bIsModified = pESh != nullptr && pESh->IsModified();
1093 
1094  SwViewOption aOpt( *pPrefs );
1095  aOpt.SetPagePreview(true);
1096  aOpt.SetTab( false );
1097  aOpt.SetBlank( false );
1098  aOpt.SetHardBlank( false );
1099  aOpt.SetParagraph( false );
1100  aOpt.SetLineBreak( false );
1101  aOpt.SetPageBreak( false );
1102  aOpt.SetColumnBreak( false );
1103  aOpt.SetSoftHyph( false );
1104  aOpt.SetFieldName( false );
1105  aOpt.SetPostIts( false );
1106  aOpt.SetShowBookmarks( false );
1107  aOpt.SetShowHiddenChar( false );
1108  aOpt.SetShowHiddenField( false );
1109  aOpt.SetShowHiddenPara( false );
1110  aOpt.SetViewHRuler( false );
1111  aOpt.SetViewVRuler( false );
1112  aOpt.SetGraphic( true );
1113  aOpt.SetTable( true );
1114  aOpt.SetSnap( false );
1115  aOpt.SetGridVisible( false );
1116  aOpt.SetOnlineSpell( false );
1117  aOpt.SetHideWhitespaceMode( false );
1118 
1119  GetViewShell()->ApplyViewOptions( aOpt );
1120  GetViewShell()->ApplyAccessibilityOptions(SW_MOD()->GetAccessibilityOptions());
1121 
1122  // adjust view shell option to the same as for print
1123  SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false);
1124  GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
1125 
1126  GetViewShell()->CalcLayout();
1127  DocSzChgd( GetViewShell()->GetDocSize() );
1128 
1129  if( !bIsModified && pESh != nullptr )
1130  pESh->ResetModified();
1131 }
1132 
1134  SfxViewShell( pViewFrame, SWVIEWFLAGS ),
1135  m_pViewWin( VclPtr<SwPagePreviewWin>::Create(&GetViewFrame()->GetWindow(), *this ) ),
1136  m_nNewPage(USHRT_MAX),
1137  m_sPageStr(SwResId(STR_PAGE)),
1138  m_pHScrollbar(nullptr),
1139  m_pVScrollbar(nullptr),
1140  m_pScrollFill(VclPtr<ScrollBarBox>::Create( &pViewFrame->GetWindow(), WB_SIZEABLE )),
1141  mnPageCount( 0 ),
1142  mbResetFormDesignMode( false ),
1143  mbFormDesignModeToReset( false )
1144 {
1145  SetName("PageView");
1146  SetWindow( m_pViewWin );
1147  CreateScrollbar( true );
1148  CreateScrollbar( false );
1149 
1150  //notify notebookbar change in context
1154  //removelisteners for notebookbar
1155  if (SfxViewFrame* pCurrent = SfxViewFrame::Current())
1156  if (auto& pBar = pCurrent->GetWindow().GetSystemWindow()->GetNotebookBar())
1157  pBar->ControlListenerForCurrentController(false);
1158 
1159  SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
1160  if ( !pOldSh )
1161  {
1162  // Exists already a view on the document?
1163  SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
1164  if ( pF == pViewFrame )
1165  pF = SfxViewFrame::GetNext( *pF, pObjShell );
1166  if ( pF )
1167  pOldSh = pF->GetViewShell();
1168  }
1169 
1170  SwViewShell *pVS, *pNew;
1171 
1172  if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview*>(pOldSh))
1173  pVS = pPagePreview->GetViewShell();
1174  else
1175  {
1176  if (SwView* pView = dynamic_cast<SwView *>(pOldSh))
1177  {
1178  pVS = pView->GetWrtShellPtr();
1179  // save the current ViewData of the previous SwView
1180  pOldSh->WriteUserData( m_sSwViewData );
1181  }
1182  else
1183  pVS = GetDocShell()->GetWrtShell();
1184  if( pVS )
1185  {
1186  // Set the current page as the first.
1187  sal_uInt16 nPhysPg, nVirtPg;
1188  static_cast<SwCursorShell*>(pVS)->GetPageNum( nPhysPg, nVirtPg, true, false );
1189  if( 1 != m_pViewWin->GetCol() && 1 == nPhysPg )
1190  --nPhysPg;
1191  m_pViewWin->SetSttPage( nPhysPg );
1192  }
1193  }
1194 
1195  // for form shell remember design mode of draw view
1196  // of previous view shell
1197  if ( pVS && pVS->HasDrawView() )
1198  {
1199  mbResetFormDesignMode = true;
1201  }
1202 
1203  if( pVS )
1204  pNew = new SwViewShell( *pVS, m_pViewWin, nullptr, VSHELLFLAG_ISPREVIEW );
1205  else
1206  pNew = new SwViewShell(
1207  *static_cast<SwDocShell*>(pViewFrame->GetObjectShell())->GetDoc(),
1208  m_pViewWin, nullptr, nullptr, VSHELLFLAG_ISPREVIEW );
1209 
1210  m_pViewWin->SetViewShell( pNew );
1211  pNew->SetSfxViewShell( this );
1212  Init();
1213 }
1214 
1216 {
1217  SetWindow( nullptr );
1218  SwViewShell* pVShell = m_pViewWin->GetViewShell();
1219  pVShell->SetWin(nullptr);
1220  delete pVShell;
1221 
1223  if (SfxViewFrame* pCurrent = SfxViewFrame::Current())
1224  if (auto& pBar = pCurrent->GetWindow().GetSystemWindow()->GetNotebookBar())
1225  pBar->ControlListenerForCurrentController(true); // start listening now
1229 }
1230 
1232 {
1233  return dynamic_cast<SwDocShell*>( GetViewFrame()->GetObjectShell() );
1234 }
1235 
1237 {
1238  vcl::Window *pMDI = &GetViewFrame()->GetWindow();
1239  VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
1240 
1241  assert(!ppScrollbar); //check beforehand!
1242 
1243  ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
1244 
1245  ScrollDocSzChg();
1246  ppScrollbar->EnableDrag();
1247  ppScrollbar->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl ));
1248 
1249  ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl ));
1250 
1251  InvalidateBorder();
1252  ppScrollbar->ExtendedShow();
1253 }
1254 
1255 bool SwPagePreview::ChgPage( int eMvMode, bool bUpdateScrollbar )
1256 {
1258  bool bChg = m_pViewWin->MovePage( eMvMode ) ||
1259  eMvMode == SwPagePreviewWin::MV_CALC ||
1261  m_aVisArea = m_pViewWin->PixelToLogic( aPixVisArea );
1262 
1263  if( bChg )
1264  {
1265  // Update statusbar
1267  SfxBindings& rBindings = GetViewFrame()->GetBindings();
1268 
1269  if( bUpdateScrollbar )
1270  {
1271  ScrollViewSzChg();
1272 
1273  static sal_uInt16 aInval[] =
1274  {
1275  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
1277  };
1278  rBindings.Invalidate( aInval );
1279  }
1280  rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
1281  }
1282  return bChg;
1283 }
1284 
1285 // From here, everything was taken from the SwView.
1287 {
1289  const tools::Long nTmp = rSet.GetScrollBarSize();
1290  if ( m_pVScrollbar->IsVisible( true ) )
1291  rToFill.Right() = nTmp;
1292  if ( m_pHScrollbar->IsVisible( true ) )
1293  rToFill.Bottom() = nTmp;
1294  SetBorderPixel( rToFill );
1295 }
1296 
1297 void SwPagePreview::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
1298 {
1299  SvBorder aBorder;
1300  CalcAndSetBorderPixel( aBorder );
1301  tools::Rectangle aRect( rOfst, rSize );
1302  aRect += aBorder;
1303  ViewResizePixel( *m_pViewWin, aRect.TopLeft(), aRect.GetSize(),
1306 
1307  // Never set EditWin !
1308  // Never set VisArea !
1309 }
1310 
1311 void SwPagePreview::OuterResizePixel( const Point &rOfst, const Size &rSize )
1312 {
1313  SvBorder aBorder;
1314  CalcAndSetBorderPixel( aBorder );
1315 
1316  // Never set EditWin !
1317 
1318  Size aTmpSize( m_pViewWin->GetOutputSizePixel() );
1319  Point aBottomRight( m_pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
1320  SetVisArea( tools::Rectangle( Point(), aBottomRight ) );
1321 
1322  // Call of the DocSzChgd-Method of the scrollbars is necessary,
1323  // because from the maximum scroll range half the height of the
1324  // VisArea is always deducted.
1325  if ( m_pVScrollbar && !aTmpSize.IsEmpty() )
1326  {
1327  ScrollDocSzChg();
1328  }
1329 
1330  SvBorder aBorderNew;
1331  CalcAndSetBorderPixel( aBorderNew );
1334 }
1335 
1337 {
1338  const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
1339  const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
1340  tools::Rectangle aLR(aTopLeft,aBottomRight);
1341 
1342  if(aLR == m_aVisArea)
1343  return;
1344  // No negative position, no negative size
1345 
1346  if(aLR.Top() < 0)
1347  {
1348  aLR.AdjustBottom(std::abs(aLR.Top()) );
1349  aLR.SetTop( 0 );
1350  }
1351 
1352  if(aLR.Left() < 0)
1353  {
1354  aLR.AdjustRight(std::abs(aLR.Left()) );
1355  aLR.SetLeft( 0 );
1356  }
1357  if(aLR.Right() < 0) aLR.SetRight( 0 );
1358  if(aLR.Bottom() < 0) aLR.SetBottom( 0 );
1359  if(aLR == m_aVisArea ||
1360  // Ignore empty rectangle
1361  ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
1362  return;
1363 
1364  if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
1365  return;
1366 
1367  // Before the data can be changed call an update if necessary.
1368  // Thereby ensured, that adjacent paints are correctly converted into
1369  // document coordinates.
1370  // As a precaution, we do this only when at the shell runs an action,
1371  // because then we do not really paint but the rectangles are just
1372  // bookmarked (in document coordinates).
1373  if( GetViewShell()->ActionPend() )
1375 
1376  // Set at View-Win the current size
1377  m_aVisArea = aLR;
1378  m_pViewWin->SetWinSize( aLR.GetSize() );
1380 
1382 }
1383 
1384 IMPL_LINK( SwPagePreview, ScrollHdl, ScrollBar *, p, void )
1385 {
1386  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
1387  if(!GetViewShell())
1388  return;
1389  if( !pScrollbar->IsHoriScroll() &&
1390  pScrollbar->GetType() == ScrollType::Drag &&
1392  GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1393  {
1394  // Scroll how many pages??
1395  OUString sStateStr(m_sPageStr);
1396  tools::Long nThmbPos = pScrollbar->GetThumbPos();
1397  if( 1 == m_pViewWin->GetCol() || !nThmbPos )
1398  ++nThmbPos;
1399  sStateStr += OUString::number( nThmbPos );
1400  Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
1401  pScrollbar->GetPosPixel());
1402  aPos.setY( pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y() );
1403  tools::Rectangle aRect;
1404  aRect.SetLeft( aPos.X() -8 );
1405  aRect.SetRight( aRect.Left() );
1406  aRect.SetTop( aPos.Y() );
1407  aRect.SetBottom( aRect.Top() );
1408 
1409  Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
1410  QuickHelpFlags::Right|QuickHelpFlags::VCenter);
1411 
1412  }
1413  else
1414  EndScrollHdl( pScrollbar );
1415 }
1416 
1417 IMPL_LINK( SwPagePreview, EndScrollHdl, ScrollBar *, p, void )
1418 {
1419  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
1420  if(!GetViewShell())
1421  return;
1422 
1423  // boolean to avoid unnecessary invalidation of the window.
1424  bool bInvalidateWin = true;
1425 
1426  if( !pScrollbar->IsHoriScroll() ) // scroll vertically
1427  {
1428  if ( Help::IsQuickHelpEnabled() )
1429  Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString());
1430  if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
1431  {
1432  // Scroll how many pages ??
1433  const sal_uInt16 nThmbPos = static_cast<sal_uInt16>(pScrollbar->GetThumbPos());
1434  // adjust to new preview functionality
1435  if( nThmbPos != m_pViewWin->SelectedPage() )
1436  {
1437  // consider case that page <nThmbPos>
1438  // is already visible
1439  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1440  if ( pPagePreviewLay->IsPageVisible( nThmbPos ) )
1441  {
1442  pPagePreviewLay->MarkNewSelectedPage( nThmbPos );
1443  // invalidation of window is unnecessary
1444  bInvalidateWin = false;
1445  }
1446  else
1447  {
1448  // consider whether layout columns
1449  // fit or not.
1450  if ( !pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
1451  {
1452  m_pViewWin->SetSttPage( nThmbPos );
1453  m_pViewWin->SetSelectedPage( nThmbPos );
1454  ChgPage( SwPagePreviewWin::MV_SCROLL, false );
1455  // update scrollbars
1456  ScrollViewSzChg();
1457  }
1458  else
1459  {
1460  // correct scroll amount
1461  const sal_Int16 nPageDiff = nThmbPos - m_pViewWin->SelectedPage();
1462  const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
1463  sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
1464  if ( nPageDiff % nVisPages )
1465  {
1466  // decrease/increase number of preview pages to scroll
1467  nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
1468  }
1469  m_pViewWin->SetSelectedPage( nThmbPos );
1470  m_pViewWin->Scroll( 0, pPagePreviewLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
1471  }
1472  }
1473  // update accessibility
1474  GetViewShell()->ShowPreviewSelection( nThmbPos );
1475  }
1476  else
1477  {
1478  // invalidation of window is unnecessary
1479  bInvalidateWin = false;
1480  }
1481  }
1482  else
1483  {
1484  tools::Long nThmbPos = pScrollbar->GetThumbPos();
1485  m_pViewWin->Scroll(0, nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Top());
1486  }
1487  }
1488  else
1489  {
1490  tools::Long nThmbPos = pScrollbar->GetThumbPos();
1491  m_pViewWin->Scroll(nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Left(), 0);
1492  }
1493  // additional invalidate page status.
1494  static sal_uInt16 aInval[] =
1495  {
1496  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
1497  FN_STAT_PAGE, 0
1498  };
1499  SfxBindings& rBindings = GetViewFrame()->GetBindings();
1500  rBindings.Invalidate( aInval );
1501  // control invalidation of window
1502  if ( bInvalidateWin )
1503  {
1504  m_pViewWin->Invalidate();
1505  }
1506 }
1507 
1508 Point SwPagePreview::AlignToPixel(const Point &rPt) const
1509 {
1510  return m_pViewWin->PixelToLogic( m_pViewWin->LogicToPixel( rPt ) );
1511 }
1512 
1513 void SwPagePreview::DocSzChgd( const Size &rSz )
1514 {
1515  if( m_aDocSize == rSz )
1516  return;
1517 
1518  m_aDocSize = rSz;
1519 
1520  // #i96726#
1521  // Due to the multiple page layout it is needed to trigger recalculation
1522  // of the page preview layout, even if the count of pages is not changing.
1524 
1525  if( m_aVisArea.GetWidth() )
1526  {
1528  ScrollDocSzChg();
1529 
1531  }
1532 }
1533 
1535 {
1536  if(!GetViewShell())
1537  return ;
1538 
1539  bool bShowVScrollbar = false, bShowHScrollbar = false;
1540 
1541  if(m_pVScrollbar)
1542  {
1543  if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1544  {
1545  //vertical scrolling by row
1546  // adjust to new preview functionality
1547  const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
1548 
1549  m_pVScrollbar->SetVisibleSize( nVisPages );
1550  // set selected page as scroll bar position,
1551  // if it is visible.
1552  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1553  if ( pPagePreviewLay->IsPageVisible( m_pViewWin->SelectedPage() ) )
1554  {
1556  }
1557  else
1558  {
1560  }
1562  m_pVScrollbar->SetPageSize( nVisPages );
1563  // calculate and set scrollbar range
1564  Range aScrollbarRange( 1, mnPageCount );
1565  // increase range by one, because left-top-corner is left blank.
1566  ++aScrollbarRange.Max();
1567  // increase range in order to access all pages
1568  aScrollbarRange.Max() += ( nVisPages - 1 );
1569  m_pVScrollbar->SetRange( aScrollbarRange );
1570 
1571  bShowVScrollbar = nVisPages < mnPageCount;
1572  }
1573  else //vertical scrolling by pixel
1574  {
1576  const Size& rPreviewSize =
1578  m_pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
1579  tools::Long nVisHeight = rDocRect.GetHeight();
1580  m_pVScrollbar->SetVisibleSize( nVisHeight );
1581  m_pVScrollbar->SetThumbPos( rDocRect.Top() );
1582  m_pVScrollbar->SetLineSize( nVisHeight / 10 );
1583  m_pVScrollbar->SetPageSize( nVisHeight / 2 );
1584 
1585  bShowVScrollbar = true;
1586  }
1587 
1588  if (!mbVScrollbarEnabled)
1589  bShowVScrollbar = false;
1590 
1591  ShowVScrollbar(bShowVScrollbar);
1592  }
1593  if(m_pHScrollbar)
1594  {
1596  const Size& rPreviewSize =
1598  Range aRange(0,0);
1599 
1600  if(rDocRect.GetWidth() < rPreviewSize.Width())
1601  {
1602  bShowHScrollbar = true;
1603 
1604  tools::Long nVisWidth = rDocRect.GetWidth();
1605  tools::Long nThumb = rDocRect.Left();
1606  aRange = Range(0, rPreviewSize.Width());
1607 
1608  m_pHScrollbar->SetRange( aRange );
1609  m_pHScrollbar->SetVisibleSize( nVisWidth );
1610  m_pHScrollbar->SetThumbPos( nThumb );
1611  m_pHScrollbar->SetLineSize( nVisWidth / 10 );
1612  m_pHScrollbar->SetPageSize( nVisWidth / 2 );
1613  }
1614 
1615  if (!mbHScrollbarEnabled)
1616  bShowHScrollbar = false;
1617 
1618  ShowHScrollbar(bShowHScrollbar);
1619  }
1620  m_pScrollFill->Show(bShowVScrollbar && bShowHScrollbar);
1621 }
1622 
1624 {
1625  ScrollViewSzChg();
1626 }
1627 
1628 // All about printing
1630 {
1632 }
1633 
1635 {
1636  SwViewShell &rSh = *GetViewShell();
1637  SfxPrinter* pOld = rSh.getIDocumentDeviceAccess().getPrinter( false );
1638  if ( pOld && pOld->IsPrinting() )
1639  return SFX_PRINTERROR_BUSY;
1640 
1641  SwEditShell &rESh = static_cast<SwEditShell&>(rSh); //Buh...
1642  if( ( SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP ) & nDiffFlags )
1643  {
1644  rSh.getIDocumentDeviceAccess().setPrinter( pNew, true, true );
1645  if( nDiffFlags & SfxPrinterChangeFlags::PRINTER )
1646  rESh.SetModified();
1647  }
1648  if ( ( nDiffFlags & SfxPrinterChangeFlags::OPTIONS ) == SfxPrinterChangeFlags::OPTIONS )
1649  ::SetPrinter( &rSh.getIDocumentDeviceAccess(), pNew, false );
1650 
1651  const bool bChgOri = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_ORIENTATION);
1652  const bool bChgSize = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_SIZE);
1653  if ( bChgOri || bChgSize )
1654  {
1655  rESh.StartAllAction();
1656  if ( bChgOri )
1657  rSh.ChgAllPageOrientation( pNew->GetOrientation() );
1658  if ( bChgSize )
1659  {
1660  Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
1661  rSh.ChgAllPageSize( aSz );
1662  }
1663  if( !m_bNormalPrint )
1665  rESh.SetModified();
1666  rESh.EndAllAction();
1667 
1668  static sal_uInt16 aInval[] =
1669  {
1670  SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
1671  SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
1672  };
1673 #if OSL_DEBUG_LEVEL > 0
1674  {
1675  const sal_uInt16* pPtr = aInval + 1;
1676  do {
1677  OSL_ENSURE( *(pPtr - 1) < *pPtr, "wrong sorting!" );
1678  } while( *++pPtr );
1679  }
1680 #endif
1681 
1682  GetViewFrame()->GetBindings().Invalidate(aInval);
1683  }
1684 
1685  return 0;
1686 }
1687 
1689 {
1690  return true;
1691 }
1692 
1693 std::unique_ptr<SfxTabPage> SwPagePreview::CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
1694  const SfxItemSet &rOptions)
1695 {
1696  return ::CreatePrintOptionsPage(pPage, pController, rOptions, !m_bNormalPrint);
1697 }
1698 
1700 {
1701  mpViewShell = pShell;
1702  if ( mpViewShell && mpViewShell->IsPreview() )
1703  {
1705  }
1706 }
1707 
1709 {
1710  // #i24183#
1712  {
1713  mpPgPreviewLayout->Repaint( tools::Rectangle( rRect.Pos(), rRect.SSize() ) );
1714  }
1715 }
1716 
1721 void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
1722  const SvxZoomType _eZoomType )
1723 {
1724  // #i19975# consider zoom type
1725  if ( _eZoomType == SvxZoomType::WHOLEPAGE )
1726  {
1727  mnRow = 1;
1728  mnCol = 1;
1735  }
1736  else if ( _nZoomFactor != 0 )
1737  {
1738  // calculate new scaling and set mapping mode appropriately.
1739  Fraction aNewScale( _nZoomFactor, 100 );
1740  MapMode aNewMapMode = GetMapMode();
1741  aNewMapMode.SetScaleX( aNewScale );
1742  aNewMapMode.SetScaleY( aNewScale );
1743  SetMapMode( aNewMapMode );
1744 
1745  // calculate new start position for preview paint
1746  Size aNewWinSize = PixelToLogic( maPxWinSize );
1747  Point aNewPaintStartPos =
1748  mpPgPreviewLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
1749 
1750  // remember new scaling and prepare preview paint
1751  // Note: paint of preview will be performed by a corresponding invalidate
1752  // due to property changes.
1753  maScale = aNewScale;
1754  mpPgPreviewLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
1756  }
1757 
1758 }
1759 
1766 {
1767  maPaintedPreviewDocRect.Move(nXMove, nYMove);
1771 
1772 }
1773 
1775 {
1776  bool bOk = false;
1777  const CommandWheelData* pWData = rCEvt.GetWheelData();
1778  if( pWData && CommandWheelMode::ZOOM == pWData->GetMode() )
1779  {
1780  //only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here
1782  {
1783  sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
1784  const sal_uInt16 nOffset = 10;
1785  if( 0L > pWData->GetDelta() )
1786  {
1787  nFactor -= nOffset;
1788  if(nFactor < MIN_PREVIEW_ZOOM)
1789  nFactor = MIN_PREVIEW_ZOOM;
1790  }
1791  else
1792  {
1793  nFactor += nOffset;
1794  if(nFactor > MAX_PREVIEW_ZOOM)
1795  nFactor = MAX_PREVIEW_ZOOM;
1796  }
1797  SetZoom(SvxZoomType::PERCENT, nFactor);
1798  }
1799  bOk = true;
1800  }
1801  else
1803  return bOk;
1804 }
1805 
1806 uno::Reference< css::accessibility::XAccessible >
1808 {
1809  SolarMutexGuard aGuard; // this should have happened already!!!
1810 
1811  OSL_ENSURE( GetViewShell() != nullptr, "We need a view shell" );
1812  css::uno::Reference< css::accessibility::XAccessible > xAcc = GetAccessible( false );
1813  if (xAcc.is())
1814  {
1815  return xAcc;
1816  }
1817  if (mpViewShell)
1818  {
1819  css::uno::Reference< css::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
1820  SetAccessible(xAccPreview);
1821  }
1822  return GetAccessible( false );
1823 }
1824 
1826 {
1827  GetViewShell()->ApplyAccessibilityOptions(rAccessibilityOptions);
1828 }
1829 
1831 {
1832  m_pHScrollbar->Show(bShow);
1833  InvalidateBorder();
1834 }
1835 
1837 {
1838  m_pVScrollbar->Show(bShow);
1839  InvalidateBorder();
1840 }
1841 
1843 {
1844  if (mbHScrollbarEnabled != bEnable)
1845  {
1846  mbHScrollbarEnabled = bEnable;
1847  ScrollViewSzChg();
1848  }
1849 }
1850 
1852 {
1853  if (mbVScrollbarEnabled != bEnable)
1854  {
1855  mbVScrollbarEnabled = bEnable;
1856  ScrollViewSzChg();
1857  }
1858 }
1859 
1860 void SwPagePreview::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
1861 {
1862  SwViewShell& rSh = *GetViewShell();
1863  SwViewOption aOpt(*rSh.GetViewOptions());
1864  // perform action only on changes of zoom or zoom type.
1865  if ( aOpt.GetZoom() != nFactor ||
1866  aOpt.GetZoomType() != eType )
1867  {
1868  aOpt.SetZoom(nFactor);
1869  aOpt.SetZoomType(eType);
1870  rSh.ApplyViewOptions( aOpt );
1871  lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
1872  // #i19975# also consider zoom type
1873  m_pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
1874  ScrollViewSzChg();
1875  }
1876 }
1877 
1879 void SwPagePreview::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
1880 {
1881  if ( m_pVScrollbar )
1882  {
1883  m_pVScrollbar->SetThumbPos( _nNewThumbPos );
1884  }
1885 }
1886 
1887 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
Point TopLeft() const
SfxViewFrame * GetViewFrame() const
const Fraction & GetScaleX() const
#define MAXZOOM
Definition: view.hxx:81
void SetLineBreak(bool b)
Definition: viewopt.hxx:252
void setOutputToWindow(bool bOutputToWindow)
Definition: viewsh.cxx:127
void SetNewCursorPos(const OUString &rStr)
Definition: pview.hxx:257
bool SetBookPreviewMode(const bool _bEnableBookPreview, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect)
enable/disable book preview
bool m_bNormalPrint
Definition: pview.hxx:186
#define FN_CLOSE_PAGEPREVIEW
Definition: cmdid.h:842
void MarkNewSelectedPage(const sal_uInt16 _nSelectedPage)
paint to mark new selected page
#define MINZOOM
Definition: view.hxx:80
Point GetPointerPosPixel()
const Wallpaper & GetBackground() const
SwViewShell * GetViewShell() const
Definition: pview.hxx:235
virtual void ApplyViewOptions(const SwViewOption &rOpt)
Definition: viewsh.cxx:2114
#define FN_SHOW_MULTIPLE_PAGES
Definition: cmdid.h:839
void SetSoftHyph(bool b)
Definition: viewopt.hxx:263
void ShowPreviewSelection(sal_uInt16 nSelPage)
Definition: viewpg.cxx:37
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:375
Point GetPreviewStartPosForNewScale(const Fraction &_aNewScale, const Fraction &_aOldScale, const Size &_aNewWinSize) const
calculate start position for new scale
sal_uInt16 GetVirtPageNumByPageNum(sal_uInt16 _nPageNum) const
get virtual page number by its physical page number
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
OUString m_sPageStr
Definition: pview.hxx:173
void SetZoom(sal_uInt16 n)
Definition: viewopt.hxx:492
void SetState(const SfxItemSet &rSet)
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:175
void ShowHScrollbar(bool bShow)
Definition: pview.cxx:1830
virtual void CalcLayout()
Definition: viewsh.cxx:975
std::unique_ptr< ContentProperties > pData
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
Definition: pview.cxx:1297
std::string GetValue
void UpdateFontList()
Definition: docshini.cxx:410
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: pview.cxx:1807
SwPagePreviewWin(vcl::Window *pParent, SwPagePreview &rView)
Definition: pview.cxx:164
VclPtr< SwPagePreviewWin > m_pViewWin
Definition: pview.hxx:165
OUString m_sSwViewData
Definition: pview.hxx:167
View of a document.
Definition: pview.hxx:161
virtual ~SwPagePreview() override
Definition: pview.cxx:1215
void SetSelectedPage(sal_uInt16 _nSelectedPageNum)
set selected page number in document preview
Definition: pview.cxx:537
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
Definition: legacyitem.cxx:32
SfxDispatcher * GetDispatcher()
bool Prepare(const sal_uInt16 _nProposedStartPageNum, const Point &rProposedStartPos, const Size &_rPxWinSize, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect, const bool _bStartWithPageAtFirstCol=true)
prepare paint of page preview
static SvxAbstractDialogFactory * Create()
void AdjustOptionsForPagePreview(SwPrintData const &rPrintOptions)
adjust view options for page preview
Definition: viewpg.cxx:43
long Long
void disposeAndClear()
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const tools::Rectangle & GetPaintedPreviewDocRect() const
Definition: pview.hxx:139
bool IsDesignMode() const
bool IsModified() const
Changes in document?
Definition: edws.cxx:65
void Scroll(tools::Long nXMove, tools::Long nYMove, ScrollFlags nFlags=ScrollFlags::NONE) override
pixel scrolling - horizontally always or vertically when less than the desired number of rows fits in...
Definition: pview.cxx:1765
bool IsPreviewPosInDocPreviewPage(const Point &rPreviewPos, Point &_orDocPos, bool &_obPosInEmptyPage, sal_uInt16 &_onPageNum) const
checks, if given position is inside a shown document page
void SetPagePreview(sal_uInt8 nRow, sal_uInt8 nCol)
Definition: pview.cxx:515
bool HasDrawView() const
Definition: vnew.cxx:360
sal_uInt16 FirstWhich()
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: pview.cxx:188
const MapMode & GetMapMode() const
static void StateUndo(SfxItemSet &)
Definition: pview.cxx:1060
sal_uInt16 GetCode() const
Fraction maScale
Definition: pview.hxx:53
tools::Long GetWidth() const
void Execute(SfxRequest &)
Definition: pview.cxx:654
SwPagePreview & mrView
Definition: pview.hxx:54
DataChangedEventType GetType() const
void Done(bool bRemove=false)
void Pos(const Point &rNew)
Definition: swrect.hxx:169
void SetHelpId(const OString &)
#define FN_STAT_PAGE
Definition: cmdid.h:829
const CommandWheelData * GetWheelData() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void SetModified()
Definition: edws.cxx:70
sal_uInt16 ConvertRelativeToAbsolutePageNum(sal_uInt16 _nRelPageNum) const
Convert relative to absolute page numbers (see PrintEmptyPages)
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
void SetHardBlank(bool b)
Definition: viewopt.hxx:230
bool mbCalcScaleForPreviewLayout
Definition: pview.hxx:55
void SetRangeMax(tools::Long nNewRange)
void SetAnimationEnabled(bool bEnable=true)
constexpr sal_uInt16 KEY_ADD
virtual SfxObjectShell * GetObjectShell() override
void SetShowHiddenChar(bool b)
Definition: viewopt.hxx:311
void PaintImmediately()
bool HandleScrollCommand(const CommandEvent &rCmd, ScrollBar *pHScrl, ScrollBar *pVScrl)
void EndAllAction()
Definition: edws.cxx:97
RET_CANCEL
void SetMapMode()
virtual const SfxItemSet * GetOutputItemSet() const =0
bool IsHorz() const
#define FN_SHOW_SINGLE_PAGE
Definition: cmdid.h:844
void SetBorderPixel(const SvBorder &rBorder)
void SetColumnBreak(bool b)
Definition: viewopt.hxx:258
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
void SetRight(tools::Long v)
bool IsPageVisible(const sal_uInt16 _nPageNum) const
determines, if page with given page number is visible in preview
sal_uInt16 NextWhich()
void ReInit()
method to adjust page preview layout to document changes
void SetPagePrevRow(sal_uInt8 n)
Definition: viewopt.hxx:446
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:532
void SetAppPrintOptions(SwViewShell *pSh, bool bWeb)
Definition: viewprt.cxx:316
#define MIN_PREVIEW_ZOOM
Definition: pview.cxx:93
bool PreviewLayoutValid() const
sal_uInt16 GetClicks() const
sal_Int64 WinBits
void disposeAndReset(reference_type *pBody)
void AddSnappingPoint(sal_Int32 nNew)
vcl::Window & GetWindow() const
void SetSlot(sal_uInt16 nNewSlot)
ScrollFlags
virtual void WriteUserData(OUString &, bool bBrowse=false)
void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor)
Definition: pview.cxx:1860
void SetSelectedPage(sal_uInt16 _nSelectedPageNum)
set selected page number
void InvalidateBorder()
bool mbFormDesignModeToReset
Definition: pview.hxx:191
SfxPrinterChangeFlags
void SetPageSize(tools::Long nNewSize)
sal_uInt16 GetButtons() const
tools::Long Left() const
#define SFX_PRINTERROR_BUSY
void SetLeft(tools::Long v)
bool IsVisible(bool bReal) const
Definition: scroll.hxx:39
void SetParagraph(bool b)
Definition: viewopt.hxx:236
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt16 m_nNewPage
Definition: pview.hxx:171
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
sal_uInt16 mnSttPage
Definition: pview.hxx:49
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2015
SAL_DLLPRIVATE void CreateScrollbar(bool bHori)
Definition: pview.cxx:1236
bool IsMouseEvent() const
AllSettingsFlags GetFlags() const
tools::Long Bottom() const
bool IsHoriScroll() const
Definition: scroll.hxx:46
std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions, bool bPreview)
Definition: viewprt.cxx:293
sal_uInt8 GetCol() const
Definition: pview.hxx:86
Size maPxWinSize
Definition: pview.hxx:52
void ApplyAccessibilityOptions(SvtAccessibilityOptions const &rAccessibilityOptions)
Definition: viewsh.cxx:2528
#define SID_JUMP_TO_SPECIFIC_PAGE
Definition: cmdid.h:722
bool IsViewVScrollBar() const
Definition: viewopt.hxx:505
sal_uInt16 GetModifier() const
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
tools::Long & Bottom()
virtual void DataChanged(const DataChangedEvent &) override
Definition: pview.cxx:550
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
void EnableHScrollbar(bool bEnable)
Definition: pview.cxx:1842
void DocSzChgd(const Size &rNewSize)
Definition: pview.cxx:1513
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
SwPagePreviewLayout * PagePreviewLayout()
Definition: viewpg.cxx:32
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
void SetThumbPos(tools::Long nThumbPos)
#define FN_START_OF_LINE
Definition: cmdid.h:641
void SetShowHiddenPara(bool b)
Definition: viewopt.hxx:386
SwDocShell * GetDocShell()
Definition: pview.cxx:1231
#define MOUSE_LEFT
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
void SetLineSize(tools::Long nNewSize)
bool IsDeltaPixel() const
#define FN_LINE_UP
Definition: cmdid.h:639
SfxItemPool & GetPool() const
bool DoesPreviewLayoutRowsFitIntoWindow() const
tools::Rectangle m_aVisArea
Definition: pview.hxx:175
::cppu::OWeakObject & m_rParent
#define SAL_N_ELEMENTS(arr)
void SetHideWhitespaceMode(bool bMode)
Definition: viewopt.hxx:470
DocumentType eType
void ApplyAccessibilityOptions(SvtAccessibilityOptions const &rAccessibilityOptions)
Definition: pview.cxx:1825
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
bool mbHScrollbarEnabled
Definition: pview.hxx:180
Point BottomRight() const
const SwPagePreviewPrtData * GetPreviewPrtData() const
Definition: doc.hxx:1456
SAL_DLLPRIVATE Point AlignToPixel(const Point &rPt) const
Definition: pview.cxx:1508
bool Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rOutRect) const
paint prepared preview
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2665
void ScrollViewSzChg()
Definition: pview.cxx:1534
void ChgAllPageOrientation(Orientation eOri)
Definition: vprint.cxx:201
void SetLineColor()
#define FN_PAGEUP
Definition: cmdid.h:669
void RepaintCoreRect(const SwRect &rRect)
Definition: pview.cxx:1708
virtual SAL_DLLPRIVATE std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
Definition: pview.cxx:1693
ScrollType GetType() const
sal_uInt16 SelectedPage() const
get selected page number of document preview
Definition: pview.cxx:531
#define FN_CHAR_LEFT
Definition: cmdid.h:637
void CalcStartValuesForSelectedPageMove(const sal_Int16 _nHoriMove, const sal_Int16 _nVertMove, sal_uInt16 &_orNewSelectedPage, sal_uInt16 &_orNewStartPage, Point &_orNewStartPos) const
calculate data to bring new selected page into view.
void SetScaleX(const Fraction &rScaleX)
page preview functionality in the writer
#define SWVIEWFLAGS
Definition: pview.cxx:91
bool mbResetFormDesignMode
Definition: pview.hxx:190
#define SW_MOD()
Definition: swmodule.hxx:255
VclPtr< vcl::Window > m_pScrollFill
Definition: pview.hxx:183
VclPtr< SwScrollbar > m_pHScrollbar
Definition: pview.hxx:178
void SetPagePrevCol(sal_uInt8 n)
Definition: viewopt.hxx:448
#define MAX_PREVIEW_ZOOM
Definition: pview.cxx:94
void SetWindow(vcl::Window *pViewPort)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SAL_DLLPRIVATE bool ChgPage(int eMvMode, bool bUpdateScrollbar=true)
Definition: pview.cxx:1255
int i
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
void SetTable(bool b)
Definition: viewopt.hxx:331
void SetOnlineSpell(bool b)
Definition: viewopt.cxx:330
#define FN_PRINT_PAGEPREVIEW
Definition: cmdid.h:841
tools::Long GetNotchDelta() const
static bool IsQuickHelpEnabled()
void SetVisibleSize(tools::Long nNewSize)
void SetShowHiddenField(bool b)
Definition: viewopt.hxx:316
bool ActionPend() const
Definition: viewsh.hxx:196
SfxBindings & GetBindings()
CommandWheelMode GetMode() const
void Repaint(const tools::Rectangle &rInvalidCoreRect) const
repaint pages on page preview
void SetTab(bool b)
Definition: viewopt.hxx:219
void SetRange(const Range &rRange)
void SetSttPage(sal_uInt16 n)
Definition: pview.hxx:96
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
bool IsPreview() const
Definition: viewsh.hxx:488
Size GetPreviewDocSize() const
sal_uInt16 Count() const
Size GetOutputSize() const
void SetPagePreview(bool bSet)
Definition: viewopt.hxx:622
sal_uInt16 GetPageCount() const
Definition: pview.hxx:251
void SetVisArea(const tools::Rectangle &)
Definition: pview.cxx:1336
SAL_DLLPRIVATE void ExecPgUpAndPgDown(const bool _bPgUp, SfxRequest *_pReq)
Helper method to execute SfxRequest FN_PAGE_UP and FN_PAGE_DOWN.
Definition: pview.cxx:581
void SetSfxViewShell(SfxViewShell *pNew)
Definition: viewsh.hxx:442
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetFillColor()
tools::Long Width() const
css::uno::Reference< css::accessibility::XAccessible > CreateAccessiblePreview()
Definition: viewsh.cxx:2458
bool HandleWheelCommands(const CommandEvent &)
Definition: pview.cxx:1774
CommandEventId GetCommand() const
void ShowVScrollbar(bool bShow)
Definition: pview.cxx:1836
sal_uInt16 GetModifier() const
virtual void Command(const CommandEvent &rCEvt) override
Definition: pview.cxx:434
sal_uInt8 mnCol
Definition: pview.hxx:51
void SetVScrollbarThumbPos(const sal_uInt16 _nNewThumbPos)
Adjust position of vertical scrollbar.
Definition: pview.cxx:1879
virtual SAL_DLLPRIVATE sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
Definition: pview.cxx:1634
void SetScaleY(const Fraction &rScaleY)
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:224
void SetWinSize(const Size &rNewSize)
Definition: pview.cxx:366
OUString GetStatusStr(sal_uInt16 nPageCount) const
Definition: pview.cxx:393
sal_uInt16 SelectedPage()
get selected page number
void SetTop(tools::Long v)
void SetViewHRuler(bool b)
Definition: viewopt.hxx:589
void SetBottom(tools::Long v)
const AllSettings & GetSettings() const
bool MovePage(int eMoveMode)
Definition: pview.cxx:264
Size GetOutputSizePixel() const
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
void SetGraphic(bool b)
Definition: viewopt.hxx:321
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
tools::Long GetScrollBarSize() const
bool IsPagePrevBookview() const
Definition: viewopt.hxx:460
void SetName(const OUString &rName)
void SSize(const Size &rNew)
Definition: swrect.hxx:178
sal_uInt16 GetModifier() const
tools::Long Top() const
virtual void KeyInput(const KeyEvent &) override
Definition: pview.cxx:410
sal_uInt8 GetRow() const
Definition: pview.hxx:81
bool GetLandscape() const
Definition: pvprtdat.hxx:63
#define COMMAND_WHEEL_PAGESCROLL
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
#define SFX_VIEW_REGISTRATION(DocClass)
vcl::Window * GetParent() const
SfxItemPool * GetPool() const
SwViewShell * mpViewShell
Definition: pview.hxx:48
virtual void setPrinter(SfxPrinter *pP, bool bDeleteOld, bool bCallPrtDataChanged)=0
Set the printer at the document.
SfxViewShell * GetViewShell() const
tools::Long SwTwips
Definition: swtypes.hxx:49
Size GetSize() const
#define Y
bool mbVScrollbarEnabled
Definition: pview.hxx:181
void SetFieldName(bool b)
Definition: viewopt.hxx:267
SwPagePreviewLayout * mpPgPreviewLayout
Definition: pview.hxx:57
#define SFX_OBJECTBAR_OBJECT
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
Definition: pview.cxx:1311
SwViewShell & GetParentViewShell()
static void lcl_InvalidateZoomSlots(SfxBindings &rBindings)
Definition: pview.cxx:122
void SetEndScrollHdl(const Link< ScrollBar *, void > &rLink)
tools::Long GetThumbPos() const
sal_uInt8 GetPagePrevRow() const
Definition: viewopt.hxx:445
SAL_DLLPRIVATE void CalcAndSetBorderPixel(SvBorder &rToFill)
Definition: pview.cxx:1286
const Point & GetMousePosPixel() const
virtual void SetLimits(sal_uInt16 nMin, sal_uInt16 nMax)=0
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
void SetReturnValue(const SfxPoolItem &)
virtual ~SwPagePreviewWin() override
Definition: pview.cxx:184
void Update(sal_uInt16 nId)
WinBits const WB_SIZEABLE
tools::Long & Right()
virtual SAL_DLLPRIVATE SfxPrinter * GetPrinter(bool bCreate=false) override
Definition: pview.cxx:1629
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetNumPages() const
Definition: viewsh.cxx:623
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
void ChgAllPageSize(Size const &rSz)
Definition: vprint.cxx:240
sal_uInt8 mnRow
Definition: pview.hxx:50
Size m_aDocSize
Definition: pview.hxx:174
static SfxViewFrame * Current()
#define FN_END_OF_LINE
Definition: cmdid.h:642
constexpr sal_uInt16 KEY_SUBTRACT
void DisableItem(sal_uInt16 nWhich)
#define FN_START_OF_DOCUMENT
Definition: cmdid.h:643
#define FN_SHOW_BOOKVIEW
Definition: cmdid.h:843
weld::Window * GetFrameWeld() const
void SetViewShell(SwViewShell *pShell)
Definition: pview.cxx:1699
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define FN_CHAR_RIGHT
Definition: cmdid.h:638
SAL_DLLPRIVATE void Init()
Definition: pview.cxx:1072
void SetValueSet(SvxZoomEnableFlags nValues)
unsigned char sal_uInt8
void SetPageBreak(bool b)
Definition: viewopt.hxx:255
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
void CalcWish(sal_uInt8 nNewRow, sal_uInt8 nNewCol)
Definition: pview.cxx:218
constexpr sal_uInt16 KEY_ESCAPE
vcl::Window * GetWin() const
Definition: viewsh.hxx:337
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: pview.cxx:468
#define FN_REFRESH_VIEW
Definition: cmdid.h:149
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
SlideSorterView & mrView
void ResetModified()
Definition: edws.cxx:75
#define FN_PRINT_LAYOUT
Definition: cmdid.h:168
sal_uInt16 GetDefSttPage() const
Definition: pview.hxx:115
IMPL_LINK(SwPagePreview, ScrollHdl, ScrollBar *, p, void)
Definition: pview.cxx:1384
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
#define VSHELLFLAG_ISPREVIEW
Definition: viewsh.hxx:76
static VclPtr< reference_type > Create(Arg &&...arg)
SwTwips GetWinPagesScrollAmount(const sal_Int16 _nWinPagesToScroll) const
determine preview window page scroll amount
static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, bool bZoomIn)
Definition: pview.cxx:96
void SetPostIts(bool b)
Definition: viewopt.hxx:272
sal_uInt16 mnPageCount
Definition: pview.hxx:185
void GetState(SfxItemSet &)
Definition: pview.cxx:927
tools::Long Height() const
sal_uInt16 GetZoom() const
Definition: viewopt.hxx:491
virtual short run()
void * p
#define FN_PAGEDOWN
Definition: cmdid.h:670
const Point & GetPosPixel() const
void ViewResizePixel(const vcl::RenderContext &rRef, const Point &rOfst, const Size &rSize, const Size &rEditSz, SwScrollbar &rVScrollbar, SwScrollbar &rHScrollbar, vcl::Window &rScrollBarBox, SvxRuler *pVRuler=nullptr, SvxRuler *pHRuler=nullptr, bool bVRulerRight=false)
Definition: viewport.cxx:837
SwPagePreview(SfxViewFrame *pFrame, SfxViewShell *)
Definition: pview.cxx:1133
vcl::Window * GetWindow() const
void EnableDrag()
SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview,"PrintPreview")
Definition: pview.cxx:73
void SetWin(vcl::Window *win)
Definition: viewsh.hxx:340
void SetSnap(bool b)
Definition: viewopt.hxx:346
void AdjustPreviewToNewZoom(const sal_uInt16 _nZoomFactor, const SvxZoomType _eZoomType)
Method to adjust preview to a new zoom factor paint of preview is prepared for a new zoom factor Zoom...
Definition: pview.cxx:1721
virtual SfxInterface * GetInterface() const
tools::Long GetHeight() const
tools::Long GetDelta() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
virtual bool KeyInput(const KeyEvent &rKeyEvent)
const MiscSettings & GetMiscSettings() const
void SetOutDevViewType(OutDevViewType eOutDevViewType)
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetViewVRuler(bool b)
Definition: viewopt.hxx:603
bool GetEnableATToolSupport() const
void SetModified()
Definition: usrpref.hxx:157
Point OutputToScreenPixel(const Point &rPos) const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual SAL_DLLPRIVATE bool HasPrintOptionsPage() const override
Definition: pview.cxx:1688
SvxZoomType
void SetGridVisible(bool b)
Definition: viewopt.hxx:354
void ExtendedShow(bool bVisible=true)
Definition: scroll.cxx:74
sal_uInt16 GetSttPage() const
Definition: pview.hxx:91
#define FN_SHOW_TWO_PAGES
Definition: cmdid.h:837
#define FN_LINE_DOWN
Definition: cmdid.h:640
tools::Long Max() const
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void BroadcastContextForActivation(const bool bIsActivated)
#define FN_STAT_ZOOM
Definition: cmdid.h:831
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2072
void Init(const sal_uInt16 _nCols, const sal_uInt16 _nRows, const Size &_rPxWinSize)
init page preview layout
bool IsViewHScrollBar() const
Definition: viewopt.hxx:513
bool DoesPreviewLayoutColsFitIntoWindow() const
void SetShowBookmarks(bool const b)
Definition: viewopt.hxx:239
bool SetBookPreviewMode(const bool _bBookPreview)
Method to enable/disable book preview.
Definition: pview.cxx:543
WinBits const WB_CLIPCHILDREN
sal_uInt8 GetPagePrevCol() const
Definition: viewopt.hxx:447
void SetContextName(const OUString &rsContextName)
aStr
void ScrollDocSzChg()
Definition: pview.cxx:1623
sal_uInt16 ConvertAbsoluteToRelativePageNum(sal_uInt16 _nAbsPageNum) const
Convert absolute to relative page numbers (see PrintEmptyPages)
tools::Long Right() const
AnyEventRef aEvent
#define HID_PAGEPREVIEW
Definition: helpids.h:31
tools::Rectangle maPaintedPreviewDocRect
Definition: pview.hxx:56
Definition: view.hxx:144
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
SwViewShell * GetViewShell() const
Definition: pview.hxx:76
VclPtr< SwScrollbar > m_pVScrollbar
Definition: pview.hxx:179
void EnableVScrollbar(bool bEnable)
Definition: pview.cxx:1851
void SetBlank(bool b)
Definition: viewopt.hxx:225
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)