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 opportunity 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 115 virtual void SAL_CALL disposing (void); 116 117 118 // XResourceFactory 119 120 virtual css::uno::Reference<css::drawing::framework::XResource> 121 SAL_CALL createResource ( 122 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId); 123 124 virtual void SAL_CALL 125 releaseResource ( 126 const css::uno::Reference<css::drawing::framework::XResource>& rxPane); 127 128 private: 129 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 130 css::uno::Reference<css::drawing::framework::XConfigurationController> 131 mxConfigurationController; 132 css::uno::WeakReference<css::frame::XController> mxControllerWeak; 133 ::rtl::Reference<PresenterController> mpPresenterController; 134 typedef ::std::pair<css::uno::Reference<css::drawing::framework::XView>, 135 css::uno::Reference<css::drawing::framework::XPane> > ViewResourceDescriptor; 136 typedef ::std::map<rtl::OUString, ViewResourceDescriptor> ResourceContainer; 137 ::boost::scoped_ptr<ResourceContainer> mpResourceCache; 138 139 PresenterViewFactory ( 140 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 141 const css::uno::Reference<css::frame::XController>& rxController, 142 const ::rtl::Reference<PresenterController>& rpPresenterController); 143 144 void Register (const css::uno::Reference<css::frame::XController>& rxController); 145 146 css::uno::Reference<css::drawing::framework::XView> CreateSlideShowView( 147 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const; 148 149 css::uno::Reference<css::drawing::framework::XView> CreateSlidePreviewView( 150 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 151 const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const; 152 153 css::uno::Reference<css::drawing::framework::XView> CreateToolBarView( 154 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const; 155 156 css::uno::Reference<css::drawing::framework::XView> CreateNotesView( 157 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 158 const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const; 159 160 css::uno::Reference<css::drawing::framework::XView> CreateSlideSorterView( 161 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const; 162 163 css::uno::Reference<css::drawing::framework::XView> CreateHelpView( 164 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const; 165 166 css::uno::Reference<css::drawing::framework::XResource> GetViewFromCache ( 167 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 168 const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane) const; 169 css::uno::Reference<css::drawing::framework::XResource> CreateView( 170 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 171 const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane); 172 173 void ThrowIfDisposed (void) const; 174 }; 175 176 } } 177 178 #endif 179