1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "framework/PresentationFactory.hxx"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
29cdf0e10cSrcweir #include "DrawController.hxx"
30cdf0e10cSrcweir #include "ViewShellBase.hxx"
31cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
32cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
33cdf0e10cSrcweir #include <tools/diagnose_ex.h>
34cdf0e10cSrcweir #include "slideshow.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::com::sun::star::lang;
39cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
40cdf0e10cSrcweir
41cdf0e10cSrcweir using ::rtl::OUString;
42cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir namespace sd { namespace framework {
46cdf0e10cSrcweir
47cdf0e10cSrcweir namespace {
48cdf0e10cSrcweir
49cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 <lang::XInitialization> PresentationFactoryProviderInterfaceBase;
50cdf0e10cSrcweir
51cdf0e10cSrcweir class PresentationFactoryProvider
52cdf0e10cSrcweir : protected MutexOwner,
53cdf0e10cSrcweir public PresentationFactoryProviderInterfaceBase
54cdf0e10cSrcweir {
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir PresentationFactoryProvider (const Reference<XComponentContext>& rxContext);
57cdf0e10cSrcweir virtual ~PresentationFactoryProvider (void);
58cdf0e10cSrcweir
59cdf0e10cSrcweir virtual void SAL_CALL disposing (void);
60cdf0e10cSrcweir
61cdf0e10cSrcweir // XInitialization
62cdf0e10cSrcweir
63cdf0e10cSrcweir virtual void SAL_CALL initialize(
64cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArguments)
65cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
66cdf0e10cSrcweir };
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweir
70cdf0e10cSrcweir
71cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 <XView> PresentationViewInterfaceBase;
72cdf0e10cSrcweir
73cdf0e10cSrcweir /** The PresentationView is not an actual view, it is a marker whose
74cdf0e10cSrcweir existence in a configuration indicates that a slideshow is running
75cdf0e10cSrcweir (in another application window).
76cdf0e10cSrcweir */
77cdf0e10cSrcweir class PresentationView
78cdf0e10cSrcweir : protected MutexOwner,
79cdf0e10cSrcweir public PresentationViewInterfaceBase
80cdf0e10cSrcweir {
81cdf0e10cSrcweir public:
PresentationView(const Reference<XResourceId> & rxViewId)82cdf0e10cSrcweir PresentationView (const Reference<XResourceId>& rxViewId)
83cdf0e10cSrcweir : PresentationViewInterfaceBase(maMutex),mxResourceId(rxViewId) {};
~PresentationView(void)84cdf0e10cSrcweir virtual ~PresentationView (void) {};
85cdf0e10cSrcweir
86cdf0e10cSrcweir // XView
87cdf0e10cSrcweir
getResourceId(void)88cdf0e10cSrcweir virtual Reference<XResourceId> SAL_CALL getResourceId (void) throw (RuntimeException)
89cdf0e10cSrcweir { return mxResourceId; };
90cdf0e10cSrcweir
isAnchorOnly(void)91cdf0e10cSrcweir virtual sal_Bool SAL_CALL isAnchorOnly (void) throw (RuntimeException)
92cdf0e10cSrcweir { return false; }
93cdf0e10cSrcweir
94cdf0e10cSrcweir
95cdf0e10cSrcweir private:
96cdf0e10cSrcweir Reference<XResourceId> mxResourceId;
97cdf0e10cSrcweir };
98cdf0e10cSrcweir
99cdf0e10cSrcweir } // end of anonymous namespace.
100cdf0e10cSrcweir
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir
104cdf0e10cSrcweir //===== PresentationFactoryProvider service ===================================
105cdf0e10cSrcweir
PresentationFactoryProvider_createInstance(const Reference<XComponentContext> & rxContext)106cdf0e10cSrcweir Reference<XInterface> SAL_CALL PresentationFactoryProvider_createInstance (
107cdf0e10cSrcweir const Reference<XComponentContext>& rxContext)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir return Reference<XInterface>(static_cast<XWeak*>(new PresentationFactoryProvider(rxContext)));
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir
113cdf0e10cSrcweir
114cdf0e10cSrcweir
PresentationFactoryProvider_getImplementationName(void)115cdf0e10cSrcweir ::rtl::OUString PresentationFactoryProvider_getImplementationName (void) throw(RuntimeException)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
118cdf0e10cSrcweir "com.sun.star.comp.Draw.framework.PresentationFactoryProvider"));
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweir
123cdf0e10cSrcweir
PresentationFactoryProvider_getSupportedServiceNames(void)124cdf0e10cSrcweir Sequence<rtl::OUString> SAL_CALL PresentationFactoryProvider_getSupportedServiceNames (void)
125cdf0e10cSrcweir throw (RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir static const ::rtl::OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM(
128cdf0e10cSrcweir "com.sun.star.drawing.framework.PresentationFactoryProvider"));
129cdf0e10cSrcweir return Sequence<rtl::OUString>(&sServiceName, 1);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
132cdf0e10cSrcweir
133cdf0e10cSrcweir
134cdf0e10cSrcweir
135cdf0e10cSrcweir //===== PresentationFactory ===================================================
136cdf0e10cSrcweir
137cdf0e10cSrcweir const ::rtl::OUString PresentationFactory::msPresentationViewURL(
138cdf0e10cSrcweir OUString::createFromAscii("private:resource/view/Presentation"));
139cdf0e10cSrcweir
140cdf0e10cSrcweir
PresentationFactory(const Reference<frame::XController> & rxController)141cdf0e10cSrcweir PresentationFactory::PresentationFactory (
142cdf0e10cSrcweir const Reference<frame::XController>& rxController)
143cdf0e10cSrcweir : PresentationFactoryInterfaceBase(MutexOwner::maMutex),
144cdf0e10cSrcweir mxConfigurationController(),
145cdf0e10cSrcweir mxController(rxController)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir try
148cdf0e10cSrcweir {
149cdf0e10cSrcweir // Get the XController from the first argument.
150cdf0e10cSrcweir Reference<XControllerManager> xControllerManager(rxController, UNO_QUERY_THROW);
151cdf0e10cSrcweir mxConfigurationController = xControllerManager->getConfigurationController();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir catch (RuntimeException&)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir
160cdf0e10cSrcweir
161cdf0e10cSrcweir
162cdf0e10cSrcweir
~PresentationFactory(void)163cdf0e10cSrcweir PresentationFactory::~PresentationFactory (void)
164cdf0e10cSrcweir {
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir
168cdf0e10cSrcweir
169cdf0e10cSrcweir
disposing(void)170cdf0e10cSrcweir void SAL_CALL PresentationFactory::disposing (void)
171cdf0e10cSrcweir {
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176cdf0e10cSrcweir
177cdf0e10cSrcweir //----- XViewFactory ----------------------------------------------------------
178cdf0e10cSrcweir
createResource(const Reference<XResourceId> & rxViewId)179cdf0e10cSrcweir Reference<XResource> SAL_CALL PresentationFactory::createResource (
180cdf0e10cSrcweir const Reference<XResourceId>& rxViewId)
181cdf0e10cSrcweir throw (RuntimeException, IllegalArgumentException, WrappedTargetException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir ThrowIfDisposed();
184cdf0e10cSrcweir
185cdf0e10cSrcweir if (rxViewId.is())
186cdf0e10cSrcweir if ( ! rxViewId->hasAnchor() && rxViewId->getResourceURL().equals(msPresentationViewURL))
187cdf0e10cSrcweir return new PresentationView(rxViewId);
188cdf0e10cSrcweir
189cdf0e10cSrcweir return Reference<XResource>();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir
193cdf0e10cSrcweir
194cdf0e10cSrcweir
releaseResource(const Reference<XResource> & rxView)195cdf0e10cSrcweir void SAL_CALL PresentationFactory::releaseResource (
196cdf0e10cSrcweir const Reference<XResource>& rxView)
197cdf0e10cSrcweir throw (RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir ThrowIfDisposed();
200cdf0e10cSrcweir (void)rxView;
201cdf0e10cSrcweir
202cdf0e10cSrcweir Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY);
203cdf0e10cSrcweir if (xTunnel.is())
204cdf0e10cSrcweir {
205cdf0e10cSrcweir ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
206cdf0e10cSrcweir xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
207cdf0e10cSrcweir if (pController != NULL)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir ViewShellBase* pBase = pController->GetViewShellBase();
210cdf0e10cSrcweir if (pBase != NULL)
211cdf0e10cSrcweir SlideShow::Stop( *pBase );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir
217cdf0e10cSrcweir
218cdf0e10cSrcweir
219cdf0e10cSrcweir //===== XConfigurationChangeListener ==========================================
220cdf0e10cSrcweir
notifyConfigurationChange(const ConfigurationChangeEvent & rEvent)221cdf0e10cSrcweir void SAL_CALL PresentationFactory::notifyConfigurationChange (
222cdf0e10cSrcweir const ConfigurationChangeEvent& rEvent)
223cdf0e10cSrcweir throw (RuntimeException)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir (void)rEvent;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweir
231cdf0e10cSrcweir //===== lang::XEventListener ==================================================
232cdf0e10cSrcweir
disposing(const lang::EventObject & rEventObject)233cdf0e10cSrcweir void SAL_CALL PresentationFactory::disposing (
234cdf0e10cSrcweir const lang::EventObject& rEventObject)
235cdf0e10cSrcweir throw (RuntimeException)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir (void)rEventObject;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir
241cdf0e10cSrcweir
242cdf0e10cSrcweir
243cdf0e10cSrcweir
244cdf0e10cSrcweir //-----------------------------------------------------------------------------
245cdf0e10cSrcweir
ThrowIfDisposed(void) const246cdf0e10cSrcweir void PresentationFactory::ThrowIfDisposed (void) const
247cdf0e10cSrcweir throw (lang::DisposedException)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir throw lang::DisposedException (
252cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
253cdf0e10cSrcweir "PresentationFactory object has already been disposed")),
254cdf0e10cSrcweir const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
255cdf0e10cSrcweir }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir
259cdf0e10cSrcweir
260cdf0e10cSrcweir namespace {
261cdf0e10cSrcweir
262cdf0e10cSrcweir //===== PresentationFactoryProvider ===========================================
263cdf0e10cSrcweir
PresentationFactoryProvider(const Reference<XComponentContext> & rxContext)264cdf0e10cSrcweir PresentationFactoryProvider::PresentationFactoryProvider (
265cdf0e10cSrcweir const Reference<XComponentContext>& rxContext)
266cdf0e10cSrcweir : PresentationFactoryProviderInterfaceBase(maMutex)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir (void)rxContext;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir
272cdf0e10cSrcweir
273cdf0e10cSrcweir
~PresentationFactoryProvider(void)274cdf0e10cSrcweir PresentationFactoryProvider::~PresentationFactoryProvider (void)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir }
277cdf0e10cSrcweir
278cdf0e10cSrcweir
279cdf0e10cSrcweir
280cdf0e10cSrcweir
disposing(void)281cdf0e10cSrcweir void PresentationFactoryProvider::disposing (void)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
285cdf0e10cSrcweir
286cdf0e10cSrcweir
287cdf0e10cSrcweir
288cdf0e10cSrcweir // XInitialization
289cdf0e10cSrcweir
initialize(const Sequence<Any> & aArguments)290cdf0e10cSrcweir void SAL_CALL PresentationFactoryProvider::initialize(
291cdf0e10cSrcweir const Sequence<Any>& aArguments)
292cdf0e10cSrcweir throw (Exception, RuntimeException)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir if (aArguments.getLength() > 0)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir try
297cdf0e10cSrcweir {
298cdf0e10cSrcweir // Get the XController from the first argument.
299cdf0e10cSrcweir Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
300cdf0e10cSrcweir Reference<XControllerManager> xCM (xController, UNO_QUERY_THROW);
301cdf0e10cSrcweir Reference<XConfigurationController> xCC (xCM->getConfigurationController());
302cdf0e10cSrcweir if (xCC.is())
303cdf0e10cSrcweir xCC->addResourceFactory(
304cdf0e10cSrcweir PresentationFactory::msPresentationViewURL,
305cdf0e10cSrcweir new PresentationFactory(xController));
306cdf0e10cSrcweir }
307cdf0e10cSrcweir catch (RuntimeException&)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir
315cdf0e10cSrcweir
316cdf0e10cSrcweir } // end of anonymous namespace.
317cdf0e10cSrcweir
318cdf0e10cSrcweir
319cdf0e10cSrcweir } } // end of namespace sd::framework
320