SidebarPanelBase.cxx (7a32b0c8) SidebarPanelBase.cxx (02c50d82)
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 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22#include "precompiled_sfx2.hxx"
23
24#include "sfx2/sidebar/SidebarPanelBase.hxx"
25#include "sfx2/sidebar/Theme.hxx"
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 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22#include "precompiled_sfx2.hxx"
23
24#include "sfx2/sidebar/SidebarPanelBase.hxx"
25#include "sfx2/sidebar/Theme.hxx"
26#include "sfx2/sidebar/ILayoutableWindow.hxx"
26#include "sfx2/imagemgr.hxx"
27#include <vcl/ctrl.hxx>
28#include <comphelper/processfactory.hxx>
29
30#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
31#include <com/sun/star/ui/UIElementType.hpp>
32
33using namespace css;
34using namespace cssu;
35
36
37namespace sfx2 { namespace sidebar {
38
39Reference<ui::XUIElement> SidebarPanelBase::Create (
40 const ::rtl::OUString& rsResourceURL,
41 const cssu::Reference<css::frame::XFrame>& rxFrame,
42 Window* pWindow,
27#include "sfx2/imagemgr.hxx"
28#include <vcl/ctrl.hxx>
29#include <comphelper/processfactory.hxx>
30
31#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
32#include <com/sun/star/ui/UIElementType.hpp>
33
34using namespace css;
35using namespace cssu;
36
37
38namespace sfx2 { namespace sidebar {
39
40Reference<ui::XUIElement> SidebarPanelBase::Create (
41 const ::rtl::OUString& rsResourceURL,
42 const cssu::Reference<css::frame::XFrame>& rxFrame,
43 Window* pWindow,
43 const ::boost::function<void(void)>& rMenuProvider)
44 const ::boost::function<void(void)>& rMenuProvider,
45 const css::ui::LayoutSize& rLayoutSize)
44{
45 Reference<ui::XUIElement> xUIElement (
46 new SidebarPanelBase(
47 rsResourceURL,
48 rxFrame,
49 pWindow,
46{
47 Reference<ui::XUIElement> xUIElement (
48 new SidebarPanelBase(
49 rsResourceURL,
50 rxFrame,
51 pWindow,
50 rMenuProvider));
52 rMenuProvider,
53 rLayoutSize));
51 return xUIElement;
52}
53
54
55
56
57SidebarPanelBase::SidebarPanelBase (
58 const ::rtl::OUString& rsResourceURL,
59 const cssu::Reference<css::frame::XFrame>& rxFrame,
60 Window* pWindow,
54 return xUIElement;
55}
56
57
58
59
60SidebarPanelBase::SidebarPanelBase (
61 const ::rtl::OUString& rsResourceURL,
62 const cssu::Reference<css::frame::XFrame>& rxFrame,
63 Window* pWindow,
61 const ::boost::function<void(void)>& rMenuProvider)
64 const ::boost::function<void(void)>& rMenuProvider,
65 const css::ui::LayoutSize& rLayoutSize)
62 : SidebarPanelBaseInterfaceBase(m_aMutex),
63 mxFrame(rxFrame),
64 mpControl(pWindow),
65 msResourceURL(rsResourceURL),
66 : SidebarPanelBaseInterfaceBase(m_aMutex),
67 mxFrame(rxFrame),
68 mpControl(pWindow),
69 msResourceURL(rsResourceURL),
66 maMenuProvider(rMenuProvider)
70 maMenuProvider(rMenuProvider),
71 maLayoutSize(rLayoutSize)
67{
72{
73 OSL_TRACE("SidebarPanelBase created at %x", this);
74
68 if (mxFrame.is())
69 {
70 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
71 css::ui::ContextChangeEventMultiplexer::get(
72 ::comphelper::getProcessComponentContext()));
73 if (xMultiplexer.is())
74 xMultiplexer->addContextChangeEventListener(this, mxFrame->getController());
75 }
76 if (mpControl != NULL)
77 mpControl->Show();
78}
79
80
81
82
83SidebarPanelBase::~SidebarPanelBase (void)
84{
75 if (mxFrame.is())
76 {
77 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
78 css::ui::ContextChangeEventMultiplexer::get(
79 ::comphelper::getProcessComponentContext()));
80 if (xMultiplexer.is())
81 xMultiplexer->addContextChangeEventListener(this, mxFrame->getController());
82 }
83 if (mpControl != NULL)
84 mpControl->Show();
85}
86
87
88
89
90SidebarPanelBase::~SidebarPanelBase (void)
91{
92 OSL_TRACE("SidebarPanelBase destroyed at %x", this);
85}
86
87
88
89
90void SAL_CALL SidebarPanelBase::disposing (void)
91 throw (cssu::RuntimeException)
92{
93}
94
95
96
97
98void SAL_CALL SidebarPanelBase::disposing (void)
99 throw (cssu::RuntimeException)
100{
93 mpControl = NULL;
101 OSL_TRACE("SidebarPanelBase disposing at %x", this);
102
103 if (mpControl != NULL)
104 {
105 delete mpControl;
106 mpControl = NULL;
107 }
94
95 if (mxFrame.is())
96 {
97 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
98 css::ui::ContextChangeEventMultiplexer::get(
99 ::comphelper::getProcessComponentContext()));
100 if (xMultiplexer.is())
101 xMultiplexer->removeAllContextChangeEventListeners(this);

--- 21 unchanged lines hidden (view full) ---

123
124
125
126// XContextChangeEventListener
127void SAL_CALL SidebarPanelBase::notifyContextChangeEvent (
128 const ui::ContextChangeEventObject& rEvent)
129 throw (cssu::RuntimeException)
130{
108
109 if (mxFrame.is())
110 {
111 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
112 css::ui::ContextChangeEventMultiplexer::get(
113 ::comphelper::getProcessComponentContext()));
114 if (xMultiplexer.is())
115 xMultiplexer->removeAllContextChangeEventListeners(this);

--- 21 unchanged lines hidden (view full) ---

137
138
139
140// XContextChangeEventListener
141void SAL_CALL SidebarPanelBase::notifyContextChangeEvent (
142 const ui::ContextChangeEventObject& rEvent)
143 throw (cssu::RuntimeException)
144{
145 OSL_TRACE("SidebarPanelBase notified at %x with control at %x", this, mpControl);
146
131 ContextChangeReceiverInterface* pContextChangeReceiver
132 = dynamic_cast<ContextChangeReceiverInterface*>(mpControl);
133 if (pContextChangeReceiver != NULL)
134 {
135 const EnumContext aContext(
136 EnumContext::GetApplicationEnum(rEvent.ApplicationName),
137 EnumContext::GetContextEnum(rEvent.ContextName));
138 pContextChangeReceiver->HandleContextChange(aContext);
139 }
140}
141
142
143
144
145void SAL_CALL SidebarPanelBase::disposing (
146 const css::lang::EventObject& rEvent)
147 throw (cssu::RuntimeException)
148{
149 (void)rEvent;
147 ContextChangeReceiverInterface* pContextChangeReceiver
148 = dynamic_cast<ContextChangeReceiverInterface*>(mpControl);
149 if (pContextChangeReceiver != NULL)
150 {
151 const EnumContext aContext(
152 EnumContext::GetApplicationEnum(rEvent.ApplicationName),
153 EnumContext::GetContextEnum(rEvent.ContextName));
154 pContextChangeReceiver->HandleContextChange(aContext);
155 }
156}
157
158
159
160
161void SAL_CALL SidebarPanelBase::disposing (
162 const css::lang::EventObject& rEvent)
163 throw (cssu::RuntimeException)
164{
165 (void)rEvent;
166
167 OSL_TRACE("SidebarPanelBase disposing(e) at %x", this);
150
151 mxFrame = NULL;
152 mpControl = NULL;
153}
154
155
156
157

--- 58 unchanged lines hidden (view full) ---

216}
217
218
219
220
221ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth)
222 throw(cssu::RuntimeException)
223{
168
169 mxFrame = NULL;
170 mpControl = NULL;
171}
172
173
174
175

--- 58 unchanged lines hidden (view full) ---

234}
235
236
237
238
239ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth)
240 throw(cssu::RuntimeException)
241{
224 if (mpControl != NULL)
242 if (maLayoutSize.Minimum >= 0)
243 return maLayoutSize;
244 else
225 {
245 {
226 const sal_Int32 nHeight (mpControl->GetSizePixel().Height());
227 return ui::LayoutSize(nHeight,nHeight,nHeight);
246 ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl);
247 if (pLayoutableWindow != NULL)
248 return pLayoutableWindow->GetHeightForWidth(nWidth);
249 else if (mpControl != NULL)
250 {
251 const sal_Int32 nHeight (mpControl->GetSizePixel().Height());
252 return ui::LayoutSize(nHeight,nHeight,nHeight);
253 }
228 }
254 }
229 else
230 return ui::LayoutSize(0,0,0);
255
256 return ui::LayoutSize(0,0,0);
231}
232
233
234
235
236void SAL_CALL SidebarPanelBase::showMenu (void)
237 throw(cssu::RuntimeException)
238{

--- 20 unchanged lines hidden ---
257}
258
259
260
261
262void SAL_CALL SidebarPanelBase::showMenu (void)
263 throw(cssu::RuntimeException)
264{

--- 20 unchanged lines hidden ---