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