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