1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_VIEW_FACTORY_HXX
29*cdf0e10cSrcweir #define SDEXT_PRESENTER_VIEW_FACTORY_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterController.hxx"
32*cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
33*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
40*cdf0e10cSrcweir #include <rtl/ref.hxx>
41*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace css = ::com::sun::star;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace sdext { namespace presenter {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class PresenterPaneContainer;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace {
50*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper1 <
51*cdf0e10cSrcweir         css::drawing::framework::XResourceFactory
52*cdf0e10cSrcweir     > PresenterViewFactoryInterfaceBase;
53*cdf0e10cSrcweir }
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir /** Base class for presenter views that allows the view factory to store
56*cdf0e10cSrcweir     them in a cache and reuse deactivated views.
57*cdf0e10cSrcweir */
58*cdf0e10cSrcweir class CachablePresenterView
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir public:
61*cdf0e10cSrcweir     virtual void ActivatePresenterView (void);
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     /** Called when the view is put into a cache.  The view must not paint
64*cdf0e10cSrcweir         itself while being deactive.
65*cdf0e10cSrcweir     */
66*cdf0e10cSrcweir     virtual void DeactivatePresenterView (void);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     /** Called before the view is disposed.  This gives the view the
69*cdf0e10cSrcweir         oportunity to trigger actions that may lead to (synchronous)
70*cdf0e10cSrcweir         callbacks that do not result in DisposedExceptions.
71*cdf0e10cSrcweir     */
72*cdf0e10cSrcweir     virtual void ReleaseView (void);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir protected:
75*cdf0e10cSrcweir     bool mbIsPresenterViewActive;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     CachablePresenterView (void);
78*cdf0e10cSrcweir };
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir /** Factory of the presenter screen specific views.  The supported set of
84*cdf0e10cSrcweir     views includes:
85*cdf0e10cSrcweir         a life view of the current slide,
86*cdf0e10cSrcweir         a static preview of the next slide,
87*cdf0e10cSrcweir         the notes of the current slide,
88*cdf0e10cSrcweir         a tool bar
89*cdf0e10cSrcweir */
90*cdf0e10cSrcweir class PresenterViewFactory
91*cdf0e10cSrcweir     : public ::cppu::BaseMutex,
92*cdf0e10cSrcweir       public PresenterViewFactoryInterfaceBase
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir public:
95*cdf0e10cSrcweir     static const ::rtl::OUString msCurrentSlidePreviewViewURL;
96*cdf0e10cSrcweir     static const ::rtl::OUString msNextSlidePreviewViewURL;
97*cdf0e10cSrcweir     static const ::rtl::OUString msNotesViewURL;
98*cdf0e10cSrcweir     static const ::rtl::OUString msToolBarViewURL;
99*cdf0e10cSrcweir     static const ::rtl::OUString msSlideSorterURL;
100*cdf0e10cSrcweir     static const ::rtl::OUString msHelpViewURL;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     /** Create a new instance of this class and register it as resource
103*cdf0e10cSrcweir         factory in the drawing framework of the given controller.
104*cdf0e10cSrcweir         This registration keeps it alive.  When the drawing framework is
105*cdf0e10cSrcweir         shut down and releases its reference to the factory then the factory
106*cdf0e10cSrcweir         is destroyed.
107*cdf0e10cSrcweir     */
108*cdf0e10cSrcweir     static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
109*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
110*cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
111*cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
112*cdf0e10cSrcweir     virtual ~PresenterViewFactory (void);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_static (void);
115*cdf0e10cSrcweir     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
116*cdf0e10cSrcweir     static css::uno::Reference<css::uno::XInterface> Create(
117*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
118*cdf0e10cSrcweir         SAL_THROW((css::uno::Exception));
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void)
121*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     // XResourceFactory
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XResource>
127*cdf0e10cSrcweir         SAL_CALL createResource (
128*cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId)
129*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir     virtual void SAL_CALL
132*cdf0e10cSrcweir         releaseResource (
133*cdf0e10cSrcweir             const css::uno::Reference<css::drawing::framework::XResource>& rxPane)
134*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir private:
137*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
138*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XConfigurationController>
139*cdf0e10cSrcweir         mxConfigurationController;
140*cdf0e10cSrcweir     css::uno::WeakReference<css::frame::XController> mxControllerWeak;
141*cdf0e10cSrcweir     ::rtl::Reference<PresenterController> mpPresenterController;
142*cdf0e10cSrcweir     typedef ::std::pair<css::uno::Reference<css::drawing::framework::XView>,
143*cdf0e10cSrcweir         css::uno::Reference<css::drawing::framework::XPane> > ViewResourceDescriptor;
144*cdf0e10cSrcweir     typedef ::std::map<rtl::OUString, ViewResourceDescriptor> ResourceContainer;
145*cdf0e10cSrcweir     ::boost::scoped_ptr<ResourceContainer> mpResourceCache;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     PresenterViewFactory (
148*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
149*cdf0e10cSrcweir         const css::uno::Reference<css::frame::XController>& rxController,
150*cdf0e10cSrcweir         const ::rtl::Reference<PresenterController>& rpPresenterController);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     void Register (const css::uno::Reference<css::frame::XController>& rxController);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlideShowView(
155*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlidePreviewView(
158*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
159*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateToolBarView(
162*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateNotesView(
165*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
166*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateSlideSorterView(
169*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XView> CreateHelpView(
172*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResource> GetViewFromCache (
175*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
176*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane) const;
177*cdf0e10cSrcweir     css::uno::Reference<css::drawing::framework::XResource> CreateView(
178*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
179*cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
182*cdf0e10cSrcweir };
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir } }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir #endif
187