LibreOffice Module sd (master) 1
viewshe2.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 <com/sun/star/embed/EmbedVerbs.hpp>
21#include <com/sun/star/embed/XEmbeddedObject.hpp>
22
23#include <ViewShell.hxx>
24#include <ViewShellHint.hxx>
25
27#include <FactoryIds.hxx>
28
29#include <svx/svxids.hrc>
30#include <svx/svdpagv.hxx>
31#include <sfx2/dispatch.hxx>
32#include <svx/ruler.hxx>
33#include <editeng/outliner.hxx>
34#include <svtools/ehdl.hxx>
35#include <svx/svdoole2.hxx>
36#include <svtools/sfxecode.hxx>
39#include <osl/diagnose.h>
40
41#include <strings.hrc>
42#include <app.hrc>
43#include <unokywds.hxx>
44
45#include <sdundogr.hxx>
46#include <FrameView.hxx>
47#include <sdresid.hxx>
48#include <drawdoc.hxx>
49#include <View.hxx>
50#include <fupoor.hxx>
51#include <Client.hxx>
52#include <DrawDocShell.hxx>
53#include <sdpage.hxx>
54#include <DrawViewShell.hxx>
55#include <ViewShellBase.hxx>
56
57#include <Window.hxx>
58
59#include <sfx2/viewfrm.hxx>
60#include <svtools/soerr.hxx>
61#include <svx/charthelper.hxx>
62#include <comphelper/lok.hxx>
63
64using namespace com::sun::star;
65
66namespace sd {
67
72{
74 {
75 ::tools::Long nW = static_cast<::tools::Long>(mpContentWindow->GetVisibleWidth() * 32000);
76 ::tools::Long nX = static_cast<::tools::Long>(mpContentWindow->GetVisibleX() * 32000);
77 mpHorizontalScrollBar->SetVisibleSize(nW);
78 mpHorizontalScrollBar->SetThumbPos(nX);
79 nW = 32000 - nW;
80 ::tools::Long nLine = static_cast<::tools::Long>(mpContentWindow->GetScrlLineWidth() * nW);
81 ::tools::Long nPage = static_cast<::tools::Long>(mpContentWindow->GetScrlPageWidth() * nW);
82 mpHorizontalScrollBar->SetLineSize(nLine);
83 mpHorizontalScrollBar->SetPageSize(nPage);
84 }
85
87 {
88 ::tools::Long nH = static_cast<::tools::Long>(mpContentWindow->GetVisibleHeight() * 32000);
89 ::tools::Long nY = static_cast<::tools::Long>(mpContentWindow->GetVisibleY() * 32000);
90
91 if(IsPageFlipMode()) // ie in zoom mode where no panning
92 {
93 SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
94 sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) / 2;
95 sal_uInt16 nTotalPages = GetDoc()->GetSdPageCount(pPage->GetPageKind());
96 mpVerticalScrollBar->SetRange(Range(0,256*nTotalPages));
97 mpVerticalScrollBar->SetVisibleSize(256);
98 mpVerticalScrollBar->SetThumbPos(256*nCurPage);
99 mpVerticalScrollBar->SetLineSize(256);
100 mpVerticalScrollBar->SetPageSize(256);
101 }
102 else
103 {
104 mpVerticalScrollBar->SetRange(Range(0,32000));
105 mpVerticalScrollBar->SetVisibleSize(nH);
106 mpVerticalScrollBar->SetThumbPos(nY);
107 nH = 32000 - nH;
108 ::tools::Long nLine = static_cast<::tools::Long>(mpContentWindow->GetScrlLineHeight() * nH);
109 ::tools::Long nPage = static_cast<::tools::Long>(mpContentWindow->GetScrlPageHeight() * nH);
110 mpVerticalScrollBar->SetLineSize(nLine);
111 mpVerticalScrollBar->SetPageSize(nPage);
112 }
113 }
114
115 if (mbHasRulers)
116 {
117 UpdateHRuler();
118 UpdateVRuler();
119 }
120
121}
126{
127 VirtHScrollHdl(mpHorizontalScrollBar);
128}
129
134{
135 double fX = static_cast<double>(pHScroll->GetThumbPos()) / pHScroll->GetRange().Len();
136
137 // scroll all windows of the column
138 ::sd::View* pView = GetView();
139 OutlinerView* pOLV = nullptr;
140
141 if (pView)
142 pOLV = pView->GetTextEditOutlinerView();
143
144 if (pOLV)
145 pOLV->HideCursor();
146
147 mpContentWindow->SetVisibleXY(fX, -1);
148
150 Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
151 aVisArea.SetPos(aVisAreaPos);
152 GetDocSh()->SetVisArea(aVisArea);
153
154 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
155 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
156 VisAreaChanged(aVisAreaWin);
157
158 if (pView)
159 {
160 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
161 }
162
163 if (pOLV)
164 pOLV->ShowCursor();
165
166 if (mbHasRulers)
167 UpdateHRuler();
168}
169
174{
175 VirtVScrollHdl(mpVerticalScrollBar);
176}
177
182{
183 if(IsPageFlipMode())
184 {
185 SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
186 sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) >> 1;
187 sal_uInt16 nNewPage = static_cast<sal_uInt16>(pVScroll->GetThumbPos())/256;
188 if( nCurPage != nNewPage )
189 static_cast<DrawViewShell*>(this)->SwitchPage(nNewPage);
190 }
191 else //panning mode
192 {
193 double fY = static_cast<double>(pVScroll->GetThumbPos()) / pVScroll->GetRange().Len();
194
195 ::sd::View* pView = GetView();
196 OutlinerView* pOLV = nullptr;
197
198 if (pView)
199 pOLV = pView->GetTextEditOutlinerView();
200
201 if (pOLV)
202 pOLV->HideCursor();
203
204 mpContentWindow->SetVisibleXY(-1, fY);
205
207 Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
208 aVisArea.SetPos(aVisAreaPos);
209 GetDocSh()->SetVisArea(aVisArea);
210
211 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
212 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
213 VisAreaChanged(aVisAreaWin);
214
215 if (pView)
216 {
217 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
218 }
219
220 if (pOLV)
221 pOLV->ShowCursor();
222
223 if (mbHasRulers)
224 UpdateVRuler();
225
226 }
227}
228
230{
231 return nullptr;
232}
233
235{
236 return nullptr;
237}
238
240{
241}
242
244{
245}
246
252{
253 if ( nLinesX )
254 {
255 nLinesX *= mpHorizontalScrollBar->GetLineSize();
256 }
257 if ( nLinesY )
258 {
259 nLinesY *= mpVerticalScrollBar->GetLineSize();
260 }
261
262 Scroll(nLinesX, nLinesY);
263}
264
266{
267 if (nScrollX)
268 {
269 ::tools::Long nNewThumb = mpHorizontalScrollBar->GetThumbPos() + nScrollX;
270 mpHorizontalScrollBar->SetThumbPos(nNewThumb);
271 }
272 if (nScrollY)
273 {
274 ::tools::Long nNewThumb = mpVerticalScrollBar->GetThumbPos() + nScrollY;
275 mpVerticalScrollBar->SetThumbPos(nNewThumb);
276 }
277 double fX = static_cast<double>(mpHorizontalScrollBar->GetThumbPos()) /
278 mpHorizontalScrollBar->GetRange().Len();
279 double fY = static_cast<double>(mpVerticalScrollBar->GetThumbPos()) /
280 mpVerticalScrollBar->GetRange().Len();
281
282 GetActiveWindow()->SetVisibleXY(fX, fY);
283
285 Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
286 aVisArea.SetPos(aVisAreaPos);
287 GetDocSh()->SetVisArea(aVisArea);
288
289 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
290 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
291 VisAreaChanged(aVisAreaWin);
292
293 ::sd::View* pView = GetView();
294 if (pView)
295 {
296 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
297 }
298
299 if (mbHasRulers)
300 {
301 UpdateHRuler();
302 UpdateVRuler();
303 }
304}
305
310{
311 Fraction aUIScale(nZoom, 100);
312 aUIScale *= GetDoc()->GetUIScale();
313
315 mpHorizontalRuler->SetZoom(aUIScale);
316
317 if (mpVerticalRuler)
318 mpVerticalRuler->SetZoom(aUIScale);
319
320 if (mpContentWindow)
321 {
322 mpContentWindow->SetZoomIntegral(nZoom);
323
324 // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
325 // of the window. It needs - like Scroll(ScrollFlags::Children) does - also to move
326 // the child windows. I am trying InvalidateFlags::Children here which makes things better,
327 // but does not solve the problem completely. Need to ask PL.
328 mpContentWindow->Invalidate(InvalidateFlags::Children);
329 }
330
331 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
332 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
333 VisAreaChanged(aVisAreaWin);
334
335 ::sd::View* pView = GetView();
336 if (pView)
337 {
338 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
339 }
340
342}
343
345{
346 if (mpContentWindow)
347 {
348 return mpContentWindow->GetZoom();
349 }
350
351 return 0;
352}
353
358void ViewShell::SetZoomRect(const ::tools::Rectangle& rZoomRect)
359{
360 ::tools::Long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
361 Fraction aUIScale(nZoom, 100);
362 aUIScale *= GetDoc()->GetUIScale();
363
365
367 mpHorizontalRuler->SetZoom(aUIScale);
368
369 if (mpVerticalRuler)
370 mpVerticalRuler->SetZoom(aUIScale);
371
372 if (mpContentWindow)
373 {
374 Point aNewPos = mpContentWindow->GetWinViewPos();
375 aNewPos.setX( aPos.X() );
376 aNewPos.setY( aPos.Y() );
377 mpContentWindow->SetZoomIntegral(nZoom);
378 mpContentWindow->SetWinViewPos(aNewPos);
379 mpContentWindow->UpdateMapOrigin();
380
381 // When tiled rendering, UpdateMapOrigin() doesn't touch the map mode.
383 // #i74769# see above
384 mpContentWindow->Invalidate(InvalidateFlags::Children);
385 }
386
387 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
388 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
389 VisAreaChanged(aVisAreaWin);
390
391 ::sd::View* pView = GetView();
392 if (pView)
393 {
394 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
395 }
396
398}
399
403void ViewShell::InitWindows(const Point& rViewOrigin, const Size& rViewSize,
404 const Point& rWinPos, bool bUpdate)
405{
406 if (mpContentWindow)
407 {
408 mpContentWindow->SetViewOrigin(rViewOrigin);
409 mpContentWindow->SetViewSize(rViewSize);
410 mpContentWindow->SetWinViewPos(rWinPos);
411
412 if ( bUpdate )
413 {
414 mpContentWindow->UpdateMapOrigin();
415 mpContentWindow->Invalidate();
416 }
417 }
418
419 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
420 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
421 VisAreaChanged(aVisAreaWin);
422
423 ::sd::View* pView = GetView();
424 if (pView)
425 {
426 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
427 }
428}
429
434{
435 if (mpContentWindow)
436 mpContentWindow->Invalidate();
437}
438
442void ViewShell::DrawMarkRect(const ::tools::Rectangle& rRect) const
443{
444 if (mpContentWindow)
445 {
446 mpContentWindow->InvertTracking(rRect, ShowTrackFlags::Object | ShowTrackFlags::TrackWindow);
447 }
448}
449
450void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
451 ::tools::Long nLeft, ::tools::Long nRight,
452 ::tools::Long nUpper, ::tools::Long nLower, bool bScaleAll,
453 Orientation eOrientation, sal_uInt16 nPaperBin,
454 bool bBackgroundFullSize)
455{
456 const sal_uInt16 nMasterPageCnt(GetDoc()->GetMasterSdPageCount(ePageKind));
457 const sal_uInt16 nPageCnt(GetDoc()->GetSdPageCount(ePageKind));
458
459 if(0 == nPageCnt && 0 == nMasterPageCnt)
460 {
461 return;
462 }
463
464 std::unique_ptr<SdUndoGroup> pUndoGroup;
465 SfxViewShell* pViewShell(GetViewShell());
466 if (pViewShell)
467 {
468 pUndoGroup.reset(new SdUndoGroup(GetDoc()));
469 pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
470 }
472
473 // use Model-based method at SdDrawDocument
475 rNewSize,
476 ePageKind,
477 pUndoGroup.get(),
478 nLeft,
479 nRight,
480 nUpper,
481 nLower,
482 bScaleAll,
483 eOrientation,
484 nPaperBin,
485 bBackgroundFullSize);
486
487 // adjust handout page to new format of the standard page
488 if(0 != nPageCnt && ((ePageKind == PageKind::Standard) || (ePageKind == PageKind::Handout)))
489 {
491 }
492
493 // handed over undo group to undo manager
494 if (pViewShell)
495 {
496 pViewShell->GetViewFrame().GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
497 }
498
499 // calculate View-Sizes
500 SdPage* pPage(0 != nPageCnt
501 ? GetDoc()->GetSdPage(0, ePageKind)
502 : GetDoc()->GetMasterSdPage(0, ePageKind));
503 const ::tools::Long nWidth(pPage->GetSize().Width());
504 const ::tools::Long nHeight(pPage->GetSize().Height());
505 const Point aPageOrg(nWidth, nHeight / 2);
506 const Size aViewSize(nWidth * 3, nHeight * 2);
507 Point aVisAreaPos;
508 ::sd::View* pView(GetView());
509 const Point aNewOrigin(pPage->GetLeftBorder(), pPage->GetUpperBorder());
510
511 InitWindows(aPageOrg, aViewSize, Point(-1, -1), true);
512
513 if ( GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
514 {
515 aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
516 }
517
518 if (pView)
519 {
520 pView->SetWorkArea(::tools::Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize));
521 }
522
524
525 if (pView)
526 {
527 pView->GetSdrPageView()->SetPageOrigin(aNewOrigin);
528 }
529
530 if(nullptr != pViewShell)
531 {
532 pViewShell->GetViewFrame().GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
533 // zoom onto (new) page size
534 pViewShell->GetViewFrame().GetDispatcher()->Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
535 }
536
538}
539
543void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&)
544{
545 ::tools::Long nZoom = static_cast<::tools::Long>(static_cast<double>(rZoomX) * 100);
546 SetZoom(nZoom);
547}
548
550{
551 SfxViewShell* pViewShell = GetViewShell();
552 OSL_ASSERT (pViewShell!=nullptr);
553
554 if (pViewShell->GetWindow() != pWin)
555 {
556 // #i31551# was wrong, it may have been a problem with the repaint at that time.
557 // For transparent form controls, it is necessary to have that flag set, all apps
558 // do set it. Enabling again.
559 if (pWin)
560 {
562 }
563 }
564
565 if (mpActiveWindow.get() != pWin)
566 mpActiveWindow = pWin;
567
568 // The rest of this function is not guarded anymore against calling this
569 // method with an already active window because the functions may still
570 // point to the old window when the new one has already been assigned to
571 // pWindow elsewhere.
572 ::sd::View* pView = GetView();
573 if (pView)
574 {
575 pView->SetActualWin(pWin->GetOutDev());
576 }
578 {
579 GetCurrentFunction()->SetWindow(pWin);
580 }
581}
582
584{
585 bool bReturn = false;
586
587 if (bool(rHEvt.GetMode()))
588 {
590 {
591 bReturn = GetCurrentFunction()->RequestHelp(rHEvt);
592 }
593 }
594
595 return bReturn;
596}
597
599{
600 mpFrameView = pNewFrameView;
602}
603
604/*************************************************************************
605|*
606|* Read FrameViews data and set actual views data
607|*
608\************************************************************************/
609
611{
612}
613
614/*************************************************************************
615|*
616|* Write actual views data to FrameView
617|*
618\************************************************************************/
619
621{
622}
623
624bool ViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb)
625{
626 ErrCode aErrCode = ERRCODE_NONE;
627
629 bool bAbort = false;
630 GetDocSh()->SetWaitCursor( true );
631 SfxViewShell* pViewShell = GetViewShell();
632 OSL_ASSERT (pViewShell!=nullptr);
633 bool bChangeDefaultsForChart = false;
634
635 uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
636 if ( !xObj.is() )
637 {
638 // provide OLE object to empty OLE object
639 OUString aName = pObj->GetProgName();
640 OUString aObjName;
641 SvGlobalName aClass;
642
643 if( aName == "StarChart" || aName == "StarOrg" )
644 {
645 if( SvtModuleOptions().IsChart() )
646 {
647 aClass = SvGlobalName( SO3_SCH_CLASSID );
648 bChangeDefaultsForChart = true;
649 }
650 }
651 else if( aName == "StarCalc" )
652 {
653 if( SvtModuleOptions().IsCalc() )
654 aClass = SvGlobalName( SO3_SC_CLASSID );
655 }
656 else if( aName == "StarMath" )
657 {
658 if( SvtModuleOptions().IsMath() )
659 aClass = SvGlobalName( SO3_SM_CLASSID );
660 }
661
662 if ( aClass != SvGlobalName() )
664
665 if( !xObj.is() )
666 {
667 aName.clear();
668
669 // call dialog "insert OLE object"
670 GetDocSh()->SetWaitCursor( false );
671 pViewShell->GetViewFrame().GetDispatcher()->Execute(
672 SID_INSERT_OBJECT,
673 SfxCallMode::SYNCHRON | SfxCallMode::RECORD);
674 xObj = pObj->GetObjRef();
675 GetDocSh()->SetWaitCursor( true );
676
677 if (!xObj.is())
678 {
679 bAbort = true;
680 }
681 }
682
683 if ( xObj.is() )
684 {
685 // OLE object is no longer empty
686 pObj->SetEmptyPresObj(false);
687 pObj->SetOutlinerParaObject(std::nullopt);
688 pObj->ClearGraphic();
689
690 // the empty OLE object gets a new IPObj
691 if (!aName.isEmpty())
692 {
693 pObj->SetObjRef(xObj);
694 pObj->SetName(aObjName);
695 pObj->SetPersistName(aObjName);
696 }
697 else
698 {
699 // insertion was done by the dialog
700 pObj->SetObjRef(xObj);
701 }
702
703 ::tools::Rectangle aRect = pObj->GetLogicRect();
704
705 if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
706 {
707 awt::Size aSz;
708 aSz.Width = aRect.GetWidth();
709 aSz.Height = aRect.GetHeight();
710 xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
711 }
712
713 GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
714
715 nVerb = embed::EmbedVerbs::MS_OLEVERB_SHOW;
716 }
717 else
718 {
719 aErrCode = ERRCODE_SFX_OLEGENERAL;
720 }
721 }
722
723 if( aErrCode == ERRCODE_NONE )
724 {
725 ::sd::View* pView = GetView();
726
727 if (pView->IsTextEdit())
728 {
729 pView->SdrEndTextEdit();
730 }
731
732 SfxInPlaceClient* pSdClient =
733 pViewShell->FindIPClient(pObj->GetObjRef(), GetActiveWindow());
734
735 if ( !pSdClient )
736 {
737 pSdClient = new Client(pObj, this, GetActiveWindow());
738 }
739
740 ::tools::Rectangle aRect = pObj->GetLogicRect();
741
742 {
743 // #i118485# center on BoundRect for activation,
744 // OLE may be sheared/rotated now
745 const ::tools::Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
746 const Point aDelta(rBoundRect.Center() - aRect.Center());
747 aRect.Move(aDelta.X(), aDelta.Y());
748 }
749
750 Size aDrawSize = aRect.GetSize();
751
752 MapMode aMapMode( GetDoc()->GetScaleUnit() );
753 Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
754 if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
755 aObjAreaSize = aDrawSize;
756
757 Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
758 Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
759 aScaleWidth.ReduceInaccurate(10); // compatible to the SdrOle2Obj
760 aScaleHeight.ReduceInaccurate(10);
761 pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
762
763 // visible section is only changed in-place!
764 aRect.SetSize(aObjAreaSize);
765 // the object area size must be set after scaling, since it triggers the resizing
766 pSdClient->SetObjArea(aRect);
767
768 if( bChangeDefaultsForChart && xObj.is())
769 {
771 }
772
773 pSdClient->DoVerb(nVerb); // if necessary, ErrCode is outputted by Sfx
774 pViewShell->GetViewFrame().GetBindings().Invalidate(
775 SID_NAVIGATOR_STATE, true);
776 }
777
778 GetDocSh()->SetWaitCursor( false );
779
780 if (aErrCode != ERRCODE_NONE && !bAbort)
781 {
782 ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, OUString() ) );
783 }
784
785 return aErrCode == ERRCODE_NONE;
786}
787
791const ::tools::Rectangle& ViewShell::GetAllWindowRect()
792{
794 mpContentWindow->OutputToScreenPixel(Point(0,0)));
796}
797
799{
800 // zoom onto VisArea from FrameView
801 GetViewShell()->GetViewFrame().GetDispatcher()->Execute(SID_SIZE_VISAREA,
802 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
803}
804
806{
807 // writing of our data is always done in WriteFrameViewData()
809}
810
814void ViewShell::SetRuler(bool bRuler)
815{
816 mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
817
819 {
820 if (mbHasRulers)
821 {
822 mpHorizontalRuler->Show();
823 }
824 else
825 {
826 mpHorizontalRuler->Hide();
827 }
828 }
829
830 if (mpVerticalRuler)
831 {
832 if (mbHasRulers)
833 {
834 mpVerticalRuler->Show();
835 }
836 else
837 {
838 mpVerticalRuler->Hide();
839 }
840 }
841
842 OSL_ASSERT(GetViewShell()!=nullptr);
843 if (IsMainViewShell())
845}
846
848{
851
854}
855
857 const AcceptDropEvent& rEvt,
858 DropTargetHelper& rTargetHelper,
859 ::sd::Window* /*pTargetWindow*/,
860 sal_uInt16 /*nPage*/,
861 SdrLayerID nLayer)
862{
863 ::sd::View* pView = GetView();
864 return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, nLayer ) : DND_ACTION_NONE );
865}
866
868 const ExecuteDropEvent& rEvt,
869 DropTargetHelper& /*rTargetHelper*/,
870 ::sd::Window* pTargetWindow,
871 sal_uInt16 nPage,
872 SdrLayerID nLayer)
873{
874 ::sd::View* pView = GetView();
875 return pView ? pView->ExecuteDrop( rEvt, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE;
876}
877
878void ViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rSequence )
879{
880 const sal_Int32 nIndex = rSequence.getLength();
881 rSequence.realloc( nIndex + 1 );
882 auto pSequence = rSequence.getArray();
883
884 OSL_ASSERT (GetViewShell()!=nullptr);
885 // Get the view id from the view shell in the center pane. This will
886 // usually be the called view shell, but to be on the safe side we call
887 // the main view shell explicitly.
889 if (GetViewShellBase().GetMainViewShell() != nullptr)
890 nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
891 pSequence[nIndex].Name = sUNO_View_ViewId;
892 pSequence[nIndex].Value <<= "view" + OUString::number( static_cast<sal_uInt16>(nViewID));
893
895}
896
897void ViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence )
898{
899 mpFrameView->ReadUserDataSequence( rSequence );
900}
901
902void ViewShell::VisAreaChanged(const ::tools::Rectangle& /*rRect*/)
903{
904 OSL_ASSERT (GetViewShell()!=nullptr);
906}
907
908void ViewShell::SetWinViewPos(const Point& rWinPos)
909{
910 if (mpContentWindow)
911 {
912 mpContentWindow->SetWinViewPos(rWinPos);
913
914 mpContentWindow->UpdateMapOrigin();
915 mpContentWindow->Invalidate();
916 }
917
918 if (mbHasRulers)
919 {
920 UpdateHRuler();
921 UpdateVRuler();
922 }
923
925
926 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
927 ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
928 VisAreaChanged(aVisAreaWin);
929
930 ::sd::View* pView = GetView();
931 if (pView)
932 {
933 pView->VisAreaChanged(GetActiveWindow()->GetOutDev());
934 }
935}
936
938{
939 return mpContentWindow->GetWinViewPos();
940}
941
943{
944 return mpContentWindow->GetViewOrigin();
945}
946
947} // end of namespace sd
948
949/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void AdaptDefaultsForChart(const css::uno::Reference< css::embed::XEmbeddedObject > &xEmbObj)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
void ReduceInaccurate(unsigned nSignificantBits)
HelpEventMode GetMode() const
void HideCursor(bool bDeactivate=false)
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
tools::Long Len() const
virtual tools::Long GetThumbPos() const override
virtual Range GetRange() const override
void AdaptPageSizeForAllPages(const Size &rNewSize, PageKind ePageKind, SdUndoGroup *pUndoGroup=nullptr, tools::Long nLeft=0, tools::Long nRight=0, tools::Long nUpper=0, tools::Long nLower=0, bool bScaleAll=false, Orientation eOrientation=Orientation::Landscape, sal_uInt16 nPaperBin=0, bool bBackgroundFullSize=false)
Definition: drawdoc.cxx:412
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
PageKind GetPageKind() const
Definition: sdpage.hxx:205
void CreateTitleAndLayout(bool bInit=false, bool bCreate=false)
Definition: sdpage.cxx:793
void SetWorkArea(const tools::Rectangle &rRect)
const Fraction & GetUIScale() const
const OutlinerView * GetTextEditOutlinerView() const
virtual bool IsTextEdit() const final override
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
void SetEmptyPresObj(bool bEpt)
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual void SetName(const OUString &rStr, const bool bSetChanged=true)
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const OUString & GetProgName() const
void ClearGraphic()
void SetObjRef(const css::uno::Reference< css::embed::XEmbeddedObject > &rNewObjRef)
Size GetOrigObjSize(MapMode const *pTargetMapMode=nullptr) const
void SetPersistName(const OUString &rPersistName, SvxOle2Shape *pCreator=nullptr)
bool IsChart() const
void SetPageOrigin(const Point &rOrg)
sal_uInt16 GetPageNum() const
Size GetSize() const
sal_Int32 GetUpperBorder() const
sal_Int32 GetLeftBorder() const
void VisAreaChanged(const OutputDevice *pOut)
SdrPageView * GetSdrPageView() const
void SetActualWin(const OutputDevice *pWin)
virtual const tools::Rectangle & GetLogicRect() const override
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)
bool SetObjArea(const tools::Rectangle &)
void SetSizeScale(const Fraction &rScaleWidth, const Fraction &rScaleHeight)
ErrCode DoVerb(sal_Int32 nVerb)
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
void SetWaitCursor(bool bSet) const
virtual void SetVisArea(const tools::Rectangle &rVisArea)
bool IsPreview() const
void SetVerbs(const css::uno::Sequence< css::embed::VerbDescriptor > &aVerbs)
virtual SfxUndoManager * GetUndoManager()
SfxViewShell * GetViewShell() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
virtual SfxObjectShell * GetObjectShell() override
void InvalidateBorder()
SfxViewFrame & GetViewFrame() const
SfxInPlaceClient * FindIPClient(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, vcl::Window *pObjParentWin) const
void VisAreaChanged()
vcl::Window * GetWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
css::uno::Sequence< sal_Int8 > GetByteSequence() const
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
#define SO3_SCH_CLASSID
#define SO3_SC_CLASSID
#define SO3_SM_CLASSID
virtual ::tools::Rectangle GetVisArea(sal_uInt16 nAspect) const override
Definition: docshel2.cxx:120
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
View for MDIFrame.
Definition: FrameView.hxx:36
void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
Definition: frmview.cxx:535
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &)
Definition: frmview.cxx:378
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
Local derivation of the SfxHint class that defines some hint ids that are used by the ViewShell class...
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
VclPtr< SvxRuler > mpHorizontalRuler
Horizontal ruler is not shown by default.
Definition: ViewShell.hxx:441
VclPtr< ScrollAdaptor > mpVerticalScrollBar
Vertical scroll bar for whole document is always visible.
Definition: ViewShell.hxx:439
bool IsMainViewShell() const
Return <TRUE> when the called view shell is the main sub shell of its ViewShellBase object,...
Definition: viewshel.cxx:1493
const rtl::Reference< FuPoor > & GetCurrentFunction() const
Definition: ViewShell.hxx:250
Point const & GetViewOrigin() const
Definition: viewshe2.cxx:942
void ReadUserData()
Definition: viewshe2.cxx:798
bool IsPageFlipMode() const
Definition: viewshel.cxx:112
FrameView * mpFrameView
Definition: ViewShell.hxx:453
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
bool RequestHelp(const HelpEvent &rEvt)
Definition: viewshe2.cxx:583
virtual void SetZoom(::tools::Long nZoom)
Set zoom factor for all split windows.
Definition: viewshe2.cxx:309
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: viewshe2.cxx:856
virtual void VirtHScrollHdl(ScrollAdaptor *pHScroll)
virtual scroll handler for horizontal Scrollbars
Definition: viewshe2.cxx:133
virtual void UpdateScrollBars()
Set internal values of all scroll bars that determine thumb size and position.
Definition: viewshe2.cxx:71
void SetWinViewPos(const Point &rWinPos)
Definition: viewshe2.cxx:908
virtual bool ActivateObject(SdrOle2Obj *pObj, sal_Int32 nVerb)
Definition: viewshe2.cxx:624
void DrawMarkRect(const ::tools::Rectangle &rRect) const
Draw a selection rectangle with the ?provided pen on all split windows.
Definition: viewshe2.cxx:442
virtual VclPtr< SvxRuler > CreateHRuler(::sd::Window *pWin)
Definition: viewshe2.cxx:229
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: viewshe2.cxx:867
void Scroll(::tools::Long nX, ::tools::Long nY)
Definition: viewshe2.cxx:265
VclPtr< SvxRuler > mpVerticalRuler
Vertical ruler is not shown by default.
Definition: ViewShell.hxx:443
virtual SdPage * GetActualPage()=0
virtual void WriteFrameViewData()
Definition: viewshe2.cxx:620
void SetPageSizeAndBorder(PageKind ePageKind, const Size &rNewSize, ::tools::Long nLeft, ::tools::Long nRight, ::tools::Long nUpper, ::tools::Long nLower, bool bScaleAll, Orientation eOrient, sal_uInt16 nPaperBin, bool bBackgroundFullSize)
Definition: viewshe2.cxx:450
const ::tools::Rectangle & GetAllWindowRect()
Return the rectangle that encloses all windows of the view.
Definition: viewshe2.cxx:791
void SetRuler(bool bRuler)
Switch ruler on/off.
Definition: viewshe2.cxx:814
void SetActiveWindow(::sd::Window *pWindow)
Set the active window.
Definition: viewshe2.cxx:549
virtual void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
Definition: viewshe2.cxx:897
void ScrollLines(::tools::Long nX, ::tools::Long nY)
Scroll a specific number of lines.
Definition: viewshe2.cxx:251
virtual void VisAreaChanged(const ::tools::Rectangle &rRect)
this method is called when the visible area of the view from this viewshell is changed
Definition: viewshe2.cxx:902
void InvalidateWindows()
Invalidate all split windows below the ?provided rectangle.
Definition: viewshe2.cxx:433
VclPtr< ::sd::Window > mpActiveWindow
The active window.
Definition: ViewShell.hxx:451
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
::sd::View * GetView() const
Definition: ViewShell.hxx:144
virtual void VirtVScrollHdl(ScrollAdaptor *pVScroll)
handling for vertical Scrollbars
Definition: viewshe2.cxx:181
virtual VclPtr< SvxRuler > CreateVRuler(::sd::Window *pWin)
Definition: viewshe2.cxx:234
void SetFrameView(FrameView *pFrameView)
Setting a frame view triggers ReadFrameViewData() for the new frame.
Definition: viewshe2.cxx:598
void WriteUserData()
Definition: viewshe2.cxx:805
::tools::Rectangle maAllWindowRectangle
Area covered by all windows, i.e.
Definition: ViewShell.hxx:480
virtual void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &)
Definition: viewshe2.cxx:878
virtual void SetZoomRect(const ::tools::Rectangle &rZoomRect)
Set zoom rectangle for active window.
Definition: viewshe2.cxx:358
virtual void ReadFrameViewData(FrameView *pView)
Definition: viewshe2.cxx:610
::tools::Long GetZoom() const
Definition: viewshe2.cxx:344
void InitWindows(const Point &rViewOrigin, const Size &rViewSize, const Point &rWinPos, bool bUpdate=false)
Initialize imaging parameters for all split windows.
Definition: viewshe2.cxx:403
virtual void UpdateHRuler()
Definition: viewshe2.cxx:239
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
virtual void SetZoomFactor(const Fraction &rZoomX, const Fraction &rZoomY)
Set zoom factor for InPlace.
Definition: viewshe2.cxx:543
Point const & GetWinViewPos() const
Definition: viewshe2.cxx:937
VclPtr< sd::Window > mpContentWindow
Window inside the rulers and scroll bars that shows a view of the document.
Definition: ViewShell.hxx:434
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
bool HasCurrentFunction() const
Definition: ViewShell.hxx:252
virtual void UpdateVRuler()
Definition: viewshe2.cxx:243
void SetScrollBarsVisible(bool bVisible)
Definition: viewshe2.cxx:847
VclPtr< ScrollAdaptor > mpHorizontalScrollBar
Horizontal scroll bar for the current slide is displayed when needed.
Definition: ViewShell.hxx:437
bool mbHasRulers
This flag controls whether the rulers are visible.
Definition: ViewShell.hxx:448
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, SdrLayerID nLayer)
Definition: sdview2.cxx:429
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer)
Definition: sdview2.cxx:609
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
const Point & GetWinViewPos() const
Definition: Window.hxx:110
::tools::Long SetZoomRect(const ::tools::Rectangle &rZoomRect)
This method is called when the whole page shall be displayed in the window.
Definition: sdwindow.cxx:447
void SetVisibleXY(double fX, double fY)
Set x and y position of the visible area as fraction (< 1) of the whole working area.
Definition: sdwindow.cxx:649
constexpr Point Center() const
constexpr tools::Long GetWidth() const
void SetSize(const Size &)
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long GetHeight() const
::OutputDevice const * GetOutDev() const
Point PixelToLogic(const Point &rDevicePt) const
Size GetOutputSizePixel() const
void EnableChildTransparentMode(bool bEnable=true)
#define ERRCODE_NONE
sal_Int32 nIndex
OUString aName
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
constexpr auto IMPRESS_FACTORY_ID
This are ids used by SfxTopFrame::Create() or CreateViewFrame() to select a factory to create an inst...
Definition: FactoryIds.hxx:32
long Long
#define ASPECT_CONTENT
PageKind
Definition: pres.hxx:45
Orientation
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define ERRCODE_SFX_OLEGENERAL
SVT_DLLPUBLIC const ErrMsgCode RID_SO_ERRCTX[]
#define ERRCTX_SO_DOVERB
bool bVisible
#define DND_ACTION_NONE
signed char sal_Int8
constexpr OUStringLiteral sUNO_View_ViewId
Definition: unokywds.hxx:66
const tools::Long nScrollX
const tools::Long nScrollY