xref: /trunk/main/sdext/source/presenter/PresenterPaneFactory.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
88     virtual void SAL_CALL disposing (void);
89 
90     // XResourceFactory
91 
92     virtual css::uno::Reference<css::drawing::framework::XResource>
93         SAL_CALL createResource (
94             const ::com::sun::star::uno::Reference<
95                 com::sun::star::drawing::framework::XResourceId>& rxPaneId);
96 
97     virtual void SAL_CALL
98         releaseResource (
99             const ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResource>&
100                 rxPane);
101 
102 private:
103     css::uno::WeakReference<css::uno::XComponentContext> mxComponentContextWeak;
104     css::uno::WeakReference<css::drawing::framework::XConfigurationController>
105         mxConfigurationControllerWeak;
106     ::rtl::Reference<PresenterController> mpPresenterController;
107     typedef ::std::map<rtl::OUString, css::uno::Reference<css::drawing::framework::XResource> >
108         ResourceContainer;
109     ::boost::scoped_ptr<ResourceContainer> mpResourceCache;
110 
111     PresenterPaneFactory (
112         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
113         const ::rtl::Reference<PresenterController>& rpPresenterController);
114 
115     void Register (const css::uno::Reference<css::frame::XController>& rxController);
116 
117     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
118         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
119         const ::rtl::OUString& rsTitle);
120     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
121         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
122         const ::rtl::OUString& rsTitle,
123         const css::uno::Reference<css::drawing::framework::XPane>& rxParentPane,
124         const bool bIsSpritePane);
125 
126     void ThrowIfDisposed (void) const;
127 };
128 
129 } }
130 
131 #endif
132