1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewshe2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/chart2/XChartDocument.hpp>
36 #include <com/sun/star/drawing/FillStyle.hpp>
37 #include <com/sun/star/drawing/LineStyle.hpp>
39 #include "ViewShell.hxx"
40 #include "ViewShellHint.hxx"
42 #include "ViewShellImplementation.hxx"
43 #include "FactoryIds.hxx"
46 #include <svx/svxids.hrc>
48 #ifndef _SCRBAR_HXX //autogen
49 #include <vcl/scrbar.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <sfx2/app.hxx>
54 #include <svx/ruler.hxx>
55 #include <svx/outliner.hxx>
56 #include <svtools/ehdl.hxx>
57 #include <svx/svdoole2.hxx>
58 #include <svtools/sfxecode.hxx>
59 #include <svx/fmshell.hxx>
60 #include <sfx2/dispatch.hxx>
61 #include <rtl/ustrbuf.hxx>
62 #include <svtools/moduleoptions.hxx>
63 #ifndef _SVX_DIALOGS_HRC
64 #include <svx/dialogs.hrc>
66 #include <sot/clsids.hxx>
69 #include "strings.hrc"
71 #include "unokywds.hxx"
73 #include "sdundogr.hxx"
74 #include "FrameView.hxx"
75 #include "undopage.hxx"
76 #include "sdresid.hxx"
77 #include "drawdoc.hxx"
81 #include "DrawDocShell.hxx"
82 #include "fusearch.hxx"
83 #include "slideshow.hxx"
85 #include "DrawViewShell.hxx"
86 #include "ViewShellBase.hxx"
90 #include <sfx2/viewfrm.hxx>
91 #include <svtools/soerr.hxx>
92 #include <toolkit/helper/vclunohelper.hxx>
95 #pragma optimize ( "", off )
98 using namespace com::sun::star
;
100 const String aEmptyStr
;
104 /*************************************************************************
106 |* Scrollbar-Update: Thumbpos und VisibleSize anpassen
108 \************************************************************************/
110 void ViewShell::UpdateScrollBars()
112 if (mpHorizontalScrollBar
.get() != NULL
)
114 long nW
= (long)(mpContentWindow
->GetVisibleWidth() * 32000);
115 long nX
= (long)(mpContentWindow
->GetVisibleX() * 32000);
116 mpHorizontalScrollBar
->SetVisibleSize(nW
);
117 mpHorizontalScrollBar
->SetThumbPos(nX
);
119 long nLine
= (long) (mpContentWindow
->GetScrlLineWidth() * nW
);
120 long nPage
= (long) (mpContentWindow
->GetScrlPageWidth() * nW
);
121 mpHorizontalScrollBar
->SetLineSize(nLine
);
122 mpHorizontalScrollBar
->SetPageSize(nPage
);
125 if (mpVerticalScrollBar
.get() != NULL
)
127 long nH
= (long)(mpContentWindow
->GetVisibleHeight() * 32000);
128 long nY
= (long)(mpContentWindow
->GetVisibleY() * 32000);
130 if(IsPageFlipMode()) // ie in zoom mode where no panning
132 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
133 USHORT nCurPage
= (pPage
->GetPageNum() - 1) / 2;
134 USHORT nTotalPages
= GetDoc()->GetSdPageCount(pPage
->GetPageKind());
135 mpVerticalScrollBar
->SetRange(Range(0,256*nTotalPages
));
136 mpVerticalScrollBar
->SetVisibleSize(256);
137 mpVerticalScrollBar
->SetThumbPos(256*nCurPage
);
138 mpVerticalScrollBar
->SetLineSize(256);
139 mpVerticalScrollBar
->SetPageSize(256);
143 mpVerticalScrollBar
->SetRange(Range(0,32000));
144 mpVerticalScrollBar
->SetVisibleSize(nH
);
145 mpVerticalScrollBar
->SetThumbPos(nY
);
147 long nLine
= (long) (mpContentWindow
->GetScrlLineHeight() * nH
);
148 long nPage
= (long) (mpContentWindow
->GetScrlPageHeight() * nH
);
149 mpVerticalScrollBar
->SetLineSize(nLine
);
150 mpVerticalScrollBar
->SetPageSize(nPage
);
161 /*************************************************************************
163 |* Handling fuer horizontale Scrollbars
165 \************************************************************************/
167 IMPL_LINK_INLINE_START(ViewShell
, HScrollHdl
, ScrollBar
*, pHScroll
)
169 return VirtHScrollHdl(pHScroll
);
171 IMPL_LINK_INLINE_END(ViewShell
, HScrollHdl
, ScrollBar
*, pHScroll
)
173 /*************************************************************************
175 |* virtueller Scroll-Handler fuer horizontale Scrollbars
177 \************************************************************************/
179 long ViewShell::VirtHScrollHdl(ScrollBar
* pHScroll
)
181 long nDelta
= pHScroll
->GetDelta();
185 double fX
= (double) pHScroll
->GetThumbPos() / pHScroll
->GetRange().Len();
187 // alle Fenster der Spalte scrollen
188 ::sd::View
* pView
= GetView();
189 OutlinerView
* pOLV
= NULL
;
192 pOLV
= pView
->GetTextEditOutlinerView();
197 mpContentWindow
->SetVisibleXY(fX
, -1);
199 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
200 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
201 aVisArea
.SetPos(aVisAreaPos
);
202 GetDocSh()->SetVisArea(aVisArea
);
204 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
205 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
206 VisAreaChanged(aVisAreaWin
);
210 pView
->VisAreaChanged(GetActiveWindow());
224 /*************************************************************************
226 |* Handling fuer vertikale Scrollbars
228 \************************************************************************/
230 IMPL_LINK_INLINE_START(ViewShell
, VScrollHdl
, ScrollBar
*, pVScroll
)
232 return VirtVScrollHdl(pVScroll
);
234 IMPL_LINK_INLINE_END(ViewShell
, VScrollHdl
, ScrollBar
*, pVScroll
)
236 /*************************************************************************
238 |* Handling fuer vertikale Scrollbars
240 \************************************************************************/
242 long ViewShell::VirtVScrollHdl(ScrollBar
* pVScroll
)
246 SdPage
* pPage
= static_cast<DrawViewShell
*>(this)->GetActualPage();
247 USHORT nCurPage
= (pPage
->GetPageNum() - 1) >> 1;
248 USHORT nNewPage
= (USHORT
)pVScroll
->GetThumbPos()/256;
249 if( nCurPage
!= nNewPage
)
250 static_cast<DrawViewShell
*>(this)->SwitchPage(nNewPage
);
254 double fY
= (double) pVScroll
->GetThumbPos() / pVScroll
->GetRange().Len();
256 ::sd::View
* pView
= GetView();
257 OutlinerView
* pOLV
= NULL
;
260 pOLV
= pView
->GetTextEditOutlinerView();
265 mpContentWindow
->SetVisibleXY(-1, fY
);
267 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
268 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
269 aVisArea
.SetPos(aVisAreaPos
);
270 GetDocSh()->SetVisArea(aVisArea
);
272 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
273 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
274 VisAreaChanged(aVisAreaWin
);
278 pView
->VisAreaChanged(GetActiveWindow());
292 SvxRuler
* ViewShell::CreateHRuler(::sd::Window
* , BOOL
)
297 SvxRuler
* ViewShell::CreateVRuler(::sd::Window
* )
302 void ViewShell::UpdateHRuler()
306 void ViewShell::UpdateVRuler()
310 long ViewShell::GetHCtrlWidth()
315 /*************************************************************************
317 |* Eine bestimmte Anzahl von Zeilen scrollen (wird beim automatischen
318 |* Scrollen (Zeichen/Draggen) verwendet)
320 \************************************************************************/
322 void ViewShell::ScrollLines(long nLinesX
, long nLinesY
)
326 nLinesX
*= mpHorizontalScrollBar
->GetLineSize();
330 nLinesY
*= mpVerticalScrollBar
->GetLineSize();
333 Scroll(nLinesX
, nLinesY
);
336 /*************************************************************************
338 |* Window um nScrollX, nScrollY scrollen
340 \************************************************************************/
342 void ViewShell::Scroll(long nScrollX
, long nScrollY
)
346 long nNewThumb
= mpHorizontalScrollBar
->GetThumbPos() + nScrollX
;
347 mpHorizontalScrollBar
->SetThumbPos(nNewThumb
);
351 long nNewThumb
= mpVerticalScrollBar
->GetThumbPos() + nScrollY
;
352 mpVerticalScrollBar
->SetThumbPos(nNewThumb
);
354 double fX
= (double) mpHorizontalScrollBar
->GetThumbPos() /
355 mpHorizontalScrollBar
->GetRange().Len();
356 double fY
= (double) mpVerticalScrollBar
->GetThumbPos() /
357 mpVerticalScrollBar
->GetRange().Len();
359 GetActiveWindow()->SetVisibleXY(fX
, fY
);
361 Rectangle aVisArea
= GetDocSh()->GetVisArea(ASPECT_CONTENT
);
362 Point aVisAreaPos
= GetActiveWindow()->PixelToLogic( Point(0,0) );
363 aVisArea
.SetPos(aVisAreaPos
);
364 GetDocSh()->SetVisArea(aVisArea
);
366 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
367 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
368 VisAreaChanged(aVisAreaWin
);
370 ::sd::View
* pView
= GetView();
373 pView
->VisAreaChanged(GetActiveWindow());
383 /*************************************************************************
385 |* Den Zoomfaktor fuer alle Split-Windows setzen
387 \************************************************************************/
389 void ViewShell::SetZoom(long nZoom
)
391 Fraction
aUIScale(nZoom
, 100);
392 aUIScale
*= GetDoc()->GetUIScale();
394 if (mpHorizontalRuler
.get() != NULL
)
395 mpHorizontalRuler
->SetZoom(aUIScale
);
397 if (mpVerticalRuler
.get() != NULL
)
398 mpVerticalRuler
->SetZoom(aUIScale
);
400 if (mpContentWindow
.get() != NULL
)
402 mpContentWindow
->SetZoomIntegral(nZoom
);
404 // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
405 // of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
406 // the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
407 // but does not solve the problem completely. Neet to ask PL.
408 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
411 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
412 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
413 VisAreaChanged(aVisAreaWin
);
415 ::sd::View
* pView
= GetView();
418 pView
->VisAreaChanged(GetActiveWindow());
424 /*************************************************************************
426 |* Zoomrechteck fuer aktives Fenster einstellen und alle Split-Windows
427 |* auf den gleichen Zoomfaktor setzen
429 \************************************************************************/
431 void ViewShell::SetZoomRect(const Rectangle
& rZoomRect
)
433 long nZoom
= GetActiveWindow()->SetZoomRect(rZoomRect
);
434 Fraction
aUIScale(nZoom
, 100);
435 aUIScale
*= GetDoc()->GetUIScale();
437 Point aPos
= GetActiveWindow()->GetWinViewPos();
439 if (mpHorizontalRuler
.get() != NULL
)
440 mpHorizontalRuler
->SetZoom(aUIScale
);
442 if (mpVerticalRuler
.get() != NULL
)
443 mpVerticalRuler
->SetZoom(aUIScale
);
445 if (mpContentWindow
.get() != NULL
)
447 Point aNewPos
= mpContentWindow
->GetWinViewPos();
448 aNewPos
.X() = aPos
.X();
449 aNewPos
.Y() = aPos
.Y();
450 mpContentWindow
->SetZoomIntegral(nZoom
);
451 mpContentWindow
->SetWinViewPos(aNewPos
);
452 mpContentWindow
->UpdateMapOrigin();
454 // #i74769# see above
455 mpContentWindow
->Invalidate(INVALIDATE_CHILDREN
);
458 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
459 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
460 VisAreaChanged(aVisAreaWin
);
462 ::sd::View
* pView
= GetView();
465 pView
->VisAreaChanged(GetActiveWindow());
471 /*************************************************************************
473 |* Abbildungsparameter fuer alle Split-Windows initialisieren
475 \************************************************************************/
477 void ViewShell::InitWindows(const Point
& rViewOrigin
, const Size
& rViewSize
,
478 const Point
& rWinPos
, BOOL bUpdate
)
480 if (mpContentWindow
.get() != NULL
)
482 mpContentWindow
->SetViewOrigin(rViewOrigin
);
483 mpContentWindow
->SetViewSize(rViewSize
);
484 mpContentWindow
->SetWinViewPos(rWinPos
);
488 mpContentWindow
->UpdateMapOrigin();
489 mpContentWindow
->Invalidate();
493 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
494 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
495 VisAreaChanged(aVisAreaWin
);
497 ::sd::View
* pView
= GetView();
500 pView
->VisAreaChanged(GetActiveWindow());
504 /*************************************************************************
506 |* Alle Split-Windows unter dem uebergebenen Rechteck invalidieren
508 \************************************************************************/
510 void ViewShell::InvalidateWindows()
512 if (mpContentWindow
.get() != NULL
)
513 mpContentWindow
->Invalidate();
517 /*************************************************************************
519 |* Auf allen Split-Windows ein Markierungsrechteck mit dem
520 |* uebergebenen Pen zeichnen
522 \************************************************************************/
524 void ViewShell::DrawMarkRect(const Rectangle
& rRect
) const
526 if (mpContentWindow
.get() != NULL
)
528 mpContentWindow
->InvertTracking(rRect
, SHOWTRACK_OBJECT
| SHOWTRACK_WINDOW
);
533 /*************************************************************************
535 |* Auf allen Split-Windows ein Rechteck zeichnen. Fuer den Rahmen wird der
536 |* uebergebene Pen, zum Fuellen die uebergebene Brush benutzt.
538 \************************************************************************/
540 void ViewShell::DrawFilledRect( const Rectangle
& rRect
, const Color
& rLColor
,
541 const Color
& rFColor
) const
543 if (mpContentWindow
.get() != NULL
)
545 const Color
& rOldLineColor
= mpContentWindow
->GetLineColor();
546 const Color
& rOldFillColor
= mpContentWindow
->GetFillColor();
548 mpContentWindow
->SetLineColor( rLColor
);
549 mpContentWindow
->SetFillColor( rFColor
);
551 mpContentWindow
->DrawRect(rRect
);
553 mpContentWindow
->SetLineColor( rOldLineColor
);
554 mpContentWindow
->SetFillColor( rOldFillColor
);
560 /*************************************************************************
562 |* Groesse und Raender aller Seiten setzen
564 \************************************************************************/
566 void ViewShell::SetPageSizeAndBorder(PageKind ePageKind
, const Size
& rNewSize
,
567 long nLeft
, long nRight
,
568 long nUpper
, long nLower
, BOOL bScaleAll
,
569 Orientation eOrientation
, USHORT nPaperBin
,
570 BOOL bBackgroundFullSize
)
573 SdUndoGroup
* pUndoGroup
= NULL
;
574 pUndoGroup
= new SdUndoGroup(GetDoc());
575 String
aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT
));
576 pUndoGroup
->SetComment(aString
);
577 SfxViewShell
* pViewShell
= GetViewShell();
578 OSL_ASSERT (pViewShell
!=NULL
);
580 USHORT i
, nPageCnt
= GetDoc()->GetMasterSdPageCount(ePageKind
);
582 Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START
));
584 for (i
= 0; i
< nPageCnt
; i
++)
586 /**********************************************************************
587 * Erst alle MasterPages bearbeiten
588 **********************************************************************/
589 pPage
= GetDoc()->GetMasterSdPage(i
, ePageKind
);
591 SdUndoAction
* pUndo
= new SdPageFormatUndoAction(GetDoc(), pPage
,
593 pPage
->GetLftBorder(), pPage
->GetRgtBorder(),
594 pPage
->GetUppBorder(), pPage
->GetLwrBorder(),
595 pPage
->IsScaleObjects(),
596 pPage
->GetOrientation(),
597 pPage
->GetPaperBin(),
598 pPage
->IsBackgroundFullSize(),
605 bBackgroundFullSize
);
606 pUndoGroup
->AddAction(pUndo
);
608 if (rNewSize
.Width() > 0 ||
609 nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0)
611 Rectangle
aNewBorderRect(nLeft
, nUpper
, nRight
, nLower
);
612 pPage
->ScaleObjects(rNewSize
, aNewBorderRect
, bScaleAll
);
614 if (rNewSize
.Width() > 0)
615 pPage
->SetSize(rNewSize
);
618 if( nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0 )
620 pPage
->SetBorder(nLeft
, nUpper
, nRight
, nLower
);
623 pPage
->SetOrientation(eOrientation
);
624 pPage
->SetPaperBin( nPaperBin
);
625 pPage
->SetBackgroundFullSize( bBackgroundFullSize
);
627 if ( ePageKind
== PK_STANDARD
)
628 GetDoc()->GetMasterSdPage(i
, PK_NOTES
)->CreateTitleAndLayout();
630 pPage
->CreateTitleAndLayout();
633 nPageCnt
= GetDoc()->GetSdPageCount(ePageKind
);
635 for (i
= 0; i
< nPageCnt
; i
++)
637 /**********************************************************************
638 * Danach alle Pages bearbeiten
639 **********************************************************************/
640 pPage
= GetDoc()->GetSdPage(i
, ePageKind
);
642 SdUndoAction
* pUndo
= new SdPageFormatUndoAction(GetDoc(), pPage
,
644 pPage
->GetLftBorder(), pPage
->GetRgtBorder(),
645 pPage
->GetUppBorder(), pPage
->GetLwrBorder(),
646 pPage
->IsScaleObjects(),
647 pPage
->GetOrientation(),
648 pPage
->GetPaperBin(),
649 pPage
->IsBackgroundFullSize(),
656 bBackgroundFullSize
);
657 pUndoGroup
->AddAction(pUndo
);
659 if (rNewSize
.Width() > 0 ||
660 nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0)
662 Rectangle
aNewBorderRect(nLeft
, nUpper
, nRight
, nLower
);
663 pPage
->ScaleObjects(rNewSize
, aNewBorderRect
, bScaleAll
);
665 if (rNewSize
.Width() > 0)
666 pPage
->SetSize(rNewSize
);
669 if( nLeft
>= 0 || nRight
>= 0 || nUpper
>= 0 || nLower
>= 0 )
671 pPage
->SetBorder(nLeft
, nUpper
, nRight
, nLower
);
674 pPage
->SetOrientation(eOrientation
);
675 pPage
->SetPaperBin( nPaperBin
);
676 pPage
->SetBackgroundFullSize( bBackgroundFullSize
);
678 if ( ePageKind
== PK_STANDARD
)
680 SdPage
* pNotesPage
= GetDoc()->GetSdPage(i
, PK_NOTES
);
681 pNotesPage
->SetAutoLayout( pNotesPage
->GetAutoLayout() );
684 pPage
->SetAutoLayout( pPage
->GetAutoLayout() );
687 // Handoutseite an neues Format der Standardseiten anpassen
688 if( (ePageKind
== PK_STANDARD
) || (ePageKind
== PK_HANDOUT
) )
689 GetDoc()->GetSdPage(0, PK_HANDOUT
)->CreateTitleAndLayout(TRUE
);
691 // Undo Gruppe dem Undo Manager uebergeben
692 pViewShell
->GetViewFrame()->GetObjectShell()
693 ->GetUndoManager()->AddUndoAction(pUndoGroup
);
695 long nWidth
= pPage
->GetSize().Width();
696 long nHeight
= pPage
->GetSize().Height();
698 Point aPageOrg
= Point(nWidth
, nHeight
/ 2);
699 Size aViewSize
= Size(nWidth
* 3, nHeight
* 2);
701 InitWindows(aPageOrg
, aViewSize
, Point(-1, -1), TRUE
);
705 if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
)
707 aVisAreaPos
= GetDocSh()->GetVisArea(ASPECT_CONTENT
).TopLeft();
710 ::sd::View
* pView
= GetView();
713 pView
->SetWorkArea(Rectangle(Point() - aVisAreaPos
- aPageOrg
, aViewSize
));
718 Point
aNewOrigin(pPage
->GetLftBorder(), pPage
->GetUppBorder());
722 pView
->GetSdrPageView()->SetPageOrigin(aNewOrigin
);
725 pViewShell
->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET
);
727 // auf (neue) Seitengroesse zoomen
728 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE
,
729 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
731 Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END
));
734 /*************************************************************************
736 |* Zoom-Faktor fuer InPlace einstellen
738 \************************************************************************/
740 void ViewShell::SetZoomFactor(const Fraction
& rZoomX
, const Fraction
&)
742 long nZoom
= (long)((double) rZoomX
* 100);
747 /*************************************************************************
749 |* Aktives Fenster setzen
751 \************************************************************************/
753 void ViewShell::SetActiveWindow (::sd::Window
* pWin
)
755 SfxViewShell
* pViewShell
= GetViewShell();
756 OSL_ASSERT (pViewShell
!=NULL
);
758 if (pViewShell
->GetWindow() != pWin
)
760 // #i31551# was wrong, it may have been a problem with the repaint at that time.
761 // For transparent form controls, it is necessary to have that flag set, all apps
762 // do set it. Enabling again.
765 pWin
->EnableChildTransparentMode();
769 if (mpActiveWindow
!= pWin
)
770 mpActiveWindow
= pWin
;
772 // The rest of this function is not guarded anymore against calling this
773 // method with an already active window because the functions may still
774 // point to the old window when the new one has already been assigned to
775 // pWindow elsewhere.
776 ::sd::View
* pView
= GetView();
779 pView
->SetActualWin(pWin
);
781 if(HasCurrentFunction())
783 GetCurrentFunction()->SetWindow(pWin
);
789 /*************************************************************************
793 \************************************************************************/
795 BOOL
ViewShell::RequestHelp(const HelpEvent
& rHEvt
, ::sd::Window
*)
797 BOOL bReturn
= FALSE
;
801 if(HasCurrentFunction())
803 bReturn
= GetCurrentFunction()->RequestHelp(rHEvt
);
813 FrameView
* ViewShell::GetFrameView (void)
821 void ViewShell::SetFrameView (FrameView
* pNewFrameView
)
823 mpFrameView
= pNewFrameView
;
824 ReadFrameViewData (mpFrameView
);
830 /*************************************************************************
832 |* Read FrameViews data and set actual views data
834 \************************************************************************/
836 void ViewShell::ReadFrameViewData(FrameView
*)
842 /*************************************************************************
844 |* Write actual views data to FrameView
846 \************************************************************************/
848 void ViewShell::WriteFrameViewData()
852 /*************************************************************************
854 |* Auf allen Split-Windows ein Update erzwingen.
856 \************************************************************************/
858 void ViewShell::UpdateWindows()
860 if (mpContentWindow
.get() != NULL
)
861 mpContentWindow
->Update();
864 /*************************************************************************
866 |* OLE-Object aktivieren
868 \************************************************************************/
870 BOOL
ViewShell::ActivateObject(SdrOle2Obj
* pObj
, long nVerb
)
872 ErrCode aErrCode
= 0;
874 SfxErrorContext
aEC(ERRCTX_SO_DOVERB
, GetActiveWindow(), RID_SO_ERRCTX
);
876 GetDocSh()->SetWaitCursor( TRUE
);
877 SfxViewShell
* pViewShell
= GetViewShell();
878 OSL_ASSERT (pViewShell
!=NULL
);
879 bool bChangeDefaultsForChart
= false;
881 uno::Reference
< embed::XEmbeddedObject
> xObj
= pObj
->GetObjRef();
884 /**********************************************************
885 * Leeres OLE-Objekt mit OLE-Objekt versehen
886 **********************************************************/
887 String aName
= pObj
->GetProgName();
888 ::rtl::OUString aObjName
;
891 if( aName
.EqualsAscii( "StarChart" ) || aName
.EqualsAscii("StarOrg") )
893 if( SvtModuleOptions().IsChart() )
895 aClass
= SvGlobalName( SO3_SCH_CLASSID
);
896 bChangeDefaultsForChart
= true;
899 else if( aName
.EqualsAscii( "StarCalc" ))
901 if( SvtModuleOptions().IsCalc() )
902 aClass
= SvGlobalName( SO3_SC_CLASSID
);
904 else if( aName
.EqualsAscii( "StarMath" ))
906 if( SvtModuleOptions().IsMath() )
907 aClass
= SvGlobalName( SO3_SM_CLASSID
);
910 if ( aClass
!= SvGlobalName() )
911 xObj
= GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass
.GetByteSequence(), aObjName
);
917 // Dialog "OLE-Objekt einfuegen" aufrufen
918 GetDocSh()->SetWaitCursor( FALSE
);
919 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(
921 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
922 xObj
= pObj
->GetObjRef();
923 GetDocSh()->SetWaitCursor( TRUE
);
933 /******************************************************
934 * OLE-Objekt ist nicht mehr leer
935 ******************************************************/
936 pObj
->SetEmptyPresObj(FALSE
);
937 pObj
->SetOutlinerParaObject(NULL
);
938 pObj
->SetGraphic(NULL
);
940 /******************************************************
941 * Das leere OLE-Objekt bekommt ein neues IPObj
942 ******************************************************/
945 pObj
->SetObjRef(xObj
);
946 pObj
->SetName(aObjName
);
947 pObj
->SetPersistName(aObjName
);
951 // Das Einfuegen hat der Dialog schon gemacht
952 pObj
->SetObjRef(xObj
);
955 Rectangle aRect
= pObj
->GetLogicRect();
957 if ( pObj
->GetAspect() != embed::Aspects::MSOLE_ICON
)
960 aSz
.Width
= aRect
.GetWidth();
961 aSz
.Height
= aRect
.GetHeight();
962 xObj
->setVisualAreaSize( pObj
->GetAspect(), aSz
);
965 GetViewShellBase().SetVerbs( xObj
->getSupportedVerbs() );
971 aErrCode
= ERRCODE_SFX_OLEGENERAL
;
977 ::sd::View
* pView
= GetView();
979 if (pView
->IsTextEdit())
981 pView
->SdrEndTextEdit();
984 SfxInPlaceClient
* pSdClient
=
985 static_cast<Client
*>(pViewShell
->FindIPClient(
986 pObj
->GetObjRef(), GetActiveWindow()));
990 pSdClient
= new Client(pObj
, this, GetActiveWindow());
993 Rectangle aRect
= pObj
->GetLogicRect();
994 Size aDrawSize
= aRect
.GetSize();
996 MapMode
aMapMode( GetDoc()->GetScaleUnit() );
997 Size aObjAreaSize
= pObj
->GetOrigObjSize( &aMapMode
);
998 if( pObj
->IsChart() ) //charts never should be stretched see #i84323# for example
999 aObjAreaSize
= aDrawSize
;
1001 Fraction
aScaleWidth (aDrawSize
.Width(), aObjAreaSize
.Width() );
1002 Fraction
aScaleHeight(aDrawSize
.Height(), aObjAreaSize
.Height() );
1003 aScaleWidth
.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
1004 aScaleHeight
.ReduceInaccurate(10);
1005 pSdClient
->SetSizeScale(aScaleWidth
, aScaleHeight
);
1007 // sichtbarer Ausschnitt wird nur inplace veraendert!
1008 aRect
.SetSize(aObjAreaSize
);
1009 // the object area size must be set after scaling, since it triggers the resizing
1010 pSdClient
->SetObjArea(aRect
);
1012 if( bChangeDefaultsForChart
&& xObj
.is())
1014 AdaptDefaultsForChart( xObj
);
1017 pSdClient
->DoVerb(nVerb
); // ErrCode wird ggf. vom Sfx ausgegeben
1018 pViewShell
->GetViewFrame()->GetBindings().Invalidate(
1019 SID_NAVIGATOR_STATE
, TRUE
, FALSE
);
1022 GetDocSh()->SetWaitCursor( FALSE
);
1024 if (aErrCode
!= 0 && !bAbort
)
1026 ErrorHandler::HandleError(* new StringErrorInfo(aErrCode
, String() ) );
1029 return aErrCode
== 0;
1032 /*************************************************************************
1034 |* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
1036 \************************************************************************/
1038 const Rectangle
& ViewShell::GetAllWindowRect()
1040 maAllWindowRectangle
.SetPos(
1041 mpContentWindow
->OutputToScreenPixel(Point(0,0)));
1042 return maAllWindowRectangle
;
1045 /*************************************************************************
1049 \************************************************************************/
1050 void ViewShell::ReadUserData(const String
&)
1052 // Auf an FrameView gemerkte VisArea zoomen
1053 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA
,
1054 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1057 /*************************************************************************
1061 \************************************************************************/
1063 void ViewShell::WriteUserData(String
&)
1065 // Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
1066 WriteFrameViewData();
1070 /*************************************************************************
1072 |* Lineale ein- / ausschalten
1074 \************************************************************************/
1076 void ViewShell::SetRuler(BOOL bRuler
)
1078 mbHasRulers
= ( bRuler
&& !GetDocSh()->IsPreview() ); // no rulers on preview mode
1080 if (mpHorizontalRuler
.get() != NULL
)
1084 mpHorizontalRuler
->Show();
1088 mpHorizontalRuler
->Hide();
1092 if (mpVerticalRuler
.get() != NULL
)
1096 mpVerticalRuler
->Show();
1100 mpVerticalRuler
->Hide();
1104 OSL_ASSERT(GetViewShell()!=NULL
);
1105 if (IsMainViewShell())
1106 GetViewShell()->InvalidateBorder();
1109 /*************************************************************************
1113 \************************************************************************/
1115 sal_Int8
ViewShell::AcceptDrop (
1116 const AcceptDropEvent
& rEvt
,
1117 DropTargetHelper
& rTargetHelper
,
1118 ::sd::Window
* pTargetWindow
,
1122 ::sd::View
* pView
= GetView();
1123 return( pView
? pView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
1126 /*************************************************************************
1130 \************************************************************************/
1132 sal_Int8
ViewShell::ExecuteDrop (
1133 const ExecuteDropEvent
& rEvt
,
1134 DropTargetHelper
& rTargetHelper
,
1135 ::sd::Window
* pTargetWindow
,
1139 ::sd::View
* pView
= GetView();
1140 return( pView
? pView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
1144 #pragma optimize ( "", on )
1147 void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence
<
1148 ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1150 const sal_Int32 nIndex
= rSequence
.getLength();
1151 rSequence
.realloc( nIndex
+ 1 );
1153 OSL_ASSERT (GetViewShell()!=NULL
);
1154 // Get the view id from the view shell in the center pane. This will
1155 // usually be the called view shell, but to be on the safe side we call
1156 // the main view shell explicitly.
1157 sal_uInt16
nViewID (IMPRESS_FACTORY_ID
);
1158 if (GetViewShellBase().GetMainViewShell().get() != NULL
)
1159 nViewID
= GetViewShellBase().GetMainViewShell()->mpImpl
->GetViewId();
1160 rSequence
[nIndex
].Name
= rtl::OUString (
1161 RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ViewId
) );
1162 rtl::OUStringBuffer
sBuffer (
1163 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1164 sBuffer
.append( static_cast<sal_Int32
>(nViewID
));
1165 rSequence
[nIndex
].Value
<<= sBuffer
.makeStringAndClear();
1167 mpFrameView
->WriteUserDataSequence( rSequence
, bBrowse
);
1171 void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1173 mpFrameView
->ReadUserDataSequence( rSequence
, bBrowse
);
1176 void ViewShell::VisAreaChanged(const Rectangle
& rRect
)
1178 OSL_ASSERT (GetViewShell()!=NULL
);
1179 GetViewShell()->VisAreaChanged(rRect
);
1182 void ViewShell::SetWinViewPos(const Point
& rWinPos
, bool bUpdate
)
1184 if (mpContentWindow
.get() != NULL
)
1186 mpContentWindow
->SetWinViewPos(rWinPos
);
1190 mpContentWindow
->UpdateMapOrigin();
1191 mpContentWindow
->Invalidate();
1203 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
1204 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
1205 VisAreaChanged(aVisAreaWin
);
1207 ::sd::View
* pView
= GetView();
1210 pView
->VisAreaChanged(GetActiveWindow());
1214 Point
ViewShell::GetWinViewPos() const
1216 return mpContentWindow
->GetWinViewPos();
1219 Point
ViewShell::GetViewOrigin() const
1221 return mpContentWindow
->GetViewOrigin();
1224 void ViewShell::AdaptDefaultsForChart(
1225 const uno::Reference
< embed::XEmbeddedObject
> & xEmbObj
)
1229 uno::Reference
< chart2::XChartDocument
> xChartDoc( xEmbObj
->getComponent(), uno::UNO_QUERY
);
1230 OSL_ENSURE( xChartDoc
.is(), "Trying to set chart property to non-chart OLE" );
1231 if( !xChartDoc
.is())
1236 // set background to transparent (none)
1237 uno::Reference
< beans::XPropertySet
> xPageProp( xChartDoc
->getPageBackground());
1239 xPageProp
->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FillStyle")),
1240 uno::makeAny( drawing::FillStyle_NONE
));
1243 xPageProp
->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")),
1244 uno::makeAny( drawing::LineStyle_NONE
));
1246 catch( const uno::Exception
& )
1248 OSL_ENSURE( false, "Exception caught in AdaptDefaultsForChart" );
1253 } // end of namespace sd