1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/chart2/XChartDocument.hpp>
23 #include <com/sun/star/drawing/FillStyle.hpp>
24 #include <com/sun/star/drawing/LineStyle.hpp>
26 #include "ViewShell.hxx"
27 #include "ViewShellHint.hxx"
29 #include "ViewShellImplementation.hxx"
30 #include "FactoryIds.hxx"
32 #include <svx/svxids.hrc>
33 #include <vcl/scrbar.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <sfx2/dispatch.hxx>
36 #include <sfx2/app.hxx>
37 #include <svx/ruler.hxx>
38 #include <editeng/outliner.hxx>
39 #include <svtools/ehdl.hxx>
40 #include <svx/svdoole2.hxx>
41 #include <svtools/sfxecode.hxx>
42 #include <svx/fmshell.hxx>
43 #include <rtl/ustrbuf.hxx>
44 #include <unotools/moduleoptions.hxx>
45 #include <svx/dialogs.hrc>
46 #include <comphelper/classids.hxx>
48 #include "strings.hrc"
50 #include "unokywds.hxx"
52 #include "sdundogr.hxx"
53 #include "FrameView.hxx"
54 #include "undopage.hxx"
55 #include "sdresid.hxx"
56 #include "drawdoc.hxx"
60 #include "DrawDocShell.hxx"
61 #include "fusearch.hxx"
62 #include "slideshow.hxx"
64 #include "DrawViewShell.hxx"
65 #include "ViewShellBase.hxx"
69 #include <sfx2/viewfrm.hxx>
70 #include <svtools/soerr.hxx>
71 #include <toolkit/helper/vclunohelper.hxx>
72 #include <svx/charthelper.hxx>
74 using namespace com::sun::star
;
78 const OUString aEmptyStr
;
81 * adjust Thumbpos and VisibleSize
83 void ViewShell::UpdateScrollBars()
85 if (mpHorizontalScrollBar
.get() != NULL
)
87 long nW
= (long)(mpContentWindow
->GetVisibleWidth() * 32000);
88 long nX
= (long)(mpContentWindow
->GetVisibleX() * 32000);
89 mpHorizontalScrollBar
->SetVisibleSize(nW
);
90 mpHorizontalScrollBar
->SetThumbPos(nX
);
92 long nLine
= (long) (mpContentWindow
->GetScrlLineWidth() * nW
);
93 long nPage
= (long) (mpContentWindow
->GetScrlPageWidth() * nW
);
94 mpHorizontalScrollBar
->SetLineSize(nLine
);
95 mpHorizontalScrollBar
->SetPageSize(nPage
);
98 if (mpVerticalScrollBar
.get() != NULL
)
100 long nH
= (long)(mpContentWindow
->GetVisibleHeight() * 32000);
101 long nY
= (long)(mpContentWindow
->GetVisibleY() * 32000);
103 if(IsPageFlipMode()) // ie in zoom mode where no panning
105 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
106 sal_uInt16 nCurPage
= (pPage
->GetPageNum() - 1) / 2;
107 sal_uInt16 nTotalPages
= GetDoc()->GetSdPageCount(pPage
->GetPageKind());
108 mpVerticalScrollBar
->SetRange(Range(0,256*nTotalPages
));
109 mpVerticalScrollBar
->SetVisibleSize(256);
110 mpVerticalScrollBar
->SetThumbPos(256*nCurPage
);
111 mpVerticalScrollBar
->SetLineSize(256);
112 mpVerticalScrollBar
->SetPageSize(256);
116 mpVerticalScrollBar
->SetRange(Range(0,32000));
117 mpVerticalScrollBar
->SetVisibleSize(nH
);
118 mpVerticalScrollBar
->SetThumbPos(nY
);
120 long nLine
= (long) (mpContentWindow
->GetScrlLineHeight() * nH
);
121 long nPage
= (long) (mpContentWindow
->GetScrlPageHeight() * nH
);
122 mpVerticalScrollBar
->SetLineSize(nLine
);
123 mpVerticalScrollBar
->SetPageSize(nPage
);
135 * Handling for horizontal Scrollbars
137 IMPL_LINK(ViewShell
, HScrollHdl
, ScrollBar
*, pHScroll
)
139 return VirtHScrollHdl(pHScroll
);
143 * virtual scroll handler for horizontal Scrollbars
145 long ViewShell::VirtHScrollHdl(ScrollBar
* pHScroll
)
147 long nDelta
= pHScroll
->GetDelta();
151 double fX
= (double) pHScroll
->GetThumbPos() / pHScroll
->GetRange().Len();
153 // scroll all windows of the column
154 ::sd::View
* pView
= GetView();
155 OutlinerView
* pOLV
= NULL
;
158 pOLV
= pView
->GetTextEditOutlinerView();
163 mpContentWindow
->SetVisibleXY(fX
, -1);
165 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
166 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
167 aVisArea
.SetPos(aVisAreaPos
);
168 GetDocSh()->SetVisArea(aVisArea
);
170 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
171 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
172 VisAreaChanged(aVisAreaWin
);
176 pView
->VisAreaChanged(GetActiveWindow());
191 * handling for vertical Scrollbars
193 IMPL_LINK(ViewShell
, VScrollHdl
, ScrollBar
*, pVScroll
)
195 return VirtVScrollHdl(pVScroll
);
199 * handling for vertical Scrollbars
201 long ViewShell::VirtVScrollHdl(ScrollBar
* pVScroll
)
205 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
206 sal_uInt16 nCurPage
= (pPage
->GetPageNum() - 1) >> 1;
207 sal_uInt16 nNewPage
= (sal_uInt16
)pVScroll
->GetThumbPos()/256;
208 if( nCurPage
!= nNewPage
)
209 static_cast<DrawViewShell
*>(this)->SwitchPage(nNewPage
);
213 double fY
= (double) pVScroll
->GetThumbPos() / pVScroll
->GetRange().Len();
215 ::sd::View
* pView
= GetView();
216 OutlinerView
* pOLV
= NULL
;
219 pOLV
= pView
->GetTextEditOutlinerView();
224 mpContentWindow
->SetVisibleXY(-1, fY
);
226 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
227 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
228 aVisArea
.SetPos(aVisAreaPos
);
229 GetDocSh()->SetVisArea(aVisArea
);
231 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
232 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
233 VisAreaChanged(aVisAreaWin
);
237 pView
->VisAreaChanged(GetActiveWindow());
251 SvxRuler
* ViewShell::CreateHRuler(::sd::Window
* , bool )
256 SvxRuler
* ViewShell::CreateVRuler(::sd::Window
* )
261 void ViewShell::UpdateHRuler()
265 void ViewShell::UpdateVRuler()
270 * Scroll a specific number of lines. Is used in the automatic scrolling
273 void ViewShell::ScrollLines(long nLinesX
, long nLinesY
)
277 nLinesX
*= mpHorizontalScrollBar
->GetLineSize();
281 nLinesY
*= mpVerticalScrollBar
->GetLineSize();
284 Scroll(nLinesX
, nLinesY
);
287 void ViewShell::Scroll(long nScrollX
, long nScrollY
)
291 long nNewThumb
= mpHorizontalScrollBar
->GetThumbPos() + nScrollX
;
292 mpHorizontalScrollBar
->SetThumbPos(nNewThumb
);
296 long nNewThumb
= mpVerticalScrollBar
->GetThumbPos() + nScrollY
;
297 mpVerticalScrollBar
->SetThumbPos(nNewThumb
);
299 double fX
= (double) mpHorizontalScrollBar
->GetThumbPos() /
300 mpHorizontalScrollBar
->GetRange().Len();
301 double fY
= (double) mpVerticalScrollBar
->GetThumbPos() /
302 mpVerticalScrollBar
->GetRange().Len();
304 GetActiveWindow()->SetVisibleXY(fX
, fY
);
306 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
307 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
308 aVisArea
.SetPos(aVisAreaPos
);
309 GetDocSh()->SetVisArea(aVisArea
);
311 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
312 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
313 VisAreaChanged(aVisAreaWin
);
315 ::sd::View
* pView
= GetView();
318 pView
->VisAreaChanged(GetActiveWindow());
329 * Set zoom factor for all split windows.
331 void ViewShell::SetZoom(long nZoom
)
333 Fraction
aUIScale(nZoom
, 100);
334 aUIScale
*= GetDoc()->GetUIScale();
336 if (mpHorizontalRuler
.get() != NULL
)
337 mpHorizontalRuler
->SetZoom(aUIScale
);
339 if (mpVerticalRuler
.get() != NULL
)
340 mpVerticalRuler
->SetZoom(aUIScale
);
342 if (mpContentWindow
.get() != NULL
)
344 mpContentWindow
->SetZoomIntegral(nZoom
);
346 // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
347 // of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
348 // the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
349 // but does not solve the problem completely. Neet to ask PL.
350 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
353 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
354 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
355 VisAreaChanged(aVisAreaWin
);
357 ::sd::View
* pView
= GetView();
360 pView
->VisAreaChanged(GetActiveWindow());
367 * Set zoom rectangle for active window. Sets all split windows to the same zoom
370 void ViewShell::SetZoomRect(const Rectangle
& rZoomRect
)
372 long nZoom
= GetActiveWindow()->SetZoomRect(rZoomRect
);
373 Fraction
aUIScale(nZoom
, 100);
374 aUIScale
*= GetDoc()->GetUIScale();
376 Point aPos
= GetActiveWindow()->GetWinViewPos();
378 if (mpHorizontalRuler
.get() != NULL
)
379 mpHorizontalRuler
->SetZoom(aUIScale
);
381 if (mpVerticalRuler
.get() != NULL
)
382 mpVerticalRuler
->SetZoom(aUIScale
);
384 if (mpContentWindow
.get() != NULL
)
386 Point aNewPos
= mpContentWindow
->GetWinViewPos();
387 aNewPos
.X() = aPos
.X();
388 aNewPos
.Y() = aPos
.Y();
389 mpContentWindow
->SetZoomIntegral(nZoom
);
390 mpContentWindow
->SetWinViewPos(aNewPos
);
391 mpContentWindow
->UpdateMapOrigin();
393 // When tiled rendering, UpdateMapOrigin() doesn't touch the map mode.
394 if (!GetDoc()->isTiledRendering())
395 // #i74769# see above
396 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
399 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
400 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
401 VisAreaChanged(aVisAreaWin
);
403 ::sd::View
* pView
= GetView();
406 pView
->VisAreaChanged(GetActiveWindow());
413 * Initialize imaging parameters for all split windows.
415 void ViewShell::InitWindows(const Point
& rViewOrigin
, const Size
& rViewSize
,
416 const Point
& rWinPos
, bool bUpdate
)
418 if (mpContentWindow
.get() != NULL
)
420 mpContentWindow
->SetViewOrigin(rViewOrigin
);
421 mpContentWindow
->SetViewSize(rViewSize
);
422 mpContentWindow
->SetWinViewPos(rWinPos
);
426 mpContentWindow
->UpdateMapOrigin();
427 mpContentWindow
->Invalidate();
431 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
432 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
433 VisAreaChanged(aVisAreaWin
);
435 ::sd::View
* pView
= GetView();
438 pView
->VisAreaChanged(GetActiveWindow());
443 * Invalidate all split windows below the ?provided rectangle.
445 void ViewShell::InvalidateWindows()
447 if (mpContentWindow
.get() != NULL
)
448 mpContentWindow
->Invalidate();
452 * Draw a selection rectangle with the ?provided pen on all split windows.
454 void ViewShell::DrawMarkRect(const Rectangle
& rRect
) const
456 if (mpContentWindow
.get() != NULL
)
458 mpContentWindow
->InvertTracking(rRect
, SHOWTRACK_OBJECT
| SHOWTRACK_WINDOW
);
462 void ViewShell::SetPageSizeAndBorder(PageKind ePageKind
, const Size
& rNewSize
,
463 long nLeft
, long nRight
,
464 long nUpper
, long nLower
, bool bScaleAll
,
465 Orientation eOrientation
, sal_uInt16 nPaperBin
,
466 bool bBackgroundFullSize
)
469 SdUndoGroup
* pUndoGroup
= NULL
;
470 pUndoGroup
= new SdUndoGroup(GetDoc());
471 OUString
aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT
));
472 pUndoGroup
->SetComment(aString
);
473 SfxViewShell
* pViewShell
= GetViewShell();
474 OSL_ASSERT (pViewShell
!=NULL
);
476 sal_uInt16 i
, nPageCnt
= GetDoc()->GetMasterSdPageCount(ePageKind
);
478 Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START
));
480 for (i
= 0; i
< nPageCnt
; i
++)
482 // first, handle all master pages
483 pPage
= GetDoc()->GetMasterSdPage(i
, ePageKind
);
485 SdUndoAction
* pUndo
= new SdPageFormatUndoAction(GetDoc(), pPage
,
487 pPage
->GetLftBorder(), pPage
->GetRgtBorder(),
488 pPage
->GetUppBorder(), pPage
->GetLwrBorder(),
489 pPage
->GetOrientation(),
490 pPage
->GetPaperBin(),
491 pPage
->IsBackgroundFullSize(),
498 bBackgroundFullSize
);
499 pUndoGroup
->AddAction(pUndo
);
501 if (rNewSize
.Width() > 0 ||
502 nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0)
504 Rectangle
aNewBorderRect(nLeft
, nUpper
, nRight
, nLower
);
505 pPage
->ScaleObjects(rNewSize
, aNewBorderRect
, bScaleAll
);
507 if (rNewSize
.Width() > 0)
508 pPage
->SetSize(rNewSize
);
511 if( nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0 )
513 pPage
->SetBorder(nLeft
, nUpper
, nRight
, nLower
);
516 pPage
->SetOrientation(eOrientation
);
517 pPage
->SetPaperBin( nPaperBin
);
518 pPage
->SetBackgroundFullSize( bBackgroundFullSize
);
520 if ( ePageKind
== PK_STANDARD
)
521 GetDoc()->GetMasterSdPage(i
, PK_NOTES
)->CreateTitleAndLayout();
523 pPage
->CreateTitleAndLayout();
526 nPageCnt
= GetDoc()->GetSdPageCount(ePageKind
);
528 for (i
= 0; i
< nPageCnt
; i
++)
530 // then, handle all pages
531 pPage
= GetDoc()->GetSdPage(i
, ePageKind
);
533 SdUndoAction
* pUndo
= new SdPageFormatUndoAction(GetDoc(), pPage
,
535 pPage
->GetLftBorder(), pPage
->GetRgtBorder(),
536 pPage
->GetUppBorder(), pPage
->GetLwrBorder(),
537 pPage
->GetOrientation(),
538 pPage
->GetPaperBin(),
539 pPage
->IsBackgroundFullSize(),
546 bBackgroundFullSize
);
547 pUndoGroup
->AddAction(pUndo
);
549 if (rNewSize
.Width() > 0 ||
550 nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0)
552 Rectangle
aNewBorderRect(nLeft
, nUpper
, nRight
, nLower
);
553 pPage
->ScaleObjects(rNewSize
, aNewBorderRect
, bScaleAll
);
555 if (rNewSize
.Width() > 0)
556 pPage
->SetSize(rNewSize
);
559 if( nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0 )
561 pPage
->SetBorder(nLeft
, nUpper
, nRight
, nLower
);
564 pPage
->SetOrientation(eOrientation
);
565 pPage
->SetPaperBin( nPaperBin
);
566 pPage
->SetBackgroundFullSize( bBackgroundFullSize
);
568 if ( ePageKind
== PK_STANDARD
)
570 SdPage
* pNotesPage
= GetDoc()->GetSdPage(i
, PK_NOTES
);
571 pNotesPage
->SetAutoLayout( pNotesPage
->GetAutoLayout() );
574 pPage
->SetAutoLayout( pPage
->GetAutoLayout() );
577 // adjust handout page to new format of the standard page
578 if( (ePageKind
== PK_STANDARD
) || (ePageKind
== PK_HANDOUT
) )
579 GetDoc()->GetSdPage(0, PK_HANDOUT
)->CreateTitleAndLayout(true);
581 // handed over undo group to undo manager
582 pViewShell
->GetViewFrame()->GetObjectShell()
583 ->GetUndoManager()->AddUndoAction(pUndoGroup
);
585 long nWidth
= pPage
->GetSize().Width();
586 long nHeight
= pPage
->GetSize().Height();
588 Point aPageOrg
= Point(nWidth
, nHeight
/ 2);
589 Size aViewSize
= Size(nWidth
* 3, nHeight
* 2);
591 InitWindows(aPageOrg
, aViewSize
, Point(-1, -1), true);
595 if ( GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
597 aVisAreaPos
= GetDocSh()->GetVisArea(ASPECT_CONTENT
).TopLeft();
600 ::sd::View
* pView
= GetView();
603 pView
->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aViewSize
));
608 Point
aNewOrigin(pPage
->GetLftBorder(), pPage
->GetUppBorder());
612 pView
->GetSdrPageView()->SetPageOrigin(aNewOrigin
);
615 pViewShell
->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET
);
617 // zoom onto (new) page size
618 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
,
619 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
621 Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END
));
625 * Set zoom factor for InPlace
627 void ViewShell::SetZoomFactor(const Fraction
& rZoomX
, const Fraction
&)
629 long nZoom
= (long)((double) rZoomX
* 100);
633 void ViewShell::SetActiveWindow (::sd::Window
* pWin
)
635 SfxViewShell
* pViewShell
= GetViewShell();
636 OSL_ASSERT (pViewShell
!=NULL
);
638 if (pViewShell
->GetWindow() != pWin
)
640 // #i31551# was wrong, it may have been a problem with the repaint at that time.
641 // For transparent form controls, it is necessary to have that flag set, all apps
642 // do set it. Enabling again.
645 pWin
->EnableChildTransparentMode();
649 if (mpActiveWindow
.get() != pWin
)
650 mpActiveWindow
= pWin
;
652 // The rest of this function is not guarded anymore against calling this
653 // method with an already active window because the functions may still
654 // point to the old window when the new one has already been assigned to
655 // pWindow elsewhere.
656 ::sd::View
* pView
= GetView();
659 pView
->SetActualWin(pWin
);
661 if(HasCurrentFunction())
663 GetCurrentFunction()->SetWindow(pWin
);
667 bool ViewShell::RequestHelp(const HelpEvent
& rHEvt
, ::sd::Window
*)
669 bool bReturn
= false;
671 if (bool(rHEvt
.GetMode()))
674 bReturn
= GetView()->getSmartTags().RequestHelp(rHEvt
);
676 if(!bReturn
&& HasCurrentFunction())
678 bReturn
= GetCurrentFunction()->RequestHelp(rHEvt
);
685 void ViewShell::SetFrameView (FrameView
* pNewFrameView
)
687 mpFrameView
= pNewFrameView
;
688 ReadFrameViewData (mpFrameView
);
691 /*************************************************************************
693 |* Read FrameViews data and set actual views data
695 \************************************************************************/
697 void ViewShell::ReadFrameViewData(FrameView
*)
701 /*************************************************************************
703 |* Write actual views data to FrameView
705 \************************************************************************/
707 void ViewShell::WriteFrameViewData()
711 bool ViewShell::ActivateObject(SdrOle2Obj
* pObj
, long nVerb
)
713 ErrCode aErrCode
= 0;
715 SfxErrorContext
aEC(ERRCTX_SO_DOVERB
, GetActiveWindow(), RID_SO_ERRCTX
);
717 GetDocSh()->SetWaitCursor( true );
718 SfxViewShell
* pViewShell
= GetViewShell();
719 OSL_ASSERT (pViewShell
!=NULL
);
720 bool bChangeDefaultsForChart
= false;
723 uno::Reference
< embed::XEmbeddedObject
> xObj
= pObj
->GetObjRef();
726 // provide OLE object to empty OLE object
727 aName
= pObj
->GetProgName();
731 if( aName
== "StarChart" || aName
== "StarOrg" )
733 if( SvtModuleOptions().IsChart() )
735 aClass
= SvGlobalName( SO3_SCH_CLASSID
);
736 bChangeDefaultsForChart
= true;
739 else if( aName
== "StarCalc" )
741 if( SvtModuleOptions().IsCalc() )
742 aClass
= SvGlobalName( SO3_SC_CLASSID
);
744 else if( aName
== "StarMath" )
746 if( SvtModuleOptions().IsMath() )
747 aClass
= SvGlobalName( SO3_SM_CLASSID
);
750 if ( aClass
!= SvGlobalName() )
751 xObj
= GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass
.GetByteSequence(), aObjName
);
757 // call dialog "insert OLE object"
758 GetDocSh()->SetWaitCursor( false );
759 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(
761 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
);
762 xObj
= pObj
->GetObjRef();
763 GetDocSh()->SetWaitCursor( true );
773 // OLE object is no longer empty
774 pObj
->SetEmptyPresObj(false);
775 pObj
->SetOutlinerParaObject(NULL
);
776 pObj
->SetGraphic(NULL
);
778 // the empty OLE object gets a new IPObj
779 if (!aName
.isEmpty())
781 pObj
->SetObjRef(xObj
);
782 pObj
->SetName(aObjName
);
783 pObj
->SetPersistName(aObjName
);
787 // insertion was done by the dialog
788 pObj
->SetObjRef(xObj
);
791 Rectangle aRect
= pObj
->GetLogicRect();
793 if ( pObj
->GetAspect() != embed::Aspects::MSOLE_ICON
)
796 aSz
.Width
= aRect
.GetWidth();
797 aSz
.Height
= aRect
.GetHeight();
798 xObj
->setVisualAreaSize( pObj
->GetAspect(), aSz
);
801 GetViewShellBase().SetVerbs( xObj
->getSupportedVerbs() );
807 aErrCode
= ERRCODE_SFX_OLEGENERAL
;
813 ::sd::View
* pView
= GetView();
815 if (pView
->IsTextEdit())
817 pView
->SdrEndTextEdit();
820 SfxInPlaceClient
* pSdClient
=
821 static_cast<Client
*>(pViewShell
->FindIPClient(
822 pObj
->GetObjRef(), GetActiveWindow()));
826 pSdClient
= new Client(pObj
, this, GetActiveWindow());
829 Rectangle aRect
= pObj
->GetLogicRect();
832 // #i118485# center on BoundRect for activation,
833 // OLE may be sheared/rotated now
834 const Rectangle
& rBoundRect
= pObj
->GetCurrentBoundRect();
835 const Point
aDelta(rBoundRect
.Center() - aRect
.Center());
836 aRect
.Move(aDelta
.X(), aDelta
.Y());
839 Size aDrawSize
= aRect
.GetSize();
841 MapMode
aMapMode( GetDoc()->GetScaleUnit() );
842 Size aObjAreaSize
= pObj
->GetOrigObjSize( &aMapMode
);
843 if( pObj
->IsChart() ) //charts never should be stretched see #i84323# for example
844 aObjAreaSize
= aDrawSize
;
846 Fraction
aScaleWidth (aDrawSize
.Width(), aObjAreaSize
.Width() );
847 Fraction
aScaleHeight(aDrawSize
.Height(), aObjAreaSize
.Height() );
848 aScaleWidth
.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
849 aScaleHeight
.ReduceInaccurate(10);
850 pSdClient
->SetSizeScale(aScaleWidth
, aScaleHeight
);
852 // visible section is only changed in-place!
853 aRect
.SetSize(aObjAreaSize
);
854 // the object area size must be set after scaling, since it triggers the resizing
855 pSdClient
->SetObjArea(aRect
);
857 if( bChangeDefaultsForChart
&& xObj
.is())
859 ChartHelper::AdaptDefaultsForChart( xObj
);
862 pSdClient
->DoVerb(nVerb
); // if necessary, ErrCode is outputted by Sfx
863 pViewShell
->GetViewFrame()->GetBindings().Invalidate(
864 SID_NAVIGATOR_STATE
, true, false);
867 GetDocSh()->SetWaitCursor( false );
869 if (aErrCode
!= 0 && !bAbort
)
871 ErrorHandler::HandleError(* new StringErrorInfo(aErrCode
, OUString() ) );
874 return aErrCode
== 0;
878 * @returns enclosing rectangle of all (split-) windows.
880 const Rectangle
& ViewShell::GetAllWindowRect()
882 maAllWindowRectangle
.SetPos(
883 mpContentWindow
->OutputToScreenPixel(Point(0,0)));
884 return maAllWindowRectangle
;
887 void ViewShell::ReadUserData(const OUString
&)
889 // zoom onto VisArea from FrameView
890 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA
,
891 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
894 void ViewShell::WriteUserData(OUString
&)
896 // writing of our data is always done in WriteFrameViewData()
897 WriteFrameViewData();
901 * Switch ruler on/off
903 void ViewShell::SetRuler(bool bRuler
)
905 mbHasRulers
= ( bRuler
&& !GetDocSh()->IsPreview() ); // no rulers on preview mode
907 if (mpHorizontalRuler
.get() != NULL
)
911 mpHorizontalRuler
->Show();
915 mpHorizontalRuler
->Hide();
919 if (mpVerticalRuler
.get() != NULL
)
923 mpVerticalRuler
->Show();
927 mpVerticalRuler
->Hide();
931 OSL_ASSERT(GetViewShell()!=NULL
);
932 if (IsMainViewShell())
933 GetViewShell()->InvalidateBorder();
936 sal_Int8
ViewShell::AcceptDrop (
937 const AcceptDropEvent
& rEvt
,
938 DropTargetHelper
& rTargetHelper
,
939 ::sd::Window
* pTargetWindow
,
943 ::sd::View
* pView
= GetView();
944 return( pView
? pView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
947 sal_Int8
ViewShell::ExecuteDrop (
948 const ExecuteDropEvent
& rEvt
,
949 DropTargetHelper
& rTargetHelper
,
950 ::sd::Window
* pTargetWindow
,
954 ::sd::View
* pView
= GetView();
955 return( pView
? pView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
958 void ViewShell::WriteUserDataSequence ( css::uno::Sequence
< css::beans::PropertyValue
>& rSequence
, bool bBrowse
)
960 const sal_Int32 nIndex
= rSequence
.getLength();
961 rSequence
.realloc( nIndex
+ 1 );
963 OSL_ASSERT (GetViewShell()!=NULL
);
964 // Get the view id from the view shell in the center pane. This will
965 // usually be the called view shell, but to be on the safe side we call
966 // the main view shell explicitly.
967 sal_uInt16
nViewID (IMPRESS_FACTORY_ID
);
968 if (GetViewShellBase().GetMainViewShell().get() != NULL
)
969 nViewID
= GetViewShellBase().GetMainViewShell()->mpImpl
->GetViewId();
970 rSequence
[nIndex
].Name
= sUNO_View_ViewId
;
971 OUStringBuffer
sBuffer( "view" );
972 sBuffer
.append( static_cast<sal_Int32
>(nViewID
));
973 rSequence
[nIndex
].Value
<<= sBuffer
.makeStringAndClear();
975 mpFrameView
->WriteUserDataSequence( rSequence
, bBrowse
);
978 void ViewShell::ReadUserDataSequence ( const css::uno::Sequence
< css::beans::PropertyValue
>& rSequence
, bool bBrowse
)
980 mpFrameView
->ReadUserDataSequence( rSequence
, bBrowse
);
983 void ViewShell::VisAreaChanged(const Rectangle
& rRect
)
985 OSL_ASSERT (GetViewShell()!=NULL
);
986 GetViewShell()->VisAreaChanged(rRect
);
989 void ViewShell::SetWinViewPos(const Point
& rWinPos
, bool bUpdate
)
991 if (mpContentWindow
.get() != NULL
)
993 mpContentWindow
->SetWinViewPos(rWinPos
);
997 mpContentWindow
->UpdateMapOrigin();
998 mpContentWindow
->Invalidate();
1010 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
1011 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
1012 VisAreaChanged(aVisAreaWin
);
1014 ::sd::View
* pView
= GetView();
1017 pView
->VisAreaChanged(GetActiveWindow());
1021 Point
ViewShell::GetWinViewPos() const
1023 return mpContentWindow
->GetWinViewPos();
1026 Point
ViewShell::GetViewOrigin() const
1028 return mpContentWindow
->GetViewOrigin();
1031 } // end of namespace sd
1033 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */