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