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/XVerticalStackLayoutElement.hpp> 35 #include <boost/noncopyable.hpp> 36 37 38 namespace css = ::com::sun::star; 39 namespace cssu = ::com::sun::star::uno; 40 41 42 class Control; 43 44 45 namespace sfx2 { namespace sidebar { 46 47 namespace 48 { 49 typedef ::cppu::WeakComponentImplHelper4 < 50 css::ui::XContextChangeEventListener, 51 css::ui::XUIElement, 52 css::ui::XToolPanel, 53 css::ui::XVerticalStackLayoutElement 54 > SidebarPanelBaseInterfaceBase; 55 } 56 57 /** Base class for sidebar panels that provides some convenience 58 functionality. 59 */ 60 class SFX2_DLLPUBLIC SidebarPanelBase 61 : private ::boost::noncopyable, 62 private ::cppu::BaseMutex, 63 public SidebarPanelBaseInterfaceBase 64 { 65 public: 66 class ContextChangeReceiverInterface 67 { 68 public: 69 virtual void HandleContextChange ( 70 const EnumContext aContext) = 0; 71 }; 72 73 static cssu::Reference<css::ui::XUIElement> Create ( 74 const ::rtl::OUString& rsResourceURL, 75 const cssu::Reference<css::frame::XFrame>& rxFrame, 76 Control* pControl); 77 78 // XContextChangeEventListener 79 virtual void SAL_CALL notifyContextChangeEvent ( 80 const css::ui::ContextChangeEventObject& rEvent) 81 throw (cssu::RuntimeException); 82 83 // XEventListener 84 virtual void SAL_CALL disposing ( 85 const css::lang::EventObject& rEvent) 86 throw (cssu::RuntimeException); 87 88 // XUIElement 89 virtual cssu::Reference<css::frame::XFrame> SAL_CALL getFrame (void) 90 throw(cssu::RuntimeException); 91 virtual ::rtl::OUString SAL_CALL getResourceURL (void) 92 throw(cssu::RuntimeException); 93 virtual sal_Int16 SAL_CALL getType (void) 94 throw(cssu::RuntimeException); 95 virtual cssu::Reference<cssu::XInterface> SAL_CALL getRealInterface (void) 96 throw(cssu::RuntimeException); 97 98 // XToolPanel 99 virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL createAccessible ( 100 const cssu::Reference<css::accessibility::XAccessible>& rxParentAccessible) 101 throw(cssu::RuntimeException); 102 virtual cssu::Reference<css::awt::XWindow> SAL_CALL getWindow (void) 103 throw(cssu::RuntimeException); 104 105 // XVerticalStackLayoutElement 106 virtual sal_Int32 SAL_CALL getHeightForWidth (const sal_Int32 nWidth) 107 throw(cssu::RuntimeException); 108 109 protected: 110 SidebarPanelBase ( 111 const ::rtl::OUString& rsResourceURL, 112 const cssu::Reference<css::frame::XFrame>& rxFrame, 113 Control* pControl); 114 virtual ~SidebarPanelBase (void); 115 116 virtual void SAL_CALL disposing (void) 117 throw (cssu::RuntimeException); 118 119 private: 120 const ::rtl::OUString msResourceURL; 121 cssu::Reference<css::frame::XFrame> mxFrame; 122 Control* mpControl; 123 }; 124 125 } } // end of namespace sfx2::sidebar 126 127 #endif 128