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