Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "framework/PresentationFactory.hxx"
31 : :
32 : : #include "framework/FrameworkHelper.hxx"
33 : : #include "DrawController.hxx"
34 : : #include "ViewShellBase.hxx"
35 : : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
36 : : #include <cppuhelper/compbase1.hxx>
37 : : #include <tools/diagnose_ex.h>
38 : : #include "slideshow.hxx"
39 : :
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::lang;
43 : : using namespace ::com::sun::star::drawing::framework;
44 : :
45 : : using ::rtl::OUString;
46 : : using ::sd::framework::FrameworkHelper;
47 : :
48 : :
49 : : namespace sd { namespace framework {
50 : :
51 : : namespace {
52 : :
53 : : typedef ::cppu::WeakComponentImplHelper1 <lang::XInitialization> PresentationFactoryProviderInterfaceBase;
54 : :
55 : : class PresentationFactoryProvider
56 : : : protected MutexOwner,
57 : : public PresentationFactoryProviderInterfaceBase
58 : : {
59 : : public:
60 : : PresentationFactoryProvider (const Reference<XComponentContext>& rxContext);
61 : : virtual ~PresentationFactoryProvider (void);
62 : :
63 : : virtual void SAL_CALL disposing (void);
64 : :
65 : : // XInitialization
66 : :
67 : : virtual void SAL_CALL initialize(
68 : : const ::com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArguments)
69 : : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
70 : : };
71 : :
72 : :
73 : :
74 : :
75 : : typedef ::cppu::WeakComponentImplHelper1 <XView> PresentationViewInterfaceBase;
76 : :
77 : : /** The PresentationView is not an actual view, it is a marker whose
78 : : existence in a configuration indicates that a slideshow is running
79 : : (in another application window).
80 : : */
81 : : class PresentationView
82 : : : protected MutexOwner,
83 : : public PresentationViewInterfaceBase
84 : : {
85 : : public:
86 : 0 : PresentationView (const Reference<XResourceId>& rxViewId)
87 : 0 : : PresentationViewInterfaceBase(maMutex),mxResourceId(rxViewId) {};
88 [ # # ][ # # ]: 0 : virtual ~PresentationView (void) {};
89 : :
90 : : // XView
91 : :
92 : 0 : virtual Reference<XResourceId> SAL_CALL getResourceId (void) throw (RuntimeException)
93 : 0 : { return mxResourceId; };
94 : :
95 : 0 : virtual sal_Bool SAL_CALL isAnchorOnly (void) throw (RuntimeException)
96 : 0 : { return false; }
97 : :
98 : :
99 : : private:
100 : : Reference<XResourceId> mxResourceId;
101 : : };
102 : :
103 : : } // end of anonymous namespace.
104 : :
105 : :
106 : :
107 : :
108 : : //===== PresentationFactoryProvider service ===================================
109 : :
110 : 130 : Reference<XInterface> SAL_CALL PresentationFactoryProvider_createInstance (
111 : : const Reference<XComponentContext>& rxContext)
112 : : {
113 [ + - ]: 130 : return Reference<XInterface>(static_cast<XWeak*>(new PresentationFactoryProvider(rxContext)));
114 : : }
115 : :
116 : :
117 : :
118 : :
119 : 38 : ::rtl::OUString PresentationFactoryProvider_getImplementationName (void) throw(RuntimeException)
120 : : {
121 : 38 : return ::rtl::OUString("com.sun.star.comp.Draw.framework.PresentationFactoryProvider");
122 : : }
123 : :
124 : :
125 : :
126 : :
127 : 16 : Sequence<rtl::OUString> SAL_CALL PresentationFactoryProvider_getSupportedServiceNames (void)
128 : : throw (RuntimeException)
129 : : {
130 [ + - ][ + - ]: 16 : static const ::rtl::OUString sServiceName("com.sun.star.drawing.framework.PresentationFactoryProvider");
131 : 16 : return Sequence<rtl::OUString>(&sServiceName, 1);
132 : : }
133 : :
134 : :
135 : :
136 : :
137 : : //===== PresentationFactory ===================================================
138 : :
139 : 25 : const ::rtl::OUString PresentationFactory::msPresentationViewURL("private:resource/view/Presentation");
140 : :
141 : :
142 : 130 : PresentationFactory::PresentationFactory (
143 : : const Reference<frame::XController>& rxController)
144 : : : PresentationFactoryInterfaceBase(MutexOwner::maMutex),
145 : : mxConfigurationController(),
146 : 130 : mxController(rxController)
147 : : {
148 : : try
149 : : {
150 : : // Get the XController from the first argument.
151 [ + - ]: 130 : Reference<XControllerManager> xControllerManager(rxController, UNO_QUERY_THROW);
152 [ + - ][ + - ]: 130 : mxConfigurationController = xControllerManager->getConfigurationController();
[ + - ][ # # ]
153 : : }
154 [ # # ]: 0 : catch (RuntimeException&)
155 : : {
156 : : DBG_UNHANDLED_EXCEPTION();
157 : : }
158 : 130 : }
159 : :
160 : :
161 : :
162 : :
163 : :
164 [ + - ]: 130 : PresentationFactory::~PresentationFactory (void)
165 : : {
166 [ - + ]: 260 : }
167 : :
168 : :
169 : :
170 : :
171 : 130 : void SAL_CALL PresentationFactory::disposing (void)
172 : : {
173 : 130 : }
174 : :
175 : :
176 : :
177 : :
178 : : //----- XViewFactory ----------------------------------------------------------
179 : :
180 : 0 : Reference<XResource> SAL_CALL PresentationFactory::createResource (
181 : : const Reference<XResourceId>& rxViewId)
182 : : throw (RuntimeException, IllegalArgumentException, WrappedTargetException)
183 : : {
184 : 0 : ThrowIfDisposed();
185 : :
186 [ # # ]: 0 : if (rxViewId.is())
187 [ # # ][ # # ]: 0 : if ( ! rxViewId->hasAnchor() && rxViewId->getResourceURL().equals(msPresentationViewURL))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
188 [ # # ][ # # ]: 0 : return new PresentationView(rxViewId);
189 : :
190 : 0 : return Reference<XResource>();
191 : : }
192 : :
193 : :
194 : :
195 : :
196 : 0 : void SAL_CALL PresentationFactory::releaseResource (
197 : : const Reference<XResource>& rxView)
198 : : throw (RuntimeException)
199 : : {
200 [ # # ]: 0 : ThrowIfDisposed();
201 : : (void)rxView;
202 : :
203 [ # # ]: 0 : Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY);
204 [ # # ]: 0 : if (xTunnel.is())
205 : : {
206 : : ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
207 [ # # ][ # # ]: 0 : xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
[ # # ]
208 [ # # ]: 0 : if (pController != NULL)
209 : : {
210 [ # # ]: 0 : ViewShellBase* pBase = pController->GetViewShellBase();
211 [ # # ]: 0 : if (pBase != NULL)
212 [ # # ]: 0 : SlideShow::Stop( *pBase );
213 : : }
214 : 0 : }
215 : 0 : }
216 : :
217 : :
218 : :
219 : :
220 : : //===== XConfigurationChangeListener ==========================================
221 : :
222 : 0 : void SAL_CALL PresentationFactory::notifyConfigurationChange (
223 : : const ConfigurationChangeEvent& rEvent)
224 : : throw (RuntimeException)
225 : : {
226 : : (void)rEvent;
227 : 0 : }
228 : :
229 : :
230 : :
231 : :
232 : : //===== lang::XEventListener ==================================================
233 : :
234 : 0 : void SAL_CALL PresentationFactory::disposing (
235 : : const lang::EventObject& rEventObject)
236 : : throw (RuntimeException)
237 : : {
238 : : (void)rEventObject;
239 : 0 : }
240 : :
241 : :
242 : :
243 : :
244 : :
245 : : //-----------------------------------------------------------------------------
246 : :
247 : 0 : void PresentationFactory::ThrowIfDisposed (void) const
248 : : throw (lang::DisposedException)
249 : : {
250 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
251 : : {
252 : : throw lang::DisposedException ("PresentationFactory object has already been disposed",
253 [ # # ][ # # ]: 0 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
254 : : }
255 : 0 : }
256 : :
257 : :
258 : :
259 : : namespace {
260 : :
261 : : //===== PresentationFactoryProvider ===========================================
262 : :
263 : 130 : PresentationFactoryProvider::PresentationFactoryProvider (
264 : : const Reference<XComponentContext>& rxContext)
265 : 130 : : PresentationFactoryProviderInterfaceBase(maMutex)
266 : : {
267 : : (void)rxContext;
268 : 130 : }
269 : :
270 : :
271 : :
272 : :
273 [ + - ]: 130 : PresentationFactoryProvider::~PresentationFactoryProvider (void)
274 : : {
275 [ - + ]: 260 : }
276 : :
277 : :
278 : :
279 : :
280 : 130 : void PresentationFactoryProvider::disposing (void)
281 : : {
282 : 130 : }
283 : :
284 : :
285 : :
286 : :
287 : : // XInitialization
288 : :
289 : 130 : void SAL_CALL PresentationFactoryProvider::initialize(
290 : : const Sequence<Any>& aArguments)
291 : : throw (Exception, RuntimeException)
292 : : {
293 [ + - ]: 130 : if (aArguments.getLength() > 0)
294 : : {
295 : : try
296 : : {
297 : : // Get the XController from the first argument.
298 [ + - ]: 130 : Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
299 [ + - ]: 130 : Reference<XControllerManager> xCM (xController, UNO_QUERY_THROW);
300 [ + - ][ + - ]: 130 : Reference<XConfigurationController> xCC (xCM->getConfigurationController());
301 [ + - ]: 130 : if (xCC.is())
302 [ + - ]: 130 : xCC->addResourceFactory(
303 : : PresentationFactory::msPresentationViewURL,
304 [ + - ][ + - ]: 130 : new PresentationFactory(xController));
[ + - ][ + - ]
[ # # ]
305 : : }
306 : 0 : catch (RuntimeException&)
307 : : {
308 : : DBG_UNHANDLED_EXCEPTION();
309 : : }
310 : : }
311 : 130 : }
312 : :
313 : :
314 : :
315 : : } // end of anonymous namespace.
316 : :
317 : :
318 [ + - ][ + - ]: 75 : } } // end of namespace sd::framework
319 : :
320 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|