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>
73 using namespace com::sun::star
;
77 const String aEmptyStr
;
80 * adjust Thumbpos and VisibleSize
82 void ViewShell::UpdateScrollBars()
84 if (mpHorizontalScrollBar
.get() != NULL
)
86 long nW
= (long)(mpContentWindow
->GetVisibleWidth() * 32000);
87 long nX
= (long)(mpContentWindow
->GetVisibleX() * 32000);
88 mpHorizontalScrollBar
->SetVisibleSize(nW
);
89 mpHorizontalScrollBar
->SetThumbPos(nX
);
91 long nLine
= (long) (mpContentWindow
->GetScrlLineWidth() * nW
);
92 long nPage
= (long) (mpContentWindow
->GetScrlPageWidth() * nW
);
93 mpHorizontalScrollBar
->SetLineSize(nLine
);
94 mpHorizontalScrollBar
->SetPageSize(nPage
);
97 if (mpVerticalScrollBar
.get() != NULL
)
99 long nH
= (long)(mpContentWindow
->GetVisibleHeight() * 32000);
100 long nY
= (long)(mpContentWindow
->GetVisibleY() * 32000);
102 if(IsPageFlipMode()) // ie in zoom mode where no panning
104 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
105 sal_uInt16 nCurPage
= (pPage
->GetPageNum() - 1) / 2;
106 sal_uInt16 nTotalPages
= GetDoc()->GetSdPageCount(pPage
->GetPageKind());
107 mpVerticalScrollBar
->SetRange(Range(0,256*nTotalPages
));
108 mpVerticalScrollBar
->SetVisibleSize(256);
109 mpVerticalScrollBar
->SetThumbPos(256*nCurPage
);
110 mpVerticalScrollBar
->SetLineSize(256);
111 mpVerticalScrollBar
->SetPageSize(256);
115 mpVerticalScrollBar
->SetRange(Range(0,32000));
116 mpVerticalScrollBar
->SetVisibleSize(nH
);
117 mpVerticalScrollBar
->SetThumbPos(nY
);
119 long nLine
= (long) (mpContentWindow
->GetScrlLineHeight() * nH
);
120 long nPage
= (long) (mpContentWindow
->GetScrlPageHeight() * nH
);
121 mpVerticalScrollBar
->SetLineSize(nLine
);
122 mpVerticalScrollBar
->SetPageSize(nPage
);
134 * Handling for horizontal Scrollbars
136 IMPL_LINK_INLINE_START(ViewShell
, HScrollHdl
, ScrollBar
*, pHScroll
)
138 return VirtHScrollHdl(pHScroll
);
140 IMPL_LINK_INLINE_END(ViewShell
, HScrollHdl
, ScrollBar
*, 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_INLINE_START(ViewShell
, VScrollHdl
, ScrollBar
*, pVScroll
)
195 return VirtVScrollHdl(pVScroll
);
197 IMPL_LINK_INLINE_END(ViewShell
, VScrollHdl
, ScrollBar
*, pVScroll
)
200 * handling for vertical Scrollbars
202 long ViewShell::VirtVScrollHdl(ScrollBar
* pVScroll
)
206 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
207 sal_uInt16 nCurPage
= (pPage
->GetPageNum() - 1) >> 1;
208 sal_uInt16 nNewPage
= (sal_uInt16
)pVScroll
->GetThumbPos()/256;
209 if( nCurPage
!= nNewPage
)
210 static_cast<DrawViewShell
*>(this)->SwitchPage(nNewPage
);
214 double fY
= (double) pVScroll
->GetThumbPos() / pVScroll
->GetRange().Len();
216 ::sd::View
* pView
= GetView();
217 OutlinerView
* pOLV
= NULL
;
220 pOLV
= pView
->GetTextEditOutlinerView();
225 mpContentWindow
->SetVisibleXY(-1, fY
);
227 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
228 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
229 aVisArea
.SetPos(aVisAreaPos
);
230 GetDocSh()->SetVisArea(aVisArea
);
232 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
233 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
234 VisAreaChanged(aVisAreaWin
);
238 pView
->VisAreaChanged(GetActiveWindow());
252 SvxRuler
* ViewShell::CreateHRuler(::sd::Window
* , sal_Bool
)
257 SvxRuler
* ViewShell::CreateVRuler(::sd::Window
* )
262 void ViewShell::UpdateHRuler()
266 void ViewShell::UpdateVRuler()
271 * Scroll a specific number of lines. Is used in the automatic scrolling
274 void ViewShell::ScrollLines(long nLinesX
, long nLinesY
)
278 nLinesX
*= mpHorizontalScrollBar
->GetLineSize();
282 nLinesY
*= mpVerticalScrollBar
->GetLineSize();
285 Scroll(nLinesX
, nLinesY
);
288 void ViewShell::Scroll(long nScrollX
, long nScrollY
)
292 long nNewThumb
= mpHorizontalScrollBar
->GetThumbPos() + nScrollX
;
293 mpHorizontalScrollBar
->SetThumbPos(nNewThumb
);
297 long nNewThumb
= mpVerticalScrollBar
->GetThumbPos() + nScrollY
;
298 mpVerticalScrollBar
->SetThumbPos(nNewThumb
);
300 double fX
= (double) mpHorizontalScrollBar
->GetThumbPos() /
301 mpHorizontalScrollBar
->GetRange().Len();
302 double fY
= (double) mpVerticalScrollBar
->GetThumbPos() /
303 mpVerticalScrollBar
->GetRange().Len();
305 GetActiveWindow()->SetVisibleXY(fX
, fY
);
307 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
308 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
309 aVisArea
.SetPos(aVisAreaPos
);
310 GetDocSh()->SetVisArea(aVisArea
);
312 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
313 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
314 VisAreaChanged(aVisAreaWin
);
316 ::sd::View
* pView
= GetView();
319 pView
->VisAreaChanged(GetActiveWindow());
330 * Set zoom factor for all split windows.
332 void ViewShell::SetZoom(long nZoom
)
334 Fraction
aUIScale(nZoom
, 100);
335 aUIScale
*= GetDoc()->GetUIScale();
337 if (mpHorizontalRuler
.get() != NULL
)
338 mpHorizontalRuler
->SetZoom(aUIScale
);
340 if (mpVerticalRuler
.get() != NULL
)
341 mpVerticalRuler
->SetZoom(aUIScale
);
343 if (mpContentWindow
.get() != NULL
)
345 mpContentWindow
->SetZoomIntegral(nZoom
);
347 // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
348 // of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
349 // the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
350 // but does not solve the problem completely. Neet to ask PL.
351 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
354 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
355 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
356 VisAreaChanged(aVisAreaWin
);
358 ::sd::View
* pView
= GetView();
361 pView
->VisAreaChanged(GetActiveWindow());
368 * Set zoom rectangle for active window. Sets all split windows to the same zoom
371 void ViewShell::SetZoomRect(const Rectangle
& rZoomRect
)
373 long nZoom
= GetActiveWindow()->SetZoomRect(rZoomRect
);
374 Fraction
aUIScale(nZoom
, 100);
375 aUIScale
*= GetDoc()->GetUIScale();
377 Point aPos
= GetActiveWindow()->GetWinViewPos();
379 if (mpHorizontalRuler
.get() != NULL
)
380 mpHorizontalRuler
->SetZoom(aUIScale
);
382 if (mpVerticalRuler
.get() != NULL
)
383 mpVerticalRuler
->SetZoom(aUIScale
);
385 if (mpContentWindow
.get() != NULL
)
387 Point aNewPos
= mpContentWindow
->GetWinViewPos();
388 aNewPos
.X() = aPos
.X();
389 aNewPos
.Y() = aPos
.Y();
390 mpContentWindow
->SetZoomIntegral(nZoom
);
391 mpContentWindow
->SetWinViewPos(aNewPos
);
392 mpContentWindow
->UpdateMapOrigin();
394 // #i74769# see above
395 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
398 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
399 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
400 VisAreaChanged(aVisAreaWin
);
402 ::sd::View
* pView
= GetView();
405 pView
->VisAreaChanged(GetActiveWindow());
412 * Initialize imaging parameters for all split windows.
414 void ViewShell::InitWindows(const Point
& rViewOrigin
, const Size
& rViewSize
,
415 const Point
& rWinPos
, sal_Bool bUpdate
)
417 if (mpContentWindow
.get() != NULL
)
419 mpContentWindow
->SetViewOrigin(rViewOrigin
);
420 mpContentWindow
->SetViewSize(rViewSize
);
421 mpContentWindow
->SetWinViewPos(rWinPos
);
425 mpContentWindow
->UpdateMapOrigin();
426 mpContentWindow
->Invalidate();
430 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
431 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
432 VisAreaChanged(aVisAreaWin
);
434 ::sd::View
* pView
= GetView();
437 pView
->VisAreaChanged(GetActiveWindow());
442 * Invalidate all split windows below the ?provided rectangle.
444 void ViewShell::InvalidateWindows()
446 if (mpContentWindow
.get() != NULL
)
447 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
, sal_Bool bScaleAll
,
465 Orientation eOrientation
, sal_uInt16 nPaperBin
,
466 sal_Bool bBackgroundFullSize
)
469 SdUndoGroup
* pUndoGroup
= NULL
;
470 pUndoGroup
= new SdUndoGroup(GetDoc());
471 String
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(sal_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), sal_True
);
595 if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_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 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_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);
635 void ViewShell::SetActiveWindow (::sd::Window
* pWin
)
637 SfxViewShell
* pViewShell
= GetViewShell();
638 OSL_ASSERT (pViewShell
!=NULL
);
640 if (pViewShell
->GetWindow() != pWin
)
642 // #i31551# was wrong, it may have been a problem with the repaint at that time.
643 // For transparent form controls, it is necessary to have that flag set, all apps
644 // do set it. Enabling again.
647 pWin
->EnableChildTransparentMode();
651 if (mpActiveWindow
!= pWin
)
652 mpActiveWindow
= pWin
;
654 // The rest of this function is not guarded anymore against calling this
655 // method with an already active window because the functions may still
656 // point to the old window when the new one has already been assigned to
657 // pWindow elsewhere.
658 ::sd::View
* pView
= GetView();
661 pView
->SetActualWin(pWin
);
663 if(HasCurrentFunction())
665 GetCurrentFunction()->SetWindow(pWin
);
671 sal_Bool
ViewShell::RequestHelp(const HelpEvent
& rHEvt
, ::sd::Window
*)
673 sal_Bool bReturn
= sal_False
;
678 bReturn
= GetView()->getSmartTags().RequestHelp(rHEvt
);
680 if(!bReturn
&& HasCurrentFunction())
682 bReturn
= GetCurrentFunction()->RequestHelp(rHEvt
);
692 FrameView
* ViewShell::GetFrameView (void)
700 void ViewShell::SetFrameView (FrameView
* pNewFrameView
)
702 mpFrameView
= pNewFrameView
;
703 ReadFrameViewData (mpFrameView
);
709 /*************************************************************************
711 |* Read FrameViews data and set actual views data
713 \************************************************************************/
715 void ViewShell::ReadFrameViewData(FrameView
*)
721 /*************************************************************************
723 |* Write actual views data to FrameView
725 \************************************************************************/
727 void ViewShell::WriteFrameViewData()
732 sal_Bool
ViewShell::ActivateObject(SdrOle2Obj
* pObj
, long nVerb
)
734 ErrCode aErrCode
= 0;
736 SfxErrorContext
aEC(ERRCTX_SO_DOVERB
, GetActiveWindow(), RID_SO_ERRCTX
);
737 sal_Bool bAbort
= sal_False
;
738 GetDocSh()->SetWaitCursor( sal_True
);
739 SfxViewShell
* pViewShell
= GetViewShell();
740 OSL_ASSERT (pViewShell
!=NULL
);
741 bool bChangeDefaultsForChart
= false;
744 uno::Reference
< embed::XEmbeddedObject
> xObj
= pObj
->GetObjRef();
747 // provide OLE object to empty OLE object
748 aName
= pObj
->GetProgName();
752 if( aName
== "StarChart" || aName
== "StarOrg" )
754 if( SvtModuleOptions().IsChart() )
756 aClass
= SvGlobalName( SO3_SCH_CLASSID
);
757 bChangeDefaultsForChart
= true;
760 else if( aName
== "StarCalc" )
762 if( SvtModuleOptions().IsCalc() )
763 aClass
= SvGlobalName( SO3_SC_CLASSID
);
765 else if( aName
== "StarMath" )
767 if( SvtModuleOptions().IsMath() )
768 aClass
= SvGlobalName( SO3_SM_CLASSID
);
771 if ( aClass
!= SvGlobalName() )
772 xObj
= GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass
.GetByteSequence(), aObjName
);
778 // call dialog "insert OLE object"
779 GetDocSh()->SetWaitCursor( sal_False
);
780 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(
782 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
783 xObj
= pObj
->GetObjRef();
784 GetDocSh()->SetWaitCursor( sal_True
);
794 // OLE object is no longer empty
795 pObj
->SetEmptyPresObj(sal_False
);
796 pObj
->SetOutlinerParaObject(NULL
);
797 pObj
->SetGraphic(NULL
);
799 // the empty OLE object gets a new IPObj
800 if (!aName
.isEmpty())
802 pObj
->SetObjRef(xObj
);
803 pObj
->SetName(aObjName
);
804 pObj
->SetPersistName(aObjName
);
808 // insertion was done by the dialog
809 pObj
->SetObjRef(xObj
);
812 Rectangle aRect
= pObj
->GetLogicRect();
814 if ( pObj
->GetAspect() != embed::Aspects::MSOLE_ICON
)
817 aSz
.Width
= aRect
.GetWidth();
818 aSz
.Height
= aRect
.GetHeight();
819 xObj
->setVisualAreaSize( pObj
->GetAspect(), aSz
);
822 GetViewShellBase().SetVerbs( xObj
->getSupportedVerbs() );
828 aErrCode
= ERRCODE_SFX_OLEGENERAL
;
834 ::sd::View
* pView
= GetView();
836 if (pView
->IsTextEdit())
838 pView
->SdrEndTextEdit();
841 SfxInPlaceClient
* pSdClient
=
842 static_cast<Client
*>(pViewShell
->FindIPClient(
843 pObj
->GetObjRef(), GetActiveWindow()));
847 pSdClient
= new Client(pObj
, this, GetActiveWindow());
850 Rectangle aRect
= pObj
->GetLogicRect();
853 // #i118485# center on BoundRect for activation,
854 // OLE may be sheared/rotated now
855 const Rectangle
& rBoundRect
= pObj
->GetCurrentBoundRect();
856 const Point
aDelta(rBoundRect
.Center() - aRect
.Center());
857 aRect
.Move(aDelta
.X(), aDelta
.Y());
860 Size aDrawSize
= aRect
.GetSize();
862 MapMode
aMapMode( GetDoc()->GetScaleUnit() );
863 Size aObjAreaSize
= pObj
->GetOrigObjSize( &aMapMode
);
864 if( pObj
->IsChart() ) //charts never should be stretched see #i84323# for example
865 aObjAreaSize
= aDrawSize
;
867 Fraction
aScaleWidth (aDrawSize
.Width(), aObjAreaSize
.Width() );
868 Fraction
aScaleHeight(aDrawSize
.Height(), aObjAreaSize
.Height() );
869 aScaleWidth
.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
870 aScaleHeight
.ReduceInaccurate(10);
871 pSdClient
->SetSizeScale(aScaleWidth
, aScaleHeight
);
873 // visible section is only changed in-place!
874 aRect
.SetSize(aObjAreaSize
);
875 // the object area size must be set after scaling, since it triggers the resizing
876 pSdClient
->SetObjArea(aRect
);
878 if( bChangeDefaultsForChart
&& xObj
.is())
880 AdaptDefaultsForChart( xObj
);
883 pSdClient
->DoVerb(nVerb
); // if necessary, ErrCode is outputted by Sfx
884 pViewShell
->GetViewFrame()->GetBindings().Invalidate(
885 SID_NAVIGATOR_STATE
, sal_True
, sal_False
);
888 GetDocSh()->SetWaitCursor( sal_False
);
890 if (aErrCode
!= 0 && !bAbort
)
892 ErrorHandler::HandleError(* new StringErrorInfo(aErrCode
, String() ) );
895 return aErrCode
== 0;
899 * @returns enclosing rectangle of all (split-) windows.
901 const Rectangle
& ViewShell::GetAllWindowRect()
903 maAllWindowRectangle
.SetPos(
904 mpContentWindow
->OutputToScreenPixel(Point(0,0)));
905 return maAllWindowRectangle
;
908 void ViewShell::ReadUserData(const String
&)
910 // zoom onto VisArea from FrameView
911 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA
,
912 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
916 void ViewShell::WriteUserData(String
&)
918 // writing of our data is always done in WriteFrameViewData()
919 WriteFrameViewData();
924 * Switch ruler on/off
926 void ViewShell::SetRuler(sal_Bool bRuler
)
928 mbHasRulers
= ( bRuler
&& !GetDocSh()->IsPreview() ); // no rulers on preview mode
930 if (mpHorizontalRuler
.get() != NULL
)
934 mpHorizontalRuler
->Show();
938 mpHorizontalRuler
->Hide();
942 if (mpVerticalRuler
.get() != NULL
)
946 mpVerticalRuler
->Show();
950 mpVerticalRuler
->Hide();
954 OSL_ASSERT(GetViewShell()!=NULL
);
955 if (IsMainViewShell())
956 GetViewShell()->InvalidateBorder();
960 sal_Int8
ViewShell::AcceptDrop (
961 const AcceptDropEvent
& rEvt
,
962 DropTargetHelper
& rTargetHelper
,
963 ::sd::Window
* pTargetWindow
,
967 ::sd::View
* pView
= GetView();
968 return( pView
? pView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
972 sal_Int8
ViewShell::ExecuteDrop (
973 const ExecuteDropEvent
& rEvt
,
974 DropTargetHelper
& rTargetHelper
,
975 ::sd::Window
* pTargetWindow
,
979 ::sd::View
* pView
= GetView();
980 return( pView
? pView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
983 void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence
<
984 ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
986 const sal_Int32 nIndex
= rSequence
.getLength();
987 rSequence
.realloc( nIndex
+ 1 );
989 OSL_ASSERT (GetViewShell()!=NULL
);
990 // Get the view id from the view shell in the center pane. This will
991 // usually be the called view shell, but to be on the safe side we call
992 // the main view shell explicitly.
993 sal_uInt16
nViewID (IMPRESS_FACTORY_ID
);
994 if (GetViewShellBase().GetMainViewShell().get() != NULL
)
995 nViewID
= GetViewShellBase().GetMainViewShell()->mpImpl
->GetViewId();
996 rSequence
[nIndex
].Name
= OUString( sUNO_View_ViewId
);
997 OUStringBuffer
sBuffer( "view" );
998 sBuffer
.append( static_cast<sal_Int32
>(nViewID
));
999 rSequence
[nIndex
].Value
<<= sBuffer
.makeStringAndClear();
1001 mpFrameView
->WriteUserDataSequence( rSequence
, bBrowse
);
1005 void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1007 mpFrameView
->ReadUserDataSequence( rSequence
, bBrowse
);
1010 void ViewShell::VisAreaChanged(const Rectangle
& rRect
)
1012 OSL_ASSERT (GetViewShell()!=NULL
);
1013 GetViewShell()->VisAreaChanged(rRect
);
1016 void ViewShell::SetWinViewPos(const Point
& rWinPos
, bool bUpdate
)
1018 if (mpContentWindow
.get() != NULL
)
1020 mpContentWindow
->SetWinViewPos(rWinPos
);
1024 mpContentWindow
->UpdateMapOrigin();
1025 mpContentWindow
->Invalidate();
1037 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
1038 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
1039 VisAreaChanged(aVisAreaWin
);
1041 ::sd::View
* pView
= GetView();
1044 pView
->VisAreaChanged(GetActiveWindow());
1048 Point
ViewShell::GetWinViewPos() const
1050 return mpContentWindow
->GetWinViewPos();
1053 Point
ViewShell::GetViewOrigin() const
1055 return mpContentWindow
->GetViewOrigin();
1058 void ViewShell::AdaptDefaultsForChart(
1059 const uno::Reference
< embed::XEmbeddedObject
> & xEmbObj
)
1063 uno::Reference
< chart2::XChartDocument
> xChartDoc( xEmbObj
->getComponent(), uno::UNO_QUERY
);
1064 OSL_ENSURE( xChartDoc
.is(), "Trying to set chart property to non-chart OLE" );
1065 if( !xChartDoc
.is())
1070 // set background to transparent (none)
1071 uno::Reference
< beans::XPropertySet
> xPageProp( xChartDoc
->getPageBackground());
1073 xPageProp
->setPropertyValue( "FillStyle" , uno::makeAny( drawing::FillStyle_NONE
));
1076 xPageProp
->setPropertyValue( "LineStyle" , uno::makeAny( drawing::LineStyle_NONE
));
1078 catch( const uno::Exception
& )
1080 OSL_FAIL( "Exception caught in AdaptDefaultsForChart" );
1085 } // end of namespace sd
1087 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */