1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_VIEW_FACTORY_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_VIEW_FACTORY_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterController.hxx"
28cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
29cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
30cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
34cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
35cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
36cdf0e10cSrcweir #include <rtl/ref.hxx>
37cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace css = ::com::sun::star;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace sdext { namespace presenter {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class PresenterPaneContainer;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace {
46cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper1 <
47cdf0e10cSrcweir         css::drawing::framework::XResourceFactory
48cdf0e10cSrcweir     > PresenterViewFactoryInterfaceBase;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /** Base class for presenter views that allows the view factory to store
52cdf0e10cSrcweir     them in a cache and reuse deactivated views.
53cdf0e10cSrcweir */
54cdf0e10cSrcweir class CachablePresenterView
55cdf0e10cSrcweir {
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir     virtual void ActivatePresenterView (void);
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /** Called when the view is put into a cache.  The view must not paint
60cdf0e10cSrcweir         itself while being deactive.
61cdf0e10cSrcweir     */
62cdf0e10cSrcweir     virtual void DeactivatePresenterView (void);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     /** Called before the view is disposed.  This gives the view the
65cdf0e10cSrcweir         oportunity to trigger actions that may lead to (synchronous)
66cdf0e10cSrcweir         callbacks that do not result in DisposedExceptions.
67cdf0e10cSrcweir     */
68cdf0e10cSrcweir     virtual void ReleaseView (void);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir protected:
71cdf0e10cSrcweir     bool mbIsPresenterViewActive;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     CachablePresenterView (void);
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir /** Factory of the presenter screen specific views.  The supported set of
80cdf0e10cSrcweir     views includes:
81cdf0e10cSrcweir         a life view of the current slide,
82cdf0e10cSrcweir         a static preview of the next slide,
83cdf0e10cSrcweir         the notes of the current slide,
84cdf0e10cSrcweir         a tool bar
85cdf0e10cSrcweir */
86cdf0e10cSrcweir class PresenterViewFactory
87cdf0e10cSrcweir     : public ::cppu::BaseMutex,
88cdf0e10cSrcweir       public PresenterViewFactoryInterfaceBase
89cdf0e10cSrcweir {
90cdf0e10cSrcweir public:
91cdf0e10cSrcweir     static const ::rtl::OUString msCurrentSlidePreviewViewURL;
92cdf0e10cSrcweir     static const ::rtl::OUString msNextSlidePreviewViewURL;
93cdf0e10cSrcweir     static const ::rtl::OUString msNotesViewURL;
94cdf0e10cSrcweir     static const ::rtl::OUString msToolBarViewURL;
95cdf0e10cSrcweir     static const ::rtl::OUString msSlideSorterURL;
96cdf0e10cSrcweir     static const ::rtl::OUString msHelpViewURL;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     /** Create a new instance of this class and register it as resource
99cdf0e10cSrcweir         factory in the drawing framework of the given controller.
100cdf0e10cSrcweir         This registration keeps it alive.  When the drawing framework is
101cdf0e10cSrcweir         shut down and releases its reference to the factory then the factory
102cdf0e10cSrcweir         is destroyed.
103cdf0e10cSrcweir     */
104cdf0e10cSrcweir     static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
105cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
106cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
107cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
108cdf0e10cSrcweir     virtual ~PresenterViewFactory (void);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_static (void);
111cdf0e10cSrcweir     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
112cdf0e10cSrcweir     static css::uno::Reference<css::uno::XInterface> Create(
113cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
114cdf0e10cSrcweir         SAL_THROW((css::uno::Exception));
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     virtual void SAL_CALL disposing (void)
117cdf0e10cSrcweir         throw (css::uno::RuntimeException);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     // XResourceFactory
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResource>
123cdf0e10cSrcweir         SAL_CALL createResource (
124cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId)
125cdf0e10cSrcweir         throw (css::uno::RuntimeException);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     virtual void SAL_CALL
128cdf0e10cSrcweir         releaseResource (
129cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResource>& rxPane)
130cdf0e10cSrcweir         throw (css::uno::RuntimeException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
134cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XConfigurationController>
135cdf0e10cSrcweir         mxConfigurationController;
136cdf0e10cSrcweir     css::uno::WeakReference<css::frame::XController> mxControllerWeak;
137cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
138cdf0e10cSrcweir     typedef ::std::pair<css::uno::Reference<css::drawing::framework::XView>,
139cdf0e10cSrcweir         css::uno::Reference<css::drawing::framework::XPane> > ViewResourceDescriptor;
140cdf0e10cSrcweir     typedef ::std::map<rtl::OUString, ViewResourceDescriptor> ResourceContainer;
141cdf0e10cSrcweir     ::boost::scoped_ptr<ResourceContainer> mpResourceCache;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     PresenterViewFactory (
144cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
145cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
146cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     void Register (const css::uno::Reference<css::frame::XController>& rxController);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlideShowView(
151cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlidePreviewView(
154cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
155cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateToolBarView(
158cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateNotesView(
161cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
162cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlideSorterView(
165cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateHelpView(
168cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResource> GetViewFromCache (
171cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
172cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane) const;
173cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResource> CreateView(
174cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
175cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
178cdf0e10cSrcweir };
179cdf0e10cSrcweir 
180cdf0e10cSrcweir } }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir #endif
183