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