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