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