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  sal_uInt16 nPageNum = 1;
843  const SfxItemSet *pArgs = rReq.GetArgs();
844  if( pArgs && pArgs->Count())
845  {
846  nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue();
847 
848  if( nPageNum > 0 && nPageNum <= mnPageCount )
849  {
850  m_pViewWin->SetSttPage( nPageNum);
851  m_pViewWin->SetSelectedPage( nPageNum );
853  ScrollViewSzChg();
854  }
855  }
856  }
857  break;
858  case FN_START_OF_LINE:
861  [[fallthrough]];
862  case FN_END_OF_LINE:
863  case FN_END_OF_DOCUMENT:
865  {
866  bool bRet = ChgPage( eMvMode );
867  // return value for Basic
868  rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
869 
870  bRefresh = bRet;
871  rReq.Done();
872  }
873  break;
874 
876  {
878  // The thing with the orientation
879  if(pPPVPD)
880  {
881  SfxPrinter* pPrinter = GetPrinter( true );
882  if((pPrinter->GetOrientation() == Orientation::Landscape)
883  != pPPVPD->GetLandscape())
884  pPrinter->SetOrientation(pPPVPD->GetLandscape() ? Orientation::Landscape : Orientation::Portrait);
885  }
887  m_bNormalPrint = false;
888  rReq.SetSlot( SID_PRINTDOC );
891  return;
892  }
893  case SID_PRINTDOCDIRECT:
894  case SID_PRINTDOC:
896  m_bNormalPrint = true;
898  return;
900  case SID_PRINTPREVIEW:
901  // print preview is now always in the same frame as the tab view
902  // -> always switch this frame back to normal view
903  // (ScTabViewShell ctor reads stored view data)
904  GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::ASYNCHRON );
905  break;
906  case FN_INSERT_BREAK:
907  {
908  sal_uInt16 nSelPage = m_pViewWin->SelectedPage();
909  //if a dummy page is selected (e.g. a non-existing right/left page)
910  //the direct neighbor is used
911  if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
912  nSelPage +=2;
913  m_nNewPage = nSelPage;
914  SfxViewFrame *pTmpFrame = GetViewFrame();
915  pTmpFrame->GetBindings().Execute( SID_VIEWSHELL0, nullptr,
916  SfxCallMode::ASYNCHRON );
917  }
918  break;
919  default:
920  OSL_ENSURE(false, "wrong dispatcher");
921  return;
922  }
923 
924  if( bRefresh )
926 }
927 
929 {
930  SfxWhichIter aIter(rSet);
931  sal_uInt16 nWhich = aIter.FirstWhich();
932  OSL_ENSURE(nWhich, "empty set");
933  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
934 
935  while(nWhich)
936  {
937  switch(nWhich)
938  {
939  case SID_BROWSER_MODE:
940  case FN_PRINT_LAYOUT:
941  rSet.DisableItem(nWhich);
942  break;
944  {
945  if ( pPagePreviewLay->IsPageVisible( 1 ) )
946  rSet.DisableItem(nWhich);
947  break;
948  }
949  case FN_END_OF_DOCUMENT:
950  {
951  if ( pPagePreviewLay->IsPageVisible( mnPageCount ) )
952  rSet.DisableItem(nWhich);
953  break;
954  }
955  case FN_PAGEUP:
956  {
957  if( pPagePreviewLay->GetWinPagesScrollAmount( -1 ) == 0 )
958  rSet.DisableItem(nWhich);
959  break;
960  }
961  case FN_PAGEDOWN:
962  {
963  if( pPagePreviewLay->GetWinPagesScrollAmount( 1 ) == 0 )
964  rSet.DisableItem(nWhich);
965  break;
966  }
967 
968  case FN_STAT_PAGE:
969  {
971  rSet.Put( SfxStringItem( nWhich, aStr) );
972  }
973  break;
974 
975  case SID_ATTR_ZOOM:
976  case FN_STAT_ZOOM:
977  {
978  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
979  SvxZoomItem aZoom(pVOpt->GetZoomType(), pVOpt->GetZoom());
980  aZoom.SetValueSet(
981  SvxZoomEnableFlags::N50|
982  SvxZoomEnableFlags::N75|
983  SvxZoomEnableFlags::N100|
984  SvxZoomEnableFlags::N150|
985  SvxZoomEnableFlags::N200);
986  rSet.Put( aZoom );
987  }
988  break;
989  case SID_ATTR_ZOOMSLIDER :
990  {
991  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
992  const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
993  SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
994  aZoomSliderItem.AddSnappingPoint( 100 );
995  rSet.Put( aZoomSliderItem );
996  }
997  break;
998  case FN_PREVIEW_ZOOM:
999  {
1000  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1001  rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
1002  }
1003  break;
1004  case SID_ZOOM_IN:
1005  case SID_ZOOM_OUT:
1006  {
1007  const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1008  if((SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
1009  (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
1010  {
1011  rSet.DisableItem(nWhich);
1012  }
1013  }
1014  break;
1016  // should never be disabled
1017  break;
1018  case FN_SHOW_BOOKVIEW:
1019  {
1021  rSet.Put(SfxBoolItem(nWhich, b));
1022  }
1023  break;
1024 
1025  case FN_SHOW_TWO_PAGES:
1026  if( 2 == m_pViewWin->GetCol() && 1 == m_pViewWin->GetRow() )
1027  rSet.DisableItem( nWhich );
1028  break;
1029 
1030  case FN_PRINT_PAGEPREVIEW:
1031  // has the same status like the normal printing
1032  {
1033  const SfxPoolItem* pItem;
1035  GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
1036  if( SfxItemState::DISABLED == aSet.GetItemState( SID_PRINTDOC,
1037  false, &pItem ))
1038  rSet.DisableItem( nWhich );
1039  else if( SfxItemState::SET == aSet.GetItemState( SID_PRINTDOC,
1040  false, &pItem ))
1041  {
1042  const_cast<SfxPoolItem*>(pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
1043  rSet.Put( *pItem );
1044  }
1045  }
1046  break;
1047 
1048  case SID_PRINTPREVIEW:
1049  rSet.Put( SfxBoolItem( nWhich, true ) );
1050  break;
1051 
1052  case SID_PRINTDOC:
1053  case SID_PRINTDOCDIRECT:
1054  GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
1055  break;
1056  }
1057  nWhich = aIter.NextWhich();
1058  }
1059 }
1060 
1062 {
1063  SfxWhichIter aIter(rSet);
1064  sal_uInt16 nWhich = aIter.FirstWhich();
1065 
1066  while (nWhich)
1067  {
1068  rSet.DisableItem(nWhich);
1069  nWhich = aIter.NextWhich();
1070  }
1071 }
1072 
1074 {
1075  if ( GetViewShell()->HasDrawView() )
1077 
1078  m_bNormalPrint = true;
1079 
1080  // Check and process the DocSize. The shell could not be found via
1081  // the handler, because the shell is unknown to the SFX management
1082  // within the CTOR phase.
1083 
1084  const SwViewOption * pPrefs = SW_MOD()->GetUsrPref(false);
1085 
1088 
1089  // Update the fields
1090  // ATTENTION: Do cast the EditShell up, to use the SS.
1091  // At the methods the current shell will be queried!
1092  SwEditShell* pESh = dynamic_cast<SwEditShell*>(GetViewShell());
1093  bool bIsModified = pESh != nullptr && pESh->IsModified();
1094 
1095  SwViewOption aOpt( *pPrefs );
1096  aOpt.SetPagePreview(true);
1097  aOpt.SetTab( false );
1098  aOpt.SetBlank( false );
1099  aOpt.SetHardBlank( false );
1100  aOpt.SetParagraph( false );
1101  aOpt.SetLineBreak( false );
1102  aOpt.SetPageBreak( false );
1103  aOpt.SetColumnBreak( false );
1104  aOpt.SetSoftHyph( false );
1105  aOpt.SetFieldName( false );
1106  aOpt.SetPostIts( false );
1107  aOpt.SetShowBookmarks( false );
1108  aOpt.SetShowHiddenChar( false );
1109  aOpt.SetShowHiddenField( false );
1110  aOpt.SetShowHiddenPara( false );
1111  aOpt.SetViewHRuler( false );
1112  aOpt.SetViewVRuler( false );
1113  aOpt.SetGraphic( true );
1114  aOpt.SetTable( true );
1115  aOpt.SetSnap( false );
1116  aOpt.SetGridVisible( false );
1117  aOpt.SetOnlineSpell( false );
1118  aOpt.SetHideWhitespaceMode( false );
1119 
1120  GetViewShell()->ApplyViewOptions( aOpt );
1121  GetViewShell()->ApplyAccessibilityOptions(SW_MOD()->GetAccessibilityOptions());
1122 
1123  // adjust view shell option to the same as for print
1124  SwPrintData const aPrintOptions = *SW_MOD()->GetPrtOptions(false);
1125  GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
1126 
1127  GetViewShell()->CalcLayout();
1128  DocSzChgd( GetViewShell()->GetDocSize() );
1129 
1130  if( !bIsModified && pESh != nullptr )
1131  pESh->ResetModified();
1132 }
1133 
1135  SfxViewShell( pViewFrame, SWVIEWFLAGS ),
1136  m_pViewWin( VclPtr<SwPagePreviewWin>::Create(&GetViewFrame()->GetWindow(), *this ) ),
1137  m_nNewPage(USHRT_MAX),
1138  m_sPageStr(SwResId(STR_PAGE)),
1139  m_pHScrollbar(nullptr),
1140  m_pVScrollbar(nullptr),
1141  m_pScrollFill(VclPtr<ScrollBarBox>::Create( &pViewFrame->GetWindow(), WB_SIZEABLE )),
1142  mnPageCount( 0 ),
1143  mbResetFormDesignMode( false ),
1144  mbFormDesignModeToReset( false )
1145 {
1146  SetName("PageView");
1147  SetWindow( m_pViewWin );
1148  CreateScrollbar( true );
1149  CreateScrollbar( false );
1150 
1151  //notify notebookbar change in context
1155  //removelisteners for notebookbar
1156  if (SfxViewFrame* pCurrent = SfxViewFrame::Current())
1157  if (auto& pBar = pCurrent->GetWindow().GetSystemWindow()->GetNotebookBar())
1158  pBar->ControlListenerForCurrentController(false);
1159 
1160  SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
1161  if ( !pOldSh )
1162  {
1163  // Exists already a view on the document?
1164  SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
1165  if ( pF == pViewFrame )
1166  pF = SfxViewFrame::GetNext( *pF, pObjShell );
1167  if ( pF )
1168  pOldSh = pF->GetViewShell();
1169  }
1170 
1171  SwViewShell *pVS, *pNew;
1172 
1173  if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview*>(pOldSh))
1174  pVS = pPagePreview->GetViewShell();
1175  else
1176  {
1177  if (SwView* pView = dynamic_cast<SwView *>(pOldSh))
1178  {
1179  pVS = pView->GetWrtShellPtr();
1180  // save the current ViewData of the previous SwView
1181  pOldSh->WriteUserData( m_sSwViewData );
1182  }
1183  else
1184  pVS = GetDocShell()->GetWrtShell();
1185  if( pVS )
1186  {
1187  // Set the current page as the first.
1188  sal_uInt16 nPhysPg, nVirtPg;
1189  static_cast<SwCursorShell*>(pVS)->GetPageNum( nPhysPg, nVirtPg, true, false );
1190  if( 1 != m_pViewWin->GetCol() && 1 == nPhysPg )
1191  --nPhysPg;
1192  m_pViewWin->SetSttPage( nPhysPg );
1193  }
1194  }
1195 
1196  // for form shell remember design mode of draw view
1197  // of previous view shell
1198  if ( pVS && pVS->HasDrawView() )
1199  {
1200  mbResetFormDesignMode = true;
1202  }
1203 
1204  if( pVS )
1205  pNew = new SwViewShell( *pVS, m_pViewWin, nullptr, VSHELLFLAG_ISPREVIEW );
1206  else
1207  pNew = new SwViewShell(
1208  *static_cast<SwDocShell*>(pViewFrame->GetObjectShell())->GetDoc(),
1209  m_pViewWin, nullptr, nullptr, VSHELLFLAG_ISPREVIEW );
1210 
1211  m_pViewWin->SetViewShell( pNew );
1212  pNew->SetSfxViewShell( this );
1213  Init();
1214 }
1215 
1217 {
1218  SetWindow( nullptr );
1219  SwViewShell* pVShell = m_pViewWin->GetViewShell();
1220  pVShell->SetWin(nullptr);
1221  delete pVShell;
1222 
1224  if (SfxViewFrame* pCurrent = SfxViewFrame::Current())
1225  if (auto& pBar = pCurrent->GetWindow().GetSystemWindow()->GetNotebookBar())
1226  pBar->ControlListenerForCurrentController(true); // start listening now
1230 }
1231 
1233 {
1234  return dynamic_cast<SwDocShell*>( GetViewFrame()->GetObjectShell() );
1235 }
1236 
1238 {
1239  vcl::Window *pMDI = &GetViewFrame()->GetWindow();
1240  VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
1241 
1242  assert(!ppScrollbar); //check beforehand!
1243 
1244  ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
1245 
1246  ScrollDocSzChg();
1247  ppScrollbar->EnableDrag();
1248  ppScrollbar->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl ));
1249 
1250  ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl ));
1251 
1252  InvalidateBorder();
1253  ppScrollbar->ExtendedShow();
1254 }
1255 
1256 bool SwPagePreview::ChgPage( int eMvMode, bool bUpdateScrollbar )
1257 {
1259  bool bChg = m_pViewWin->MovePage( eMvMode ) ||
1260  eMvMode == SwPagePreviewWin::MV_CALC ||
1262  m_aVisArea = m_pViewWin->PixelToLogic( aPixVisArea );
1263 
1264  if( bChg )
1265  {
1266  // Update statusbar
1268  SfxBindings& rBindings = GetViewFrame()->GetBindings();
1269 
1270  if( bUpdateScrollbar )
1271  {
1272  ScrollViewSzChg();
1273 
1274  static sal_uInt16 aInval[] =
1275  {
1276  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
1278  };
1279  rBindings.Invalidate( aInval );
1280  }
1281  rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
1282  }
1283  return bChg;
1284 }
1285 
1286 // From here, everything was taken from the SwView.
1288 {
1290  const long nTmp = rSet.GetScrollBarSize();
1291  if ( m_pVScrollbar->IsVisible( true ) )
1292  rToFill.Right() = nTmp;
1293  if ( m_pHScrollbar->IsVisible( true ) )
1294  rToFill.Bottom() = nTmp;
1295  SetBorderPixel( rToFill );
1296 }
1297 
1298 void SwPagePreview::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
1299 {
1300  SvBorder aBorder;
1301  CalcAndSetBorderPixel( aBorder );
1302  tools::Rectangle aRect( rOfst, rSize );
1303  aRect += aBorder;
1304  ViewResizePixel( *m_pViewWin, aRect.TopLeft(), aRect.GetSize(),
1307 
1308  // Never set EditWin !
1309  // Never set VisArea !
1310 }
1311 
1312 void SwPagePreview::OuterResizePixel( const Point &rOfst, const Size &rSize )
1313 {
1314  SvBorder aBorder;
1315  CalcAndSetBorderPixel( aBorder );
1316 
1317  // Never set EditWin !
1318 
1319  Size aTmpSize( m_pViewWin->GetOutputSizePixel() );
1320  Point aBottomRight( m_pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
1321  SetVisArea( tools::Rectangle( Point(), aBottomRight ) );
1322 
1323  // Call of the DocSzChgd-Method of the scrollbars is necessary,
1324  // because from the maximum scroll range half the height of the
1325  // VisArea is always deducted.
1326  if ( m_pVScrollbar && !aTmpSize.IsEmpty() )
1327  {
1328  ScrollDocSzChg();
1329  }
1330 
1331  SvBorder aBorderNew;
1332  CalcAndSetBorderPixel( aBorderNew );
1335 }
1336 
1338 {
1339  const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
1340  const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
1341  tools::Rectangle aLR(aTopLeft,aBottomRight);
1342 
1343  if(aLR == m_aVisArea)
1344  return;
1345  // No negative position, no negative size
1346 
1347  if(aLR.Top() < 0)
1348  {
1349  aLR.AdjustBottom(std::abs(aLR.Top()) );
1350  aLR.SetTop( 0 );
1351  }
1352 
1353  if(aLR.Left() < 0)
1354  {
1355  aLR.AdjustRight(std::abs(aLR.Left()) );
1356  aLR.SetLeft( 0 );
1357  }
1358  if(aLR.Right() < 0) aLR.SetRight( 0 );
1359  if(aLR.Bottom() < 0) aLR.SetBottom( 0 );
1360  if(aLR == m_aVisArea ||
1361  // Ignore empty rectangle
1362  ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
1363  return;
1364 
1365  if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
1366  return;
1367 
1368  // Before the data can be changed call an update if necessary.
1369  // Thereby ensured, that adjacent paints are correctly converted into
1370  // document coordinates.
1371  // As a precaution, we do this only when at the shell runs an action,
1372  // because then we do not really paint but the rectangles are just
1373  // bookmarked (in document coordinates).
1374  if( GetViewShell()->ActionPend() )
1376 
1377  // Set at View-Win the current size
1378  m_aVisArea = aLR;
1379  m_pViewWin->SetWinSize( aLR.GetSize() );
1381 
1383 }
1384 
1385 IMPL_LINK( SwPagePreview, ScrollHdl, ScrollBar *, p, void )
1386 {
1387  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
1388  if(!GetViewShell())
1389  return;
1390  if( !pScrollbar->IsHoriScroll() &&
1391  pScrollbar->GetType() == ScrollType::Drag &&
1393  GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1394  {
1395  // Scroll how many pages??
1396  OUString sStateStr(m_sPageStr);
1397  long nThmbPos = pScrollbar->GetThumbPos();
1398  if( 1 == m_pViewWin->GetCol() || !nThmbPos )
1399  ++nThmbPos;
1400  sStateStr += OUString::number( nThmbPos );
1401  Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
1402  pScrollbar->GetPosPixel());
1403  aPos.setY( pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y() );
1404  tools::Rectangle aRect;
1405  aRect.SetLeft( aPos.X() -8 );
1406  aRect.SetRight( aRect.Left() );
1407  aRect.SetTop( aPos.Y() );
1408  aRect.SetBottom( aRect.Top() );
1409 
1410  Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
1411  QuickHelpFlags::Right|QuickHelpFlags::VCenter);
1412 
1413  }
1414  else
1415  EndScrollHdl( pScrollbar );
1416 }
1417 
1418 IMPL_LINK( SwPagePreview, EndScrollHdl, ScrollBar *, p, void )
1419 {
1420  SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
1421  if(!GetViewShell())
1422  return;
1423 
1424  // boolean to avoid unnecessary invalidation of the window.
1425  bool bInvalidateWin = true;
1426 
1427  if( !pScrollbar->IsHoriScroll() ) // scroll vertically
1428  {
1429  if ( Help::IsQuickHelpEnabled() )
1430  Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString());
1431  if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
1432  {
1433  // Scroll how many pages ??
1434  const sal_uInt16 nThmbPos = static_cast<sal_uInt16>(pScrollbar->GetThumbPos());
1435  // adjust to new preview functionality
1436  if( nThmbPos != m_pViewWin->SelectedPage() )
1437  {
1438  // consider case that page <nThmbPos>
1439  // is already visible
1440  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1441  if ( pPagePreviewLay->IsPageVisible( nThmbPos ) )
1442  {
1443  pPagePreviewLay->MarkNewSelectedPage( nThmbPos );
1444  // invalidation of window is unnecessary
1445  bInvalidateWin = false;
1446  }
1447  else
1448  {
1449  // consider whether layout columns
1450  // fit or not.
1451  if ( !pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
1452  {
1453  m_pViewWin->SetSttPage( nThmbPos );
1454  m_pViewWin->SetSelectedPage( nThmbPos );
1455  ChgPage( SwPagePreviewWin::MV_SCROLL, false );
1456  // update scrollbars
1457  ScrollViewSzChg();
1458  }
1459  else
1460  {
1461  // correct scroll amount
1462  const sal_Int16 nPageDiff = nThmbPos - m_pViewWin->SelectedPage();
1463  const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
1464  sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
1465  if ( nPageDiff % nVisPages )
1466  {
1467  // decrease/increase number of preview pages to scroll
1468  nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
1469  }
1470  m_pViewWin->SetSelectedPage( nThmbPos );
1471  m_pViewWin->Scroll( 0, pPagePreviewLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
1472  }
1473  }
1474  // update accessibility
1475  GetViewShell()->ShowPreviewSelection( nThmbPos );
1476  }
1477  else
1478  {
1479  // invalidation of window is unnecessary
1480  bInvalidateWin = false;
1481  }
1482  }
1483  else
1484  {
1485  long nThmbPos = pScrollbar->GetThumbPos();
1486  m_pViewWin->Scroll(0, nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Top());
1487  }
1488  }
1489  else
1490  {
1491  long nThmbPos = pScrollbar->GetThumbPos();
1492  m_pViewWin->Scroll(nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Left(), 0);
1493  }
1494  // additional invalidate page status.
1495  static sal_uInt16 aInval[] =
1496  {
1497  FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
1498  FN_STAT_PAGE, 0
1499  };
1500  SfxBindings& rBindings = GetViewFrame()->GetBindings();
1501  rBindings.Invalidate( aInval );
1502  // control invalidation of window
1503  if ( bInvalidateWin )
1504  {
1505  m_pViewWin->Invalidate();
1506  }
1507 }
1508 
1509 Point SwPagePreview::AlignToPixel(const Point &rPt) const
1510 {
1511  return m_pViewWin->PixelToLogic( m_pViewWin->LogicToPixel( rPt ) );
1512 }
1513 
1514 void SwPagePreview::DocSzChgd( const Size &rSz )
1515 {
1516  if( m_aDocSize == rSz )
1517  return;
1518 
1519  m_aDocSize = rSz;
1520 
1521  // #i96726#
1522  // Due to the multiple page layout it is needed to trigger recalculation
1523  // of the page preview layout, even if the count of pages is not changing.
1525 
1526  if( m_aVisArea.GetWidth() )
1527  {
1529  ScrollDocSzChg();
1530 
1532  }
1533 }
1534 
1536 {
1537  if(!GetViewShell())
1538  return ;
1539 
1540  bool bShowVScrollbar = false, bShowHScrollbar = false;
1541 
1542  if(m_pVScrollbar)
1543  {
1544  if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1545  {
1546  //vertical scrolling by row
1547  // adjust to new preview functionality
1548  const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
1549 
1550  m_pVScrollbar->SetVisibleSize( nVisPages );
1551  // set selected page as scroll bar position,
1552  // if it is visible.
1553  SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1554  if ( pPagePreviewLay->IsPageVisible( m_pViewWin->SelectedPage() ) )
1555  {
1557  }
1558  else
1559  {
1561  }
1563  m_pVScrollbar->SetPageSize( nVisPages );
1564  // calculate and set scrollbar range
1565  Range aScrollbarRange( 1, mnPageCount );
1566  // increase range by one, because left-top-corner is left blank.
1567  ++aScrollbarRange.Max();
1568  // increase range in order to access all pages
1569  aScrollbarRange.Max() += ( nVisPages - 1 );
1570  m_pVScrollbar->SetRange( aScrollbarRange );
1571 
1572  bShowVScrollbar = nVisPages < mnPageCount;
1573  }
1574  else //vertical scrolling by pixel
1575  {
1577  const Size& rPreviewSize =
1579  m_pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
1580  long nVisHeight = rDocRect.GetHeight();
1581  m_pVScrollbar->SetVisibleSize( nVisHeight );
1582  m_pVScrollbar->SetThumbPos( rDocRect.Top() );
1583  m_pVScrollbar->SetLineSize( nVisHeight / 10 );
1584  m_pVScrollbar->SetPageSize( nVisHeight / 2 );
1585 
1586  bShowVScrollbar = true;
1587  }
1588 
1589  if (!mbVScrollbarEnabled)
1590  bShowVScrollbar = false;
1591 
1592  ShowVScrollbar(bShowVScrollbar);
1593  }
1594  if(m_pHScrollbar)
1595  {
1597  const Size& rPreviewSize =
1599  Range aRange(0,0);
1600 
1601  if(rDocRect.GetWidth() < rPreviewSize.Width())
1602  {
1603  bShowHScrollbar = true;
1604 
1605  long nVisWidth = rDocRect.GetWidth();
1606  long nThumb = rDocRect.Left();
1607  aRange = Range(0, rPreviewSize.Width());
1608 
1609  m_pHScrollbar->SetRange( aRange );
1610  m_pHScrollbar->SetVisibleSize( nVisWidth );
1611  m_pHScrollbar->SetThumbPos( nThumb );
1612  m_pHScrollbar->SetLineSize( nVisWidth / 10 );
1613  m_pHScrollbar->SetPageSize( nVisWidth / 2 );
1614  }
1615 
1616  if (!mbHScrollbarEnabled)
1617  bShowHScrollbar = false;
1618 
1619  ShowHScrollbar(bShowHScrollbar);
1620  }
1621  m_pScrollFill->Show(bShowVScrollbar && bShowHScrollbar);
1622 }
1623 
1625 {
1626  ScrollViewSzChg();
1627 }
1628 
1629 // All about printing
1631 {
1633 }
1634 
1636 {
1637  SwViewShell &rSh = *GetViewShell();
1638  SfxPrinter* pOld = rSh.getIDocumentDeviceAccess().getPrinter( false );
1639  if ( pOld && pOld->IsPrinting() )
1640  return SFX_PRINTERROR_BUSY;
1641 
1642  SwEditShell &rESh = static_cast<SwEditShell&>(rSh); //Buh...
1643  if( ( SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP ) & nDiffFlags )
1644  {
1645  rSh.getIDocumentDeviceAccess().setPrinter( pNew, true, true );
1646  if( nDiffFlags & SfxPrinterChangeFlags::PRINTER )
1647  rESh.SetModified();
1648  }
1649  if ( ( nDiffFlags & SfxPrinterChangeFlags::OPTIONS ) == SfxPrinterChangeFlags::OPTIONS )
1650  ::SetPrinter( &rSh.getIDocumentDeviceAccess(), pNew, false );
1651 
1652  const bool bChgOri = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_ORIENTATION);
1653  const bool bChgSize = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_SIZE);
1654  if ( bChgOri || bChgSize )
1655  {
1656  rESh.StartAllAction();
1657  if ( bChgOri )
1658  rSh.ChgAllPageOrientation( pNew->GetOrientation() );
1659  if ( bChgSize )
1660  {
1661  Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
1662  rSh.ChgAllPageSize( aSz );
1663  }
1664  if( !m_bNormalPrint )
1666  rESh.SetModified();
1667  rESh.EndAllAction();
1668 
1669  static sal_uInt16 aInval[] =
1670  {
1671  SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
1672  SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
1673  };
1674 #if OSL_DEBUG_LEVEL > 0
1675  {
1676  const sal_uInt16* pPtr = aInval + 1;
1677  do {
1678  OSL_ENSURE( *(pPtr - 1) < *pPtr, "wrong sorting!" );
1679  } while( *++pPtr );
1680  }
1681 #endif
1682 
1683  GetViewFrame()->GetBindings().Invalidate(aInval);
1684  }
1685 
1686  return 0;
1687 }
1688 
1690 {
1691  return true;
1692 }
1693 
1694 std::unique_ptr<SfxTabPage> SwPagePreview::CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
1695  const SfxItemSet &rOptions)
1696 {
1697  return ::CreatePrintOptionsPage(pPage, pController, rOptions, !m_bNormalPrint);
1698 }
1699 
1701 {
1702  mpViewShell = pShell;
1703  if ( mpViewShell && mpViewShell->IsPreview() )
1704  {
1706  }
1707 }
1708 
1710 {
1711  // #i24183#
1713  {
1714  mpPgPreviewLayout->Repaint( tools::Rectangle( rRect.Pos(), rRect.SSize() ) );
1715  }
1716 }
1717 
1722 void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
1723  const SvxZoomType _eZoomType )
1724 {
1725  // #i19975# consider zoom type
1726  if ( _eZoomType == SvxZoomType::WHOLEPAGE )
1727  {
1728  mnRow = 1;
1729  mnCol = 1;
1736  }
1737  else if ( _nZoomFactor != 0 )
1738  {
1739  // calculate new scaling and set mapping mode appropriately.
1740  Fraction aNewScale( _nZoomFactor, 100 );
1741  MapMode aNewMapMode = GetMapMode();
1742  aNewMapMode.SetScaleX( aNewScale );
1743  aNewMapMode.SetScaleY( aNewScale );
1744  SetMapMode( aNewMapMode );
1745 
1746  // calculate new start position for preview paint
1747  Size aNewWinSize = PixelToLogic( maPxWinSize );
1748  Point aNewPaintStartPos =
1749  mpPgPreviewLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
1750 
1751  // remember new scaling and prepare preview paint
1752  // Note: paint of preview will be performed by a corresponding invalidate
1753  // due to property changes.
1754  maScale = aNewScale;
1755  mpPgPreviewLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
1757  }
1758 
1759 }
1760 
1766 void SwPagePreviewWin::Scroll(long nXMove, long nYMove, ScrollFlags /*nFlags*/)
1767 {
1768  maPaintedPreviewDocRect.Move(nXMove, nYMove);
1772 
1773 }
1774 
1776 {
1777  bool bOk = false;
1778  const CommandWheelData* pWData = rCEvt.GetWheelData();
1779  if( pWData && CommandWheelMode::ZOOM == pWData->GetMode() )
1780  {
1781  //only the Preference shouldn't control the Zoom, it is better to detect AT tools running. So the bridge can be used here
1783  {
1784  sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
1785  const sal_uInt16 nOffset = 10;
1786  if( 0L > pWData->GetDelta() )
1787  {
1788  nFactor -= nOffset;
1789  if(nFactor < MIN_PREVIEW_ZOOM)
1790  nFactor = MIN_PREVIEW_ZOOM;
1791  }
1792  else
1793  {
1794  nFactor += nOffset;
1795  if(nFactor > MAX_PREVIEW_ZOOM)
1796  nFactor = MAX_PREVIEW_ZOOM;
1797  }
1798  SetZoom(SvxZoomType::PERCENT, nFactor);
1799  }
1800  bOk = true;
1801  }
1802  else
1804  return bOk;
1805 }
1806 
1807 uno::Reference< css::accessibility::XAccessible >
1809 {
1810  SolarMutexGuard aGuard; // this should have happened already!!!
1811 
1812  OSL_ENSURE( GetViewShell() != nullptr, "We need a view shell" );
1813  css::uno::Reference< css::accessibility::XAccessible > xAcc = GetAccessible( false );
1814  if (xAcc.is())
1815  {
1816  return xAcc;
1817  }
1818  if (mpViewShell)
1819  {
1820  css::uno::Reference< css::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
1821  SetAccessible(xAccPreview);
1822  }
1823  return GetAccessible( false );
1824 }
1825 
1827 {
1828  GetViewShell()->ApplyAccessibilityOptions(rAccessibilityOptions);
1829 }
1830 
1832 {
1833  m_pHScrollbar->Show(bShow);
1834  InvalidateBorder();
1835 }
1836 
1838 {
1839  m_pVScrollbar->Show(bShow);
1840  InvalidateBorder();
1841 }
1842 
1844 {
1845  if (mbHScrollbarEnabled != bEnable)
1846  {
1847  mbHScrollbarEnabled = bEnable;
1848  ScrollViewSzChg();
1849  }
1850 }
1851 
1853 {
1854  if (mbVScrollbarEnabled != bEnable)
1855  {
1856  mbVScrollbarEnabled = bEnable;
1857  ScrollViewSzChg();
1858  }
1859 }
1860 
1861 void SwPagePreview::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
1862 {
1863  SwViewShell& rSh = *GetViewShell();
1864  SwViewOption aOpt(*rSh.GetViewOptions());
1865  // perform action only on changes of zoom or zoom type.
1866  if ( aOpt.GetZoom() != nFactor ||
1867  aOpt.GetZoomType() != eType )
1868  {
1869  aOpt.SetZoom(nFactor);
1870  aOpt.SetZoomType(eType);
1871  rSh.ApplyViewOptions( aOpt );
1872  lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
1873  // #i19975# also consider zoom type
1874  m_pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
1875  ScrollViewSzChg();
1876  }
1877 }
1878 
1880 void SwPagePreview::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
1881 {
1882  if ( m_pVScrollbar )
1883  {
1884  m_pVScrollbar->SetThumbPos( _nNewThumbPos );
1885  }
1886 }
1887 
1888 /* 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
long Width() const
#define MAXZOOM
Definition: view.hxx:81
void SetLineBreak(bool b)
Definition: viewopt.hxx:253
void setOutputToWindow(bool bOutputToWindow)
Definition: viewsh.cxx:126
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:839
long GetWidth() const
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:2112
long GetHeight() const
#define FN_SHOW_MULTIPLE_PAGES
Definition: cmdid.h:836
void SetSoftHyph(bool b)
Definition: viewopt.hxx:264
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
OUString m_sPageStr
Definition: pview.hxx:173
void SetZoom(sal_uInt16 n)
Definition: viewopt.hxx:488
void SetState(const SfxItemSet &rSet)
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:175
void ShowHScrollbar(bool bShow)
Definition: pview.cxx:1831
virtual void CalcLayout()
Definition: viewsh.cxx:973
std::unique_ptr< ContentProperties > pData
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
Definition: pview.cxx:1298
std::string GetValue
void UpdateFontList()
Definition: docshini.cxx:410
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: pview.cxx:1808
SwPagePreviewWin(vcl::Window *pParent, SwPagePreview &rView)
Definition: pview.cxx:164
VclPtr< SwPagePreviewWin > m_pViewWin
Definition: pview.hxx:165
long Height() const
OUString m_sSwViewData
Definition: pview.hxx:167
View of a document.
Definition: pview.hxx:161
virtual ~SwPagePreview() override
Definition: pview.cxx:1216
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
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
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
long GetThumbPos() const
const MapMode & GetMapMode() const
static void StateUndo(SfxItemSet &)
Definition: pview.cxx:1061
sal_uInt16 GetCode() const
Fraction maScale
Definition: pview.hxx:53
void Execute(SfxRequest &)
Definition: pview.cxx:654
long SwTwips
Definition: swtypes.hxx:49
SwPagePreview & mrView
Definition: pview.hxx:54
long GetNotchDelta() const
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:826
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:231
bool mbCalcScaleForPreviewLayout
Definition: pview.hxx:55
void SetAnimationEnabled(bool bEnable=true)
constexpr sal_uInt16 KEY_ADD
void Scroll(long nXMove, 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:1766
virtual SfxObjectShell * GetObjectShell() override
void SetShowHiddenChar(bool b)
Definition: viewopt.hxx:307
void PaintImmediately()
bool HandleScrollCommand(const CommandEvent &rCmd, ScrollBar *pHScrl, ScrollBar *pVScrl)
void EndAllAction()
Definition: edws.cxx:97
RET_CANCEL
long & Bottom()
void SetMapMode()
virtual const SfxItemSet * GetOutputItemSet() const =0
bool IsHorz() const
#define FN_SHOW_SINGLE_PAGE
Definition: cmdid.h:841
void SetBorderPixel(const SvBorder &rBorder)
void SetColumnBreak(bool b)
Definition: viewopt.hxx:259
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
bool IsPageVisible(const sal_uInt16 _nPageNum) const
determines, if page with given page number is visible in preview
sal_uInt16 NextWhich()
long AdjustBottom(long nVertMoveDelta)
void ReInit()
method to adjust page preview layout to document changes
void SetPagePrevRow(sal_uInt8 n)
Definition: viewopt.hxx:442
void Move(long nHorzMoveDelta, long nVertMoveDelta)
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:528
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)
long Right() const
void SetZoom(SvxZoomType eSet, sal_uInt16 nFactor)
Definition: pview.cxx:1861
void SetSelectedPage(sal_uInt16 _nSelectedPageNum)
set selected page number
void InvalidateBorder()
bool mbFormDesignModeToReset
Definition: pview.hxx:191
SfxPrinterChangeFlags
sal_uInt16 GetButtons() const
#define SFX_PRINTERROR_BUSY
bool IsVisible(bool bReal) const
Definition: scroll.hxx:39
void SetParagraph(bool b)
Definition: viewopt.hxx:237
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:2013
SAL_DLLPRIVATE void CreateScrollbar(bool bHori)
Definition: pview.cxx:1237
bool IsMouseEvent() const
AllSettingsFlags GetFlags() 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:2466
#define SID_JUMP_TO_SPECIFIC_PAGE
Definition: cmdid.h:721
bool IsViewVScrollBar() const
Definition: viewopt.hxx:501
sal_uInt16 GetModifier() const
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
long Top() const
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:1843
void DocSzChgd(const Size &rNewSize)
Definition: pview.cxx:1514
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
SwPagePreviewLayout * PagePreviewLayout()
Definition: viewpg.cxx:32
#define FN_START_OF_LINE
Definition: cmdid.h:640
void SetShowHiddenPara(bool b)
Definition: viewopt.hxx:382
SwDocShell * GetDocShell()
Definition: pview.cxx:1232
#define MOUSE_LEFT
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
bool IsDeltaPixel() const
#define FN_LINE_UP
Definition: cmdid.h:638
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:466
DocumentType eType
void ApplyAccessibilityOptions(SvtAccessibilityOptions const &rAccessibilityOptions)
Definition: pview.cxx:1826
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:1454
SAL_DLLPRIVATE Point AlignToPixel(const Point &rPt) const
Definition: pview.cxx:1509
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:2586
void ScrollViewSzChg()
Definition: pview.cxx:1535
void ChgAllPageOrientation(Orientation eOri)
Definition: vprint.cxx:201
void SetLineColor()
#define FN_PAGEUP
Definition: cmdid.h:668
void RepaintCoreRect(const SwRect &rRect)
Definition: pview.cxx:1709
virtual SAL_DLLPRIVATE std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
Definition: pview.cxx:1694
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:636
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
void SetTop(long v)
#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:444
#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:1256
int i
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
void SetTable(bool b)
Definition: viewopt.hxx:327
void SetOnlineSpell(bool b)
Definition: viewopt.cxx:322
#define FN_PRINT_PAGEPREVIEW
Definition: cmdid.h:838
void SetRangeMax(long nNewRange)
void SetVisibleSize(long nNewSize)
static bool IsQuickHelpEnabled()
void SetShowHiddenField(bool b)
Definition: viewopt.hxx:312
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:220
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:618
sal_uInt16 GetPageCount() const
Definition: pview.hxx:251
void SetVisArea(const tools::Rectangle &)
Definition: pview.cxx:1337
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 SetRight(long v)
void SetSfxViewShell(SfxViewShell *pNew)
Definition: viewsh.hxx:442
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetFillColor()
css::uno::Reference< css::accessibility::XAccessible > CreateAccessiblePreview()
Definition: viewsh.cxx:2396
bool HandleWheelCommands(const CommandEvent &)
Definition: pview.cxx:1775
CommandEventId GetCommand() const
void ShowVScrollbar(bool bShow)
Definition: pview.cxx:1837
sal_uInt16 GetModifier() const
virtual void Command(const CommandEvent &rCEvt) override
Definition: pview.cxx:434
sal_uInt8 mnCol
Definition: pview.hxx:51
long Bottom() const
void SetVScrollbarThumbPos(const sal_uInt16 _nNewThumbPos)
Adjust position of vertical scrollbar.
Definition: pview.cxx:1880
virtual SAL_DLLPRIVATE sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
Definition: pview.cxx:1635
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
void SetPageSize(long nNewSize)
sal_uInt16 SelectedPage()
get selected page number
void SetViewHRuler(bool b)
Definition: viewopt.hxx:585
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:317
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
bool IsPagePrevBookview() const
Definition: viewopt.hxx:456
void SetName(const OUString &rName)
void SSize(const Size &rNew)
Definition: swrect.hxx:178
sal_uInt16 GetModifier() 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
Size GetSize() const
#define Y
bool mbVScrollbarEnabled
Definition: pview.hxx:181
void SetFieldName(bool b)
Definition: viewopt.hxx:268
SwPagePreviewLayout * mpPgPreviewLayout
Definition: pview.hxx:57
#define SFX_OBJECTBAR_OBJECT
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
Definition: pview.cxx:1312
SwViewShell & GetParentViewShell()
static void lcl_InvalidateZoomSlots(SfxBindings &rBindings)
Definition: pview.cxx:122
void SetEndScrollHdl(const Link< ScrollBar *, void > &rLink)
sal_uInt8 GetPagePrevRow() const
Definition: viewopt.hxx:441
void SetLineSize(long nNewSize)
SAL_DLLPRIVATE void CalcAndSetBorderPixel(SvBorder &rToFill)
Definition: pview.cxx:1287
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
virtual SAL_DLLPRIVATE SfxPrinter * GetPrinter(bool bCreate=false) override
Definition: pview.cxx:1630
long Max() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetNumPages() const
Definition: viewsh.cxx:622
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:641
constexpr sal_uInt16 KEY_SUBTRACT
void DisableItem(sal_uInt16 nWhich)
#define FN_START_OF_DOCUMENT
Definition: cmdid.h:642
long AdjustRight(long nHorzMoveDelta)
#define FN_SHOW_BOOKVIEW
Definition: cmdid.h:840
weld::Window * GetFrameWeld() const
long GetDelta() const
void SetViewShell(SwViewShell *pShell)
Definition: pview.cxx:1700
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define FN_CHAR_RIGHT
Definition: cmdid.h:637
SAL_DLLPRIVATE void Init()
Definition: pview.cxx:1073
long & Right()
void SetValueSet(SvxZoomEnableFlags nValues)
unsigned char sal_uInt8
void SetPageBreak(bool b)
Definition: viewopt.hxx:256
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:1385
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:273
void SetBottom(long v)
sal_uInt16 mnPageCount
Definition: pview.hxx:185
void GetState(SfxItemSet &)
Definition: pview.cxx:928
sal_uInt16 GetZoom() const
Definition: viewopt.hxx:487
virtual short run()
void * p
#define FN_PAGEDOWN
Definition: cmdid.h:669
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:1134
vcl::Window * GetWindow() const
long Left() 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:342
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:1722
virtual SfxInterface * GetInterface() const
virtual bool KeyInput(const KeyEvent &rKeyEvent)
const MiscSettings & GetMiscSettings() const
void SetOutDevViewType(OutDevViewType eOutDevViewType)
void SetLeft(long v)
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetViewVRuler(bool b)
Definition: viewopt.hxx:599
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:1689
SvxZoomType
void SetGridVisible(bool b)
Definition: viewopt.hxx:350
long GetScrollBarSize() const
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:834
#define FN_LINE_DOWN
Definition: cmdid.h:639
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void BroadcastContextForActivation(const bool bIsActivated)
#define FN_STAT_ZOOM
Definition: cmdid.h:828
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2070
void Init(const sal_uInt16 _nCols, const sal_uInt16 _nRows, const Size &_rPxWinSize)
init page preview layout
bool IsViewHScrollBar() const
Definition: viewopt.hxx:509
bool DoesPreviewLayoutColsFitIntoWindow() const
void SetShowBookmarks(bool const b)
Definition: viewopt.hxx:240
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:443
void SetContextName(const OUString &rsContextName)
aStr
void ScrollDocSzChg()
Definition: pview.cxx:1624
sal_uInt16 ConvertAbsoluteToRelativePageNum(sal_uInt16 _nAbsPageNum) const
Convert absolute to relative page numbers (see PrintEmptyPages)
AnyEventRef aEvent
#define HID_PAGEPREVIEW
Definition: helpids.h:31
void SetThumbPos(long nThumbPos)
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:1852
void SetBlank(bool b)
Definition: viewopt.hxx:226
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)