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_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef __FRAMEWORK_FRAMECONTAINER_HXX_
36*cdf0e10cSrcweir #include <classes/framecontainer.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
39*cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #ifndef __FRAMEWORK_COMMANDS_HXX_
42*cdf0e10cSrcweir #include <commands.h>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46*cdf0e10cSrcweir //	interface includes
47*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCH_FLAG_HPP_
50*cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54*cdf0e10cSrcweir //	includes of other projects
55*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56*cdf0e10cSrcweir #include <vcl/svapp.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59*cdf0e10cSrcweir //	namespace
60*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir namespace framework{
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65*cdf0e10cSrcweir //	non exported const
66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69*cdf0e10cSrcweir //	non exported definitions
70*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
73*cdf0e10cSrcweir //	declarations
74*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir /**-***************************************************************************************************************
77*cdf0e10cSrcweir     @short      initialize an empty container
78*cdf0e10cSrcweir     @descr      The container will be empty then - special features (e.g. the async quit mechanism) are disabled.
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     @threadsafe not neccessary - its not a singleton
81*cdf0e10cSrcweir     @modified   01.07.2002 14:42,as96863
82*cdf0e10cSrcweir  *****************************************************************************************************************/
83*cdf0e10cSrcweir FrameContainer::FrameContainer()
84*cdf0e10cSrcweir         // initialize base classes first.
85*cdf0e10cSrcweir         // Order is neccessary for right initilization of his and OUR member ... m_aLock
86*cdf0e10cSrcweir         : ThreadHelpBase ( &Application::GetSolarMutex()                  )
87*cdf0e10cSrcweir /*DEPRECATEME
88*cdf0e10cSrcweir         , m_bAsyncQuit   ( sal_False                                      ) // default must be "disabled"!
89*cdf0e10cSrcweir         , m_aAsyncCall   ( LINK( this, FrameContainer, implts_asyncQuit ) )
90*cdf0e10cSrcweir */
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir /**-***************************************************************************************************************
95*cdf0e10cSrcweir     @short      deinitialize may a filled container
96*cdf0e10cSrcweir     @descr      Special features (if the currently are running) will be dsiabled and we free all used other ressources.
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     @threadsafe not neccessary - its not a singleton
99*cdf0e10cSrcweir     @modified   01.07.2002 14:43,as96863
100*cdf0e10cSrcweir  *****************************************************************************************************************/
101*cdf0e10cSrcweir FrameContainer::~FrameContainer()
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	// Don't forget to free memory!
104*cdf0e10cSrcweir     m_aContainer.clear();
105*cdf0e10cSrcweir     m_xActiveFrame.clear();
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir /**-***************************************************************************************************************
109*cdf0e10cSrcweir     @short      append a new frame to the container
110*cdf0e10cSrcweir     @descr      We accept the incoming frame only, if it is a valid reference and dosnt exist already.
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     @param      xFrame
113*cdf0e10cSrcweir                     frame, which should be added to this container
114*cdf0e10cSrcweir                     Must be a valid reference.
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     @threadsafe yes
117*cdf0e10cSrcweir     @modified   01.07.2002 14:44,as96863
118*cdf0e10cSrcweir  *****************************************************************************************************************/
119*cdf0e10cSrcweir void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xFrame )
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     if (xFrame.is() && ! exist(xFrame))
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         /* SAFE { */
124*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
125*cdf0e10cSrcweir         m_aContainer.push_back( xFrame );
126*cdf0e10cSrcweir         aWriteLock.unlock();
127*cdf0e10cSrcweir         /* } SAFE */
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir /**-***************************************************************************************************************
132*cdf0e10cSrcweir     @short      remove a frame from the container
133*cdf0e10cSrcweir     @descr      In case we remove the last frame and our internal special feature (the async quit mechanism)
134*cdf0e10cSrcweir                 was enabled by the desktop instance, we start it.
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     @param      xFrame
137*cdf0e10cSrcweir                     frame, which should be deleted from this container
138*cdf0e10cSrcweir                     Must be a valid reference.
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     @threadsafe yes
141*cdf0e10cSrcweir     @modified   01.07.2002 14:52,as96863
142*cdf0e10cSrcweir  *****************************************************************************************************************/
143*cdf0e10cSrcweir void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xFrame )
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir     /* SAFE { */
146*cdf0e10cSrcweir     // write lock neccessary for follwing erase()!
147*cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     TFrameIterator aSearchedItem = ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame );
150*cdf0e10cSrcweir     if (aSearchedItem!=m_aContainer.end())
151*cdf0e10cSrcweir     {
152*cdf0e10cSrcweir         m_aContainer.erase( aSearchedItem );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         // If removed frame was the current active frame - reset state variable.
155*cdf0e10cSrcweir         if (m_xActiveFrame==xFrame)
156*cdf0e10cSrcweir             m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         // We don't need the write lock any longer ...
159*cdf0e10cSrcweir         // downgrade to read access.
160*cdf0e10cSrcweir         aWriteLock.downgrade();
161*cdf0e10cSrcweir /*DEPRECATEME
162*cdf0e10cSrcweir         // If last frame was removed and special quit mode is enabled by the desktop
163*cdf0e10cSrcweir         // we must terminate the application by using this asynchronous callback!
164*cdf0e10cSrcweir         if (m_aContainer.size()<1 && m_bAsyncQuit)
165*cdf0e10cSrcweir             m_aAsyncCall.Post(0);
166*cdf0e10cSrcweir */
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     aWriteLock.unlock();
170*cdf0e10cSrcweir     // } SAFE
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir /**-***************************************************************************************************************
174*cdf0e10cSrcweir     @short      check if the given frame currently exist inside the container
175*cdf0e10cSrcweir     @descr      -
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     @param      xFrame
178*cdf0e10cSrcweir                     reference to the queried frame
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     @return     <TRUE/> if frame is oart of this container
181*cdf0e10cSrcweir                 <FALSE/> otherwhise
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     @threadsafe yes
184*cdf0e10cSrcweir     @modified   01.07.2002 14:55,as96863
185*cdf0e10cSrcweir  *****************************************************************************************************************/
186*cdf0e10cSrcweir sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir     /* SAFE { */
189*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
190*cdf0e10cSrcweir     return( ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame ) != m_aContainer.end() );
191*cdf0e10cSrcweir     /* } SAFE */
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir /**-***************************************************************************************************************
195*cdf0e10cSrcweir     @short      delete all existing items of the container
196*cdf0e10cSrcweir     @descr      -
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     @threadsafe yes
199*cdf0e10cSrcweir     @modified   01.07.2002 15:00,as96863
200*cdf0e10cSrcweir  *****************************************************************************************************************/
201*cdf0e10cSrcweir void FrameContainer::clear()
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir     // SAFE {
204*cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	// Clear the container ...
207*cdf0e10cSrcweir     m_aContainer.clear();
208*cdf0e10cSrcweir 	// ... and don't forget to reset the active frame.
209*cdf0e10cSrcweir 	// Its an reference to a valid container-item.
210*cdf0e10cSrcweir 	// But no container item => no active frame!
211*cdf0e10cSrcweir     m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
212*cdf0e10cSrcweir /*DEPRECATEME
213*cdf0e10cSrcweir     // If special quit mode is used - we must terminate the desktop.
214*cdf0e10cSrcweir 	// He is the owner of this container and can't work without any visible tasks/frames!
215*cdf0e10cSrcweir     if (m_bAsyncQuit)
216*cdf0e10cSrcweir         m_aAsyncCall.Post(0);
217*cdf0e10cSrcweir */
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir     aWriteLock.unlock();
220*cdf0e10cSrcweir     // } SAFE
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir /**-***************************************************************************************************************
224*cdf0e10cSrcweir     @short      returns count of all current existing frames
225*cdf0e10cSrcweir     @descr      -
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     @deprecated This value can't be guaranteed for multithreading environments.
228*cdf0e10cSrcweir                 So it will be marked as deprecated and should be replaced by "getAllElements()".
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     @return     the count of existing container items
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     @threadsafe yes
233*cdf0e10cSrcweir     @modified   01.07.2002 15:00,as96863
234*cdf0e10cSrcweir  *****************************************************************************************************************/
235*cdf0e10cSrcweir sal_uInt32 FrameContainer::getCount() const
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     /* SAFE { */
238*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
239*cdf0e10cSrcweir     return( (sal_uInt32)m_aContainer.size() );
240*cdf0e10cSrcweir     /* } SAFE */
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir /**-***************************************************************************************************************
244*cdf0e10cSrcweir     @short      returns one item of this container
245*cdf0e10cSrcweir     @descr      -
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     @deprecated This value can't be guaranteed for multithreading environments.
248*cdf0e10cSrcweir                 So it will be marked as deprecated and should be replaced by "getAllElements()".
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     @param      nIndex
251*cdf0e10cSrcweir                     a valud between 0 and (getCount()-1) to adress one container item
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     @return     a reference to a frame inside the container, which match with given index
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     @threadsafe yes
256*cdf0e10cSrcweir     @modified   01.07.2002 15:03,as96863
257*cdf0e10cSrcweir  *****************************************************************************************************************/
258*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32 nIndex ) const
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xFrame;
262*cdf0e10cSrcweir     try
263*cdf0e10cSrcweir     {
264*cdf0e10cSrcweir         // Get element form container WITH automatic test of ranges!
265*cdf0e10cSrcweir         // If index not valid, a out_of_range exception is thrown.
266*cdf0e10cSrcweir         /* SAFE { */
267*cdf0e10cSrcweir         ReadGuard aReadLock( m_aLock );
268*cdf0e10cSrcweir         xFrame = m_aContainer.at( nIndex );
269*cdf0e10cSrcweir         aReadLock.unlock();
270*cdf0e10cSrcweir         /* } SAFE */
271*cdf0e10cSrcweir     }
272*cdf0e10cSrcweir     catch( std::out_of_range& )
273*cdf0e10cSrcweir     {
274*cdf0e10cSrcweir         // The index is not valid for current container-content - we must handle this case!
275*cdf0e10cSrcweir         // We can return the default value ...
276*cdf0e10cSrcweir         LOG_EXCEPTION( "FrameContainer::operator[]", "Exception catched ...", DECLARE_ASCII("::std::out_of_range") )
277*cdf0e10cSrcweir     }
278*cdf0e10cSrcweir 	return xFrame;
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir /**-***************************************************************************************************************
282*cdf0e10cSrcweir     @short      returns a snapshot of all currently existing frames inside this container
283*cdf0e10cSrcweir     @descr      Should be used to replace the deprecated functions getCount()/operator[]!
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir     @return     a list of all frame refrences inside this container
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     @threadsafe yes
288*cdf0e10cSrcweir     @modified   01.07.2002 15:09,as96863
289*cdf0e10cSrcweir  *****************************************************************************************************************/
290*cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > FrameContainer::getAllElements() const
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     /* SAFE { */
293*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     sal_Int32                                                       nPosition = 0;
296*cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lElements ( (sal_uInt32)m_aContainer.size() );
297*cdf0e10cSrcweir     for (TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem)
298*cdf0e10cSrcweir         lElements[nPosition++] = *pItem;
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir     aReadLock.unlock();
301*cdf0e10cSrcweir     /* } SAFE */
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	return lElements;
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir /**-***************************************************************************************************************
307*cdf0e10cSrcweir     @short      set the given frame as  the new active one inside this container
308*cdf0e10cSrcweir     @descr      We accept this frame only, if it's already a part of this container.
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir     @param      xFrame
311*cdf0e10cSrcweir                     reference to the new active frame
312*cdf0e10cSrcweir                     Must be a valid reference and already part of this container.
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     @threadsafe yes
315*cdf0e10cSrcweir     @modified   01.07.2002 15:11,as96863
316*cdf0e10cSrcweir  *****************************************************************************************************************/
317*cdf0e10cSrcweir void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >& xFrame )
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     if ( !xFrame.is() || exist(xFrame) )
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir         /* SAFE { */
322*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
323*cdf0e10cSrcweir         m_xActiveFrame = xFrame;
324*cdf0e10cSrcweir         aWriteLock.unlock();
325*cdf0e10cSrcweir         /* } SAFE */
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir /**-***************************************************************************************************************
330*cdf0e10cSrcweir     @short      return sthe current active frame of this container
331*cdf0e10cSrcweir     @descr      Value can be null in case the frame was removed from the container and nobody
332*cdf0e10cSrcweir                 from outside decide which of all others should be the new one ...
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     @return     a reference to the current active frame
335*cdf0e10cSrcweir                 Value can be NULL!
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     @threadsafe yes
338*cdf0e10cSrcweir     @modified   01.07.2002 15:11,as96863
339*cdf0e10cSrcweir  *****************************************************************************************************************/
340*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir     /* SAFE { */
343*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
344*cdf0e10cSrcweir     return m_xActiveFrame;
345*cdf0e10cSrcweir     /* } SAFE */
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir /**-***************************************************************************************************************
349*cdf0e10cSrcweir     @short      implements a simple search based on current container items
350*cdf0e10cSrcweir     @descr      It can be used for findFrame() and implements a deep down search.
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     @param      sName
353*cdf0e10cSrcweir                     target name, which is searched
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     @return     reference to the found frame or NULL if not.
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     @threadsafe yes
358*cdf0e10cSrcweir     @modified   01.07.2002 15:22,as96863
359*cdf0e10cSrcweir  *****************************************************************************************************************/
360*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( const ::rtl::OUString& sName ) const
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir     /* SAFE { */
363*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     // Step over all child frames. But if direct child isn't the right one search on his children first - before
366*cdf0e10cSrcweir     // you go to next direct child of this container!
367*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xSearchedFrame;
368*cdf0e10cSrcweir     for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
369*cdf0e10cSrcweir     {
370*cdf0e10cSrcweir         if ((*pIterator)->getName()==sName)
371*cdf0e10cSrcweir         {
372*cdf0e10cSrcweir             xSearchedFrame = *pIterator;
373*cdf0e10cSrcweir             break;
374*cdf0e10cSrcweir         }
375*cdf0e10cSrcweir         else
376*cdf0e10cSrcweir         {
377*cdf0e10cSrcweir             xSearchedFrame = (*pIterator)->findFrame( sName, css::frame::FrameSearchFlag::CHILDREN );
378*cdf0e10cSrcweir             if (xSearchedFrame.is())
379*cdf0e10cSrcweir                 break;
380*cdf0e10cSrcweir         }
381*cdf0e10cSrcweir     }
382*cdf0e10cSrcweir     aReadLock.unlock();
383*cdf0e10cSrcweir     /* } SAFE */
384*cdf0e10cSrcweir 	return xSearchedFrame;
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir /**-***************************************************************************************************************
388*cdf0e10cSrcweir     @short      implements a simple search based on current container items
389*cdf0e10cSrcweir     @descr      It can be used for findFrame() and search on members of this container only!
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     @param      sName
392*cdf0e10cSrcweir                     target name, which is searched
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir     @return     reference to the found frame or NULL if not.
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     @threadsafe yes
397*cdf0e10cSrcweir     @modified   01.07.2002 15:22,as96863
398*cdf0e10cSrcweir  *****************************************************************************************************************/
399*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildrens( const ::rtl::OUString& sName ) const
400*cdf0e10cSrcweir {
401*cdf0e10cSrcweir     /* SAFE { */
402*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xSearchedFrame;
405*cdf0e10cSrcweir     for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         if ((*pIterator)->getName()==sName)
408*cdf0e10cSrcweir         {
409*cdf0e10cSrcweir             xSearchedFrame = *pIterator;
410*cdf0e10cSrcweir             break;
411*cdf0e10cSrcweir         }
412*cdf0e10cSrcweir     }
413*cdf0e10cSrcweir     aReadLock.unlock();
414*cdf0e10cSrcweir     /* } SAFE */
415*cdf0e10cSrcweir 	return xSearchedFrame;
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir } //  namespace framework
419