1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SDEXT_PRESENTER_PRESENTER_SCREEN_HXX 29 #define SDEXT_PRESENTER_PRESENTER_SCREEN_HXX 30 31 #include "PresenterConfigurationAccess.hxx" 32 #include "PresenterPaneContainer.hxx" 33 #include <cppuhelper/compbase1.hxx> 34 #include <cppuhelper/basemutex.hxx> 35 #include <com/sun/star/lang/XInitialization.hpp> 36 #include <com/sun/star/frame/XController.hpp> 37 #include <com/sun/star/frame/XModel2.hpp> 38 #include <com/sun/star/task/XJob.hpp> 39 #include <com/sun/star/document/XEventListener.hpp> 40 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 41 #include <com/sun/star/drawing/framework/XView.hpp> 42 #include <com/sun/star/presentation/XSlideShowController.hpp> 43 #include <com/sun/star/presentation/XPresentation2.hpp> 44 #include <rtl/ref.hxx> 45 #include <boost/noncopyable.hpp> 46 #include <boost/shared_ptr.hpp> 47 #include <boost/scoped_ptr.hpp> 48 49 namespace css = ::com::sun::star; 50 51 namespace sdext { namespace presenter { 52 53 class PresenterWindowManager; 54 class PresenterController; 55 56 namespace { 57 typedef ::cppu::WeakComponentImplHelper1 < 58 css::task::XJob 59 > PresenterScreenJobInterfaceBase; 60 typedef ::cppu::WeakComponentImplHelper1 < 61 css::lang::XEventListener 62 > PresenterScreenInterfaceBase; 63 } 64 65 66 67 68 /** The PresenterScreenJob service is instantiated every time a document is 69 created or loaded. In its execute() method it then filters out all 70 non-Impress documents and creates and registers a new PresenterScreen 71 object. 72 */ 73 class PresenterScreenJob 74 : private ::boost::noncopyable, 75 private ::cppu::BaseMutex, 76 public PresenterScreenJobInterfaceBase 77 { 78 public: 79 static ::rtl::OUString getImplementationName_static (void); 80 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void); 81 static css::uno::Reference<css::uno::XInterface> Create( 82 const css::uno::Reference<css::uno::XComponentContext>& rxContext) 83 SAL_THROW((css::uno::Exception)); 84 85 virtual void SAL_CALL disposing (void); 86 87 // XJob 88 89 virtual css::uno::Any SAL_CALL execute( 90 const css::uno::Sequence<css::beans::NamedValue >& Arguments) 91 throw (css::lang::IllegalArgumentException, 92 css::uno::Exception, 93 css::uno::RuntimeException); 94 95 private: 96 PresenterScreenJob (const css::uno::Reference<css::uno::XComponentContext>& rxContext); 97 virtual ~PresenterScreenJob (void); 98 99 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 100 }; 101 102 103 104 105 /** This is the bootstrap class of the presenter screen. It is registered 106 as drawing framework startup service. That means that every drawing 107 framework instance creates an instance of this class. 108 109 <p>A PresenterScreen object registers itself as listener for drawing 110 framework configuration changes. It waits for the full screen marker (a 111 top level resource) to appear in the current configuration. When that 112 happens the actual presenter screen is initialized. A new 113 PresenterController is created and takes over the task of controlling 114 the presenter screen.</p> 115 */ 116 class PresenterScreen 117 : private ::boost::noncopyable, 118 private ::cppu::BaseMutex, 119 public PresenterScreenInterfaceBase 120 { 121 public: 122 PresenterScreen ( 123 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 124 const css::uno::Reference<css::frame::XModel2>& rxModel); 125 virtual ~PresenterScreen (void); 126 127 virtual void SAL_CALL disposing (void); 128 129 /** Make the presenter screen visible. 130 */ 131 void InitializePresenterScreen (void); 132 133 /** Do not call ShutdownPresenterScreen() directly. Call 134 RequestShutdownPresenterScreen() instead. It will issue an 135 asynchronous call to ShutdownPresenterScreen() when that is safe. 136 */ 137 void RequestShutdownPresenterScreen (void); 138 139 140 // XEventListener 141 142 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException); 143 144 private: 145 css::uno::Reference<css::frame::XModel2 > mxModel; 146 css::uno::Reference<css::frame::XController> mxController; 147 css::uno::WeakReference<css::drawing::framework::XConfigurationController> 148 mxConfigurationControllerWeak; 149 css::uno::WeakReference<css::uno::XComponentContext> mxContextWeak; 150 css::uno::WeakReference<css::presentation::XSlideShowController> mxSlideShowControllerWeak; 151 ::rtl::Reference<PresenterController> mpPresenterController; 152 css::uno::Reference<css::drawing::framework::XResourceId> mxSlideShowViewId; 153 css::uno::Reference<css::drawing::framework::XConfiguration> mxSavedConfiguration; 154 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer; 155 sal_Int32 mnComponentIndex; 156 css::uno::Reference<css::drawing::framework::XResourceFactory> mxPaneFactory; 157 css::uno::Reference<css::drawing::framework::XResourceFactory> mxViewFactory; 158 159 class ViewDescriptor 160 { 161 public: 162 ::rtl::OUString msTitle; 163 ::rtl::OUString msAccessibleTitle; 164 bool mbIsOpaque; 165 }; 166 typedef ::std::map<rtl::OUString,ViewDescriptor> ViewDescriptorContainer; 167 ViewDescriptorContainer maViewDescriptors; 168 169 170 void ShutdownPresenterScreen (void); 171 172 /** Create and initialize the factory for presenter view specific panes. 173 */ 174 void SetupPaneFactory ( 175 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 176 177 /** Create and initialize the factory for presenter view specific views. 178 */ 179 void SetupViewFactory ( 180 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 181 182 /** Read the current layout from the configuration and call 183 ProcessLayout to bring it on to the screen. 184 */ 185 void SetupConfiguration ( 186 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 187 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId); 188 189 /** Read one layout from the configuration and make resource activation 190 requests to bring it on to the screen. When one layout references a 191 parent layout then this method calls itself recursively. 192 */ 193 void ProcessLayout ( 194 PresenterConfigurationAccess& rConfiguration, 195 const ::rtl::OUString& rsLayoutName, 196 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 197 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId); 198 199 /** Called by ProcessLayout for a single entry of a Layouts 200 configuration list. 201 */ 202 void ProcessComponent ( 203 const ::rtl::OUString& rsKey, 204 const ::std::vector<css::uno::Any>& rValues, 205 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 206 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId); 207 208 /** Read the view descriptions from the configuration. 209 */ 210 void ProcessViewDescriptions ( 211 PresenterConfigurationAccess& rConfiguration); 212 213 /** Called by ProcessViewDescriptions for a single entry. 214 */ 215 void ProcessViewDescription ( 216 const ::rtl::OUString& rsKey, 217 const ::std::vector<css::uno::Any>& rValues); 218 219 void SetupView ( 220 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 221 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId, 222 const ::rtl::OUString& rsPaneURL, 223 const ::rtl::OUString& rsViewURL, 224 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization, 225 const double nLeft, 226 const double nTop, 227 const double nRight, 228 const double nBottom); 229 230 /** Return the screen number on which to display the presenter screen. 231 @return 232 Returns -1 when the presenter screen can or shall not be 233 displayed. 234 */ 235 sal_Int32 GetScreenNumber ( 236 const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const; 237 238 /** Create a resource id for the full screen background pane so that it 239 is displayed on another screen than the full screen presentation. 240 */ 241 css::uno::Reference<css::drawing::framework::XResourceId> GetMainPaneId ( 242 const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const; 243 }; 244 245 } } 246 247 #endif 248