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 #ifndef SFX_SIDEBAR_PANEL_BASE_HXX 23 #define SFX_SIDEBAR_PANEL_BASE_HXX 24 25 #include "EnumContext.hxx" 26 27 #include <cppuhelper/compbase4.hxx> 28 #include <cppuhelper/basemutex.hxx> 29 30 #include <com/sun/star/frame/XController.hpp> 31 #include <com/sun/star/ui/XContextChangeEventListener.hpp> 32 #include <com/sun/star/ui/XUIElement.hpp> 33 #include <com/sun/star/ui/XToolPanel.hpp> 34 #include <com/sun/star/ui/XSidebarPanel.hpp> 35 36 #include <boost/noncopyable.hpp> 37 #include <boost/function.hpp> 38 39 40 namespace css = ::com::sun::star; 41 namespace cssu = ::com::sun::star::uno; 42 43 44 class Window; 45 46 namespace sfx2 { namespace sidebar { 47 48 namespace 49 { 50 typedef ::cppu::WeakComponentImplHelper4 < 51 css::ui::XContextChangeEventListener, 52 css::ui::XUIElement, 53 css::ui::XToolPanel, 54 css::ui::XSidebarPanel 55 > SidebarPanelBaseInterfaceBase; 56 } 57 58 /** Base class for sidebar panels that provides some convenience 59 functionality. 60 */ 61 class SFX2_DLLPUBLIC SidebarPanelBase 62 : private ::boost::noncopyable, 63 private ::cppu::BaseMutex, 64 public SidebarPanelBaseInterfaceBase 65 { 66 public: 67 class ContextChangeReceiverInterface 68 { 69 public: 70 virtual void HandleContextChange ( 71 const EnumContext aContext) = 0; 72 }; 73 74 static cssu::Reference<css::ui::XUIElement> Create ( 75 const ::rtl::OUString& rsResourceURL, 76 const cssu::Reference<css::frame::XFrame>& rxFrame, 77 Window* mpWindow, 78 const ::boost::function<void(void)>& rMenuProvider, 79 const css::ui::LayoutSize& rLayoutSize); 80 81 // XContextChangeEventListener 82 virtual void SAL_CALL notifyContextChangeEvent ( 83 const css::ui::ContextChangeEventObject& rEvent) 84 throw (cssu::RuntimeException); 85 86 // XEventListener 87 virtual void SAL_CALL disposing ( 88 const css::lang::EventObject& rEvent) 89 throw (cssu::RuntimeException); 90 91 // XUIElement 92 virtual cssu::Reference<css::frame::XFrame> SAL_CALL getFrame (void) 93 throw(cssu::RuntimeException); 94 virtual ::rtl::OUString SAL_CALL getResourceURL (void) 95 throw(cssu::RuntimeException); 96 virtual sal_Int16 SAL_CALL getType (void) 97 throw(cssu::RuntimeException); 98 virtual cssu::Reference<cssu::XInterface> SAL_CALL getRealInterface (void) 99 throw(cssu::RuntimeException); 100 101 // XToolPanel 102 virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL createAccessible ( 103 const cssu::Reference<css::accessibility::XAccessible>& rxParentAccessible) 104 throw(cssu::RuntimeException); 105 virtual cssu::Reference<css::awt::XWindow> SAL_CALL getWindow (void) 106 throw(cssu::RuntimeException); 107 108 // XSidebarPanel 109 virtual css::ui::LayoutSize SAL_CALL getHeightForWidth (sal_Int32 nWidth) 110 throw(cssu::RuntimeException); 111 virtual void SAL_CALL showMenu (void) 112 throw(cssu::RuntimeException); 113 /** Always return <TRUE/> in the assumption that the panel 114 descriptor in the registry has this covered. 115 If a panel needs finer control then it has to overload this 116 method. 117 */ 118 virtual sal_Bool SAL_CALL isContextSupported ( 119 const ::rtl::OUString& rsApplicationName, 120 const ::rtl::OUString& rsContextName) 121 throw(cssu::RuntimeException); 122 123 protected: 124 cssu::Reference<css::frame::XFrame> mxFrame; 125 126 SidebarPanelBase ( 127 const ::rtl::OUString& rsResourceURL, 128 const cssu::Reference<css::frame::XFrame>& rxFrame, 129 Window* pWindow, 130 const ::boost::function<void(void)>& rMenuProvider, 131 const css::ui::LayoutSize& rLayoutSize); 132 virtual ~SidebarPanelBase (void); 133 134 virtual void SAL_CALL disposing (void) 135 throw (cssu::RuntimeException); 136 137 void SetControl (::Window* pControl); 138 ::Window* GetControl (void) const; 139 140 private: 141 Window* mpControl; 142 const ::rtl::OUString msResourceURL; 143 const ::boost::function<void(void)> maMenuProvider; 144 const css::ui::LayoutSize maLayoutSize; 145 }; 146 147 } } // end of namespace sfx2::sidebar 148 149 #endif 150