1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sdext.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
32*cdf0e10cSrcweir #include "PresenterPaneBase.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/awt/XGraphics.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceId.hpp>
37*cdf0e10cSrcweir #include <vector>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using namespace ::com::sun::star;
40*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
41*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
42*cdf0e10cSrcweir using ::rtl::OUString;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir namespace sdext { namespace presenter {
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir PresenterPaneContainer::PresenterPaneContainer (
47*cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext)
48*cdf0e10cSrcweir     : PresenterPaneContainerInterfaceBase(m_aMutex),
49*cdf0e10cSrcweir       maPanes(),
50*cdf0e10cSrcweir       mxPresenterHelper()
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir     Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager());
53*cdf0e10cSrcweir     if (xFactory.is())
54*cdf0e10cSrcweir     {
55*cdf0e10cSrcweir         mxPresenterHelper = Reference<drawing::XPresenterHelper>(
56*cdf0e10cSrcweir             xFactory->createInstanceWithContext(
57*cdf0e10cSrcweir                 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
58*cdf0e10cSrcweir                 rxContext),
59*cdf0e10cSrcweir             UNO_QUERY_THROW);
60*cdf0e10cSrcweir     }
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir PresenterPaneContainer::~PresenterPaneContainer (void)
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir void PresenterPaneContainer::PreparePane (
74*cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId,
75*cdf0e10cSrcweir     const OUString& rsViewURL,
76*cdf0e10cSrcweir     const OUString& rsTitle,
77*cdf0e10cSrcweir     const OUString& rsAccessibleTitle,
78*cdf0e10cSrcweir     const bool bIsOpaque,
79*cdf0e10cSrcweir     const ViewInitializationFunction& rViewInitialization,
80*cdf0e10cSrcweir     const double nLeft,
81*cdf0e10cSrcweir     const double nTop,
82*cdf0e10cSrcweir     const double nRight,
83*cdf0e10cSrcweir     const double nBottom)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     if ( ! rxPaneId.is())
86*cdf0e10cSrcweir         return;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     SharedPaneDescriptor pPane (FindPaneURL(rxPaneId->getResourceURL()));
89*cdf0e10cSrcweir     if (pPane.get() == NULL)
90*cdf0e10cSrcweir     {
91*cdf0e10cSrcweir         // No entry found for the given pane id.  Create a new one.
92*cdf0e10cSrcweir         SharedPaneDescriptor pDescriptor (new PaneDescriptor());
93*cdf0e10cSrcweir         pDescriptor->mxPaneId = rxPaneId;
94*cdf0e10cSrcweir         pDescriptor->msViewURL = rsViewURL;
95*cdf0e10cSrcweir         pDescriptor->mxPane = NULL;
96*cdf0e10cSrcweir         if (rsTitle.indexOf('%') < 0)
97*cdf0e10cSrcweir         {
98*cdf0e10cSrcweir             pDescriptor->msTitle = rsTitle;
99*cdf0e10cSrcweir             pDescriptor->msTitleTemplate = OUString();
100*cdf0e10cSrcweir         }
101*cdf0e10cSrcweir         else
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir             pDescriptor->msTitleTemplate = rsTitle;
104*cdf0e10cSrcweir             pDescriptor->msTitle = OUString();
105*cdf0e10cSrcweir         }
106*cdf0e10cSrcweir         pDescriptor->msAccessibleTitleTemplate = rsAccessibleTitle;
107*cdf0e10cSrcweir         pDescriptor->maViewInitialization = rViewInitialization;
108*cdf0e10cSrcweir         pDescriptor->mnLeft = nLeft;
109*cdf0e10cSrcweir         pDescriptor->mnTop = nTop;
110*cdf0e10cSrcweir         pDescriptor->mnRight = nRight;
111*cdf0e10cSrcweir         pDescriptor->mnBottom = nBottom;
112*cdf0e10cSrcweir         pDescriptor->mbIsActive = true;
113*cdf0e10cSrcweir         pDescriptor->mbIsOpaque = bIsOpaque;
114*cdf0e10cSrcweir         pDescriptor->maSpriteProvider = PaneDescriptor::SpriteProvider();
115*cdf0e10cSrcweir         pDescriptor->mbIsSprite = false;
116*cdf0e10cSrcweir         pDescriptor->maCalloutAnchorLocation = awt::Point(-1,-1);
117*cdf0e10cSrcweir         pDescriptor->mbHasCalloutAnchor = false;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         maPanes.push_back(pDescriptor);
120*cdf0e10cSrcweir     }
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir void SAL_CALL PresenterPaneContainer::disposing (void)
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     PaneList::iterator iPane (maPanes.begin());
129*cdf0e10cSrcweir     PaneList::const_iterator iEnd (maPanes.end());
130*cdf0e10cSrcweir     for ( ; iPane!=iEnd; ++iPane)
131*cdf0e10cSrcweir         if ((*iPane)->mxPaneId.is())
132*cdf0e10cSrcweir             RemovePane((*iPane)->mxPaneId);
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor
139*cdf0e10cSrcweir     PresenterPaneContainer::StorePane (const rtl::Reference<PresenterPaneBase>& rxPane)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     if (rxPane.is())
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         OUString sPaneURL;
146*cdf0e10cSrcweir         Reference<XResourceId> xPaneId (rxPane->getResourceId());
147*cdf0e10cSrcweir         if (xPaneId.is())
148*cdf0e10cSrcweir             sPaneURL = xPaneId->getResourceURL();
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir         pDescriptor = FindPaneURL(sPaneURL);
151*cdf0e10cSrcweir         if (pDescriptor.get() == NULL)
152*cdf0e10cSrcweir             PreparePane(xPaneId, OUString(), OUString(), OUString(),
153*cdf0e10cSrcweir                 false, ViewInitializationFunction(), 0,0,0,0);
154*cdf0e10cSrcweir         pDescriptor = FindPaneURL(sPaneURL);
155*cdf0e10cSrcweir         if (pDescriptor.get() != NULL)
156*cdf0e10cSrcweir         {
157*cdf0e10cSrcweir             Reference<awt::XWindow> xWindow (rxPane->getWindow());
158*cdf0e10cSrcweir             pDescriptor->mxContentWindow = xWindow;
159*cdf0e10cSrcweir             pDescriptor->mxPaneId = xPaneId;
160*cdf0e10cSrcweir             pDescriptor->mxPane = rxPane;
161*cdf0e10cSrcweir             pDescriptor->mxPane->SetTitle(pDescriptor->msTitle);
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir             // When there is a call out anchor location set then tell the
164*cdf0e10cSrcweir             // window about it.
165*cdf0e10cSrcweir             if (pDescriptor->mbHasCalloutAnchor)
166*cdf0e10cSrcweir                 pDescriptor->mxPane->SetCalloutAnchor(pDescriptor->maCalloutAnchorLocation);
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir             if (xWindow.is())
169*cdf0e10cSrcweir                 xWindow->addEventListener(this);
170*cdf0e10cSrcweir         }
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     return pDescriptor;
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor
180*cdf0e10cSrcweir     PresenterPaneContainer::StoreBorderWindow(
181*cdf0e10cSrcweir         const Reference<XResourceId>& rxPaneId,
182*cdf0e10cSrcweir         const Reference<awt::XWindow>& rxBorderWindow)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     // The content window may not be present.  Use the resource URL of the
185*cdf0e10cSrcweir     // pane id as key.
186*cdf0e10cSrcweir     OUString sPaneURL;
187*cdf0e10cSrcweir     if (rxPaneId.is())
188*cdf0e10cSrcweir         sPaneURL = rxPaneId->getResourceURL();
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor (FindPaneURL(sPaneURL));
191*cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
192*cdf0e10cSrcweir     {
193*cdf0e10cSrcweir         pDescriptor->mxBorderWindow = rxBorderWindow;
194*cdf0e10cSrcweir         return pDescriptor;
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir     else
197*cdf0e10cSrcweir         return SharedPaneDescriptor();
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor
204*cdf0e10cSrcweir     PresenterPaneContainer::StoreView (
205*cdf0e10cSrcweir         const Reference<XView>& rxView,
206*cdf0e10cSrcweir         const SharedBitmapDescriptor& rpViewBackground)
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     if (rxView.is())
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         OUString sPaneURL;
213*cdf0e10cSrcweir         Reference<XResourceId> xViewId (rxView->getResourceId());
214*cdf0e10cSrcweir         if (xViewId.is())
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             Reference<XResourceId> xPaneId (xViewId->getAnchor());
217*cdf0e10cSrcweir             if (xPaneId.is())
218*cdf0e10cSrcweir                 sPaneURL = xPaneId->getResourceURL();
219*cdf0e10cSrcweir         }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir         pDescriptor = FindPaneURL(sPaneURL);
222*cdf0e10cSrcweir         if (pDescriptor.get() != NULL)
223*cdf0e10cSrcweir         {
224*cdf0e10cSrcweir             pDescriptor->mxView = rxView;
225*cdf0e10cSrcweir             pDescriptor->mpViewBackground = rpViewBackground;
226*cdf0e10cSrcweir             pDescriptor->mxPane->SetBackground(rpViewBackground);
227*cdf0e10cSrcweir             try
228*cdf0e10cSrcweir             {
229*cdf0e10cSrcweir                 if ( ! pDescriptor->maViewInitialization.empty())
230*cdf0e10cSrcweir                     pDescriptor->maViewInitialization(rxView);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir                 // Activate or deactivate the pane/view.
233*cdf0e10cSrcweir                 if ( ! pDescriptor->maActivator.empty())
234*cdf0e10cSrcweir                     pDescriptor->maActivator(pDescriptor->mbIsActive);
235*cdf0e10cSrcweir             }
236*cdf0e10cSrcweir             catch (RuntimeException&)
237*cdf0e10cSrcweir             {
238*cdf0e10cSrcweir                 OSL_ASSERT(false);
239*cdf0e10cSrcweir             }
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir     return pDescriptor;
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor
250*cdf0e10cSrcweir     PresenterPaneContainer::RemovePane (const Reference<XResourceId>& rxPaneId)
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor (FindPaneId(rxPaneId));
253*cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         if (pDescriptor->mxContentWindow.is())
256*cdf0e10cSrcweir             pDescriptor->mxContentWindow->removeEventListener(this);
257*cdf0e10cSrcweir         pDescriptor->mxContentWindow = NULL;
258*cdf0e10cSrcweir         pDescriptor->mxBorderWindow = NULL;
259*cdf0e10cSrcweir         pDescriptor->mxPane = NULL;
260*cdf0e10cSrcweir         pDescriptor->mxView = NULL;
261*cdf0e10cSrcweir         pDescriptor->mbIsActive = false;
262*cdf0e10cSrcweir     }
263*cdf0e10cSrcweir     return pDescriptor;
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor
271*cdf0e10cSrcweir     PresenterPaneContainer::RemoveView (const Reference<XView>& rxView)
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor;
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     if (rxView.is())
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir         OUString sPaneURL;
278*cdf0e10cSrcweir         Reference<XResourceId> xViewId (rxView->getResourceId());
279*cdf0e10cSrcweir         if (xViewId.is())
280*cdf0e10cSrcweir         {
281*cdf0e10cSrcweir             Reference<XResourceId> xPaneId (xViewId->getAnchor());
282*cdf0e10cSrcweir             if (xPaneId.is())
283*cdf0e10cSrcweir                 sPaneURL = xPaneId->getResourceURL();
284*cdf0e10cSrcweir         }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir         pDescriptor = FindPaneURL(sPaneURL);
287*cdf0e10cSrcweir         if (pDescriptor.get() != NULL)
288*cdf0e10cSrcweir         {
289*cdf0e10cSrcweir             pDescriptor->mxView = NULL;
290*cdf0e10cSrcweir             pDescriptor->mpViewBackground = SharedBitmapDescriptor();
291*cdf0e10cSrcweir         }
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir     return pDescriptor;
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindBorderWindow (
301*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxBorderWindow)
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     PaneList::const_iterator iPane;
304*cdf0e10cSrcweir     PaneList::iterator iEnd (maPanes.end());
305*cdf0e10cSrcweir     for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
306*cdf0e10cSrcweir     {
307*cdf0e10cSrcweir         if ((*iPane)->mxBorderWindow == rxBorderWindow)
308*cdf0e10cSrcweir             return *iPane;
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir     return SharedPaneDescriptor();
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindContentWindow (
317*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxContentWindow)
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     PaneList::const_iterator iPane;
320*cdf0e10cSrcweir     PaneList::iterator iEnd (maPanes.end());
321*cdf0e10cSrcweir     for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
322*cdf0e10cSrcweir     {
323*cdf0e10cSrcweir         if ((*iPane)->mxContentWindow == rxContentWindow)
324*cdf0e10cSrcweir             return *iPane;
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir     return SharedPaneDescriptor();
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindPaneURL (
333*cdf0e10cSrcweir     const OUString& rsPaneURL)
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir     PaneList::const_iterator iPane;
336*cdf0e10cSrcweir     PaneList::const_iterator iEnd (maPanes.end());
337*cdf0e10cSrcweir     for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir         if ((*iPane)->mxPaneId->getResourceURL() == rsPaneURL)
340*cdf0e10cSrcweir             return *iPane;
341*cdf0e10cSrcweir     }
342*cdf0e10cSrcweir     return SharedPaneDescriptor();
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindPaneId (
349*cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId)
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir     PaneList::iterator iEnd (maPanes.end());
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     if ( ! rxPaneId.is())
354*cdf0e10cSrcweir         return SharedPaneDescriptor();
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     PaneList::iterator iPane;
357*cdf0e10cSrcweir     for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         if (rxPaneId->compareTo((*iPane)->mxPaneId) == 0)
360*cdf0e10cSrcweir             return *iPane;
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir     return SharedPaneDescriptor();
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindViewURL (
369*cdf0e10cSrcweir     const OUString& rsViewURL)
370*cdf0e10cSrcweir {
371*cdf0e10cSrcweir     PaneList::iterator iEnd (maPanes.end());
372*cdf0e10cSrcweir     PaneList::iterator iPane;
373*cdf0e10cSrcweir     for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         if (rsViewURL == (*iPane)->msViewURL)
376*cdf0e10cSrcweir             return *iPane;
377*cdf0e10cSrcweir     }
378*cdf0e10cSrcweir     return SharedPaneDescriptor();
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir ::rtl::OUString PresenterPaneContainer::GetPaneURLForViewURL (const ::rtl::OUString& rsViewURL)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor (FindViewURL(rsViewURL));
387*cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
388*cdf0e10cSrcweir         if (pDescriptor->mxPaneId.is())
389*cdf0e10cSrcweir             return pDescriptor->mxPaneId->getResourceURL();
390*cdf0e10cSrcweir     return OUString();
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir void PresenterPaneContainer::ToTop (const SharedPaneDescriptor& rpDescriptor)
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir     if (rpDescriptor.get() != NULL)
399*cdf0e10cSrcweir     {
400*cdf0e10cSrcweir         // Find iterator for pDescriptor.
401*cdf0e10cSrcweir         PaneList::iterator iPane;
402*cdf0e10cSrcweir         PaneList::iterator iEnd (maPanes.end());
403*cdf0e10cSrcweir         for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
404*cdf0e10cSrcweir             if (iPane->get() == rpDescriptor.get())
405*cdf0e10cSrcweir                 break;
406*cdf0e10cSrcweir         OSL_ASSERT(iPane!=iEnd);
407*cdf0e10cSrcweir         if (iPane == iEnd)
408*cdf0e10cSrcweir             return;
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         if (mxPresenterHelper.is())
411*cdf0e10cSrcweir             mxPresenterHelper->toTop(rpDescriptor->mxBorderWindow);
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir         maPanes.erase(iPane);
414*cdf0e10cSrcweir         maPanes.push_back(rpDescriptor);
415*cdf0e10cSrcweir     }
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir //----- XEventListener --------------------------------------------------------
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir void SAL_CALL PresenterPaneContainer::disposing (
424*cdf0e10cSrcweir     const com::sun::star::lang::EventObject& rEvent)
425*cdf0e10cSrcweir     throw (com::sun::star::uno::RuntimeException)
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir     SharedPaneDescriptor pDescriptor (
428*cdf0e10cSrcweir         FindContentWindow(Reference<awt::XWindow>(rEvent.Source, UNO_QUERY)));
429*cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         RemovePane(pDescriptor->mxPaneId);
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir //===== PresenterPaneContainer::PaneDescriptor ================================
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir void PresenterPaneContainer::PaneDescriptor::SetActivationState (const bool bIsActive)
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir     mbIsActive = bIsActive;
443*cdf0e10cSrcweir     if ( ! maActivator.empty())
444*cdf0e10cSrcweir         maActivator(mbIsActive);
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
448