xref: /AOO41X/main/sd/source/ui/framework/factories/BasicPaneFactory.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "BasicPaneFactory.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "ChildWindowPane.hxx"
29cdf0e10cSrcweir #include "FrameWindowPane.hxx"
30cdf0e10cSrcweir #include "FullScreenPane.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
33cdf0e10cSrcweir #include "ViewShellBase.hxx"
34cdf0e10cSrcweir #include "PaneChildWindows.hxx"
35cdf0e10cSrcweir #include "DrawController.hxx"
36cdf0e10cSrcweir #include "DrawDocShell.hxx"
37cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
38cdf0e10cSrcweir #include <boost/bind.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir using namespace ::com::sun::star::lang;
44cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using ::rtl::OUString;
47cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace {
50cdf0e10cSrcweir     enum PaneId {
51cdf0e10cSrcweir         CenterPaneId,
52cdf0e10cSrcweir         FullScreenPaneId,
53cdf0e10cSrcweir         LeftImpressPaneId,
54*62024513SAndre Fischer         LeftDrawPaneId
55cdf0e10cSrcweir     };
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     static const sal_Int32 gnConfigurationUpdateStartEvent(0);
58cdf0e10cSrcweir     static const sal_Int32 gnConfigurationUpdateEndEvent(1);
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir namespace sd { namespace framework {
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /** Store URL, XPane reference and (local) PaneId for every pane factory
65cdf0e10cSrcweir     that is registered at the PaneController.
66cdf0e10cSrcweir */
67cdf0e10cSrcweir class BasicPaneFactory::PaneDescriptor
68cdf0e10cSrcweir {
69cdf0e10cSrcweir public:
70cdf0e10cSrcweir     OUString msPaneURL;
71cdf0e10cSrcweir     Reference<XResource> mxPane;
72cdf0e10cSrcweir     PaneId mePaneId;
73cdf0e10cSrcweir     /** The mbReleased flag is set when the pane has been released.  Some
74cdf0e10cSrcweir         panes are just hidden and destroyed.  When the pane is reused this
75cdf0e10cSrcweir         flag is reset.
76cdf0e10cSrcweir     */
77cdf0e10cSrcweir     bool mbIsReleased;
78cdf0e10cSrcweir     bool mbIsChildWindow;
79cdf0e10cSrcweir 
CompareURL(const OUString & rsPaneURL)80cdf0e10cSrcweir     bool CompareURL (const OUString& rsPaneURL) { return msPaneURL.equals(rsPaneURL); }
ComparePane(const Reference<XResource> & rxPane)81cdf0e10cSrcweir     bool ComparePane (const Reference<XResource>& rxPane) { return mxPane==rxPane; }
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir class BasicPaneFactory::PaneContainer
86cdf0e10cSrcweir     : public ::std::vector<PaneDescriptor>
87cdf0e10cSrcweir {
88cdf0e10cSrcweir public:
PaneContainer(void)89cdf0e10cSrcweir     PaneContainer (void) {}
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
BasicPaneFactory_createInstance(const Reference<XComponentContext> & rxContext)94cdf0e10cSrcweir Reference<XInterface> SAL_CALL BasicPaneFactory_createInstance (
95cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     return Reference<XInterface>(static_cast<XWeak*>(new BasicPaneFactory(rxContext)));
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
BasicPaneFactory_getImplementationName(void)103cdf0e10cSrcweir ::rtl::OUString BasicPaneFactory_getImplementationName (void) throw(RuntimeException)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     return ::rtl::OUString(
106cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.framework.BasicPaneFactory"));
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
BasicPaneFactory_getSupportedServiceNames(void)112cdf0e10cSrcweir Sequence<rtl::OUString> SAL_CALL BasicPaneFactory_getSupportedServiceNames (void)
113cdf0e10cSrcweir     throw (RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	static const ::rtl::OUString sServiceName(
116cdf0e10cSrcweir         ::rtl::OUString::createFromAscii("com.sun.star.drawing.framework.BasicPaneFactory"));
117cdf0e10cSrcweir 	return Sequence<rtl::OUString>(&sServiceName, 1);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir //===== PaneFactory ===========================================================
124cdf0e10cSrcweir 
BasicPaneFactory(const Reference<XComponentContext> & rxContext)125cdf0e10cSrcweir BasicPaneFactory::BasicPaneFactory (
126cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext)
127cdf0e10cSrcweir     : BasicPaneFactoryInterfaceBase(m_aMutex),
128cdf0e10cSrcweir       mxComponentContext(rxContext),
129cdf0e10cSrcweir       mxConfigurationControllerWeak(),
130cdf0e10cSrcweir       mpViewShellBase(NULL),
131cdf0e10cSrcweir       mpPaneContainer(new PaneContainer),
132cdf0e10cSrcweir       mbFirstUpdateSeen(false),
133cdf0e10cSrcweir       mpUpdateLockManager()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
~BasicPaneFactory(void)141cdf0e10cSrcweir BasicPaneFactory::~BasicPaneFactory (void)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
disposing(void)148cdf0e10cSrcweir void SAL_CALL BasicPaneFactory::disposing (void)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
151cdf0e10cSrcweir     if (xCC.is())
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         xCC->removeResourceFactoryForReference(this);
154cdf0e10cSrcweir         xCC->removeConfigurationChangeListener(this);
155cdf0e10cSrcweir         mxConfigurationControllerWeak = Reference<XConfigurationController>();
156cdf0e10cSrcweir     }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     for (PaneContainer::const_iterator iDescriptor = mpPaneContainer->begin();
159cdf0e10cSrcweir          iDescriptor != mpPaneContainer->end();
160cdf0e10cSrcweir          ++iDescriptor)
161cdf0e10cSrcweir     {
162cdf0e10cSrcweir         if (iDescriptor->mbIsReleased)
163cdf0e10cSrcweir         {
164cdf0e10cSrcweir             Reference<XComponent> xComponent (iDescriptor->mxPane, UNO_QUERY);
165cdf0e10cSrcweir             if (xComponent.is())
166cdf0e10cSrcweir             {
167cdf0e10cSrcweir                 xComponent->removeEventListener(this);
168cdf0e10cSrcweir                 xComponent->dispose();
169cdf0e10cSrcweir             }
170cdf0e10cSrcweir         }
171cdf0e10cSrcweir     }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 
initialize(const Sequence<Any> & aArguments)177cdf0e10cSrcweir void SAL_CALL BasicPaneFactory::initialize (const Sequence<Any>& aArguments)
178cdf0e10cSrcweir     throw (Exception, RuntimeException)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir     if (aArguments.getLength() > 0)
181cdf0e10cSrcweir     {
182cdf0e10cSrcweir         try
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir             // Get the XController from the first argument.
185cdf0e10cSrcweir             Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
186cdf0e10cSrcweir             mxControllerWeak = xController;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir             // Tunnel through the controller to obtain access to the ViewShellBase.
189cdf0e10cSrcweir             try
190cdf0e10cSrcweir             {
191cdf0e10cSrcweir                 Reference<lang::XUnoTunnel> xTunnel (xController, UNO_QUERY_THROW);
192cdf0e10cSrcweir                 DrawController* pController
193cdf0e10cSrcweir                     = reinterpret_cast<DrawController*>(
194cdf0e10cSrcweir                         (sal::static_int_cast<sal_uIntPtr>(
195cdf0e10cSrcweir                             xTunnel->getSomething(DrawController::getUnoTunnelId()))));
196cdf0e10cSrcweir                 mpViewShellBase = pController->GetViewShellBase();
197cdf0e10cSrcweir                 mpUpdateLockManager = mpViewShellBase->GetUpdateLockManager();
198cdf0e10cSrcweir             }
199cdf0e10cSrcweir             catch(RuntimeException&)
200cdf0e10cSrcweir             {}
201cdf0e10cSrcweir 
202cdf0e10cSrcweir             Reference<XControllerManager> xCM (xController, UNO_QUERY_THROW);
203cdf0e10cSrcweir             Reference<XConfigurationController> xCC (xCM->getConfigurationController());
204cdf0e10cSrcweir             mxConfigurationControllerWeak = xCC;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir             // Add pane factories for the two left panes (one for Impress and one for
2077a32b0c8SAndre Fischer             // Draw) and the center pane.
208cdf0e10cSrcweir             if (xController.is() && xCC.is())
209cdf0e10cSrcweir             {
210cdf0e10cSrcweir                 PaneDescriptor aDescriptor;
211cdf0e10cSrcweir                 aDescriptor.msPaneURL = FrameworkHelper::msCenterPaneURL;
212cdf0e10cSrcweir                 aDescriptor.mePaneId = CenterPaneId;
213cdf0e10cSrcweir                 aDescriptor.mbIsReleased = false;
214cdf0e10cSrcweir                 aDescriptor.mbIsChildWindow = false;
215cdf0e10cSrcweir                 mpPaneContainer->push_back(aDescriptor);
216cdf0e10cSrcweir                 xCC->addResourceFactory(aDescriptor.msPaneURL, this);
217cdf0e10cSrcweir 
218cdf0e10cSrcweir                 aDescriptor.msPaneURL = FrameworkHelper::msFullScreenPaneURL;
219cdf0e10cSrcweir                 aDescriptor.mePaneId = FullScreenPaneId;
220cdf0e10cSrcweir                 mpPaneContainer->push_back(aDescriptor);
221cdf0e10cSrcweir                 xCC->addResourceFactory(aDescriptor.msPaneURL, this);
222cdf0e10cSrcweir 
223cdf0e10cSrcweir                 aDescriptor.msPaneURL = FrameworkHelper::msLeftImpressPaneURL;
224cdf0e10cSrcweir                 aDescriptor.mePaneId = LeftImpressPaneId;
225cdf0e10cSrcweir                 aDescriptor.mbIsChildWindow = true;
226cdf0e10cSrcweir                 mpPaneContainer->push_back(aDescriptor);
227cdf0e10cSrcweir                 xCC->addResourceFactory(aDescriptor.msPaneURL, this);
228cdf0e10cSrcweir 
229cdf0e10cSrcweir                 aDescriptor.msPaneURL = FrameworkHelper::msLeftDrawPaneURL;
230cdf0e10cSrcweir                 aDescriptor.mePaneId = LeftDrawPaneId;
231cdf0e10cSrcweir                 mpPaneContainer->push_back(aDescriptor);
232cdf0e10cSrcweir                 xCC->addResourceFactory(aDescriptor.msPaneURL, this);
233cdf0e10cSrcweir             }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir             // Register as configuration change listener.
236cdf0e10cSrcweir             if (xCC.is())
237cdf0e10cSrcweir             {
238cdf0e10cSrcweir                 xCC->addConfigurationChangeListener(
239cdf0e10cSrcweir                     this,
240cdf0e10cSrcweir                     FrameworkHelper::msConfigurationUpdateStartEvent,
241cdf0e10cSrcweir                     makeAny(gnConfigurationUpdateStartEvent));
242cdf0e10cSrcweir                 xCC->addConfigurationChangeListener(
243cdf0e10cSrcweir                     this,
244cdf0e10cSrcweir                     FrameworkHelper::msConfigurationUpdateEndEvent,
245cdf0e10cSrcweir                     makeAny(gnConfigurationUpdateEndEvent));
246cdf0e10cSrcweir             }
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir         catch (RuntimeException&)
249cdf0e10cSrcweir         {
250cdf0e10cSrcweir             Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
251cdf0e10cSrcweir             if (xCC.is())
252cdf0e10cSrcweir                 xCC->removeResourceFactoryForReference(this);
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
260cdf0e10cSrcweir //===== XPaneFactory ==========================================================
261cdf0e10cSrcweir 
createResource(const Reference<XResourceId> & rxPaneId)262cdf0e10cSrcweir Reference<XResource> SAL_CALL BasicPaneFactory::createResource (
263cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId)
264cdf0e10cSrcweir     throw (RuntimeException, IllegalArgumentException, WrappedTargetException)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     ThrowIfDisposed();
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     Reference<XResource> xPane;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     // Based on the ResourceURL of the given ResourceId look up the
271cdf0e10cSrcweir     // corresponding factory descriptor.
272cdf0e10cSrcweir     PaneContainer::iterator iDescriptor (
273cdf0e10cSrcweir         ::std::find_if (
274cdf0e10cSrcweir             mpPaneContainer->begin(),
275cdf0e10cSrcweir             mpPaneContainer->end(),
276cdf0e10cSrcweir             ::boost::bind(&PaneDescriptor::CompareURL, _1, rxPaneId->getResourceURL())));
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     if (iDescriptor != mpPaneContainer->end())
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         if (iDescriptor->mxPane.is())
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             // The pane has already been created and is still active (has
283cdf0e10cSrcweir             // not yet been released).  This should not happen.
284cdf0e10cSrcweir             xPane = iDescriptor->mxPane;
285cdf0e10cSrcweir         }
286cdf0e10cSrcweir         else
287cdf0e10cSrcweir         {
288cdf0e10cSrcweir             // Create a new pane.
289cdf0e10cSrcweir             switch (iDescriptor->mePaneId)
290cdf0e10cSrcweir             {
291cdf0e10cSrcweir                 case CenterPaneId:
292cdf0e10cSrcweir                     xPane = CreateFrameWindowPane(rxPaneId);
293cdf0e10cSrcweir                     break;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir                 case FullScreenPaneId:
296cdf0e10cSrcweir                     xPane = CreateFullScreenPane(mxComponentContext, rxPaneId);
297cdf0e10cSrcweir                     break;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir                 case LeftImpressPaneId:
300cdf0e10cSrcweir                 case LeftDrawPaneId:
301cdf0e10cSrcweir                     xPane = CreateChildWindowPane(
302cdf0e10cSrcweir                         rxPaneId,
303cdf0e10cSrcweir                         *iDescriptor);
304cdf0e10cSrcweir                     break;
305cdf0e10cSrcweir             }
306cdf0e10cSrcweir             iDescriptor->mxPane = xPane;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir             // Listen for the pane being disposed.
309cdf0e10cSrcweir             Reference<lang::XComponent> xComponent (xPane, UNO_QUERY);
310cdf0e10cSrcweir             if (xComponent.is())
311cdf0e10cSrcweir                 xComponent->addEventListener(this);
312cdf0e10cSrcweir         }
313cdf0e10cSrcweir         iDescriptor->mbIsReleased = false;
314cdf0e10cSrcweir     }
315cdf0e10cSrcweir     else
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         // The requested pane can not be created by any of the factories
318cdf0e10cSrcweir         // managed by the called BasicPaneFactory object.
319cdf0e10cSrcweir         throw lang::IllegalArgumentException(
320cdf0e10cSrcweir             ::rtl::OUString::createFromAscii(
321cdf0e10cSrcweir                 "BasicPaneFactory::createPane() called for unknown resource id"),
322cdf0e10cSrcweir             NULL,
323cdf0e10cSrcweir             0);
324cdf0e10cSrcweir     }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     return xPane;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 
releaseResource(const Reference<XResource> & rxPane)333cdf0e10cSrcweir void SAL_CALL BasicPaneFactory::releaseResource (
334cdf0e10cSrcweir     const Reference<XResource>& rxPane)
335cdf0e10cSrcweir     throw (RuntimeException)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     ThrowIfDisposed();
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     // Based on the given XPane reference look up the corresponding factory
340cdf0e10cSrcweir     // descriptor.
341cdf0e10cSrcweir     PaneContainer::iterator iDescriptor (
342cdf0e10cSrcweir         ::std::find_if(
343cdf0e10cSrcweir             mpPaneContainer->begin(),
344cdf0e10cSrcweir             mpPaneContainer->end(),
345cdf0e10cSrcweir             ::boost::bind(&PaneDescriptor::ComparePane, _1, rxPane)));
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     if (iDescriptor != mpPaneContainer->end())
348cdf0e10cSrcweir     {
349cdf0e10cSrcweir         // The given pane was created by one of the factories.  Child
350cdf0e10cSrcweir         // windows are just hidden and will be reused when requested later.
351cdf0e10cSrcweir         // Other windows are disposed and their reference is reset so that
352cdf0e10cSrcweir         // on the next createPane() call for the same pane type the pane is
353cdf0e10cSrcweir         // created anew.
354cdf0e10cSrcweir         ChildWindowPane* pChildWindowPane = dynamic_cast<ChildWindowPane*>(rxPane.get());
355cdf0e10cSrcweir         if (pChildWindowPane != NULL)
356cdf0e10cSrcweir         {
357cdf0e10cSrcweir             iDescriptor->mbIsReleased = true;
358cdf0e10cSrcweir             pChildWindowPane->Hide();
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir         else
361cdf0e10cSrcweir         {
362cdf0e10cSrcweir             iDescriptor->mxPane = NULL;
363cdf0e10cSrcweir             Reference<XComponent> xComponent (rxPane, UNO_QUERY);
364cdf0e10cSrcweir             if (xComponent.is())
365cdf0e10cSrcweir             {
366cdf0e10cSrcweir                 // We are disposing the pane and do not have to be informed of
367cdf0e10cSrcweir                 // that.
368cdf0e10cSrcweir                 xComponent->removeEventListener(this);
369cdf0e10cSrcweir                 xComponent->dispose();
370cdf0e10cSrcweir             }
371cdf0e10cSrcweir         }
372cdf0e10cSrcweir     }
373cdf0e10cSrcweir     else
374cdf0e10cSrcweir     {
375cdf0e10cSrcweir         // The given XPane reference is either empty or the pane was not
376cdf0e10cSrcweir         // created by any of the factories managed by the called
377cdf0e10cSrcweir         // BasicPaneFactory object.
378cdf0e10cSrcweir         throw lang::IllegalArgumentException(
379cdf0e10cSrcweir             ::rtl::OUString::createFromAscii(
380cdf0e10cSrcweir                 "BasicPaneFactory::releasePane() called for pane that that was not created by same factory."),
381cdf0e10cSrcweir             NULL,
382cdf0e10cSrcweir             0);
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 
389cdf0e10cSrcweir //===== XConfigurationChangeListener ==========================================
390cdf0e10cSrcweir 
notifyConfigurationChange(const ConfigurationChangeEvent & rEvent)391cdf0e10cSrcweir void SAL_CALL BasicPaneFactory::notifyConfigurationChange (
392cdf0e10cSrcweir     const ConfigurationChangeEvent& rEvent)
393cdf0e10cSrcweir     throw (RuntimeException)
394cdf0e10cSrcweir {
395cdf0e10cSrcweir     sal_Int32 nEventType = 0;
396cdf0e10cSrcweir     rEvent.UserData >>= nEventType;
397cdf0e10cSrcweir     switch (nEventType)
398cdf0e10cSrcweir     {
399cdf0e10cSrcweir         case gnConfigurationUpdateStartEvent:
400cdf0e10cSrcweir             // Lock UI updates while we are switching the views except for
401cdf0e10cSrcweir             // the first time after creation.  Outherwise this leads to
402cdf0e10cSrcweir             // problems after reload (missing resizes for the side panes).
403cdf0e10cSrcweir             if (mbFirstUpdateSeen)
404cdf0e10cSrcweir             {
405cdf0e10cSrcweir                 if (mpUpdateLockManager.get()!=NULL)
406cdf0e10cSrcweir                 {
407cdf0e10cSrcweir                     //                    ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
408cdf0e10cSrcweir                     //                    mpUpdateLockManager->Lock();
409cdf0e10cSrcweir                 }
410cdf0e10cSrcweir             }
411cdf0e10cSrcweir             else
412cdf0e10cSrcweir                 mbFirstUpdateSeen = true;
413cdf0e10cSrcweir             break;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir         case gnConfigurationUpdateEndEvent:
416cdf0e10cSrcweir             // Unlock the update lock here when only the visibility of
417cdf0e10cSrcweir             // windows but not the view shells displayed in them have
418cdf0e10cSrcweir             // changed.  Otherwise the UpdateLockManager takes care of
419cdf0e10cSrcweir             // unlocking at the right time.
420cdf0e10cSrcweir             if (mpUpdateLockManager.get() != NULL)
421cdf0e10cSrcweir             {
422cdf0e10cSrcweir                 ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
423cdf0e10cSrcweir                 //                if (mpUpdateLockManager->IsLocked())
424cdf0e10cSrcweir                 //                    mpUpdateLockManager->Unlock();
425cdf0e10cSrcweir             }
426cdf0e10cSrcweir             break;
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 
433cdf0e10cSrcweir //===== lang::XEventListener ==================================================
434cdf0e10cSrcweir 
disposing(const lang::EventObject & rEventObject)435cdf0e10cSrcweir void SAL_CALL BasicPaneFactory::disposing (
436cdf0e10cSrcweir     const lang::EventObject& rEventObject)
437cdf0e10cSrcweir     throw (RuntimeException)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir     if (mxConfigurationControllerWeak == rEventObject.Source)
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         mxConfigurationControllerWeak = Reference<XConfigurationController>();
442cdf0e10cSrcweir     }
443cdf0e10cSrcweir     else
444cdf0e10cSrcweir     {
445cdf0e10cSrcweir         // Has one of the panes been disposed?  If so, then release the
446cdf0e10cSrcweir         // reference to that pane, but not the pane descriptor.
447cdf0e10cSrcweir         Reference<XResource> xPane (rEventObject.Source, UNO_QUERY);
448cdf0e10cSrcweir         PaneContainer::iterator iDescriptor (
449cdf0e10cSrcweir             ::std::find_if (
450cdf0e10cSrcweir                 mpPaneContainer->begin(),
451cdf0e10cSrcweir                 mpPaneContainer->end(),
452cdf0e10cSrcweir                 ::boost::bind(&PaneDescriptor::ComparePane, _1, xPane)));
453cdf0e10cSrcweir         if (iDescriptor != mpPaneContainer->end())
454cdf0e10cSrcweir         {
455cdf0e10cSrcweir             iDescriptor->mxPane = NULL;
456cdf0e10cSrcweir         }
457cdf0e10cSrcweir     }
458cdf0e10cSrcweir }
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 
463cdf0e10cSrcweir //-----------------------------------------------------------------------------
464cdf0e10cSrcweir 
CreateFrameWindowPane(const Reference<XResourceId> & rxPaneId)465cdf0e10cSrcweir Reference<XResource> BasicPaneFactory::CreateFrameWindowPane (
466cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir     Reference<XResource> xPane;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir     if (mpViewShellBase != NULL)
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir         xPane = new FrameWindowPane(rxPaneId, mpViewShellBase->GetViewWindow());
473cdf0e10cSrcweir     }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     return xPane;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 
CreateFullScreenPane(const Reference<XComponentContext> & rxComponentContext,const Reference<XResourceId> & rxPaneId)481cdf0e10cSrcweir Reference<XResource> BasicPaneFactory::CreateFullScreenPane (
482cdf0e10cSrcweir     const Reference<XComponentContext>& rxComponentContext,
483cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir     Reference<XResource> xPane (
486cdf0e10cSrcweir         new FullScreenPane(
487cdf0e10cSrcweir             rxComponentContext,
488cdf0e10cSrcweir             rxPaneId,
489cdf0e10cSrcweir             mpViewShellBase->GetViewWindow()));
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     return xPane;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
CreateChildWindowPane(const Reference<XResourceId> & rxPaneId,const PaneDescriptor & rDescriptor)497cdf0e10cSrcweir Reference<XResource> BasicPaneFactory::CreateChildWindowPane (
498cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId,
499cdf0e10cSrcweir     const PaneDescriptor& rDescriptor)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir     Reference<XResource> xPane;
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     if (mpViewShellBase != NULL)
504cdf0e10cSrcweir     {
505cdf0e10cSrcweir         // Create the corresponding shell and determine the id of the child window.
506cdf0e10cSrcweir         sal_uInt16 nChildWindowId = 0;
507cdf0e10cSrcweir         ::std::auto_ptr<SfxShell> pShell;
508cdf0e10cSrcweir         switch (rDescriptor.mePaneId)
509cdf0e10cSrcweir         {
510cdf0e10cSrcweir             case LeftImpressPaneId:
511cdf0e10cSrcweir                 pShell.reset(new LeftImpressPaneShell());
512cdf0e10cSrcweir                 nChildWindowId = ::sd::LeftPaneImpressChildWindow::GetChildWindowId();
513cdf0e10cSrcweir                 break;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir             case LeftDrawPaneId:
516cdf0e10cSrcweir                 pShell.reset(new LeftDrawPaneShell());
517cdf0e10cSrcweir                 nChildWindowId = ::sd::LeftPaneDrawChildWindow::GetChildWindowId();
518cdf0e10cSrcweir                 break;
519cdf0e10cSrcweir 
520cdf0e10cSrcweir             default:
521cdf0e10cSrcweir                 break;
522cdf0e10cSrcweir         }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir         // With shell and child window id create the ChildWindowPane
525cdf0e10cSrcweir         // wrapper.
526cdf0e10cSrcweir         if (pShell.get() != NULL)
527cdf0e10cSrcweir         {
528cdf0e10cSrcweir             xPane = new ChildWindowPane(
529cdf0e10cSrcweir                 rxPaneId,
530cdf0e10cSrcweir                 nChildWindowId,
531cdf0e10cSrcweir                 *mpViewShellBase,
532cdf0e10cSrcweir                 pShell);
533cdf0e10cSrcweir         }
534cdf0e10cSrcweir     }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     return xPane;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
ThrowIfDisposed(void) const539cdf0e10cSrcweir void BasicPaneFactory::ThrowIfDisposed (void) const
540cdf0e10cSrcweir     throw (lang::DisposedException)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
543cdf0e10cSrcweir 	{
544cdf0e10cSrcweir         throw lang::DisposedException (
545cdf0e10cSrcweir             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
546cdf0e10cSrcweir                 "BasicPaneFactory object has already been disposed")),
547cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
548cdf0e10cSrcweir     }
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 
552cdf0e10cSrcweir } } // end of namespace sd::framework
553