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/lang/XMultiServiceFactory.hpp>
21 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <PresentationViewShell.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/objface.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <svx/svxids.hrc>
28 #include <svx/ruler.hxx>
29 #include <FrameView.hxx>
30 #include <DrawDocShell.hxx>
31 #include <slideshow.hxx>
33 #include <ViewShellBase.hxx>
38 #define ShellClass_PresentationViewShell
40 #include <sdslots.hxx>
44 SFX_IMPL_INTERFACE(PresentationViewShell
, DrawViewShell
)
46 void PresentationViewShell::InitInterface_Impl()
48 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS
, SfxVisibilityFlags::Standard
| SfxVisibilityFlags::FullScreen
| SfxVisibilityFlags::Server
,
49 ToolbarId::Draw_Toolbox_Sd
);
50 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION
, SfxVisibilityFlags::Standard
| SfxVisibilityFlags::Client
| SfxVisibilityFlags::Viewer
| SfxVisibilityFlags::ReadonlyDoc
,
51 ToolbarId::Draw_Viewer_Toolbox
);
52 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OPTIONS
, SfxVisibilityFlags::Standard
| SfxVisibilityFlags::Server
,
53 ToolbarId::Draw_Options_Toolbox
);
54 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_COMMONTASK
, SfxVisibilityFlags::Standard
| SfxVisibilityFlags::Server
,
55 ToolbarId::Draw_CommonTask_Toolbox
);
59 PresentationViewShell::PresentationViewShell( ViewShellBase
& rViewShellBase
, vcl::Window
* pParentWindow
, FrameView
* pFrameView
)
60 : DrawViewShell(rViewShellBase
, pParentWindow
, PageKind::Standard
, pFrameView
)
61 , mnAbortSlideShowEvent(nullptr)
63 if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
)
64 maOldVisArea
= GetDocSh()->GetVisArea( ASPECT_CONTENT
);
65 meShellType
= ST_PRESENTATION
;
68 PresentationViewShell::~PresentationViewShell()
70 if (mnAbortSlideShowEvent
)
71 Application::RemoveUserEvent(mnAbortSlideShowEvent
);
73 if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
&& !maOldVisArea
.IsEmpty() )
74 GetDocSh()->SetVisArea( maOldVisArea
);
77 void PresentationViewShell::FinishInitialization( FrameView
* pFrameView
)
79 DrawViewShell::Init(true);
81 // Use the frame view that comes form the view shell that initiated our
83 if (pFrameView
!= nullptr)
85 GetFrameView()->Disconnect();
86 SetFrameView (pFrameView
);
87 pFrameView
->Connect();
92 GetActiveWindow()->GrabFocus();
95 VclPtr
<SvxRuler
> PresentationViewShell::CreateHRuler(::sd::Window
*)
100 VclPtr
<SvxRuler
> PresentationViewShell::CreateVRuler(::sd::Window
*)
105 IMPL_LINK_NOARG(PresentationViewShell
, AbortSlideShowHdl
, void*, void)
107 mnAbortSlideShowEvent
= nullptr;
108 rtl::Reference
<SlideShow
> xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
113 void PresentationViewShell::Activate( bool bIsMDIActivate
)
115 DrawViewShell::Activate( bIsMDIActivate
);
119 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, true );
121 GetViewFrame()->GetDispatcher()->ExecuteList(SID_NAVIGATOR_INIT
,
122 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, { &aItem
});
124 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
125 if( xSlideShow
.is() )
127 bool bSuccess
= xSlideShow
->activate(GetViewShellBase());
130 /* tdf#64711 PresentationViewShell is deleted by 'end' due to end closing
131 the object shell. So if we call xSlideShow->end during Activate there are
132 a lot of places in the call stack of Activate which understandable don't
133 expect this ViewShell to be deleted during use. Defer to the next event
134 loop the abort of the slideshow
136 if (!mnAbortSlideShowEvent
)
137 mnAbortSlideShowEvent
= Application::PostUserEvent(LINK(this, PresentationViewShell
, AbortSlideShowHdl
));
141 if( HasCurrentFunction() )
142 GetCurrentFunction()->Activate();
144 ReadFrameViewData(mpFrameView
);
147 GetDocSh()->Connect( this );
150 void PresentationViewShell::Paint( const ::tools::Rectangle
& /*rRect*/, ::sd::Window
* )
152 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
153 if( xSlideShow
.is() )
157 void PresentationViewShell::Resize()
159 ViewShell::Resize(); // do not call DrawViewShell here!
161 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
162 if( xSlideshow
.is() )
163 xSlideshow
->resize(maViewSize
);
166 } // end of namespace sd
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */