1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SDEXT_PRESENTER_PANE_FACTORY_HXX
29 #define SDEXT_PRESENTER_PANE_FACTORY_HXX
30 
31 #include <cppuhelper/compbase1.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 #include <com/sun/star/frame/XController.hpp>
34 #include <com/sun/star/lang/XInitialization.hpp>
35 #include <com/sun/star/drawing/XPresenterHelper.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/drawing/framework/XPane.hpp>
38 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <rtl/ref.hxx>
41 #include <boost/scoped_ptr.hpp>
42 #include <map>
43 
44 namespace css = ::com::sun::star;
45 
46 namespace sdext { namespace presenter {
47 
48 class PresenterController;
49 
50 namespace {
51     typedef ::cppu::WeakComponentImplHelper1 <
52         css::drawing::framework::XResourceFactory
53     > PresenterPaneFactoryInterfaceBase;
54 }
55 
56 
57 /** The PresenerPaneFactory provides a fixed set of panes.
58 
59     In order to make the presener screen more easily extendable in the
60     future the set of supported panes could be made extendable on demand.
61 */
62 class PresenterPaneFactory
63     : public ::cppu::BaseMutex,
64       public PresenterPaneFactoryInterfaceBase
65 {
66 public:
67     static const ::rtl::OUString msCurrentSlidePreviewPaneURL;
68     static const ::rtl::OUString msNextSlidePreviewPaneURL;
69     static const ::rtl::OUString msNotesPaneURL;
70     static const ::rtl::OUString msToolBarPaneURL;
71     static const ::rtl::OUString msSlideSorterPaneURL;
72     static const ::rtl::OUString msHelpPaneURL;
73     static const ::rtl::OUString msOverlayPaneURL;
74 
75     /** Create a new instance of this class and register it as resource
76         factory in the drawing framework of the given controller.
77         This registration keeps it alive.  When the drawing framework is
78         shut down and releases its reference to the factory then the factory
79         is destroyed.
80     */
81     static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
82         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
83         const css::uno::Reference<css::frame::XController>& rxController,
84         const ::rtl::Reference<PresenterController>& rpPresenterController);
85     virtual ~PresenterPaneFactory (void);
86 
87     static ::rtl::OUString getImplementationName_static (void);
88     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
89     static css::uno::Reference<css::uno::XInterface> Create(
90         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
91         SAL_THROW((css::uno::Exception));
92 
93     virtual void SAL_CALL disposing (void)
94         throw (css::uno::RuntimeException);
95 
96     // XResourceFactory
97 
98     virtual css::uno::Reference<css::drawing::framework::XResource>
99         SAL_CALL createResource (
100             const ::com::sun::star::uno::Reference<
101                 com::sun::star::drawing::framework::XResourceId>& rxPaneId)
102         throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException);
103 
104     virtual void SAL_CALL
105         releaseResource (
106             const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResource>&
107                 rxPane)
108         throw (::com::sun::star::uno::RuntimeException);
109 
110 private:
111     css::uno::WeakReference<css::uno::XComponentContext> mxComponentContextWeak;
112     css::uno::WeakReference<css::drawing::framework::XConfigurationController>
113         mxConfigurationControllerWeak;
114     ::rtl::Reference<PresenterController> mpPresenterController;
115     typedef ::std::map<rtl::OUString, css::uno::Reference<css::drawing::framework::XResource> >
116         ResourceContainer;
117     ::boost::scoped_ptr<ResourceContainer> mpResourceCache;
118 
119     PresenterPaneFactory (
120         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
121         const ::rtl::Reference<PresenterController>& rpPresenterController);
122 
123     void Register (const css::uno::Reference<css::frame::XController>& rxController);
124 
125     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
126         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
127         const ::rtl::OUString& rsTitle);
128     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
129         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
130         const ::rtl::OUString& rsTitle,
131         const css::uno::Reference<css::drawing::framework::XPane>& rxParentPane,
132         const bool bIsSpritePane);
133 
134     void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
135 };
136 
137 } }
138 
139 #endif
140