1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SDEXT_PRESENTER_PANE_FACTORY_HXX
25 #define SDEXT_PRESENTER_PANE_FACTORY_HXX
26 
27 #include <cppuhelper/compbase1.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <com/sun/star/frame/XController.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/drawing/XPresenterHelper.hpp>
32 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
33 #include <com/sun/star/drawing/framework/XPane.hpp>
34 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <rtl/ref.hxx>
37 #include <boost/scoped_ptr.hpp>
38 #include <map>
39 
40 namespace css = ::com::sun::star;
41 
42 namespace sdext { namespace presenter {
43 
44 class PresenterController;
45 
46 namespace {
47     typedef ::cppu::WeakComponentImplHelper1 <
48         css::drawing::framework::XResourceFactory
49     > PresenterPaneFactoryInterfaceBase;
50 }
51 
52 
53 /** The PresenerPaneFactory provides a fixed set of panes.
54 
55     In order to make the presener screen more easily extendable in the
56     future the set of supported panes could be made extendable on demand.
57 */
58 class PresenterPaneFactory
59     : public ::cppu::BaseMutex,
60       public PresenterPaneFactoryInterfaceBase
61 {
62 public:
63     static const ::rtl::OUString msCurrentSlidePreviewPaneURL;
64     static const ::rtl::OUString msNextSlidePreviewPaneURL;
65     static const ::rtl::OUString msNotesPaneURL;
66     static const ::rtl::OUString msToolBarPaneURL;
67     static const ::rtl::OUString msSlideSorterPaneURL;
68     static const ::rtl::OUString msHelpPaneURL;
69     static const ::rtl::OUString msOverlayPaneURL;
70 
71     /** Create a new instance of this class and register it as resource
72         factory in the drawing framework of the given controller.
73         This registration keeps it alive.  When the drawing framework is
74         shut down and releases its reference to the factory then the factory
75         is destroyed.
76     */
77     static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
78         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
79         const css::uno::Reference<css::frame::XController>& rxController,
80         const ::rtl::Reference<PresenterController>& rpPresenterController);
81     virtual ~PresenterPaneFactory (void);
82 
83     static ::rtl::OUString getImplementationName_static (void);
84     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
85     static css::uno::Reference<css::uno::XInterface> Create(
86         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
87         SAL_THROW((css::uno::Exception));
88 
89     virtual void SAL_CALL disposing (void)
90         throw (css::uno::RuntimeException);
91 
92     // XResourceFactory
93 
94     virtual css::uno::Reference<css::drawing::framework::XResource>
95         SAL_CALL createResource (
96             const ::com::sun::star::uno::Reference<
97                 com::sun::star::drawing::framework::XResourceId>& rxPaneId)
98         throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException);
99 
100     virtual void SAL_CALL
101         releaseResource (
102             const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResource>&
103                 rxPane)
104         throw (::com::sun::star::uno::RuntimeException);
105 
106 private:
107     css::uno::WeakReference<css::uno::XComponentContext> mxComponentContextWeak;
108     css::uno::WeakReference<css::drawing::framework::XConfigurationController>
109         mxConfigurationControllerWeak;
110     ::rtl::Reference<PresenterController> mpPresenterController;
111     typedef ::std::map<rtl::OUString, css::uno::Reference<css::drawing::framework::XResource> >
112         ResourceContainer;
113     ::boost::scoped_ptr<ResourceContainer> mpResourceCache;
114 
115     PresenterPaneFactory (
116         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
117         const ::rtl::Reference<PresenterController>& rpPresenterController);
118 
119     void Register (const css::uno::Reference<css::frame::XController>& rxController);
120 
121     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
122         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
123         const ::rtl::OUString& rsTitle);
124     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
125         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
126         const ::rtl::OUString& rsTitle,
127         const css::uno::Reference<css::drawing::framework::XPane>& rxParentPane,
128         const bool bIsSpritePane);
129 
130     void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
131 };
132 
133 } }
134 
135 #endif
136