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     static cssu::Reference<css::ui::XUIElement> Create (
68         const ::rtl::OUString& rsResourceURL,
69         const cssu::Reference<css::frame::XFrame>& rxFrame,
70         Window* mpWindow,
71         const css::ui::LayoutSize& rLayoutSize);
72 
73     // XContextChangeEventListener
74     virtual void SAL_CALL notifyContextChangeEvent (
75         const css::ui::ContextChangeEventObject& rEvent)
76         throw (cssu::RuntimeException);
77 
78     // XEventListener
79     virtual void SAL_CALL disposing (
80         const css::lang::EventObject& rEvent)
81         throw (cssu::RuntimeException);
82 
83     // XUIElement
84     virtual cssu::Reference<css::frame::XFrame> SAL_CALL getFrame (void)
85         throw(cssu::RuntimeException);
86     virtual ::rtl::OUString SAL_CALL getResourceURL (void)
87         throw(cssu::RuntimeException);
88     virtual sal_Int16 SAL_CALL getType (void)
89         throw(cssu::RuntimeException);
90     virtual cssu::Reference<cssu::XInterface> SAL_CALL getRealInterface (void)
91         throw(cssu::RuntimeException);
92 
93     // XToolPanel
94     virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL createAccessible (
95         const cssu::Reference<css::accessibility::XAccessible>& rxParentAccessible)
96         throw(cssu::RuntimeException);
97     virtual cssu::Reference<css::awt::XWindow> SAL_CALL getWindow (void)
98         throw(cssu::RuntimeException);
99 
100     // XSidebarPanel
101     virtual css::ui::LayoutSize SAL_CALL getHeightForWidth (sal_Int32 nWidth)
102         throw(cssu::RuntimeException);
103 
104 protected:
105     cssu::Reference<css::frame::XFrame> mxFrame;
106 
107     SidebarPanelBase (
108         const ::rtl::OUString& rsResourceURL,
109         const cssu::Reference<css::frame::XFrame>& rxFrame,
110         Window* pWindow,
111         const css::ui::LayoutSize& rLayoutSize);
112     virtual ~SidebarPanelBase (void);
113 
114     virtual void SAL_CALL disposing (void)
115         throw (cssu::RuntimeException);
116 
117     void SetControl (::Window* pControl);
118     ::Window* GetControl (void) const;
119 
120 private:
121     Window* mpControl;
122     const ::rtl::OUString msResourceURL;
123     const css::ui::LayoutSize maLayoutSize;
124 };
125 
126 } } // end of namespace sfx2::sidebar
127 
128 #endif
129