16d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file
56d739b60SAndrew Rist * distributed with this work for additional information
66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file
76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the
86d739b60SAndrew Rist * "License"); you may not use this file except in compliance
96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing,
146d739b60SAndrew Rist * software distributed under the License is distributed on an
156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166d739b60SAndrew Rist * KIND, either express or implied. See the License for the
176d739b60SAndrew Rist * specific language governing permissions and limitations
186d739b60SAndrew Rist * under the License.
19cdf0e10cSrcweir *
206d739b60SAndrew Rist *************************************************************/
216d739b60SAndrew Rist
226d739b60SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir // my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir #include <helper/oframes.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #ifndef _FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_
33cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir
36cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37cdf0e10cSrcweir // interface includes
38cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
40cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
41cdf0e10cSrcweir
42cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43cdf0e10cSrcweir // includes of other projects
44cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir //_________________________________________________________________________________________________________________
48cdf0e10cSrcweir // namespace
49cdf0e10cSrcweir //_________________________________________________________________________________________________________________
50cdf0e10cSrcweir
51cdf0e10cSrcweir namespace framework{
52cdf0e10cSrcweir
53cdf0e10cSrcweir using namespace ::com::sun::star::container ;
54cdf0e10cSrcweir using namespace ::com::sun::star::frame ;
55cdf0e10cSrcweir using namespace ::com::sun::star::lang ;
56cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
57cdf0e10cSrcweir using namespace ::cppu ;
58cdf0e10cSrcweir using namespace ::osl ;
59cdf0e10cSrcweir using namespace ::rtl ;
60cdf0e10cSrcweir using namespace ::std ;
61cdf0e10cSrcweir using namespace ::vos ;
62cdf0e10cSrcweir
63cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64cdf0e10cSrcweir // non exported const
65cdf0e10cSrcweir //_________________________________________________________________________________________________________________
66cdf0e10cSrcweir
67cdf0e10cSrcweir //_________________________________________________________________________________________________________________
68cdf0e10cSrcweir // non exported definitions
69cdf0e10cSrcweir //_________________________________________________________________________________________________________________
70cdf0e10cSrcweir
71cdf0e10cSrcweir //_________________________________________________________________________________________________________________
72cdf0e10cSrcweir // declarations
73cdf0e10cSrcweir //_________________________________________________________________________________________________________________
74cdf0e10cSrcweir
75cdf0e10cSrcweir //*****************************************************************************************************************
76cdf0e10cSrcweir // constructor
77cdf0e10cSrcweir //*****************************************************************************************************************
OFrames(const css::uno::Reference<XMultiServiceFactory> & xFactory,const css::uno::Reference<XFrame> & xOwner,FrameContainer * pFrameContainer)78cdf0e10cSrcweir OFrames::OFrames( const css::uno::Reference< XMultiServiceFactory >& xFactory ,
79cdf0e10cSrcweir const css::uno::Reference< XFrame >& xOwner ,
80cdf0e10cSrcweir FrameContainer* pFrameContainer )
81cdf0e10cSrcweir // Init baseclasses first
82cdf0e10cSrcweir : ThreadHelpBase ( &Application::GetSolarMutex() )
83cdf0e10cSrcweir // Init member
84cdf0e10cSrcweir , m_xFactory ( xFactory )
85cdf0e10cSrcweir , m_xOwner ( xOwner )
86cdf0e10cSrcweir , m_pFrameContainer ( pFrameContainer )
87cdf0e10cSrcweir , m_bRecursiveSearchProtection( sal_False )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir // Safe impossible cases
90cdf0e10cSrcweir // Method is not defined for ALL incoming parameters!
91cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_OFramesCtor( xFactory, xOwner, pFrameContainer ), "OFrames::OFrames()\nInvalid parameter detected!\n" )
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir //*****************************************************************************************************************
95cdf0e10cSrcweir // (proteced!) destructor
96cdf0e10cSrcweir //*****************************************************************************************************************
~OFrames()97cdf0e10cSrcweir OFrames::~OFrames()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir // Reset instance, free memory ....
100cdf0e10cSrcweir impl_resetObject();
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir //*****************************************************************************************************************
104cdf0e10cSrcweir // XFrames
105cdf0e10cSrcweir //*****************************************************************************************************************
append(const css::uno::Reference<XFrame> & xFrame)106cdf0e10cSrcweir void SAL_CALL OFrames::append( const css::uno::Reference< XFrame >& xFrame ) throw( RuntimeException )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir // Ready for multithreading
109cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
110cdf0e10cSrcweir
111cdf0e10cSrcweir // Safe impossible cases
112cdf0e10cSrcweir // Method is not defined for ALL incoming parameters!
113cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_append( xFrame ), "OFrames::append()\nInvalid parameter detected!\n" )
114cdf0e10cSrcweir
115cdf0e10cSrcweir // Do the follow only, if owner instance valid!
116cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
117cdf0e10cSrcweir css::uno::Reference< XFramesSupplier > xOwner( m_xOwner.get(), UNO_QUERY );
118cdf0e10cSrcweir if ( xOwner.is() == sal_True )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir // Append frame to the end of the container ...
121cdf0e10cSrcweir m_pFrameContainer->append( xFrame );
122cdf0e10cSrcweir // Set owner of this instance as parent of the new frame in container!
123cdf0e10cSrcweir xFrame->setCreator( xOwner );
124cdf0e10cSrcweir }
125b12a77c9Smseidel // Else; Do nothing! Our owner is dead.
126b12a77c9Smseidel LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::append()\nOur owner is dead - you can't append any frames ...!\n" )
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir //*****************************************************************************************************************
130cdf0e10cSrcweir // XFrames
131cdf0e10cSrcweir //*****************************************************************************************************************
remove(const css::uno::Reference<XFrame> & xFrame)132cdf0e10cSrcweir void SAL_CALL OFrames::remove( const css::uno::Reference< XFrame >& xFrame ) throw( RuntimeException )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir // Ready for multithreading
135cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
136cdf0e10cSrcweir
137cdf0e10cSrcweir // Safe impossible cases
138cdf0e10cSrcweir // Method is not defined for ALL incoming parameters!
139cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_remove( xFrame ), "OFrames::remove()\nInvalid parameter detected!\n" )
140cdf0e10cSrcweir
141cdf0e10cSrcweir // Do the follow only, if owner instance valid!
142cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
143cdf0e10cSrcweir css::uno::Reference< XFramesSupplier > xOwner( m_xOwner.get(), UNO_QUERY );
144cdf0e10cSrcweir if ( xOwner.is() == sal_True )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir // Search frame and remove it from container ...
147cdf0e10cSrcweir m_pFrameContainer->remove( xFrame );
148cdf0e10cSrcweir // Don't reset owner-property of removed frame!
149cdf0e10cSrcweir // This must do the caller of this method himself.
150cdf0e10cSrcweir // See documentation of interface XFrames for further informations.
151cdf0e10cSrcweir }
152b12a77c9Smseidel // Else; Do nothing! Our owner is dead.
153b12a77c9Smseidel LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::remove()\nOur owner is dead - you can't remove any frames ...!\n" )
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //*****************************************************************************************************************
157cdf0e10cSrcweir // XFrames
158cdf0e10cSrcweir //*****************************************************************************************************************
queryFrames(sal_Int32 nSearchFlags)159cdf0e10cSrcweir Sequence< css::uno::Reference< XFrame > > SAL_CALL OFrames::queryFrames( sal_Int32 nSearchFlags ) throw( RuntimeException )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir // Ready for multithreading
162cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
163cdf0e10cSrcweir
164cdf0e10cSrcweir // Safe impossible cases
165cdf0e10cSrcweir // Method is not defined for ALL incoming parameters!
166cdf0e10cSrcweir LOG_ASSERT( impldbg_checkParameter_queryFrames( nSearchFlags ), "OFrames::queryFrames()\nInvalid parameter detected!\n" )
167cdf0e10cSrcweir
168cdf0e10cSrcweir // Set default return value. (empty sequence)
169cdf0e10cSrcweir Sequence< css::uno::Reference< XFrame > > seqFrames;
170cdf0e10cSrcweir
171cdf0e10cSrcweir // Do the follow only, if owner instance valid.
172cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
173cdf0e10cSrcweir css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
174cdf0e10cSrcweir if ( xOwner.is() == sal_True )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir // Work only, if search was not started here ...!
177cdf0e10cSrcweir if( m_bRecursiveSearchProtection == sal_False )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir // This class is a helper for services, which must implement XFrames.
180cdf0e10cSrcweir // His parent and childs are MY parent and childs to.
181cdf0e10cSrcweir // All searchflags are supported by this implementation!
182cdf0e10cSrcweir // If some flags should not be supported - don't call me with this flags!!!
183cdf0e10cSrcweir
184cdf0e10cSrcweir //_____________________________________________________________________________________________________________
185cdf0e10cSrcweir // Search with AUTO-flag is not supported yet!
186cdf0e10cSrcweir // We think about right implementation.
187cdf0e10cSrcweir LOG_ASSERT( !(nSearchFlags & FrameSearchFlag::AUTO), "OFrames::queryFrames()\nSearch with AUTO-flag is not supported yet!\nWe think about right implementation.\n" )
188cdf0e10cSrcweir // If searched for tasks ...
189cdf0e10cSrcweir // Its not supported yet.
190cdf0e10cSrcweir LOG_ASSERT( !(nSearchFlags & FrameSearchFlag::AUTO), "OFrames::queryFrames()\nSearch for tasks not supported yet!\n" )
191cdf0e10cSrcweir
192cdf0e10cSrcweir //_____________________________________________________________________________________________________________
193cdf0e10cSrcweir // Search for ALL and GLOBAL is superflous!
194cdf0e10cSrcweir // We support all necessary flags, from which these two flags are derived.
195cdf0e10cSrcweir // ALL = PARENT + SELF + CHILDREN + SIBLINGS
196cdf0e10cSrcweir // GLOBAL = ALL + TASKS
197cdf0e10cSrcweir
198cdf0e10cSrcweir //_____________________________________________________________________________________________________________
199cdf0e10cSrcweir // Add parent to list ... if any exist!
200cdf0e10cSrcweir if( nSearchFlags & FrameSearchFlag::PARENT )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir css::uno::Reference< XFrame > xParent( xOwner->getCreator(), UNO_QUERY );
203cdf0e10cSrcweir if( xParent.is() == sal_True )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir Sequence< css::uno::Reference< XFrame > > seqParent( 1 );
206cdf0e10cSrcweir seqParent[0] = xParent;
207cdf0e10cSrcweir impl_appendSequence( seqFrames, seqParent );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir //_____________________________________________________________________________________________________________
212cdf0e10cSrcweir // Add owner to list if SELF is searched.
213cdf0e10cSrcweir if( nSearchFlags & FrameSearchFlag::SELF )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir Sequence< css::uno::Reference< XFrame > > seqSelf( 1 );
216cdf0e10cSrcweir seqSelf[0] = xOwner;
217cdf0e10cSrcweir impl_appendSequence( seqFrames, seqSelf );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir //_____________________________________________________________________________________________________________
221cdf0e10cSrcweir // Add SIBLINGS to list.
222cdf0e10cSrcweir if( nSearchFlags & FrameSearchFlag::SIBLINGS )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir // Else; start a new search.
225cdf0e10cSrcweir // Protect this instance against recursive calls from parents.
226cdf0e10cSrcweir m_bRecursiveSearchProtection = sal_True;
227cdf0e10cSrcweir // Ask parent of my owner for frames and append results to return list.
228cdf0e10cSrcweir css::uno::Reference< XFramesSupplier > xParent( xOwner->getCreator(), UNO_QUERY );
229cdf0e10cSrcweir // If a parent exist ...
230cdf0e10cSrcweir if ( xParent.is() == sal_True )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir // ... ask him for right frames.
233cdf0e10cSrcweir impl_appendSequence( seqFrames, xParent->getFrames()->queryFrames( nSearchFlags ) );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir // We have all searched informations.
236cdf0e10cSrcweir // Reset protection-mode.
237cdf0e10cSrcweir m_bRecursiveSearchProtection = sal_False;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir //_____________________________________________________________________________________________________________
241cdf0e10cSrcweir // If searched for children, step over all elements in container and collect the informations.
242cdf0e10cSrcweir if ( nSearchFlags & FrameSearchFlag::CHILDREN )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir // Don't search for parents, siblings and self at childrens!
245cdf0e10cSrcweir // These things are supported by this instance himself.
246cdf0e10cSrcweir sal_Int32 nChildSearchFlags = FrameSearchFlag::SELF | FrameSearchFlag::CHILDREN;
247cdf0e10cSrcweir // Step over all items of container and ask childrens for frames.
248cdf0e10cSrcweir sal_uInt32 nCount = m_pFrameContainer->getCount();
249cdf0e10cSrcweir for ( sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir // We don't must control this conversion.
252cdf0e10cSrcweir // We have done this at append()!
253cdf0e10cSrcweir css::uno::Reference< XFramesSupplier > xItem( (*m_pFrameContainer)[nIndex], UNO_QUERY );
254cdf0e10cSrcweir impl_appendSequence( seqFrames, xItem->getFrames()->queryFrames( nChildSearchFlags ) );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir }
259b12a77c9Smseidel // Else; Do nothing! Our owner is dead.
260b12a77c9Smseidel LOG_ASSERT( !(xOwner.is()==sal_False), "OFrames::queryFrames()\nOur owner is dead - you can't query for frames ...!\n" )
261cdf0e10cSrcweir
262de337080SJohn Bampton // Return result of this operation.
263cdf0e10cSrcweir return seqFrames;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir //*****************************************************************************************************************
267cdf0e10cSrcweir // XIndexAccess
268cdf0e10cSrcweir //*****************************************************************************************************************
getCount()269cdf0e10cSrcweir sal_Int32 SAL_CALL OFrames::getCount() throw( RuntimeException )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir // Ready for multithreading
272cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
273cdf0e10cSrcweir
274cdf0e10cSrcweir // Set default return value.
275cdf0e10cSrcweir sal_Int32 nCount = 0;
276cdf0e10cSrcweir
277cdf0e10cSrcweir // Do the follow only, if owner instance valid.
278cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
279cdf0e10cSrcweir css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
280cdf0e10cSrcweir if ( xOwner.is() == sal_True )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir // Set CURRENT size of container for return.
283cdf0e10cSrcweir nCount = m_pFrameContainer->getCount();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir // Return result.
287cdf0e10cSrcweir return nCount;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir //*****************************************************************************************************************
291cdf0e10cSrcweir // XIndexAccess
292cdf0e10cSrcweir //*****************************************************************************************************************
getByIndex(sal_Int32 nIndex)293cdf0e10cSrcweir Any SAL_CALL OFrames::getByIndex( sal_Int32 nIndex ) throw( IndexOutOfBoundsException ,
294cdf0e10cSrcweir WrappedTargetException ,
295cdf0e10cSrcweir RuntimeException )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir // Ready for multithreading
298cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
299cdf0e10cSrcweir
300cdf0e10cSrcweir sal_uInt32 nCount = m_pFrameContainer->getCount();
301cdf0e10cSrcweir if ( nIndex < 0 || ( sal::static_int_cast< sal_uInt32 >( nIndex ) >= nCount ))
302cdf0e10cSrcweir throw IndexOutOfBoundsException( OUString::createFromAscii( "OFrames::getByIndex - Index out of bounds" ),
303cdf0e10cSrcweir (OWeakObject *)this );
304cdf0e10cSrcweir
305cdf0e10cSrcweir // Set default return value.
306cdf0e10cSrcweir Any aReturnValue;
307cdf0e10cSrcweir
308cdf0e10cSrcweir // Do the follow only, if owner instance valid.
309cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
310cdf0e10cSrcweir css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
311cdf0e10cSrcweir if ( xOwner.is() == sal_True )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir // Get element form container.
314cdf0e10cSrcweir // (If index not valid, FrameContainer return NULL!)
315cdf0e10cSrcweir aReturnValue <<= (*m_pFrameContainer)[nIndex];
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir // Return result of this operation.
319cdf0e10cSrcweir return aReturnValue;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir //*****************************************************************************************************************
323cdf0e10cSrcweir // XElementAccess
324cdf0e10cSrcweir //*****************************************************************************************************************
getElementType()325cdf0e10cSrcweir Type SAL_CALL OFrames::getElementType() throw( RuntimeException )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir // This "container" support XFrame-interfaces only!
328cdf0e10cSrcweir return ::getCppuType( (const css::uno::Reference< XFrame >*)NULL );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir
331cdf0e10cSrcweir //*****************************************************************************************************************
332cdf0e10cSrcweir // XElementAccess
333cdf0e10cSrcweir //*****************************************************************************************************************
hasElements()334cdf0e10cSrcweir sal_Bool SAL_CALL OFrames::hasElements() throw( RuntimeException )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir // Ready for multithreading
337cdf0e10cSrcweir ResetableGuard aGuard( m_aLock );
338cdf0e10cSrcweir
339cdf0e10cSrcweir // Set default return value.
340cdf0e10cSrcweir sal_Bool bHasElements = sal_False;
341cdf0e10cSrcweir // Do the follow only, if owner instance valid.
342cdf0e10cSrcweir // Lock owner for follow operations - make a "hard reference"!
343cdf0e10cSrcweir css::uno::Reference< XFrame > xOwner( m_xOwner.get(), UNO_QUERY );
344cdf0e10cSrcweir if ( xOwner.is() == sal_True )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir // If some elements exist ...
347cdf0e10cSrcweir if ( m_pFrameContainer->getCount() > 0 )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir // ... change this state value!
350cdf0e10cSrcweir bHasElements = sal_True;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir }
353cdf0e10cSrcweir // Return result of this operation.
354cdf0e10cSrcweir return bHasElements;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
357cdf0e10cSrcweir //*****************************************************************************************************************
358cdf0e10cSrcweir // proteced method
359cdf0e10cSrcweir //*****************************************************************************************************************
impl_resetObject()360cdf0e10cSrcweir void OFrames::impl_resetObject()
361cdf0e10cSrcweir {
362cdf0e10cSrcweir // Attention:
363cdf0e10cSrcweir // Write this for multiple calls - NOT AT THE SAME TIME - but for more then one call again)!
364cdf0e10cSrcweir // It exist two ways to call this method. From destructor and from disposing().
3652e3a1b6eSmseidel // I can't say, which one is the first. Normally the disposing-call - but other way ....
366cdf0e10cSrcweir
367cdf0e10cSrcweir // This instance can't work if the weakreference to owner is invalid!
368cdf0e10cSrcweir // Destroy this to reset this object.
369cdf0e10cSrcweir m_xOwner = WeakReference< XFrame >();
370cdf0e10cSrcweir // Reset pointer to shared container to!
371cdf0e10cSrcweir m_pFrameContainer = NULL;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
374cdf0e10cSrcweir //*****************************************************************************************************************
375cdf0e10cSrcweir // private method
376cdf0e10cSrcweir //*****************************************************************************************************************
impl_appendSequence(Sequence<css::uno::Reference<XFrame>> & seqDestination,const Sequence<css::uno::Reference<XFrame>> & seqSource)377cdf0e10cSrcweir void OFrames::impl_appendSequence( Sequence< css::uno::Reference< XFrame > >& seqDestination ,
378cdf0e10cSrcweir const Sequence< css::uno::Reference< XFrame > >& seqSource )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir // Get some informations about the sequences.
381cdf0e10cSrcweir sal_Int32 nSourceCount = seqSource.getLength();
382cdf0e10cSrcweir sal_Int32 nDestinationCount = seqDestination.getLength();
383cdf0e10cSrcweir const css::uno::Reference< XFrame >* pSourceAccess = seqSource.getConstArray();
384cdf0e10cSrcweir css::uno::Reference< XFrame >* pDestinationAccess = seqDestination.getArray();
385cdf0e10cSrcweir
386cdf0e10cSrcweir // Get memory for result list.
387cdf0e10cSrcweir Sequence< css::uno::Reference< XFrame > > seqResult ( nSourceCount + nDestinationCount );
388cdf0e10cSrcweir css::uno::Reference< XFrame >* pResultAccess = seqResult.getArray();
389cdf0e10cSrcweir sal_Int32 nResultPosition = 0;
390cdf0e10cSrcweir
391cdf0e10cSrcweir // Copy all items from first sequence.
392cdf0e10cSrcweir for ( sal_Int32 nSourcePosition=0; nSourcePosition<nSourceCount; ++nSourcePosition )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir pResultAccess[nResultPosition] = pSourceAccess[nSourcePosition];
395cdf0e10cSrcweir ++nResultPosition;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir // Don't manipulate nResultPosition between these two loops!
399cdf0e10cSrcweir // Its the current position in the result list.
400cdf0e10cSrcweir
401cdf0e10cSrcweir // Copy all items from second sequence.
402cdf0e10cSrcweir for ( sal_Int32 nDestinationPosition=0; nDestinationPosition<nDestinationCount; ++nDestinationPosition )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir pResultAccess[nResultPosition] = pDestinationAccess[nDestinationPosition];
405cdf0e10cSrcweir ++nResultPosition;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
408cdf0e10cSrcweir // Return result of this operation.
409cdf0e10cSrcweir seqDestination.realloc( 0 );
410cdf0e10cSrcweir seqDestination = seqResult;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir //_________________________________________________________________________________________________________________
414cdf0e10cSrcweir // debug methods
415cdf0e10cSrcweir //_________________________________________________________________________________________________________________
416cdf0e10cSrcweir
417cdf0e10cSrcweir /*-----------------------------------------------------------------------------------------------------------------
418cdf0e10cSrcweir The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
419cdf0e10cSrcweir we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
420cdf0e10cSrcweir
421cdf0e10cSrcweir ATTENTION
422cdf0e10cSrcweir
42307a3d7f1SPedro Giffuni If you miss a test for one of this parameters, contact the author or add it himself !(?)
424cdf0e10cSrcweir But ... look for right testing! See using of this methods!
425cdf0e10cSrcweir -----------------------------------------------------------------------------------------------------------------*/
426cdf0e10cSrcweir
427cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS
428cdf0e10cSrcweir
429cdf0e10cSrcweir //*****************************************************************************************************************
430cdf0e10cSrcweir // An instance of this class can only work with valid initialization.
431*5e7dbebbSJohn Bampton // We share the mutex with our owner class, need a valid factory to instantiate new services and
432b12a77c9Smseidel // use the access to our owner for some operations.
impldbg_checkParameter_OFramesCtor(const css::uno::Reference<XMultiServiceFactory> & xFactory,const css::uno::Reference<XFrame> & xOwner,FrameContainer * pFrameContainer)433cdf0e10cSrcweir sal_Bool OFrames::impldbg_checkParameter_OFramesCtor( const css::uno::Reference< XMultiServiceFactory >& xFactory ,
434cdf0e10cSrcweir const css::uno::Reference< XFrame >& xOwner ,
435cdf0e10cSrcweir FrameContainer* pFrameContainer )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir // Set default return value.
438cdf0e10cSrcweir sal_Bool bOK = sal_True;
439cdf0e10cSrcweir // Check parameter.
440cdf0e10cSrcweir if (
441cdf0e10cSrcweir ( &xFactory == NULL ) ||
442cdf0e10cSrcweir ( &xOwner == NULL ) ||
443cdf0e10cSrcweir ( xFactory.is() == sal_False ) ||
444cdf0e10cSrcweir ( xOwner.is() == sal_False ) ||
445cdf0e10cSrcweir ( pFrameContainer == NULL )
446cdf0e10cSrcweir )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir bOK = sal_False ;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir // Return result of check.
451cdf0e10cSrcweir return bOK ;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir
454cdf0e10cSrcweir //*****************************************************************************************************************
455cdf0e10cSrcweir // Its only allowed to add valid references to container.
456cdf0e10cSrcweir // AND - alle frames must support XFrames-interface!
impldbg_checkParameter_append(const css::uno::Reference<XFrame> & xFrame)457cdf0e10cSrcweir sal_Bool OFrames::impldbg_checkParameter_append( const css::uno::Reference< XFrame >& xFrame )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir // Set default return value.
460cdf0e10cSrcweir sal_Bool bOK = sal_True;
461cdf0e10cSrcweir // Check parameter.
462cdf0e10cSrcweir if (
463cdf0e10cSrcweir ( &xFrame == NULL ) ||
464cdf0e10cSrcweir ( xFrame.is() == sal_False )
465cdf0e10cSrcweir )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir bOK = sal_False ;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir // Return result of check.
470cdf0e10cSrcweir return bOK ;
471cdf0e10cSrcweir }
472cdf0e10cSrcweir
473cdf0e10cSrcweir //*****************************************************************************************************************
474cdf0e10cSrcweir // Its only allowed to add valid references to container...
475cdf0e10cSrcweir // ... => You can only delete valid references!
impldbg_checkParameter_remove(const css::uno::Reference<XFrame> & xFrame)476cdf0e10cSrcweir sal_Bool OFrames::impldbg_checkParameter_remove( const css::uno::Reference< XFrame >& xFrame )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir // Set default return value.
479cdf0e10cSrcweir sal_Bool bOK = sal_True;
480cdf0e10cSrcweir // Check parameter.
481cdf0e10cSrcweir if (
482cdf0e10cSrcweir ( &xFrame == NULL ) ||
483cdf0e10cSrcweir ( xFrame.is() == sal_False )
484cdf0e10cSrcweir )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir bOK = sal_False ;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir // Return result of check.
489cdf0e10cSrcweir return bOK ;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
492cdf0e10cSrcweir //*****************************************************************************************************************
493cdf0e10cSrcweir // A search for frames must initiate with right flags.
494cdf0e10cSrcweir // Some one are superflous and not supported yet. But here we control only the range of incoming parameter!
impldbg_checkParameter_queryFrames(sal_Int32 nSearchFlags)495cdf0e10cSrcweir sal_Bool OFrames::impldbg_checkParameter_queryFrames( sal_Int32 nSearchFlags )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir // Set default return value.
498cdf0e10cSrcweir sal_Bool bOK = sal_True;
499cdf0e10cSrcweir // Check parameter.
500cdf0e10cSrcweir if (
501cdf0e10cSrcweir ( nSearchFlags != FrameSearchFlag::AUTO ) &&
502cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::PARENT ) ) &&
503cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::SELF ) ) &&
504cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::CHILDREN ) ) &&
505cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::CREATE ) ) &&
506cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::SIBLINGS ) ) &&
507cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::TASKS ) ) &&
508cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::ALL ) ) &&
509cdf0e10cSrcweir ( !( nSearchFlags & FrameSearchFlag::GLOBAL ) )
510cdf0e10cSrcweir )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir bOK = sal_False ;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir // Return result of check.
515cdf0e10cSrcweir return bOK ;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir
518cdf0e10cSrcweir #endif // #ifdef ENABLE_ASSERTIONS
519cdf0e10cSrcweir
520cdf0e10cSrcweir } // namespace framework
521