1*7a32b0c8SAndre Fischer /**************************************************************
2*7a32b0c8SAndre Fischer  *
3*7a32b0c8SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*7a32b0c8SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*7a32b0c8SAndre Fischer  * distributed with this work for additional information
6*7a32b0c8SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*7a32b0c8SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*7a32b0c8SAndre Fischer  * "License"); you may not use this file except in compliance
9*7a32b0c8SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*7a32b0c8SAndre Fischer  *
11*7a32b0c8SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*7a32b0c8SAndre Fischer  *
13*7a32b0c8SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*7a32b0c8SAndre Fischer  * software distributed under the License is distributed on an
15*7a32b0c8SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*7a32b0c8SAndre Fischer  * KIND, either express or implied.  See the License for the
17*7a32b0c8SAndre Fischer  * specific language governing permissions and limitations
18*7a32b0c8SAndre Fischer  * under the License.
19*7a32b0c8SAndre Fischer  *
20*7a32b0c8SAndre Fischer  *************************************************************/
21*7a32b0c8SAndre Fischer 
22*7a32b0c8SAndre Fischer #include "precompiled_sd.hxx"
23*7a32b0c8SAndre Fischer 
24*7a32b0c8SAndre Fischer #include "SidebarFactory.hxx"
25*7a32b0c8SAndre Fischer #include "framework/FrameworkHelper.hxx"
26*7a32b0c8SAndre Fischer #include "framework/Pane.hxx"
27*7a32b0c8SAndre Fischer #include "ViewShellBase.hxx"
28*7a32b0c8SAndre Fischer #include "UIElementWrapper.hxx"
29*7a32b0c8SAndre Fischer 
30*7a32b0c8SAndre Fischer #include <sfx2/viewfrm.hxx>
31*7a32b0c8SAndre Fischer #include <comphelper/namedvaluecollection.hxx>
32*7a32b0c8SAndre Fischer #include <vcl/window.hxx>
33*7a32b0c8SAndre Fischer #include <toolkit/helper/vclunohelper.hxx>
34*7a32b0c8SAndre Fischer 
35*7a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XControllerManager.hpp>
36*7a32b0c8SAndre Fischer 
37*7a32b0c8SAndre Fischer using namespace css;
38*7a32b0c8SAndre Fischer using namespace cssu;
39*7a32b0c8SAndre Fischer using namespace css::drawing::framework;
40*7a32b0c8SAndre Fischer using namespace ::sd::framework;
41*7a32b0c8SAndre Fischer using ::rtl::OUString;
42*7a32b0c8SAndre Fischer 
43*7a32b0c8SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
44*7a32b0c8SAndre Fischer 
45*7a32b0c8SAndre Fischer namespace sd { namespace sidebar {
46*7a32b0c8SAndre Fischer 
47*7a32b0c8SAndre Fischer namespace {
48*7a32b0c8SAndre Fischer     /** Note that these names have to be identical to (the tail of)
49*7a32b0c8SAndre Fischer         the entries in officecfg/registry/data/org/openoffice/Office/Impress.xcu
50*7a32b0c8SAndre Fischer         for the TaskPanelFactory.
51*7a32b0c8SAndre Fischer     */
52*7a32b0c8SAndre Fischer     const static char* gsResourceNameCustomAnimations = "/CustomAnimations";
53*7a32b0c8SAndre Fischer     const static char* gsResourceNameLayouts = "/Layouts";
54*7a32b0c8SAndre Fischer     const static char* gsResourceNameAllMasterPages = "/AllMasterPages";
55*7a32b0c8SAndre Fischer     const static char* gsResourceNameRecentMasterPages = "/RecentMasterPages";
56*7a32b0c8SAndre Fischer     const static char* gsResourceNameUsedMasterPages = "/UsedMasterPages";
57*7a32b0c8SAndre Fischer     const static char* gsResourceNameSlideTransitions = "/SlideTransitions";
58*7a32b0c8SAndre Fischer     const static char* gsResourceNameTableDesign = "/TableDesign";
59*7a32b0c8SAndre Fischer }
60*7a32b0c8SAndre Fischer 
61*7a32b0c8SAndre Fischer class SidebarFactory::Implementation
62*7a32b0c8SAndre Fischer {
63*7a32b0c8SAndre Fischer public:
64*7a32b0c8SAndre Fischer     Reference<cssdf::XConfigurationController> mxConfigurationController;
65*7a32b0c8SAndre Fischer     rtl::Reference<framework::Pane> mxPane;
66*7a32b0c8SAndre Fischer     Reference<ui::XUIElement> mxUIElement;
67*7a32b0c8SAndre Fischer     Reference<frame::XController> mxController;
68*7a32b0c8SAndre Fischer     Reference<awt::XWindow> mxParentWindow;
69*7a32b0c8SAndre Fischer     bool mbIsDisposed;
70*7a32b0c8SAndre Fischer 
71*7a32b0c8SAndre Fischer     Implementation (const Reference<frame::XController>& rxController);
72*7a32b0c8SAndre Fischer     ~Implementation (void);
73*7a32b0c8SAndre Fischer     void Dispose (void);
74*7a32b0c8SAndre Fischer };
75*7a32b0c8SAndre Fischer 
76*7a32b0c8SAndre Fischer 
77*7a32b0c8SAndre Fischer SidebarFactory::ControllerToImplementationMap SidebarFactory::maControllerToImplementationMap;
78*7a32b0c8SAndre Fischer Reference<lang::XEventListener> mxControllerDisposeListener;
79*7a32b0c8SAndre Fischer 
80*7a32b0c8SAndre Fischer 
81*7a32b0c8SAndre Fischer 
82*7a32b0c8SAndre Fischer // ----- Service functions ----------------------------------------------------
83*7a32b0c8SAndre Fischer 
84*7a32b0c8SAndre Fischer Reference<XInterface> SAL_CALL SidebarFactory_createInstance (
85*7a32b0c8SAndre Fischer     const Reference<XComponentContext>& rxContext)
86*7a32b0c8SAndre Fischer {
87*7a32b0c8SAndre Fischer     return Reference<XInterface>(static_cast<XWeak*>(new SidebarFactory(rxContext)));
88*7a32b0c8SAndre Fischer }
89*7a32b0c8SAndre Fischer 
90*7a32b0c8SAndre Fischer 
91*7a32b0c8SAndre Fischer 
92*7a32b0c8SAndre Fischer 
93*7a32b0c8SAndre Fischer ::rtl::OUString SidebarFactory_getImplementationName (void) throw(RuntimeException)
94*7a32b0c8SAndre Fischer {
95*7a32b0c8SAndre Fischer     return ::rtl::OUString(
96*7a32b0c8SAndre Fischer         RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.Draw.framework.SidebarFactory"));
97*7a32b0c8SAndre Fischer }
98*7a32b0c8SAndre Fischer 
99*7a32b0c8SAndre Fischer 
100*7a32b0c8SAndre Fischer 
101*7a32b0c8SAndre Fischer 
102*7a32b0c8SAndre Fischer Sequence<rtl::OUString> SAL_CALL SidebarFactory_getSupportedServiceNames (void)
103*7a32b0c8SAndre Fischer     throw (RuntimeException)
104*7a32b0c8SAndre Fischer {
105*7a32b0c8SAndre Fischer 	static const ::rtl::OUString sServiceName(
106*7a32b0c8SAndre Fischer         ::rtl::OUString::createFromAscii("com.sun.star.drawing.framework.SidebarFactory"));
107*7a32b0c8SAndre Fischer 	return Sequence<rtl::OUString>(&sServiceName, 1);
108*7a32b0c8SAndre Fischer }
109*7a32b0c8SAndre Fischer 
110*7a32b0c8SAndre Fischer 
111*7a32b0c8SAndre Fischer 
112*7a32b0c8SAndre Fischer 
113*7a32b0c8SAndre Fischer //----- SidebarFactory --------------------------------------------------------
114*7a32b0c8SAndre Fischer 
115*7a32b0c8SAndre Fischer SidebarFactory::SidebarFactory(
116*7a32b0c8SAndre Fischer         const css::uno::Reference<css::uno::XComponentContext>& rxContext)
117*7a32b0c8SAndre Fischer     : SidebarFactoryInterfaceBase(m_aMutex),
118*7a32b0c8SAndre Fischer       mpImplementation()
119*7a32b0c8SAndre Fischer {
120*7a32b0c8SAndre Fischer }
121*7a32b0c8SAndre Fischer 
122*7a32b0c8SAndre Fischer 
123*7a32b0c8SAndre Fischer 
124*7a32b0c8SAndre Fischer 
125*7a32b0c8SAndre Fischer SidebarFactory::~SidebarFactory (void)
126*7a32b0c8SAndre Fischer {
127*7a32b0c8SAndre Fischer }
128*7a32b0c8SAndre Fischer 
129*7a32b0c8SAndre Fischer 
130*7a32b0c8SAndre Fischer 
131*7a32b0c8SAndre Fischer 
132*7a32b0c8SAndre Fischer void SAL_CALL SidebarFactory::disposing (void)
133*7a32b0c8SAndre Fischer {
134*7a32b0c8SAndre Fischer     SharedImplementation pImplementation;
135*7a32b0c8SAndre Fischer     pImplementation.swap(mpImplementation);
136*7a32b0c8SAndre Fischer     if (pImplementation)
137*7a32b0c8SAndre Fischer         pImplementation->Dispose();
138*7a32b0c8SAndre Fischer }
139*7a32b0c8SAndre Fischer 
140*7a32b0c8SAndre Fischer 
141*7a32b0c8SAndre Fischer 
142*7a32b0c8SAndre Fischer 
143*7a32b0c8SAndre Fischer // XInitialization
144*7a32b0c8SAndre Fischer 
145*7a32b0c8SAndre Fischer void SAL_CALL SidebarFactory::initialize (const Sequence<Any>& aArguments)
146*7a32b0c8SAndre Fischer     throw (Exception, RuntimeException)
147*7a32b0c8SAndre Fischer {
148*7a32b0c8SAndre Fischer     if (aArguments.getLength() > 0)
149*7a32b0c8SAndre Fischer     {
150*7a32b0c8SAndre Fischer         mpImplementation = GetImplementationForController(
151*7a32b0c8SAndre Fischer             Reference<frame::XController>(aArguments[0], UNO_QUERY));
152*7a32b0c8SAndre Fischer     }
153*7a32b0c8SAndre Fischer }
154*7a32b0c8SAndre Fischer 
155*7a32b0c8SAndre Fischer 
156*7a32b0c8SAndre Fischer 
157*7a32b0c8SAndre Fischer 
158*7a32b0c8SAndre Fischer // XUIElementFactory
159*7a32b0c8SAndre Fischer 
160*7a32b0c8SAndre Fischer Reference<ui::XUIElement> SAL_CALL SidebarFactory::createUIElement (
161*7a32b0c8SAndre Fischer     const ::rtl::OUString& rsUIElementResourceURL,
162*7a32b0c8SAndre Fischer     const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
163*7a32b0c8SAndre Fischer     throw(
164*7a32b0c8SAndre Fischer         css::container::NoSuchElementException,
165*7a32b0c8SAndre Fischer         css::lang::IllegalArgumentException,
166*7a32b0c8SAndre Fischer         cssu::RuntimeException)
167*7a32b0c8SAndre Fischer {
168*7a32b0c8SAndre Fischer     // Process arguments.
169*7a32b0c8SAndre Fischer     const ::comphelper::NamedValueCollection aArguments (rArguments);
170*7a32b0c8SAndre Fischer     Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
171*7a32b0c8SAndre Fischer     Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
172*7a32b0c8SAndre Fischer     Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault("Sidebar", Reference<ui::XSidebar>()));
173*7a32b0c8SAndre Fischer 
174*7a32b0c8SAndre Fischer     // Throw exceptions when the arguments are not as expected.
175*7a32b0c8SAndre Fischer     ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
176*7a32b0c8SAndre Fischer     if ( ! xParentWindow.is() || pParentWindow==NULL)
177*7a32b0c8SAndre Fischer         throw RuntimeException(
178*7a32b0c8SAndre Fischer             A2S("SidebarFactory::createUIElement called without ParentWindow"),
179*7a32b0c8SAndre Fischer             NULL);
180*7a32b0c8SAndre Fischer     if ( ! xFrame.is())
181*7a32b0c8SAndre Fischer         throw RuntimeException(
182*7a32b0c8SAndre Fischer             A2S("SidebarFactory::createUIElement called without XFrame"),
183*7a32b0c8SAndre Fischer             NULL);
184*7a32b0c8SAndre Fischer     mpImplementation = GetImplementationForController(xFrame->getController());
185*7a32b0c8SAndre Fischer     if ( ! mpImplementation)
186*7a32b0c8SAndre Fischer         throw RuntimeException(
187*7a32b0c8SAndre Fischer             A2S("SidebarFactory::createUIElement called without XController"),
188*7a32b0c8SAndre Fischer             NULL);
189*7a32b0c8SAndre Fischer     if (mpImplementation->mxConfigurationController.is())
190*7a32b0c8SAndre Fischer         mpImplementation->mxConfigurationController->addResourceFactory(
191*7a32b0c8SAndre Fischer             FrameworkHelper::msSidebarPaneURL+A2S("*"), this);
192*7a32b0c8SAndre Fischer 
193*7a32b0c8SAndre Fischer     //  Remember the parent window, so that following calls to
194*7a32b0c8SAndre Fischer     //  createResource() can access it.
195*7a32b0c8SAndre Fischer     mpImplementation->mxParentWindow = xParentWindow;
196*7a32b0c8SAndre Fischer     if (mpImplementation->mxPane.is())
197*7a32b0c8SAndre Fischer         mpImplementation->mxPane->SetWindow(VCLUnoHelper::GetWindow(xParentWindow));
198*7a32b0c8SAndre Fischer 
199*7a32b0c8SAndre Fischer     // Create a framework view.
200*7a32b0c8SAndre Fischer     OUString sTaskPanelURL;
201*7a32b0c8SAndre Fischer #define EndsWith(s,t) s.endsWithAsciiL(t,strlen(t))
202*7a32b0c8SAndre Fischer     if (EndsWith(rsUIElementResourceURL, gsResourceNameCustomAnimations))
203*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msCustomAnimationTaskPanelURL;
204*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameLayouts))
205*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msLayoutTaskPanelURL;
206*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameAllMasterPages))
207*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msAllMasterPagesTaskPanelURL;
208*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameRecentMasterPages))
209*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msRecentMasterPagesTaskPanelURL;
210*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameUsedMasterPages))
211*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msUsedMasterPagesTaskPanelURL;
212*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameSlideTransitions))
213*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msSlideTransitionTaskPanelURL;
214*7a32b0c8SAndre Fischer     else if (EndsWith(rsUIElementResourceURL, gsResourceNameTableDesign))
215*7a32b0c8SAndre Fischer         sTaskPanelURL = FrameworkHelper::msTableDesignPanelURL;
216*7a32b0c8SAndre Fischer #undef EndsWith
217*7a32b0c8SAndre Fischer 
218*7a32b0c8SAndre Fischer     if (sTaskPanelURL.getLength() == 0)
219*7a32b0c8SAndre Fischer         throw lang::IllegalArgumentException();
220*7a32b0c8SAndre Fischer 
221*7a32b0c8SAndre Fischer     // Create a wrapper around pane and view and return it as
222*7a32b0c8SAndre Fischer     // XUIElement.
223*7a32b0c8SAndre Fischer     Reference<ui::XUIElement> xUIElement;
224*7a32b0c8SAndre Fischer     try
225*7a32b0c8SAndre Fischer     {
226*7a32b0c8SAndre Fischer         xUIElement.set(new UIElementWrapper(
227*7a32b0c8SAndre Fischer                 rsUIElementResourceURL,
228*7a32b0c8SAndre Fischer                 xFrame,
229*7a32b0c8SAndre Fischer                 sTaskPanelURL,
230*7a32b0c8SAndre Fischer                 xSidebar,
231*7a32b0c8SAndre Fischer                 VCLUnoHelper::GetWindow(xParentWindow)));
232*7a32b0c8SAndre Fischer     }
233*7a32b0c8SAndre Fischer     catch(Exception& rException)
234*7a32b0c8SAndre Fischer     {
235*7a32b0c8SAndre Fischer         // Creation of XUIElement failed. mxUIElement remains empty.
236*7a32b0c8SAndre Fischer     }
237*7a32b0c8SAndre Fischer 
238*7a32b0c8SAndre Fischer     Reference<lang::XComponent> xComponent (xUIElement, UNO_QUERY);
239*7a32b0c8SAndre Fischer     if (xComponent.is())
240*7a32b0c8SAndre Fischer         xComponent->addEventListener(this);
241*7a32b0c8SAndre Fischer 
242*7a32b0c8SAndre Fischer     return xUIElement;
243*7a32b0c8SAndre Fischer }
244*7a32b0c8SAndre Fischer 
245*7a32b0c8SAndre Fischer 
246*7a32b0c8SAndre Fischer 
247*7a32b0c8SAndre Fischer 
248*7a32b0c8SAndre Fischer // XResourceFactory
249*7a32b0c8SAndre Fischer 
250*7a32b0c8SAndre Fischer Reference<drawing::framework::XResource>
251*7a32b0c8SAndre Fischer     SAL_CALL SidebarFactory::createResource (
252*7a32b0c8SAndre Fischer         const Reference<drawing::framework::XResourceId>& rxPaneId)
253*7a32b0c8SAndre Fischer     throw (RuntimeException, lang::IllegalArgumentException, lang::WrappedTargetException)
254*7a32b0c8SAndre Fischer {
255*7a32b0c8SAndre Fischer     if ( ! rxPaneId.is())
256*7a32b0c8SAndre Fischer         throw lang::IllegalArgumentException();
257*7a32b0c8SAndre Fischer 
258*7a32b0c8SAndre Fischer     const OUString sResourceURL (rxPaneId->getResourceURL());
259*7a32b0c8SAndre Fischer     if ( ! sResourceURL.equals(FrameworkHelper::msSidebarPaneURL))
260*7a32b0c8SAndre Fischer         throw lang::IllegalArgumentException();
261*7a32b0c8SAndre Fischer 
262*7a32b0c8SAndre Fischer     if ( ! mpImplementation)
263*7a32b0c8SAndre Fischer         throw RuntimeException(A2S("SidebarFactory not initialized"), NULL);
264*7a32b0c8SAndre Fischer 
265*7a32b0c8SAndre Fischer     ::Window* pWindow = VCLUnoHelper::GetWindow(mpImplementation->mxParentWindow);
266*7a32b0c8SAndre Fischer     if (pWindow == NULL)
267*7a32b0c8SAndre Fischer         throw RuntimeException();
268*7a32b0c8SAndre Fischer 
269*7a32b0c8SAndre Fischer     mpImplementation->mxPane.set(new Pane(rxPaneId, pWindow));
270*7a32b0c8SAndre Fischer     Reference<drawing::framework::XResource> xPane (static_cast<XPane*>(mpImplementation->mxPane.get()));
271*7a32b0c8SAndre Fischer     return xPane;
272*7a32b0c8SAndre Fischer }
273*7a32b0c8SAndre Fischer 
274*7a32b0c8SAndre Fischer 
275*7a32b0c8SAndre Fischer 
276*7a32b0c8SAndre Fischer 
277*7a32b0c8SAndre Fischer void SAL_CALL SidebarFactory::releaseResource (
278*7a32b0c8SAndre Fischer     const Reference<drawing::framework::XResource>& rxPane)
279*7a32b0c8SAndre Fischer     throw (RuntimeException)
280*7a32b0c8SAndre Fischer {
281*7a32b0c8SAndre Fischer     (void)rxPane;
282*7a32b0c8SAndre Fischer 
283*7a32b0c8SAndre Fischer     // Any panes created by us are just wrappers around windows whose lifetime
284*7a32b0c8SAndre Fischer     // is controlled somewhere else => nothing to do.
285*7a32b0c8SAndre Fischer }
286*7a32b0c8SAndre Fischer 
287*7a32b0c8SAndre Fischer 
288*7a32b0c8SAndre Fischer 
289*7a32b0c8SAndre Fischer 
290*7a32b0c8SAndre Fischer void SAL_CALL SidebarFactory::disposing (const ::css::lang::EventObject& rEvent)
291*7a32b0c8SAndre Fischer     throw(cssu::RuntimeException)
292*7a32b0c8SAndre Fischer {
293*7a32b0c8SAndre Fischer     /*
294*7a32b0c8SAndre Fischer     if (mpImplementation
295*7a32b0c8SAndre Fischer         && rEvent.Source == mpImplementation->mxUIElement)
296*7a32b0c8SAndre Fischer     {
297*7a32b0c8SAndre Fischer         mpImplementation->mxUIElement.clear();
298*7a32b0c8SAndre Fischer     }
299*7a32b0c8SAndre Fischer     */
300*7a32b0c8SAndre Fischer }
301*7a32b0c8SAndre Fischer 
302*7a32b0c8SAndre Fischer 
303*7a32b0c8SAndre Fischer 
304*7a32b0c8SAndre Fischer 
305*7a32b0c8SAndre Fischer SidebarFactory::SharedImplementation SidebarFactory::GetImplementationForController (
306*7a32b0c8SAndre Fischer     const cssu::Reference<css::frame::XController>& rxController)
307*7a32b0c8SAndre Fischer {
308*7a32b0c8SAndre Fischer     SharedImplementation pImplementation;
309*7a32b0c8SAndre Fischer     if (rxController.is())
310*7a32b0c8SAndre Fischer     {
311*7a32b0c8SAndre Fischer         ControllerToImplementationMap::const_iterator iImplementation (
312*7a32b0c8SAndre Fischer             maControllerToImplementationMap.find(rxController));
313*7a32b0c8SAndre Fischer         if (iImplementation == maControllerToImplementationMap.end())
314*7a32b0c8SAndre Fischer         {
315*7a32b0c8SAndre Fischer             pImplementation.reset(new Implementation(rxController));
316*7a32b0c8SAndre Fischer             maControllerToImplementationMap[rxController] = pImplementation;
317*7a32b0c8SAndre Fischer 
318*7a32b0c8SAndre Fischer             // Each Implementation object is referenced by two
319*7a32b0c8SAndre Fischer             // SidebarFactory objects.  The Implementation object is
320*7a32b0c8SAndre Fischer             // destroyed when the first of the SidebarFactory objects
321*7a32b0c8SAndre Fischer             // is disposed.
322*7a32b0c8SAndre Fischer         }
323*7a32b0c8SAndre Fischer         else
324*7a32b0c8SAndre Fischer             pImplementation = iImplementation->second;
325*7a32b0c8SAndre Fischer     }
326*7a32b0c8SAndre Fischer     return pImplementation;
327*7a32b0c8SAndre Fischer }
328*7a32b0c8SAndre Fischer 
329*7a32b0c8SAndre Fischer 
330*7a32b0c8SAndre Fischer 
331*7a32b0c8SAndre Fischer 
332*7a32b0c8SAndre Fischer //----- SidebarFactory::Implementation ----------------------------------------
333*7a32b0c8SAndre Fischer 
334*7a32b0c8SAndre Fischer SidebarFactory::Implementation::Implementation (const Reference<frame::XController>& rxController)
335*7a32b0c8SAndre Fischer     : mxConfigurationController(),
336*7a32b0c8SAndre Fischer       mxPane(),
337*7a32b0c8SAndre Fischer       mxUIElement(),
338*7a32b0c8SAndre Fischer       mxController(rxController),
339*7a32b0c8SAndre Fischer       mxParentWindow(),
340*7a32b0c8SAndre Fischer       mbIsDisposed(false)
341*7a32b0c8SAndre Fischer {
342*7a32b0c8SAndre Fischer     Reference<XControllerManager> xCM (rxController, UNO_QUERY);
343*7a32b0c8SAndre Fischer     if (xCM.is())
344*7a32b0c8SAndre Fischer     {
345*7a32b0c8SAndre Fischer         mxConfigurationController = xCM->getConfigurationController();
346*7a32b0c8SAndre Fischer     }
347*7a32b0c8SAndre Fischer }
348*7a32b0c8SAndre Fischer 
349*7a32b0c8SAndre Fischer 
350*7a32b0c8SAndre Fischer 
351*7a32b0c8SAndre Fischer 
352*7a32b0c8SAndre Fischer SidebarFactory::Implementation::~Implementation (void)
353*7a32b0c8SAndre Fischer {
354*7a32b0c8SAndre Fischer     Dispose();
355*7a32b0c8SAndre Fischer }
356*7a32b0c8SAndre Fischer 
357*7a32b0c8SAndre Fischer 
358*7a32b0c8SAndre Fischer 
359*7a32b0c8SAndre Fischer 
360*7a32b0c8SAndre Fischer void SidebarFactory::Implementation::Dispose (void)
361*7a32b0c8SAndre Fischer {
362*7a32b0c8SAndre Fischer     if (mbIsDisposed)
363*7a32b0c8SAndre Fischer         return;
364*7a32b0c8SAndre Fischer 
365*7a32b0c8SAndre Fischer     mbIsDisposed = true;
366*7a32b0c8SAndre Fischer 
367*7a32b0c8SAndre Fischer     // Release the entry in the maControllerToImplementationMap even though there
368*7a32b0c8SAndre Fischer     // may be another object that "references" to it.
369*7a32b0c8SAndre Fischer     ControllerToImplementationMap::iterator iImplementation (
370*7a32b0c8SAndre Fischer         maControllerToImplementationMap.find(mxController));
371*7a32b0c8SAndre Fischer         if (iImplementation != maControllerToImplementationMap.end())
372*7a32b0c8SAndre Fischer             maControllerToImplementationMap.erase(iImplementation);
373*7a32b0c8SAndre Fischer 
374*7a32b0c8SAndre Fischer     mxController.clear();
375*7a32b0c8SAndre Fischer }
376*7a32b0c8SAndre Fischer 
377*7a32b0c8SAndre Fischer 
378*7a32b0c8SAndre Fischer } } // end of namespace sd::sidebar
379