docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / uibase / uiview / pview.cxx
blob9811b027f58658f117eefe728b4d4599adea4f1b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_wasm_strip.h>
22 #include <sfx2/objface.hxx>
23 #include <vcl/help.hxx>
24 #include <vcl/commandevent.hxx>
25 #include <vcl/settings.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/syswin.hxx>
28 #include <vcl/weld.hxx>
30 #include <svl/whiter.hxx>
31 #include <svl/slstitm.hxx>
32 #include <svl/eitem.hxx>
33 #include <sfx2/printer.hxx>
34 #include <sfx2/bindings.hxx>
35 #include <sfx2/request.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <editeng/paperinf.hxx>
38 #include <svx/svdview.hxx>
39 #include <svx/viewlayoutitem.hxx>
40 #include <svx/zoomslideritem.hxx>
41 #include <tools/svborder.hxx>
42 #include <osl/diagnose.h>
44 #include <globdoc.hxx>
45 #include <wdocsh.hxx>
46 #include <pvprtdat.hxx>
47 #include <swmodule.hxx>
48 #include <wrtsh.hxx>
49 #include <docsh.hxx>
50 #include <viewopt.hxx>
51 #include <doc.hxx>
52 #include <IDocumentDeviceAccess.hxx>
53 #include <pview.hxx>
54 #include <view.hxx>
55 #include <scroll.hxx>
56 #include <prtopt.hxx>
57 #include <usrpref.hxx>
58 #include "viewfunc.hxx"
60 #include <helpids.h>
61 #include <cmdid.h>
62 #include <strings.hrc>
64 #define ShellClass_SwPagePreview
65 #include <sfx2/msg.hxx>
66 #include <swslots.hxx>
67 #include <pagepreviewlayout.hxx>
69 #include <svx/svxdlg.hxx>
71 #include <memory>
72 #include <vcl/EnumContext.hxx>
73 #include <vcl/notebookbar/notebookbar.hxx>
75 using namespace ::com::sun::star;
76 SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview, "PrintPreview")
78 SFX_VIEW_REGISTRATION(SwDocShell);
79 SFX_VIEW_REGISTRATION(SwWebDocShell);
80 SFX_VIEW_REGISTRATION(SwGlobalDocShell);
83 SFX_IMPL_INTERFACE(SwPagePreview, SfxViewShell)
85 void SwPagePreview::InitInterface_Impl()
87 GetStaticInterface()->RegisterPopupMenu(u"preview"_ustr);
88 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
89 SfxVisibilityFlags::Standard|SfxVisibilityFlags::Client|SfxVisibilityFlags::FullScreen|SfxVisibilityFlags::ReadonlyDoc,
90 ToolbarId::PView_Toolbox);
94 #define SWVIEWFLAGS SfxViewShellFlags::HAS_PRINTOPTIONS
96 #define MIN_PREVIEW_ZOOM 25
97 #define MAX_PREVIEW_ZOOM 600
99 static sal_uInt16 lcl_GetNextZoomStep(sal_uInt16 nCurrentZoom, bool bZoomIn)
101 static const sal_uInt16 aZoomArr[] =
103 25, 50, 75, 100, 150, 200, 400, 600
105 const int nZoomArrSize = static_cast<int>(SAL_N_ELEMENTS(aZoomArr));
106 if (bZoomIn)
108 for(sal_uInt16 i : aZoomArr)
110 if(nCurrentZoom < i)
111 return i;
114 else
116 for(int i = nZoomArrSize - 1; i >= 0; --i)
118 if(nCurrentZoom > aZoomArr[i] || !i)
119 return aZoomArr[i];
122 return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
125 static void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
127 static sal_uInt16 const aInval[] =
129 SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
132 rBindings.Invalidate( aInval );
135 namespace {
137 // At first the zoom dialog
138 class SwPreviewZoomDlg : public weld::GenericDialogController
140 SwPagePreviewWin& m_rParent;
141 std::unique_ptr<weld::SpinButton> m_xRowEdit;
142 std::unique_ptr<weld::SpinButton> m_xColEdit;
144 public:
145 SwPreviewZoomDlg(SwPagePreviewWin& rParent)
146 : GenericDialogController(rParent.GetFrameWeld(), u"modules/swriter/ui/previewzoomdialog.ui"_ustr, u"PreviewZoomDialog"_ustr)
147 , m_rParent(rParent)
148 , m_xRowEdit(m_xBuilder->weld_spin_button(u"rows"_ustr))
149 , m_xColEdit(m_xBuilder->weld_spin_button(u"cols"_ustr))
151 m_xRowEdit->set_value(rParent.GetRow());
152 m_xColEdit->set_value(rParent.GetCol());
155 void execute()
157 if (run() == RET_OK)
159 m_rParent.CalcWish(m_xRowEdit->get_value(), m_xColEdit->get_value());
166 // all for SwPagePreviewWin
167 SwPagePreviewWin::SwPagePreviewWin( vcl::Window *pParent, SwPagePreview& rPView )
168 : Window(pParent, WinBits(WB_CLIPCHILDREN))
169 , mpViewShell(nullptr)
170 , mrView(rPView)
171 , mbCalcScaleForPreviewLayout(true)
172 , maPaintedPreviewDocRect(tools::Rectangle(0,0,0,0))
173 , mpPgPreviewLayout(nullptr)
175 GetOutDev()->SetOutDevViewType( OutDevViewType::PrintPreview );
176 SetHelpId(HID_PAGEPREVIEW);
177 GetOutDev()->SetFillColor( GetBackground().GetColor() );
178 GetOutDev()->SetLineColor( GetBackground().GetColor());
179 SetMapMode( MapMode(MapUnit::MapTwip) );
181 const SwMasterUsrPref* pUsrPref = SwModule::get()->GetUsrPref(false);
182 mnRow = pUsrPref->GetPagePrevRow(); // 1 row
183 mnCol = pUsrPref->GetPagePrevCol(); // 1 column
184 mnSttPage = USHRT_MAX;
187 SwPagePreviewWin::~SwPagePreviewWin()
191 void SwPagePreviewWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
193 if (!mpViewShell || !mpViewShell->GetLayout())
194 return;
196 if (USHRT_MAX == mnSttPage) // was never calculated ? (Init-Phase!)
198 // This is the size to which I always relate.
199 if (!maPxWinSize.Height() || !maPxWinSize.Width())
200 maPxWinSize = GetOutputSizePixel();
202 tools::Rectangle aRect(rRenderContext.LogicToPixel(rRect));
203 mpPgPreviewLayout->Prepare(1, Point(0,0), maPxWinSize,
204 mnSttPage, maPaintedPreviewDocRect);
205 SetSelectedPage(1);
206 mpPgPreviewLayout->Paint(rRenderContext, rRenderContext.PixelToLogic(aRect));
207 SetPagePreview(mnRow, mnCol);
209 else
211 MapMode aMM(rRenderContext.GetMapMode());
212 aMM.SetScaleX(maScale);
213 aMM.SetScaleY(maScale);
214 rRenderContext.SetMapMode(aMM);
215 mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(true);
216 mpPgPreviewLayout->Paint(rRenderContext, rRect);
217 mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(false);
221 void SwPagePreviewWin::CalcWish( sal_Int16 nNewRow, sal_Int16 nNewCol )
223 if( !mpViewShell || !mpViewShell->GetLayout() )
224 return;
226 const sal_Int16 nOldCol = mnCol;
227 mnRow = nNewRow;
228 mnCol = nNewCol;
229 const sal_uInt16 nPages = mnRow * mnCol;
230 const sal_uInt16 nLastSttPg = mrView.GetPageCount()+1 > nPages
231 ? mrView.GetPageCount()+1 - nPages : 0;
232 if( mnSttPage > nLastSttPg )
233 mnSttPage = nLastSttPg;
235 mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize );
236 mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
237 mnSttPage, maPaintedPreviewDocRect );
238 SetSelectedPage( mnSttPage );
239 SetPagePreview(mnRow, mnCol);
240 maScale = GetMapMode().GetScaleX();
242 // If changes have taken place at the columns, the special case "single column"
243 // must be considered and corrected if necessary.
244 if( (1 == nOldCol) != (1 == mnCol) )
245 mrView.ScrollDocSzChg();
247 // Order must be maintained!
248 // additional invalidate page status.
249 static sal_uInt16 aInval[] =
251 SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
252 FN_PREVIEW_ZOOM,
253 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
254 FN_STAT_PAGE, FN_STAT_ZOOM,
255 FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES,
258 SfxBindings& rBindings = mrView.GetViewFrame().GetBindings();
259 rBindings.Invalidate( aInval );
260 rBindings.Update( FN_SHOW_TWO_PAGES );
261 rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
262 // adjust scrollbars
263 mrView.ScrollViewSzChg();
266 // mnSttPage is Absolute
267 bool SwPagePreviewWin::MovePage( int eMoveMode )
269 // number of pages up
270 const sal_uInt16 nPages = mnRow * mnCol;
271 sal_uInt16 nNewSttPage = mnSttPage;
272 const sal_uInt16 nPageCount = mrView.GetPageCount();
273 const sal_uInt16 nDefSttPg = GetDefSttPage();
274 bool bPaintPageAtFirstCol = true;
276 switch( eMoveMode )
278 case MV_PAGE_UP:
280 const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
281 const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
282 mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
283 nDefSttPg;
284 nNewSttPage = nNewAbsSttPage;
286 const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
287 const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
288 nRelSelPage - nPages :
290 SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) );
292 break;
294 case MV_PAGE_DOWN:
296 const sal_uInt16 nRelSttPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
297 const sal_uInt16 nNewAbsSttPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
298 nNewSttPage = std::min(nNewAbsSttPage, nPageCount);
300 const sal_uInt16 nRelSelPage = mpPgPreviewLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
301 const sal_uInt16 nNewAbsSelPage = mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
302 SetSelectedPage( std::min(nNewAbsSelPage, nPageCount) );
304 break;
306 case MV_DOC_STT:
307 nNewSttPage = nDefSttPg;
308 SetSelectedPage( mpPgPreviewLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
309 break;
310 case MV_DOC_END:
311 // correct calculation of new start page.
312 nNewSttPage = nPageCount;
313 SetSelectedPage( nPageCount );
314 break;
316 case MV_SELPAGE:
317 // <nNewSttPage> and <SelectedPage()> are already set.
318 // not start at first column, only if the
319 // complete preview layout columns doesn't fit into window.
320 if ( !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
321 bPaintPageAtFirstCol = false;
322 break;
323 case MV_SCROLL:
324 // check, if paint page at first column
325 // has to be avoided
326 if ( !mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() ||
327 !mpPgPreviewLayout->DoesPreviewLayoutColsFitIntoWindow() )
328 bPaintPageAtFirstCol = false;
329 break;
330 case MV_NEWWINSIZE:
331 // nothing special to do.
332 break;
333 case MV_CALC:
334 // re-init page preview layout.
335 mpPgPreviewLayout->ReInit();
337 // correct calculation of new start page.
338 if( nNewSttPage > nPageCount )
339 nNewSttPage = nPageCount;
341 // correct selected page number
342 if( SelectedPage() > nPageCount )
343 SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
346 mpPgPreviewLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
347 nNewSttPage,
348 maPaintedPreviewDocRect, bPaintPageAtFirstCol );
349 if( nNewSttPage == mnSttPage &&
350 eMoveMode != MV_SELPAGE )
351 return false;
353 SetPagePreview(mnRow, mnCol);
354 mnSttPage = nNewSttPage;
356 // additional invalidate page status.
357 static sal_uInt16 aInval[] =
359 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
360 FN_STAT_PAGE, 0
363 SfxBindings& rBindings = mrView.GetViewFrame().GetBindings();
364 rBindings.Invalidate( aInval );
366 return true;
369 void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
371 // We always want the size as pixel units.
372 maPxWinSize = LogicToPixel( rNewSize );
374 if( USHRT_MAX == mnSttPage )
376 mnSttPage = GetDefSttPage();
377 SetSelectedPage( GetDefSttPage() );
380 if ( mbCalcScaleForPreviewLayout )
382 mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize );
383 maScale = GetMapMode().GetScaleX();
385 mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
386 mnSttPage, maPaintedPreviewDocRect );
387 if ( mbCalcScaleForPreviewLayout )
389 SetSelectedPage( mnSttPage );
390 mbCalcScaleForPreviewLayout = false;
392 SetPagePreview(mnRow, mnCol);
393 maScale = GetMapMode().GetScaleX();
396 OUString SwPagePreviewWin::GetStatusStr( sal_uInt16 nPageCnt ) const
398 // show physical and virtual page number of
399 // selected page, if it's visible.
400 const sal_uInt16 nPageNum = mpPgPreviewLayout->IsPageVisible( mpPgPreviewLayout->SelectedPage() )
401 ? mpPgPreviewLayout->SelectedPage() : std::max<sal_uInt16>(mnSttPage, 1);
403 OUString aStatusStr;
404 const sal_uInt16 nVirtPageNum = mpPgPreviewLayout->GetVirtPageNumByPageNum( nPageNum );
405 if( nVirtPageNum && nVirtPageNum != nPageNum )
407 aStatusStr = OUString::number(nVirtPageNum) + " " ;
409 return aStatusStr + OUString::number(nPageNum) + " / " + OUString::number(nPageCnt);
412 void SwPagePreviewWin::KeyInput( const KeyEvent &rKEvt )
414 const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
415 bool bHandled = false;
416 if(!rKeyCode.GetModifier())
418 sal_uInt16 nSlot = 0;
419 switch(rKeyCode.GetCode())
421 case KEY_ADD : nSlot = SID_ZOOM_IN; break;
422 case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
423 case KEY_SUBTRACT : nSlot = SID_ZOOM_OUT; break;
425 if(nSlot)
427 bHandled = true;
428 mrView.GetViewFrame().GetDispatcher()->Execute(
429 nSlot, SfxCallMode::ASYNCHRON );
432 if( !bHandled && !mrView.KeyInput( rKEvt ) )
433 Window::KeyInput( rKEvt );
436 void SwPagePreviewWin::Command( const CommandEvent& rCEvt )
438 bool bCallBase = true;
439 switch( rCEvt.GetCommand() )
441 case CommandEventId::ContextMenu:
442 SfxDispatcher::ExecutePopup();
443 bCallBase = false;
444 break;
446 case CommandEventId::Wheel:
447 case CommandEventId::StartAutoScroll:
448 case CommandEventId::AutoScroll:
450 const CommandWheelData* pData = rCEvt.GetWheelData();
451 if( pData )
453 const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
454 pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
455 const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
456 bCallBase = !mrView.HandleWheelCommands( aEvent );
458 else
459 bCallBase = !mrView.HandleWheelCommands( rCEvt );
461 break;
462 default:
466 if( bCallBase )
467 Window::Command( rCEvt );
470 void SwPagePreviewWin::MouseButtonDown( const MouseEvent& rMEvt )
472 // consider single-click to set selected page
473 if( MOUSE_LEFT != ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
474 return;
476 Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) );
477 Point aDocPos;
478 bool bPosInEmptyPage;
479 sal_uInt16 nNewSelectedPage;
480 bool bIsDocPos =
481 mpPgPreviewLayout->IsPreviewPosInDocPreviewPage( aPreviewPos,
482 aDocPos, bPosInEmptyPage, nNewSelectedPage );
483 if ( bIsDocPos && rMEvt.GetClicks() == 2 )
485 // close page preview, set new cursor position and switch to
486 // normal view.
487 OUString sNewCursorPos = OUString::number( aDocPos.X() ) + ";" +
488 OUString::number( aDocPos.Y() ) + ";";
489 mrView.SetNewCursorPos( sNewCursorPos );
491 SfxViewFrame& rTmpFrame = mrView.GetViewFrame();
492 rTmpFrame.GetBindings().Execute( SID_VIEWSHELL0, nullptr,
493 SfxCallMode::ASYNCHRON );
495 else if ( bIsDocPos || bPosInEmptyPage )
497 // show clicked page as the selected one
498 mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage );
499 GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
500 // adjust position at vertical scrollbar.
501 if ( mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() )
503 mrView.SetVScrollbarThumbPos( nNewSelectedPage );
505 // invalidate page status.
506 static sal_uInt16 aInval[] =
508 FN_STAT_PAGE, 0
510 SfxBindings& rBindings = mrView.GetViewFrame().GetBindings();
511 rBindings.Invalidate( aInval );
515 // Set user prefs or view options
517 void SwPagePreviewWin::SetPagePreview( sal_Int16 nRow, sal_Int16 nCol )
519 SwMasterUsrPref* pOpt = const_cast<SwMasterUsrPref*>(SwModule::get()->GetUsrPref(false));
521 if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
523 pOpt->SetPagePrevRow( nRow );
524 pOpt->SetPagePrevCol( nCol );
525 pOpt->SetModified();
527 // Update scrollbar!
528 mrView.ScrollViewSzChg();
532 /** get selected page in document preview */
533 sal_uInt16 SwPagePreviewWin::SelectedPage() const
535 return mpPgPreviewLayout->SelectedPage();
538 /** set selected page number in document preview */
539 void SwPagePreviewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
541 mpPgPreviewLayout->SetSelectedPage( _nSelectedPageNum );
544 /** method to enable/disable book preview */
545 bool SwPagePreviewWin::SetBookPreviewMode( const bool _bBookPreview )
547 return mpPgPreviewLayout->SetBookPreviewMode( _bBookPreview,
548 mnSttPage,
549 maPaintedPreviewDocRect );
552 void SwPagePreviewWin::DataChanged( const DataChangedEvent& rDCEvt )
554 Window::DataChanged( rDCEvt );
556 switch( rDCEvt.GetType() )
558 case DataChangedEventType::SETTINGS:
559 // Rearrange the scrollbars or trigger resize, because the
560 // size of the scrollbars may have be changed. Also the
561 // size of the scrollbars has to be retrieved from the settings
562 // out of the resize handler.
563 if( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
564 mrView.InvalidateBorder(); // Scrollbar widths
565 // zoom has to be disabled if Accessibility support is switched on
566 lcl_InvalidateZoomSlots(mrView.GetViewFrame().GetBindings());
567 break;
569 case DataChangedEventType::PRINTER:
570 case DataChangedEventType::DISPLAY:
571 case DataChangedEventType::FONTS:
572 case DataChangedEventType::FONTSUBSTITUTION:
573 mrView.GetDocShell()->UpdateFontList(); // Font change
574 mpViewShell->InvalidateLayout(true);
575 if ( mpViewShell->GetWin() )
576 mpViewShell->GetWin()->Invalidate();
577 break;
578 default: break;
582 void SwPagePreviewWin::ReInit()
584 mpPgPreviewLayout->ReInit();
586 /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN */
587 void SwPagePreview::ExecPgUpAndPgDown( const bool _bPgUp,
588 SfxRequest* _pReq )
590 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
591 // check, if top/bottom of preview is *not* already visible.
592 if( pPagePreviewLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
594 if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() &&
595 pPagePreviewLay->DoesPreviewLayoutColsFitIntoWindow() )
597 const int eMvMode = _bPgUp ?
598 SwPagePreviewWin::MV_PAGE_UP :
599 SwPagePreviewWin::MV_PAGE_DOWN;
600 if ( ChgPage( eMvMode ) )
601 m_pViewWin->Invalidate();
603 else
605 SwTwips nScrollAmount;
606 sal_uInt16 nNewSelectedPageNum = 0;
607 const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
608 if( _bPgUp )
610 if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
612 nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( -1 );
613 if ( (m_pViewWin->SelectedPage() - nVisPages) > 0 )
614 nNewSelectedPageNum = m_pViewWin->SelectedPage() - nVisPages;
615 else
616 nNewSelectedPageNum = 1;
618 else
619 nScrollAmount = - std::min( m_pViewWin->GetOutDev()->GetOutputSize().Height(),
620 m_pViewWin->GetPaintedPreviewDocRect().Top() );
622 else
624 if ( pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
626 nScrollAmount = pPagePreviewLay->GetWinPagesScrollAmount( 1 );
627 if ( (m_pViewWin->SelectedPage() + nVisPages) <= mnPageCount )
628 nNewSelectedPageNum = m_pViewWin->SelectedPage() + nVisPages;
629 else
630 nNewSelectedPageNum = mnPageCount;
632 else
633 nScrollAmount = std::min( m_pViewWin->GetOutDev()->GetOutputSize().Height(),
634 ( pPagePreviewLay->GetPreviewDocSize().Height() -
635 m_pViewWin->GetPaintedPreviewDocRect().Bottom() ) );
637 m_pViewWin->Scroll( 0, nScrollAmount );
638 if ( nNewSelectedPageNum != 0 )
640 m_pViewWin->SetSelectedPage( nNewSelectedPageNum );
642 ScrollViewSzChg();
643 // additional invalidate page status.
644 static sal_uInt16 aInval[] =
646 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
647 FN_STAT_PAGE, 0
649 SfxBindings& rBindings = GetViewFrame().GetBindings();
650 rBindings.Invalidate( aInval );
651 m_pViewWin->Invalidate();
655 if ( _pReq )
656 _pReq->Done();
659 // Then all for the SwPagePreview
660 void SwPagePreview::Execute( SfxRequest &rReq )
662 int eMvMode = SwPagePreviewWin::MV_DOC_END;
663 sal_Int16 nRow = 1;
664 bool bRefresh = true;
666 switch(rReq.GetSlot())
668 case SID_REFRESH_VIEW:
669 case FN_STAT_PAGE:
670 case FN_STAT_ZOOM:
671 break;
673 case FN_SHOW_MULTIPLE_PAGES:
675 const SfxItemSet *pArgs = rReq.GetArgs();
676 if( pArgs && pArgs->Count() >= 2 )
678 sal_Int16 nCols = pArgs->Get(SID_ATTR_TABLE_COLUMN).GetValue();
679 sal_Int16 nRows = pArgs->Get(SID_ATTR_TABLE_ROW).GetValue();
680 m_pViewWin->CalcWish( nRows, nCols );
683 else
685 SwPreviewZoomDlg aDlg(*m_pViewWin);
686 aDlg.execute();
689 break;
690 case FN_SHOW_BOOKVIEW:
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 ) )
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
701 if ( m_pViewWin->SetBookPreviewMode( bBookPreview ) )
703 // book preview mode changed. Thus, adjust scrollbars and
704 // invalidate corresponding states.
705 ScrollViewSzChg();
706 static sal_uInt16 aInval[] =
708 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
709 FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0
711 SfxBindings& rBindings = GetViewFrame().GetBindings();
712 rBindings.Invalidate( aInval );
713 m_pViewWin->Invalidate();
717 break;
718 case FN_SHOW_TWO_PAGES:
719 m_pViewWin->CalcWish( nRow, 2 );
720 break;
722 case FN_SHOW_SINGLE_PAGE:
723 m_pViewWin->CalcWish( nRow, 1 );
724 break;
726 case FN_PREVIEW_ZOOM:
727 case SID_ATTR_ZOOM:
729 const SfxItemSet *pArgs = rReq.GetArgs();
730 ScopedVclPtr<AbstractSvxZoomDialog> pDlg;
731 if(!pArgs)
733 SfxItemSetFixed<SID_ATTR_ZOOM, SID_ATTR_ZOOM> aCoreSet(GetPool());
734 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
735 SvxZoomItem aZoom( pVOpt->GetZoomType(), pVOpt->GetZoom() );
736 aZoom.SetValueSet(
737 SvxZoomEnableFlags::N50|
738 SvxZoomEnableFlags::N75|
739 SvxZoomEnableFlags::N100|
740 SvxZoomEnableFlags::N150|
741 SvxZoomEnableFlags::N200|
742 SvxZoomEnableFlags::WHOLEPAGE);
743 aCoreSet.Put( aZoom );
745 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
746 pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetViewFrame().GetFrameWeld(), aCoreSet));
747 pDlg->SetLimits( MINZOOM, MAXZOOM );
749 if( pDlg->Execute() != RET_CANCEL )
750 pArgs = pDlg->GetOutputItemSet();
752 if( pArgs )
754 SvxZoomType eType = SvxZoomType::PERCENT;
755 sal_uInt16 nZoomFactor = USHRT_MAX;
756 if(const SvxZoomItem* pZoomItem = pArgs->GetItemIfSet(SID_ATTR_ZOOM))
758 eType = pZoomItem->GetType();
759 nZoomFactor = pZoomItem->GetValue();
761 else if(const SfxUInt16Item* pPreviewItem = pArgs->GetItemIfSet(FN_PREVIEW_ZOOM))
762 nZoomFactor = pPreviewItem->GetValue();
763 if(USHRT_MAX != nZoomFactor)
764 SetZoom(eType, nZoomFactor);
767 break;
768 case SID_ATTR_ZOOMSLIDER :
770 const SfxItemSet *pArgs = rReq.GetArgs();
771 const SvxZoomSliderItem* pItem;
773 if ( pArgs && (pItem = pArgs->GetItemIfSet(SID_ATTR_ZOOMSLIDER ) ) )
775 const sal_uInt16 nCurrentZoom = pItem->GetValue();
776 SetZoom( SvxZoomType::PERCENT, nCurrentZoom );
779 break;
780 case SID_ZOOM_IN:
781 case SID_ZOOM_OUT:
783 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
784 SetZoom(SvxZoomType::PERCENT,
785 lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
787 break;
788 case FN_CHAR_LEFT:
789 case FN_CHAR_RIGHT:
790 case FN_LINE_UP:
791 case FN_LINE_DOWN:
793 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
794 sal_uInt16 nNewSelectedPage;
795 sal_uInt16 nNewStartPage;
796 Point aNewStartPos;
797 sal_Int16 nHoriMove = 0;
798 sal_Int16 nVertMove = 0;
799 switch(rReq.GetSlot())
801 case FN_CHAR_LEFT: nHoriMove = -1; break;
802 case FN_CHAR_RIGHT: nHoriMove = 1; break;
803 case FN_LINE_UP: nVertMove = -1; break;
804 case FN_LINE_DOWN: nVertMove = 1; break;
806 pPagePreviewLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
807 nNewSelectedPage, nNewStartPage, aNewStartPos );
808 if ( m_pViewWin->SelectedPage() != nNewSelectedPage )
810 if ( pPagePreviewLay->IsPageVisible( nNewSelectedPage ) )
812 pPagePreviewLay->MarkNewSelectedPage( nNewSelectedPage );
813 // adjust position at vertical scrollbar.
814 SetVScrollbarThumbPos( nNewSelectedPage );
815 bRefresh = false;
817 else
819 m_pViewWin->SetSelectedPage( nNewSelectedPage );
820 m_pViewWin->SetSttPage( nNewStartPage );
821 bRefresh = ChgPage( SwPagePreviewWin::MV_SELPAGE );
823 GetViewShell()->ShowPreviewSelection( nNewSelectedPage );
824 // invalidate page status.
825 static sal_uInt16 aInval[] =
827 FN_STAT_PAGE, 0
829 SfxBindings& rBindings = GetViewFrame().GetBindings();
830 rBindings.Invalidate( aInval );
831 rReq.Done();
833 else
835 bRefresh = false;
837 break;
839 case FN_PAGEUP:
840 case FN_PAGEDOWN:
842 ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
843 break;
845 case SID_JUMP_TO_SPECIFIC_PAGE:
847 const SfxItemSet *pArgs = rReq.GetArgs();
848 if( pArgs && pArgs->Count())
850 sal_uInt16 nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue();
852 if( nPageNum > 0 && nPageNum <= mnPageCount )
854 m_pViewWin->SetSttPage( nPageNum);
855 m_pViewWin->SetSelectedPage( nPageNum );
856 ChgPage( SwPagePreviewWin::MV_SPECIFIC_PAGE, false );
857 ScrollViewSzChg();
861 break;
862 case FN_START_OF_LINE:
863 case FN_START_OF_DOCUMENT:
864 eMvMode = SwPagePreviewWin::MV_DOC_STT;
865 [[fallthrough]];
866 case FN_END_OF_LINE:
867 case FN_END_OF_DOCUMENT:
868 m_pViewWin->SetSelectedPage(eMvMode == SwPagePreviewWin::MV_DOC_STT ? 1 : mnPageCount);
870 bool bRet = ChgPage( eMvMode );
871 // return value for Basic
872 rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
874 bRefresh = bRet;
875 rReq.Done();
877 break;
879 case FN_PRINT_PAGEPREVIEW:
881 const SwPagePreviewPrtData* pPPVPD = m_pViewWin->GetViewShell()->GetDoc()->GetPreviewPrtData();
882 // The thing with the orientation
883 if(pPPVPD)
885 SfxPrinter* pPrinter = GetPrinter( true );
886 if((pPrinter->GetOrientation() == Orientation::Landscape)
887 != pPPVPD->GetLandscape())
888 pPrinter->SetOrientation(pPPVPD->GetLandscape() ? Orientation::Landscape : Orientation::Portrait);
890 ::SetAppPrintOptions( m_pViewWin->GetViewShell(), false );
891 m_bNormalPrint = false;
892 rReq.SetSlot( SID_PRINTDOC );
893 SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
894 rReq.SetSlot( FN_PRINT_PAGEPREVIEW );
895 return;
897 case SID_PRINTDOCDIRECT:
898 case SID_PRINTDOC:
899 ::SetAppPrintOptions( m_pViewWin->GetViewShell(), false );
900 m_bNormalPrint = true;
901 SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
902 return;
903 case FN_CLOSE_PAGEPREVIEW:
904 case SID_PRINTPREVIEW:
905 // print preview is now always in the same frame as the tab view
906 // -> always switch this frame back to normal view
907 // (ScTabViewShell ctor reads stored view data)
908 GetViewFrame().GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::ASYNCHRON );
909 break;
910 case FN_INSERT_BREAK:
912 sal_uInt16 nSelPage = m_pViewWin->SelectedPage();
913 //if a dummy page is selected (e.g. a non-existing right/left page)
914 //the direct neighbor is used
915 if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
916 nSelPage +=2;
917 m_nNewPage = nSelPage;
918 SfxViewFrame& rTmpFrame = GetViewFrame();
919 rTmpFrame.GetBindings().Execute( SID_VIEWSHELL0, nullptr,
920 SfxCallMode::ASYNCHRON );
922 break;
923 default:
924 OSL_ENSURE(false, "wrong dispatcher");
925 return;
928 if( bRefresh )
929 m_pViewWin->Invalidate();
932 void SwPagePreview::GetState( SfxItemSet& rSet )
934 SfxWhichIter aIter(rSet);
935 sal_uInt16 nWhich = aIter.FirstWhich();
936 OSL_ENSURE(nWhich, "empty set");
937 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
939 while(nWhich)
941 switch(nWhich)
943 case SID_BROWSER_MODE:
944 case FN_PRINT_LAYOUT:
945 case FN_SINGLE_PAGE_PER_ROW:
946 case FN_MULTIPLE_PAGES_PER_ROW:
947 case FN_BOOKVIEW:
948 rSet.DisableItem(nWhich);
949 break;
950 case FN_START_OF_DOCUMENT:
952 if ( pPagePreviewLay->IsPageVisible( 1 ) )
953 rSet.DisableItem(nWhich);
954 break;
956 case FN_END_OF_DOCUMENT:
958 if ( pPagePreviewLay->IsPageVisible( mnPageCount ) )
959 rSet.DisableItem(nWhich);
960 break;
962 case FN_PAGEUP:
964 if( pPagePreviewLay->GetWinPagesScrollAmount( -1 ) == 0 )
965 rSet.DisableItem(nWhich);
966 break;
968 case FN_PAGEDOWN:
970 if( pPagePreviewLay->GetWinPagesScrollAmount( 1 ) == 0 )
971 rSet.DisableItem(nWhich);
972 break;
975 case FN_STAT_PAGE:
977 std::vector<OUString> aStringList
979 m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount),
980 OUString()
982 rSet.Put(SfxStringListItem(FN_STAT_PAGE, &aStringList));
984 break;
986 case SID_ATTR_ZOOM:
987 case FN_STAT_ZOOM:
989 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
990 SvxZoomItem aZoom(pVOpt->GetZoomType(), pVOpt->GetZoom());
991 aZoom.SetValueSet(
992 SvxZoomEnableFlags::N50|
993 SvxZoomEnableFlags::N75|
994 SvxZoomEnableFlags::N100|
995 SvxZoomEnableFlags::N150|
996 SvxZoomEnableFlags::N200);
997 rSet.Put( aZoom );
999 break;
1000 case SID_ATTR_ZOOMSLIDER :
1002 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1003 const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1004 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1005 aZoomSliderItem.AddSnappingPoint( 100 );
1006 rSet.Put( aZoomSliderItem );
1008 break;
1009 case FN_PREVIEW_ZOOM:
1011 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1012 rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
1014 break;
1015 case SID_ZOOM_IN:
1016 case SID_ZOOM_OUT:
1018 const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
1019 if((SID_ZOOM_IN == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM) ||
1020 (SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
1022 rSet.DisableItem(nWhich);
1025 break;
1026 case SID_ATTR_VIEWLAYOUT:
1028 rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1030 break;
1031 case FN_SHOW_MULTIPLE_PAGES:
1032 // should never be disabled
1033 break;
1034 case FN_SHOW_BOOKVIEW:
1036 bool b = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1037 rSet.Put(SfxBoolItem(nWhich, b));
1039 break;
1041 case FN_SHOW_TWO_PAGES:
1042 if( 2 == m_pViewWin->GetCol() && 1 == m_pViewWin->GetRow() )
1043 rSet.DisableItem( nWhich );
1044 break;
1046 case FN_PRINT_PAGEPREVIEW:
1047 // has the same status like the normal printing
1049 const SfxPoolItem* pItem;
1050 SfxItemSetFixed<SID_PRINTDOC, SID_PRINTDOC> aSet( *rSet.GetPool() );
1051 GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
1052 if( SfxItemState::DISABLED == aSet.GetItemState( SID_PRINTDOC, false ))
1053 rSet.DisableItem( nWhich );
1054 else if( SfxItemState::SET == aSet.GetItemState( SID_PRINTDOC,
1055 false, &pItem ))
1057 const_cast<SfxPoolItem*>(pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
1058 rSet.Put( *pItem );
1061 break;
1063 case SID_PRINTPREVIEW:
1064 rSet.Put( SfxBoolItem( nWhich, true ) );
1065 break;
1067 case SID_PRINTDOC:
1068 case SID_PRINTDOCDIRECT:
1069 GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
1070 break;
1072 nWhich = aIter.NextWhich();
1076 void SwPagePreview::StateUndo(SfxItemSet& rSet)
1078 SfxWhichIter aIter(rSet);
1079 sal_uInt16 nWhich = aIter.FirstWhich();
1081 while (nWhich)
1083 rSet.DisableItem(nWhich);
1084 nWhich = aIter.NextWhich();
1088 void SwPagePreview::Init()
1090 if ( GetViewShell()->HasDrawView() )
1091 GetViewShell()->GetDrawView()->SetAnimationEnabled( false );
1093 m_bNormalPrint = true;
1095 // Check and process the DocSize. The shell could not be found via
1096 // the handler, because the shell is unknown to the SFX management
1097 // within the CTOR phase.
1099 SwModule* mod = SwModule::get();
1100 const SwViewOption* pPrefs = mod->GetUsrPref(false);
1102 mbHScrollbarEnabled = pPrefs->IsViewHScrollBar();
1103 mbVScrollbarEnabled = pPrefs->IsViewVScrollBar();
1105 // Update the fields
1106 // ATTENTION: Do cast the EditShell up, to use the SS.
1107 // At the methods the current shell will be queried!
1108 SwEditShell* pESh = dynamic_cast<SwEditShell*>(GetViewShell());
1109 bool bIsModified = pESh != nullptr && pESh->IsModified();
1111 SwViewOption aOpt( *pPrefs );
1112 aOpt.SetPagePreview(true);
1113 aOpt.SetTab( false );
1114 aOpt.SetBlank( false );
1115 aOpt.SetHardBlank( false );
1116 aOpt.SetParagraph( false );
1117 aOpt.SetLineBreak( false );
1118 aOpt.SetPageBreak( false );
1119 aOpt.SetColumnBreak( false );
1120 aOpt.SetSoftHyph( false );
1121 aOpt.SetFieldName( false );
1122 aOpt.SetPostIts( false );
1123 aOpt.SetShowBookmarks( false );
1124 aOpt.SetShowHiddenChar( false );
1125 aOpt.SetShowHiddenField( false );
1126 aOpt.SetShowHiddenPara( false );
1127 aOpt.SetViewHRuler( false );
1128 aOpt.SetViewVRuler( false );
1129 aOpt.SetGraphic( true );
1130 aOpt.SetTable( true );
1131 aOpt.SetSnap( false );
1132 aOpt.SetGridVisible( false );
1133 aOpt.SetOnlineSpell( false );
1134 aOpt.SetHideWhitespaceMode( false );
1136 GetViewShell()->ApplyViewOptions( aOpt );
1137 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
1138 GetViewShell()->ApplyAccessibilityOptions();
1139 #endif
1141 // adjust view shell option to the same as for print
1142 SwPrintData const aPrintOptions = *mod->GetPrtOptions(false);
1143 GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
1145 GetViewShell()->CalcLayout();
1146 DocSzChgd( GetViewShell()->GetDocSize() );
1148 if( !bIsModified && pESh != nullptr )
1149 pESh->ResetModified();
1152 SwPagePreview::SwPagePreview(SfxViewFrame& rViewFrame, SfxViewShell* pOldSh):
1153 SfxViewShell(rViewFrame, SWVIEWFLAGS),
1154 m_pViewWin( VclPtr<SwPagePreviewWin>::Create(&GetViewFrame().GetWindow(), *this ) ),
1155 m_nNewPage(USHRT_MAX),
1156 m_sPageStr(SwResId(STR_PAGE)),
1157 m_pHScrollbar(nullptr),
1158 m_pVScrollbar(nullptr),
1159 mnPageCount( 0 ),
1160 mbResetFormDesignMode( false ),
1161 mbFormDesignModeToReset( false )
1163 SetName(u"PageView"_ustr);
1164 SetWindow( m_pViewWin );
1165 CreateScrollbar( true );
1166 CreateScrollbar( false );
1168 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview));
1170 SfxObjectShell* pObjShell = rViewFrame.GetObjectShell();
1171 if ( !pOldSh )
1173 // Exists already a view on the document?
1174 SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
1175 if (pF == &rViewFrame)
1176 pF = SfxViewFrame::GetNext( *pF, pObjShell );
1177 if ( pF )
1178 pOldSh = pF->GetViewShell();
1181 SwViewShell *pVS, *pNew;
1183 if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview*>(pOldSh))
1184 pVS = pPagePreview->GetViewShell();
1185 else
1187 if (SwView* pView = dynamic_cast<SwView *>(pOldSh))
1189 pVS = pView->GetWrtShellPtr();
1190 // save the current ViewData of the previous SwView
1191 pOldSh->WriteUserData( m_sSwViewData );
1193 else
1194 pVS = GetDocShell()->GetWrtShell();
1195 if( pVS )
1197 // Set the current page as the first.
1198 sal_uInt16 nPhysPg, nVirtPg;
1199 static_cast<SwCursorShell*>(pVS)->GetPageNum( nPhysPg, nVirtPg, true, false );
1200 if( 1 != m_pViewWin->GetCol() && 1 == nPhysPg )
1201 --nPhysPg;
1202 m_pViewWin->SetSttPage( nPhysPg );
1206 // for form shell remember design mode of draw view
1207 // of previous view shell
1208 if ( pVS && pVS->HasDrawView() )
1210 mbResetFormDesignMode = true;
1211 mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode();
1214 if( pVS )
1215 pNew = new SwViewShell( *pVS, m_pViewWin, nullptr, VSHELLFLAG_ISPREVIEW );
1216 else
1217 pNew = new SwViewShell(
1218 *static_cast<SwDocShell*>(rViewFrame.GetObjectShell())->GetDoc(),
1219 m_pViewWin, nullptr, nullptr, VSHELLFLAG_ISPREVIEW );
1221 m_pViewWin->SetViewShell( pNew );
1222 pNew->SetSfxViewShell( this );
1223 Init();
1226 SwPagePreview::~SwPagePreview()
1228 SetWindow( nullptr );
1229 SwViewShell* pVShell = m_pViewWin->GetViewShell();
1230 pVShell->SetWin(nullptr);
1231 delete pVShell;
1233 m_pViewWin.disposeAndClear();
1234 m_pHScrollbar.disposeAndClear();
1235 m_pVScrollbar.disposeAndClear();
1238 void SwPagePreview::Activate(bool bMDI)
1240 SfxViewShell::Activate(bMDI);
1241 SfxShell::Activate(bMDI);
1244 SwDocShell* SwPagePreview::GetDocShell()
1246 return dynamic_cast<SwDocShell*>( GetViewFrame().GetObjectShell() );
1249 void SwPagePreview::CreateScrollbar( bool bHori )
1251 vcl::Window *pMDI = &GetViewFrame().GetWindow();
1252 VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
1254 assert(!ppScrollbar); //check beforehand!
1255 ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
1257 ScrollDocSzChg();
1259 if (bHori)
1260 ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, HoriScrollHdl ));
1261 else
1262 ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, VertScrollHdl ));
1264 InvalidateBorder();
1265 ppScrollbar->ExtendedShow();
1268 bool SwPagePreview::ChgPage( int eMvMode, bool bUpdateScrollbar )
1270 tools::Rectangle aPixVisArea( m_pViewWin->LogicToPixel( m_aVisArea ) );
1271 bool bChg = m_pViewWin->MovePage( eMvMode ) ||
1272 eMvMode == SwPagePreviewWin::MV_CALC ||
1273 eMvMode == SwPagePreviewWin::MV_NEWWINSIZE;
1274 m_aVisArea = m_pViewWin->PixelToLogic( aPixVisArea );
1276 if( bChg )
1278 // Update statusbar
1279 SfxBindings& rBindings = GetViewFrame().GetBindings();
1281 if( bUpdateScrollbar )
1283 ScrollViewSzChg();
1285 static sal_uInt16 aInval[] =
1287 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
1288 FN_PAGEUP, FN_PAGEDOWN, 0
1290 rBindings.Invalidate( aInval );
1292 std::vector<OUString> aStringList
1294 m_sPageStr + m_pViewWin->GetStatusStr(mnPageCount),
1295 OUString()
1297 rBindings.SetState(SfxStringListItem(FN_STAT_PAGE, &aStringList));
1299 return bChg;
1302 // From here, everything was taken from the SwView.
1303 void SwPagePreview::CalcAndSetBorderPixel( SvBorder &rToFill )
1305 const StyleSettings &rSet = m_pViewWin->GetSettings().GetStyleSettings();
1306 const tools::Long nTmp = rSet.GetScrollBarSize();
1307 if (m_pVScrollbar->IsScrollbarVisible(true))
1308 rToFill.Right() = nTmp;
1309 if (m_pHScrollbar->IsScrollbarVisible(true))
1310 rToFill.Bottom() = nTmp;
1311 SetBorderPixel( rToFill );
1314 void SwPagePreview::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
1316 SvBorder aBorder;
1317 CalcAndSetBorderPixel( aBorder );
1318 tools::Rectangle aRect( rOfst, rSize );
1319 aRect += aBorder;
1320 ViewResizePixel( *m_pViewWin->GetOutDev(), aRect.TopLeft(), aRect.GetSize(),
1321 m_pViewWin->GetOutputSizePixel(),
1322 *m_pVScrollbar, *m_pHScrollbar );
1324 // Never set EditWin !
1325 // Never set VisArea !
1328 void SwPagePreview::OuterResizePixel( const Point &rOfst, const Size &rSize )
1330 SvBorder aBorder;
1331 CalcAndSetBorderPixel( aBorder );
1333 // Never set EditWin !
1335 Size aTmpSize( m_pViewWin->GetOutputSizePixel() );
1336 Point aBottomRight( m_pViewWin->PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
1337 SetVisArea( tools::Rectangle( Point(), aBottomRight ) );
1339 // Call of the DocSzChgd-Method of the scrollbars is necessary,
1340 // because from the maximum scroll range half the height of the
1341 // VisArea is always deducted.
1342 if ( m_pVScrollbar && !aTmpSize.IsEmpty() )
1344 ScrollDocSzChg();
1347 SvBorder aBorderNew;
1348 CalcAndSetBorderPixel( aBorderNew );
1349 ViewResizePixel( *m_pViewWin->GetOutDev(), rOfst, rSize, m_pViewWin->GetOutputSizePixel(),
1350 *m_pVScrollbar, *m_pHScrollbar );
1353 void SwPagePreview::SetVisArea( const tools::Rectangle &rRect )
1355 const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
1356 const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
1357 tools::Rectangle aLR(aTopLeft,aBottomRight);
1359 if(aLR == m_aVisArea)
1360 return;
1361 // No negative position, no negative size
1363 if(aLR.Top() < 0)
1365 aLR.AdjustBottom(std::abs(aLR.Top()) );
1366 aLR.SetTop( 0 );
1369 if(aLR.Left() < 0)
1371 aLR.AdjustRight(std::abs(aLR.Left()) );
1372 aLR.SetLeft( 0 );
1374 if(aLR.Right() < 0) aLR.SetRight( 0 );
1375 if(aLR.Bottom() < 0) aLR.SetBottom( 0 );
1376 if(aLR == m_aVisArea ||
1377 // Ignore empty rectangle
1378 ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
1379 return;
1381 if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
1382 return;
1384 // Before the data can be changed call an update if necessary.
1385 // Thereby ensured, that adjacent paints are correctly converted into
1386 // document coordinates.
1387 // As a precaution, we do this only when at the shell runs an action,
1388 // because then we do not really paint but the rectangles are just
1389 // bookmarked (in document coordinates).
1390 if( GetViewShell()->ActionPend() )
1391 m_pViewWin->PaintImmediately();
1393 // Set at View-Win the current size
1394 m_aVisArea = aLR;
1395 m_pViewWin->SetWinSize( aLR.GetSize() );
1396 ChgPage( SwPagePreviewWin::MV_NEWWINSIZE );
1398 m_pViewWin->Invalidate();
1401 void SwPagePreview::PrintSettingsChanged()
1403 m_pViewWin->ReInit();
1404 ChgPage( SwPagePreviewWin::MV_DOC_STT );
1407 IMPL_LINK(SwPagePreview, HoriScrollHdl, weld::Scrollbar&, rScrollbar, void)
1409 ScrollHdl(rScrollbar, true);
1412 IMPL_LINK(SwPagePreview, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
1414 ScrollHdl(rScrollbar, false);
1417 void SwPagePreview::ScrollHdl(weld::Scrollbar& rScrollbar, bool bHori)
1419 if(!GetViewShell())
1420 return;
1422 EndScrollHdl(rScrollbar, bHori);
1424 if( !bHori &&
1425 rScrollbar.get_scroll_type() == ScrollType::Drag &&
1426 Help::IsQuickHelpEnabled() &&
1427 GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1429 // Scroll how many pages??
1430 OUString sStateStr(m_sPageStr);
1431 tools::Long nThmbPos = rScrollbar.adjustment_get_value();
1432 if( 1 == m_pViewWin->GetCol() || !nThmbPos )
1433 ++nThmbPos;
1434 sStateStr += OUString::number( nThmbPos );
1435 Point aPos = m_pVScrollbar->GetParent()->OutputToScreenPixel(
1436 m_pVScrollbar->GetPosPixel());
1437 aPos.setY( m_pVScrollbar->OutputToScreenPixel(m_pVScrollbar->GetPointerPosPixel()).Y() );
1438 tools::Rectangle aRect;
1439 aRect.SetLeft( aPos.X() -8 );
1440 aRect.SetRight( aRect.Left() );
1441 aRect.SetTop( aPos.Y() );
1442 aRect.SetBottom( aRect.Top() );
1444 Help::ShowQuickHelp(m_pVScrollbar, aRect, sStateStr,
1445 QuickHelpFlags::Right|QuickHelpFlags::VCenter);
1450 void SwPagePreview::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHori)
1452 if(!GetViewShell())
1453 return;
1455 // boolean to avoid unnecessary invalidation of the window.
1456 bool bInvalidateWin = true;
1458 if (!bHori) // scroll vertically
1460 if ( Help::IsQuickHelpEnabled() )
1461 Help::ShowQuickHelp(m_pVScrollbar, tools::Rectangle(), OUString());
1462 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1463 if (pPagePreviewLay->DoesPreviewLayoutRowsFitIntoWindow() )
1465 // Scroll how many pages ??
1466 const sal_uInt16 nThmbPos = pPagePreviewLay->ConvertRelativeToAbsolutePageNum(
1467 o3tl::narrowing<sal_uInt16>(rScrollbar.adjustment_get_value()) );
1468 // adjust to new preview functionality
1469 if( nThmbPos != m_pViewWin->SelectedPage() )
1471 // consider case that page <nThmbPos>
1472 // is already visible
1473 if ( pPagePreviewLay->IsPageVisible( nThmbPos ) )
1475 pPagePreviewLay->MarkNewSelectedPage( nThmbPos );
1476 // invalidation of window is unnecessary
1477 bInvalidateWin = false;
1479 else
1481 // consider whether layout columns
1482 m_pViewWin->SetSttPage( nThmbPos );
1483 m_pViewWin->SetSelectedPage( nThmbPos );
1484 ChgPage( SwPagePreviewWin::MV_SCROLL, false );
1485 // update scrollbars
1486 ScrollViewSzChg();
1488 // update accessibility
1489 GetViewShell()->ShowPreviewSelection( nThmbPos );
1491 else
1493 // invalidation of window is unnecessary
1494 bInvalidateWin = false;
1497 else
1499 tools::Long nThmbPos = rScrollbar.adjustment_get_value();
1500 m_pViewWin->Scroll(0, nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Top());
1503 else
1505 tools::Long nThmbPos = rScrollbar.adjustment_get_value();
1506 m_pViewWin->Scroll(nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Left(), 0);
1508 // additional invalidate page status.
1509 static sal_uInt16 aInval[] =
1511 FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
1512 FN_STAT_PAGE, 0
1514 SfxBindings& rBindings = GetViewFrame().GetBindings();
1515 rBindings.Invalidate( aInval );
1516 // control invalidation of window
1517 if ( bInvalidateWin )
1519 m_pViewWin->Invalidate();
1523 Point SwPagePreview::AlignToPixel(const Point &rPt) const
1525 return m_pViewWin->PixelToLogic( m_pViewWin->LogicToPixel( rPt ) );
1528 void SwPagePreview::DocSzChgd( const Size &rSz )
1530 if( m_aDocSize == rSz )
1531 return;
1533 m_aDocSize = rSz;
1535 // #i96726#
1536 // Due to the multiple page layout it is needed to trigger recalculation
1537 // of the page preview layout, even if the count of pages is not changing.
1538 mnPageCount = GetViewShell()->GetNumPages();
1540 if( m_aVisArea.GetWidth() )
1542 ChgPage( SwPagePreviewWin::MV_CALC );
1543 ScrollDocSzChg();
1545 m_pViewWin->Invalidate();
1549 void SwPagePreview::ScrollViewSzChg()
1551 if(!GetViewShell())
1552 return ;
1554 bool bShowVScrollbar = false, bShowHScrollbar = false;
1556 if(m_pVScrollbar)
1558 if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
1560 //vertical scrolling by row
1561 // adjust to new preview functionality
1562 const sal_uInt16 nVisPages = m_pViewWin->GetRow() * m_pViewWin->GetCol();
1564 m_pVScrollbar->SetVisibleSize( nVisPages );
1565 // set selected page as scroll bar position,
1566 // if it is visible.
1567 SwPagePreviewLayout* pPagePreviewLay = GetViewShell()->PagePreviewLayout();
1568 if ( pPagePreviewLay->IsPageVisible( m_pViewWin->SelectedPage() ) )
1570 m_pVScrollbar->SetThumbPos(
1571 pPagePreviewLay->ConvertAbsoluteToRelativePageNum(m_pViewWin->SelectedPage()) );
1573 else
1575 m_pVScrollbar->SetThumbPos(
1576 pPagePreviewLay->ConvertAbsoluteToRelativePageNum(m_pViewWin->GetSttPage()) );
1578 m_pVScrollbar->SetLineSize( m_pViewWin->GetCol() );
1579 m_pVScrollbar->SetPageSize( nVisPages );
1580 // calculate and set scrollbar range
1581 Range aScrollbarRange( 1, pPagePreviewLay->GetMaxPreviewPages() );
1582 // increase range by one, because left-top-corner is left blank.
1583 ++aScrollbarRange.Max();
1584 // increase range in order to access all pages
1585 aScrollbarRange.Max() += ( nVisPages - 1 );
1586 m_pVScrollbar->SetRange( aScrollbarRange );
1588 bShowVScrollbar = nVisPages < pPagePreviewLay->GetMaxPreviewPages();
1590 else //vertical scrolling by pixel
1592 const tools::Rectangle& rDocRect = m_pViewWin->GetPaintedPreviewDocRect();
1593 const Size aPreviewSize =
1594 GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
1595 m_pVScrollbar->SetRangeMax(aPreviewSize.Height()) ;
1596 tools::Long nVisHeight = rDocRect.GetHeight();
1597 m_pVScrollbar->SetVisibleSize( nVisHeight );
1598 m_pVScrollbar->SetThumbPos( rDocRect.Top() );
1599 m_pVScrollbar->SetLineSize( nVisHeight / 10 );
1600 m_pVScrollbar->SetPageSize( nVisHeight / 2 );
1602 bShowVScrollbar = true;
1605 if (!mbVScrollbarEnabled)
1606 bShowVScrollbar = false;
1608 ShowVScrollbar(bShowVScrollbar);
1610 if(m_pHScrollbar)
1612 const tools::Rectangle& rDocRect = m_pViewWin->GetPaintedPreviewDocRect();
1613 const Size aPreviewSize =
1614 GetViewShell()->PagePreviewLayout()->GetPreviewDocSize();
1615 Range aRange(0,0);
1617 if(rDocRect.GetWidth() < aPreviewSize.Width())
1619 bShowHScrollbar = true;
1621 tools::Long nVisWidth = rDocRect.GetWidth();
1622 tools::Long nThumb = rDocRect.Left();
1623 aRange = Range(0, aPreviewSize.Width());
1625 m_pHScrollbar->SetRange( aRange );
1626 m_pHScrollbar->SetVisibleSize( nVisWidth );
1627 m_pHScrollbar->SetThumbPos( nThumb );
1628 m_pHScrollbar->SetLineSize( nVisWidth / 10 );
1629 m_pHScrollbar->SetPageSize( nVisWidth / 2 );
1632 if (!mbHScrollbarEnabled)
1633 bShowHScrollbar = false;
1635 ShowHScrollbar(bShowHScrollbar);
1639 void SwPagePreview::ScrollDocSzChg()
1641 ScrollViewSzChg();
1644 // All about printing
1645 SfxPrinter* SwPagePreview::GetPrinter( bool bCreate )
1647 return m_pViewWin->GetViewShell()->getIDocumentDeviceAccess().getPrinter( bCreate );
1650 sal_uInt16 SwPagePreview::SetPrinter( SfxPrinter *pNew, SfxPrinterChangeFlags nDiffFlags )
1652 SwViewShell &rSh = *GetViewShell();
1653 SfxPrinter* pOld = rSh.getIDocumentDeviceAccess().getPrinter( false );
1654 if ( pOld && pOld->IsPrinting() )
1655 return SFX_PRINTERROR_BUSY;
1657 SwEditShell &rESh = static_cast<SwEditShell&>(rSh); //Buh...
1658 if( ( SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP ) & nDiffFlags )
1660 rSh.getIDocumentDeviceAccess().setPrinter( pNew, true, true );
1661 if( nDiffFlags & SfxPrinterChangeFlags::PRINTER )
1662 rESh.SetModified();
1664 if ( ( nDiffFlags & SfxPrinterChangeFlags::OPTIONS ) == SfxPrinterChangeFlags::OPTIONS )
1665 ::SetPrinter( &rSh.getIDocumentDeviceAccess(), pNew, false );
1667 const bool bChgOri = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_ORIENTATION);
1668 const bool bChgSize = bool(nDiffFlags & SfxPrinterChangeFlags::CHG_SIZE);
1669 if ( bChgOri || bChgSize )
1671 rESh.StartAllAction();
1672 if ( bChgOri )
1673 rSh.ChgAllPageOrientation( pNew->GetOrientation() );
1674 if ( bChgSize )
1676 Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
1677 rSh.ChgAllPageSize( aSz );
1679 if( !m_bNormalPrint )
1680 m_pViewWin->CalcWish( m_pViewWin->GetRow(), m_pViewWin->GetCol() );
1681 rESh.SetModified();
1682 rESh.EndAllAction();
1684 static sal_uInt16 aInval[] =
1686 SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
1687 SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
1689 #if OSL_DEBUG_LEVEL > 0
1691 const sal_uInt16* pPtr = aInval + 1;
1692 do {
1693 OSL_ENSURE( *(pPtr - 1) < *pPtr, "wrong sorting!" );
1694 } while( *++pPtr );
1696 #endif
1698 GetViewFrame().GetBindings().Invalidate(aInval);
1701 return 0;
1704 bool SwPagePreview::HasPrintOptionsPage() const
1706 return true;
1709 std::unique_ptr<SfxTabPage> SwPagePreview::CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
1710 const SfxItemSet &rOptions)
1712 return ::CreatePrintOptionsPage(pPage, pController, rOptions, !m_bNormalPrint);
1715 void SwPagePreviewWin::SetViewShell( SwViewShell* pShell )
1717 mpViewShell = pShell;
1718 if ( mpViewShell && mpViewShell->IsPreview() )
1720 mpPgPreviewLayout = mpViewShell->PagePreviewLayout();
1724 void SwPagePreviewWin::RepaintCoreRect( const SwRect& rRect )
1726 // #i24183#
1727 if ( mpPgPreviewLayout->PreviewLayoutValid() )
1729 mpPgPreviewLayout->Repaint( tools::Rectangle( rRect.Pos(), rRect.SSize() ) );
1733 /** method to adjust preview to a new zoom factor
1735 #i19975# also consider zoom type - adding parameter <_eZoomType>
1737 void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
1738 const SvxZoomType _eZoomType )
1740 // #i19975# consider zoom type
1741 if ( _eZoomType == SvxZoomType::WHOLEPAGE )
1743 mnRow = 1;
1744 mnCol = 1;
1745 mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize );
1746 mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
1747 mnSttPage, maPaintedPreviewDocRect );
1748 SetSelectedPage( mnSttPage );
1749 SetPagePreview(mnRow, mnCol);
1750 maScale = GetMapMode().GetScaleX();
1752 else if ( _nZoomFactor != 0 )
1754 // calculate new scaling and set mapping mode appropriately.
1755 Fraction aNewScale( _nZoomFactor, 100 );
1756 MapMode aNewMapMode = GetMapMode();
1757 aNewMapMode.SetScaleX( aNewScale );
1758 aNewMapMode.SetScaleY( aNewScale );
1759 SetMapMode( aNewMapMode );
1761 // calculate new start position for preview paint
1762 Size aNewWinSize = PixelToLogic( maPxWinSize );
1763 Point aNewPaintStartPos =
1764 mpPgPreviewLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
1766 // remember new scaling and prepare preview paint
1767 // Note: paint of preview will be performed by a corresponding invalidate
1768 // due to property changes.
1769 maScale = aNewScale;
1770 mpPgPreviewLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
1771 mnSttPage, maPaintedPreviewDocRect );
1777 * pixel scrolling - horizontally always or vertically
1778 * when less than the desired number of rows fits into
1779 * the view
1781 void SwPagePreviewWin::Scroll(tools::Long nXMove, tools::Long nYMove, ScrollFlags /*nFlags*/)
1783 maPaintedPreviewDocRect.Move(nXMove, nYMove);
1784 mpPgPreviewLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(),
1785 maPxWinSize, mnSttPage,
1786 maPaintedPreviewDocRect );
1790 bool SwPagePreview::HandleWheelCommands( const CommandEvent& rCEvt )
1792 bool bOk = false;
1793 const CommandWheelData* pWData = rCEvt.GetWheelData();
1794 if( pWData && CommandWheelMode::ZOOM == pWData->GetMode() )
1796 sal_uInt16 nFactor = GetViewShell()->GetViewOptions()->GetZoom();
1797 const sal_uInt16 nOffset = 10;
1798 if( 0L > pWData->GetDelta() )
1800 nFactor -= nOffset;
1801 if(nFactor < MIN_PREVIEW_ZOOM)
1802 nFactor = MIN_PREVIEW_ZOOM;
1804 else
1806 nFactor += nOffset;
1807 if(nFactor > MAX_PREVIEW_ZOOM)
1808 nFactor = MAX_PREVIEW_ZOOM;
1810 SetZoom(SvxZoomType::PERCENT, nFactor);
1811 bOk = true;
1813 else
1814 bOk = m_pViewWin->HandleScrollCommand( rCEvt, m_pHScrollbar, m_pVScrollbar );
1815 return bOk;
1818 uno::Reference< css::accessibility::XAccessible >
1819 SwPagePreviewWin::CreateAccessible()
1821 SolarMutexGuard aGuard; // this should have happened already!!!
1822 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
1823 OSL_ENSURE( GetViewShell() != nullptr, "We need a view shell" );
1824 css::uno::Reference< css::accessibility::XAccessible > xAcc = GetAccessible( false );
1825 if (xAcc.is())
1827 return xAcc;
1829 if (mpViewShell)
1831 css::uno::Reference< css::accessibility::XAccessible > xAccPreview = mpViewShell->CreateAccessiblePreview();
1832 SetAccessible(xAccPreview);
1834 #endif
1835 return GetAccessible( false );
1838 void SwPagePreview::ShowHScrollbar(bool bShow)
1840 m_pHScrollbar->Show(bShow);
1841 InvalidateBorder();
1844 void SwPagePreview::ShowVScrollbar(bool bShow)
1846 m_pVScrollbar->Show(bShow);
1847 InvalidateBorder();
1850 void SwPagePreview::EnableHScrollbar(bool bEnable)
1852 if (mbHScrollbarEnabled != bEnable)
1854 mbHScrollbarEnabled = bEnable;
1855 ScrollViewSzChg();
1859 void SwPagePreview::EnableVScrollbar(bool bEnable)
1861 if (mbVScrollbarEnabled != bEnable)
1863 mbVScrollbarEnabled = bEnable;
1864 ScrollViewSzChg();
1868 void SwPagePreview::SetZoom(SvxZoomType eType, sal_uInt16 nFactor)
1870 SwViewShell& rSh = *GetViewShell();
1871 SwViewOption aOpt(*rSh.GetViewOptions());
1872 // perform action only on changes of zoom or zoom type.
1873 if ( aOpt.GetZoom() != nFactor ||
1874 aOpt.GetZoomType() != eType )
1876 aOpt.SetZoom(nFactor);
1877 aOpt.SetZoomType(eType);
1878 rSh.ApplyViewOptions( aOpt );
1879 lcl_InvalidateZoomSlots(GetViewFrame().GetBindings());
1880 // #i19975# also consider zoom type
1881 m_pViewWin->AdjustPreviewToNewZoom( nFactor, eType );
1882 ScrollViewSzChg();
1886 /** adjust position of vertical scrollbar */
1887 void SwPagePreview::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
1889 if ( m_pVScrollbar )
1891 m_pVScrollbar->SetThumbPos( _nNewThumbPos );
1895 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */