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