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