/src/libreoffice/sd/source/ui/view/presvish.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
21 | | #include <com/sun/star/beans/XPropertySet.hpp> |
22 | | |
23 | | #include <PresentationViewShell.hxx> |
24 | | #include <sfx2/dispatch.hxx> |
25 | | #include <sfx2/objface.hxx> |
26 | | #include <sfx2/toolbarids.hxx> |
27 | | #include <sfx2/viewfrm.hxx> |
28 | | #include <svx/svxids.hrc> |
29 | | #include <svx/ruler.hxx> |
30 | | #include <vcl/svapp.hxx> |
31 | | #include <FrameView.hxx> |
32 | | #include <DrawDocShell.hxx> |
33 | | #include <slideshow.hxx> |
34 | | #include <app.hrc> |
35 | | #include <ViewShellBase.hxx> |
36 | | |
37 | | #include <fupoor.hxx> |
38 | | #include <Window.hxx> |
39 | | |
40 | | #define ShellClass_PresentationViewShell |
41 | | using namespace sd; |
42 | | #include <sdslots.hxx> |
43 | | |
44 | | namespace sd { |
45 | | |
46 | | SFX_IMPL_INTERFACE(PresentationViewShell, DrawViewShell) |
47 | | |
48 | | void PresentationViewShell::InitInterface_Impl() |
49 | 5 | { |
50 | 5 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server, |
51 | 5 | ToolbarId::Draw_Toolbox_Sd); |
52 | 5 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer | SfxVisibilityFlags::ReadonlyDoc, |
53 | 5 | ToolbarId::Draw_Viewer_Toolbox); |
54 | 5 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OPTIONS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server, |
55 | 5 | ToolbarId::Draw_Options_Toolbox); |
56 | 5 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_COMMONTASK, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server, |
57 | 5 | ToolbarId::Draw_CommonTask_Toolbox); |
58 | 5 | } |
59 | | |
60 | | |
61 | | PresentationViewShell::PresentationViewShell( ViewShellBase& rViewShellBase, vcl::Window* pParentWindow, FrameView* pFrameView) |
62 | 0 | : DrawViewShell(rViewShellBase, pParentWindow, PageKind::Standard, pFrameView) |
63 | 0 | , mnAbortSlideShowEvent(nullptr) |
64 | 0 | { |
65 | 0 | if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) |
66 | 0 | maOldVisArea = GetDocSh()->GetVisArea( ASPECT_CONTENT ); |
67 | 0 | meShellType = ShellType::Presentation; |
68 | 0 | } |
69 | | |
70 | | PresentationViewShell::~PresentationViewShell() |
71 | 0 | { |
72 | 0 | if (mnAbortSlideShowEvent) |
73 | 0 | Application::RemoveUserEvent(mnAbortSlideShowEvent); |
74 | |
|
75 | 0 | if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && !maOldVisArea.IsEmpty() ) |
76 | 0 | GetDocSh()->SetVisArea( maOldVisArea ); |
77 | 0 | } |
78 | | |
79 | | void PresentationViewShell::FinishInitialization( FrameView* pFrameView ) |
80 | 0 | { |
81 | 0 | DrawViewShell::Init(true); |
82 | | |
83 | | // Use the frame view that comes form the view shell that initiated our |
84 | | // creation. |
85 | 0 | if (pFrameView != nullptr) |
86 | 0 | { |
87 | 0 | GetFrameView()->Disconnect(); |
88 | 0 | SetFrameView (pFrameView); |
89 | 0 | pFrameView->Connect(); |
90 | 0 | } |
91 | 0 | SetRuler(false); |
92 | 0 | WriteFrameViewData(); |
93 | |
|
94 | 0 | GetActiveWindow()->GrabFocus(); |
95 | 0 | } |
96 | | |
97 | | VclPtr<SvxRuler> PresentationViewShell::CreateHRuler(::sd::Window*) |
98 | 0 | { |
99 | 0 | return nullptr; |
100 | 0 | } |
101 | | |
102 | | VclPtr<SvxRuler> PresentationViewShell::CreateVRuler(::sd::Window*) |
103 | 0 | { |
104 | 0 | return nullptr; |
105 | 0 | } |
106 | | |
107 | | IMPL_LINK_NOARG(PresentationViewShell, AbortSlideShowHdl, void*, void) |
108 | 0 | { |
109 | 0 | mnAbortSlideShowEvent = nullptr; |
110 | 0 | rtl::Reference<SlideShow> xSlideShow(SlideShow::GetSlideShow(GetViewShellBase())); |
111 | 0 | if (xSlideShow.is()) |
112 | 0 | xSlideShow->end(); |
113 | 0 | } |
114 | | |
115 | | void PresentationViewShell::Activate( bool bIsMDIActivate ) |
116 | 0 | { |
117 | 0 | DrawViewShell::Activate( bIsMDIActivate ); |
118 | |
|
119 | 0 | if( bIsMDIActivate ) |
120 | 0 | { |
121 | 0 | SfxBoolItem aItem( SID_NAVIGATOR_INIT, true ); |
122 | |
|
123 | 0 | GetViewFrame()->GetDispatcher()->ExecuteList(SID_NAVIGATOR_INIT, |
124 | 0 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem }); |
125 | |
|
126 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
127 | 0 | if( xSlideShow.is() ) |
128 | 0 | { |
129 | 0 | bool bSuccess = xSlideShow->activate(GetViewShellBase()); |
130 | 0 | if (!bSuccess) |
131 | 0 | { |
132 | | /* tdf#64711 PresentationViewShell is deleted by 'end' due to end closing |
133 | | the object shell. So if we call xSlideShow->end during Activate there are |
134 | | a lot of places in the call stack of Activate which understandable don't |
135 | | expect this ViewShell to be deleted during use. Defer to the next event |
136 | | loop the abort of the slideshow |
137 | | */ |
138 | 0 | if (!mnAbortSlideShowEvent) |
139 | 0 | mnAbortSlideShowEvent = Application::PostUserEvent(LINK(this, PresentationViewShell, AbortSlideShowHdl)); |
140 | 0 | } |
141 | 0 | } |
142 | |
|
143 | 0 | if( HasCurrentFunction() ) |
144 | 0 | GetCurrentFunction()->Activate(); |
145 | |
|
146 | 0 | ReadFrameViewData(mpFrameView); |
147 | 0 | } |
148 | |
|
149 | 0 | GetDocSh()->Connect( this ); |
150 | 0 | } |
151 | | |
152 | | void PresentationViewShell::Paint( const ::tools::Rectangle& /*rRect*/, ::sd::Window* ) |
153 | 0 | { |
154 | 0 | rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
155 | 0 | if( xSlideShow.is() ) |
156 | 0 | xSlideShow->paint(); |
157 | 0 | } |
158 | | |
159 | | void PresentationViewShell::Resize() |
160 | 0 | { |
161 | 0 | ViewShell::Resize(); // do not call DrawViewShell here! |
162 | |
|
163 | 0 | rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) ); |
164 | 0 | if( xSlideshow.is() ) |
165 | 0 | xSlideshow->resize(maViewSize); |
166 | 0 | } |
167 | | |
168 | | } // end of namespace sd |
169 | | |
170 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |