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
;
802 bReturn
= GetView()->getSmartTags().RequestHelp(rHEvt
);
804 if(!bReturn
&& HasCurrentFunction())
806 bReturn
= GetCurrentFunction()->RequestHelp(rHEvt
);
816 FrameView
* ViewShell::GetFrameView (void)
824 void ViewShell::SetFrameView (FrameView
* pNewFrameView
)
826 mpFrameView
= pNewFrameView
;
827 ReadFrameViewData (mpFrameView
);
833 /*************************************************************************
835 |* Read FrameViews data and set actual views data
837 \************************************************************************/
839 void ViewShell::ReadFrameViewData(FrameView
*)
845 /*************************************************************************
847 |* Write actual views data to FrameView
849 \************************************************************************/
851 void ViewShell::WriteFrameViewData()
855 /*************************************************************************
857 |* Auf allen Split-Windows ein Update erzwingen.
859 \************************************************************************/
861 void ViewShell::UpdateWindows()
863 if (mpContentWindow
.get() != NULL
)
864 mpContentWindow
->Update();
867 /*************************************************************************
869 |* OLE-Object aktivieren
871 \************************************************************************/
873 BOOL
ViewShell::ActivateObject(SdrOle2Obj
* pObj
, long nVerb
)
875 ErrCode aErrCode
= 0;
877 SfxErrorContext
aEC(ERRCTX_SO_DOVERB
, GetActiveWindow(), RID_SO_ERRCTX
);
879 GetDocSh()->SetWaitCursor( TRUE
);
880 SfxViewShell
* pViewShell
= GetViewShell();
881 OSL_ASSERT (pViewShell
!=NULL
);
882 bool bChangeDefaultsForChart
= false;
884 uno::Reference
< embed::XEmbeddedObject
> xObj
= pObj
->GetObjRef();
887 /**********************************************************
888 * Leeres OLE-Objekt mit OLE-Objekt versehen
889 **********************************************************/
890 String aName
= pObj
->GetProgName();
891 ::rtl::OUString aObjName
;
894 if( aName
.EqualsAscii( "StarChart" ) || aName
.EqualsAscii("StarOrg") )
896 if( SvtModuleOptions().IsChart() )
898 aClass
= SvGlobalName( SO3_SCH_CLASSID
);
899 bChangeDefaultsForChart
= true;
902 else if( aName
.EqualsAscii( "StarCalc" ))
904 if( SvtModuleOptions().IsCalc() )
905 aClass
= SvGlobalName( SO3_SC_CLASSID
);
907 else if( aName
.EqualsAscii( "StarMath" ))
909 if( SvtModuleOptions().IsMath() )
910 aClass
= SvGlobalName( SO3_SM_CLASSID
);
913 if ( aClass
!= SvGlobalName() )
914 xObj
= GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass
.GetByteSequence(), aObjName
);
920 // Dialog "OLE-Objekt einfuegen" aufrufen
921 GetDocSh()->SetWaitCursor( FALSE
);
922 pViewShell
->GetViewFrame()->GetDispatcher()->Execute(
924 SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
925 xObj
= pObj
->GetObjRef();
926 GetDocSh()->SetWaitCursor( TRUE
);
936 /******************************************************
937 * OLE-Objekt ist nicht mehr leer
938 ******************************************************/
939 pObj
->SetEmptyPresObj(FALSE
);
940 pObj
->SetOutlinerParaObject(NULL
);
941 pObj
->SetGraphic(NULL
);
943 /******************************************************
944 * Das leere OLE-Objekt bekommt ein neues IPObj
945 ******************************************************/
948 pObj
->SetObjRef(xObj
);
949 pObj
->SetName(aObjName
);
950 pObj
->SetPersistName(aObjName
);
954 // Das Einfuegen hat der Dialog schon gemacht
955 pObj
->SetObjRef(xObj
);
958 Rectangle aRect
= pObj
->GetLogicRect();
960 if ( pObj
->GetAspect() != embed::Aspects::MSOLE_ICON
)
963 aSz
.Width
= aRect
.GetWidth();
964 aSz
.Height
= aRect
.GetHeight();
965 xObj
->setVisualAreaSize( pObj
->GetAspect(), aSz
);
968 GetViewShellBase().SetVerbs( xObj
->getSupportedVerbs() );
974 aErrCode
= ERRCODE_SFX_OLEGENERAL
;
980 ::sd::View
* pView
= GetView();
982 if (pView
->IsTextEdit())
984 pView
->SdrEndTextEdit();
987 SfxInPlaceClient
* pSdClient
=
988 static_cast<Client
*>(pViewShell
->FindIPClient(
989 pObj
->GetObjRef(), GetActiveWindow()));
993 pSdClient
= new Client(pObj
, this, GetActiveWindow());
996 Rectangle aRect
= pObj
->GetLogicRect();
997 Size aDrawSize
= aRect
.GetSize();
999 MapMode
aMapMode( GetDoc()->GetScaleUnit() );
1000 Size aObjAreaSize
= pObj
->GetOrigObjSize( &aMapMode
);
1001 if( pObj
->IsChart() ) //charts never should be stretched see #i84323# for example
1002 aObjAreaSize
= aDrawSize
;
1004 Fraction
aScaleWidth (aDrawSize
.Width(), aObjAreaSize
.Width() );
1005 Fraction
aScaleHeight(aDrawSize
.Height(), aObjAreaSize
.Height() );
1006 aScaleWidth
.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
1007 aScaleHeight
.ReduceInaccurate(10);
1008 pSdClient
->SetSizeScale(aScaleWidth
, aScaleHeight
);
1010 // sichtbarer Ausschnitt wird nur inplace veraendert!
1011 aRect
.SetSize(aObjAreaSize
);
1012 // the object area size must be set after scaling, since it triggers the resizing
1013 pSdClient
->SetObjArea(aRect
);
1015 if( bChangeDefaultsForChart
&& xObj
.is())
1017 AdaptDefaultsForChart( xObj
);
1020 pSdClient
->DoVerb(nVerb
); // ErrCode wird ggf. vom Sfx ausgegeben
1021 pViewShell
->GetViewFrame()->GetBindings().Invalidate(
1022 SID_NAVIGATOR_STATE
, TRUE
, FALSE
);
1025 GetDocSh()->SetWaitCursor( FALSE
);
1027 if (aErrCode
!= 0 && !bAbort
)
1029 ErrorHandler::HandleError(* new StringErrorInfo(aErrCode
, String() ) );
1032 return aErrCode
== 0;
1035 /*************************************************************************
1037 |* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
1039 \************************************************************************/
1041 const Rectangle
& ViewShell::GetAllWindowRect()
1043 maAllWindowRectangle
.SetPos(
1044 mpContentWindow
->OutputToScreenPixel(Point(0,0)));
1045 return maAllWindowRectangle
;
1048 /*************************************************************************
1052 \************************************************************************/
1053 void ViewShell::ReadUserData(const String
&)
1055 // Auf an FrameView gemerkte VisArea zoomen
1056 GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA
,
1057 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1060 /*************************************************************************
1064 \************************************************************************/
1066 void ViewShell::WriteUserData(String
&)
1068 // Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
1069 WriteFrameViewData();
1073 /*************************************************************************
1075 |* Lineale ein- / ausschalten
1077 \************************************************************************/
1079 void ViewShell::SetRuler(BOOL bRuler
)
1081 mbHasRulers
= ( bRuler
&& !GetDocSh()->IsPreview() ); // no rulers on preview mode
1083 if (mpHorizontalRuler
.get() != NULL
)
1087 mpHorizontalRuler
->Show();
1091 mpHorizontalRuler
->Hide();
1095 if (mpVerticalRuler
.get() != NULL
)
1099 mpVerticalRuler
->Show();
1103 mpVerticalRuler
->Hide();
1107 OSL_ASSERT(GetViewShell()!=NULL
);
1108 if (IsMainViewShell())
1109 GetViewShell()->InvalidateBorder();
1112 /*************************************************************************
1116 \************************************************************************/
1118 sal_Int8
ViewShell::AcceptDrop (
1119 const AcceptDropEvent
& rEvt
,
1120 DropTargetHelper
& rTargetHelper
,
1121 ::sd::Window
* pTargetWindow
,
1125 ::sd::View
* pView
= GetView();
1126 return( pView
? pView
->AcceptDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
1129 /*************************************************************************
1133 \************************************************************************/
1135 sal_Int8
ViewShell::ExecuteDrop (
1136 const ExecuteDropEvent
& rEvt
,
1137 DropTargetHelper
& rTargetHelper
,
1138 ::sd::Window
* pTargetWindow
,
1142 ::sd::View
* pView
= GetView();
1143 return( pView
? pView
->ExecuteDrop( rEvt
, rTargetHelper
, pTargetWindow
, nPage
, nLayer
) : DND_ACTION_NONE
);
1147 #pragma optimize ( "", on )
1150 void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence
<
1151 ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1153 const sal_Int32 nIndex
= rSequence
.getLength();
1154 rSequence
.realloc( nIndex
+ 1 );
1156 OSL_ASSERT (GetViewShell()!=NULL
);
1157 // Get the view id from the view shell in the center pane. This will
1158 // usually be the called view shell, but to be on the safe side we call
1159 // the main view shell explicitly.
1160 sal_uInt16
nViewID (IMPRESS_FACTORY_ID
);
1161 if (GetViewShellBase().GetMainViewShell().get() != NULL
)
1162 nViewID
= GetViewShellBase().GetMainViewShell()->mpImpl
->GetViewId();
1163 rSequence
[nIndex
].Name
= rtl::OUString (
1164 RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ViewId
) );
1165 rtl::OUStringBuffer
sBuffer (
1166 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1167 sBuffer
.append( static_cast<sal_Int32
>(nViewID
));
1168 rSequence
[nIndex
].Value
<<= sBuffer
.makeStringAndClear();
1170 mpFrameView
->WriteUserDataSequence( rSequence
, bBrowse
);
1174 void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1176 mpFrameView
->ReadUserDataSequence( rSequence
, bBrowse
);
1179 void ViewShell::VisAreaChanged(const Rectangle
& rRect
)
1181 OSL_ASSERT (GetViewShell()!=NULL
);
1182 GetViewShell()->VisAreaChanged(rRect
);
1185 void ViewShell::SetWinViewPos(const Point
& rWinPos
, bool bUpdate
)
1187 if (mpContentWindow
.get() != NULL
)
1189 mpContentWindow
->SetWinViewPos(rWinPos
);
1193 mpContentWindow
->UpdateMapOrigin();
1194 mpContentWindow
->Invalidate();
1206 Size aVisSizePixel
= GetActiveWindow()->GetOutputSizePixel();
1207 Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
1208 VisAreaChanged(aVisAreaWin
);
1210 ::sd::View
* pView
= GetView();
1213 pView
->VisAreaChanged(GetActiveWindow());
1217 Point
ViewShell::GetWinViewPos() const
1219 return mpContentWindow
->GetWinViewPos();
1222 Point
ViewShell::GetViewOrigin() const
1224 return mpContentWindow
->GetViewOrigin();
1227 void ViewShell::AdaptDefaultsForChart(
1228 const uno::Reference
< embed::XEmbeddedObject
> & xEmbObj
)
1232 uno::Reference
< chart2::XChartDocument
> xChartDoc( xEmbObj
->getComponent(), uno::UNO_QUERY
);
1233 OSL_ENSURE( xChartDoc
.is(), "Trying to set chart property to non-chart OLE" );
1234 if( !xChartDoc
.is())
1239 // set background to transparent (none)
1240 uno::Reference
< beans::XPropertySet
> xPageProp( xChartDoc
->getPageBackground());
1242 xPageProp
->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FillStyle")),
1243 uno::makeAny( drawing::FillStyle_NONE
));
1246 xPageProp
->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")),
1247 uno::makeAny( drawing::LineStyle_NONE
));
1249 catch( const uno::Exception
& )
1251 OSL_ENSURE( false, "Exception caught in AdaptDefaultsForChart" );
1256 } // end of namespace sd