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_PANE_CONTAINER_HXX 29 #define SDEXT_PRESENTER_PANE_CONTAINER_HXX 30 31 #include "PresenterTheme.hxx" 32 #include <com/sun/star/awt/Point.hpp> 33 #include <com/sun/star/awt/Rectangle.hpp> 34 #include <com/sun/star/awt/XWindow.hpp> 35 #include <com/sun/star/drawing/XPresenterHelper.hpp> 36 #include <com/sun/star/drawing/framework/XResourceId.hpp> 37 #include <com/sun/star/drawing/framework/XPane.hpp> 38 #include <com/sun/star/drawing/framework/XView.hpp> 39 #include <com/sun/star/uno/XComponentContext.hpp> 40 #include <com/sun/star/util/Color.hpp> 41 #include <cppuhelper/basemutex.hxx> 42 #include <cppuhelper/compbase1.hxx> 43 #include <rtl/ref.hxx> 44 #include <vector> 45 #include <boost/function.hpp> 46 #include <boost/noncopyable.hpp> 47 #include <boost/shared_ptr.hpp> 48 49 namespace css = ::com::sun::star; 50 51 namespace sdext { namespace presenter { 52 53 class PresenterPaneBase; 54 class PresenterSprite; 55 56 namespace { 57 typedef ::cppu::WeakComponentImplHelper1 < 58 css::lang::XEventListener 59 > PresenterPaneContainerInterfaceBase; 60 } 61 62 /** This class could also be called PresenterPaneAndViewContainer because it 63 stores not only references to all panes that belong to the presenter 64 screen but stores the views displayed in these panes as well. 65 */ 66 class PresenterPaneContainer 67 : private ::boost::noncopyable, 68 private ::cppu::BaseMutex, 69 public PresenterPaneContainerInterfaceBase 70 { 71 public: 72 PresenterPaneContainer ( 73 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 74 virtual ~PresenterPaneContainer (void); 75 76 virtual void SAL_CALL disposing (void); 77 78 typedef ::boost::function1<void, const css::uno::Reference<css::drawing::framework::XView>&> 79 ViewInitializationFunction; 80 81 /** Each pane descriptor holds references to one pane and the view 82 displayed in this pane as well as the other information that is used 83 to manage the pane window like an XWindow reference, the title, and 84 the coordinates. 85 86 A initialization function for the view is stored as well. This 87 function is executed as soon as a view is created. 88 */ 89 class PaneDescriptor 90 { 91 public: 92 typedef ::boost::function<void(bool)> Activator; 93 typedef ::boost::function<boost::shared_ptr<PresenterSprite>()> SpriteProvider; 94 css::uno::Reference<css::drawing::framework::XResourceId> mxPaneId; 95 ::rtl::OUString msViewURL; 96 ::rtl::Reference<PresenterPaneBase> mxPane; 97 css::uno::Reference<css::drawing::framework::XView> mxView; 98 css::uno::Reference<css::awt::XWindow> mxContentWindow; 99 css::uno::Reference<css::awt::XWindow> mxBorderWindow; 100 ::rtl::OUString msTitleTemplate; 101 ::rtl::OUString msAccessibleTitleTemplate; 102 ::rtl::OUString msTitle; 103 ViewInitializationFunction maViewInitialization; 104 double mnLeft; 105 double mnTop; 106 double mnRight; 107 double mnBottom; 108 SharedBitmapDescriptor mpViewBackground; 109 bool mbIsActive; 110 bool mbNeedsClipping; 111 bool mbIsOpaque; 112 SpriteProvider maSpriteProvider; 113 bool mbIsSprite; 114 Activator maActivator; 115 css::awt::Point maCalloutAnchorLocation; 116 bool mbHasCalloutAnchor; 117 118 void SetActivationState (const bool bIsActive); 119 }; 120 typedef ::boost::shared_ptr<PaneDescriptor> SharedPaneDescriptor; 121 typedef ::std::vector<SharedPaneDescriptor> PaneList; 122 PaneList maPanes; 123 124 void PreparePane ( 125 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 126 const ::rtl::OUString& rsViewURL, 127 const ::rtl::OUString& rsTitle, 128 const ::rtl::OUString& rsAccessibleTitle, 129 const bool bIsOpaque, 130 const ViewInitializationFunction& rViewIntialization, 131 const double nLeft, 132 const double nTop, 133 const double nRight, 134 const double nBottom); 135 136 SharedPaneDescriptor StorePane ( 137 const rtl::Reference<PresenterPaneBase>& rxPane); 138 139 SharedPaneDescriptor StoreBorderWindow( 140 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 141 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow); 142 143 SharedPaneDescriptor StoreView ( 144 const css::uno::Reference<css::drawing::framework::XView>& rxView, 145 const SharedBitmapDescriptor& rpViewBackground); 146 147 SharedPaneDescriptor RemovePane ( 148 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId); 149 150 SharedPaneDescriptor RemoveView ( 151 const css::uno::Reference<css::drawing::framework::XView>& rxView); 152 153 void CreateBorderWindow (PaneDescriptor& rDescriptor); 154 155 /** Find the pane whose border window is identical to the given border 156 window. 157 */ 158 SharedPaneDescriptor FindBorderWindow ( 159 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow); 160 161 /** Find the pane whose border window is identical to the given content 162 window. 163 */ 164 SharedPaneDescriptor FindContentWindow ( 165 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow); 166 167 /** Find the pane whose pane URL is identical to the given URL string. 168 */ 169 SharedPaneDescriptor FindPaneURL (const ::rtl::OUString& rsPaneURL); 170 171 /** Find the pane whose resource id is identical to the given one. 172 */ 173 SharedPaneDescriptor FindPaneId (const css::uno::Reference< 174 css::drawing::framework::XResourceId>& rxPaneId); 175 176 SharedPaneDescriptor FindViewURL (const ::rtl::OUString& rsViewURL); 177 178 ::rtl::OUString GetPaneURLForViewURL (const ::rtl::OUString& rsViewURL); 179 180 void ToTop (const SharedPaneDescriptor& rpDescriptor); 181 182 183 // XEventListener 184 185 virtual void SAL_CALL disposing ( 186 const com::sun::star::lang::EventObject& rEvent) 187 throw (com::sun::star::uno::RuntimeException); 188 189 private: 190 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 191 192 PaneList::const_iterator FindIteratorForPaneURL (const ::rtl::OUString& rsPaneURL); 193 }; 194 195 } } // end of namespace ::sdext::presenter 196 197 #endif 198