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