android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / presvish.cxx
blob34a789f4dd180d28fe62f76e2a6f6e7c2a72dd48
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
32 #include <app.hrc>
33 #include <ViewShellBase.hxx>
35 #include <fupoor.hxx>
36 #include <Window.hxx>
38 #define ShellClass_PresentationViewShell
39 using namespace sd;
40 #include <sdslots.hxx>
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::beans;
46 namespace sd {
48 SFX_IMPL_INTERFACE(PresentationViewShell, DrawViewShell)
50 void PresentationViewShell::InitInterface_Impl()
52 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server,
53 ToolbarId::Draw_Toolbox_Sd);
54 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer | SfxVisibilityFlags::ReadonlyDoc,
55 ToolbarId::Draw_Viewer_Toolbox);
56 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OPTIONS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
57 ToolbarId::Draw_Options_Toolbox);
58 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_COMMONTASK, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
59 ToolbarId::Draw_CommonTask_Toolbox);
63 PresentationViewShell::PresentationViewShell( ViewShellBase& rViewShellBase, vcl::Window* pParentWindow, FrameView* pFrameView)
64 : DrawViewShell(rViewShellBase, pParentWindow, PageKind::Standard, pFrameView)
65 , mnAbortSlideShowEvent(nullptr)
67 if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
68 maOldVisArea = GetDocSh()->GetVisArea( ASPECT_CONTENT );
69 meShellType = ST_PRESENTATION;
72 PresentationViewShell::~PresentationViewShell()
74 if (mnAbortSlideShowEvent)
75 Application::RemoveUserEvent(mnAbortSlideShowEvent);
77 if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && !maOldVisArea.IsEmpty() )
78 GetDocSh()->SetVisArea( maOldVisArea );
81 void PresentationViewShell::FinishInitialization( FrameView* pFrameView )
83 DrawViewShell::Init(true);
85 // Use the frame view that comes form the view shell that initiated our
86 // creation.
87 if (pFrameView != nullptr)
89 GetFrameView()->Disconnect();
90 SetFrameView (pFrameView);
91 pFrameView->Connect();
93 SetRuler(false);
94 WriteFrameViewData();
96 GetActiveWindow()->GrabFocus();
99 VclPtr<SvxRuler> PresentationViewShell::CreateHRuler(::sd::Window*)
101 return nullptr;
104 VclPtr<SvxRuler> PresentationViewShell::CreateVRuler(::sd::Window*)
106 return nullptr;
109 IMPL_LINK_NOARG(PresentationViewShell, AbortSlideShowHdl, void*, void)
111 mnAbortSlideShowEvent = nullptr;
112 rtl::Reference<SlideShow> xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
113 if (xSlideShow.is())
114 xSlideShow->end();
117 void PresentationViewShell::Activate( bool bIsMDIActivate )
119 DrawViewShell::Activate( bIsMDIActivate );
121 if( bIsMDIActivate )
123 SfxBoolItem aItem( SID_NAVIGATOR_INIT, true );
125 GetViewFrame()->GetDispatcher()->ExecuteList(SID_NAVIGATOR_INIT,
126 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
128 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
129 if( xSlideShow.is() )
131 bool bSuccess = xSlideShow->activate(GetViewShellBase());
132 if (!bSuccess)
134 /* tdf#64711 PresentationViewShell is deleted by 'end' due to end closing
135 the object shell. So if we call xSlideShow->end during Activate there are
136 a lot of places in the call stack of Activate which understandable don't
137 expect this ViewShell to be deleted during use. Defer to the next event
138 loop the abort of the slideshow
140 if (!mnAbortSlideShowEvent)
141 mnAbortSlideShowEvent = Application::PostUserEvent(LINK(this, PresentationViewShell, AbortSlideShowHdl));
145 if( HasCurrentFunction() )
146 GetCurrentFunction()->Activate();
148 ReadFrameViewData(mpFrameView);
151 GetDocSh()->Connect( this );
154 void PresentationViewShell::Paint( const ::tools::Rectangle& /*rRect*/, ::sd::Window* )
156 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
157 if( xSlideShow.is() )
158 xSlideShow->paint();
161 void PresentationViewShell::Resize()
163 ViewShell::Resize(); // do not call DrawViewShell here!
165 rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
166 if( xSlideshow.is() )
167 xSlideshow->resize(maViewSize);
170 } // end of namespace sd
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */