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 #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_ 29*cdf0e10cSrcweir #define __FRAMEWORK_HELPER_OFRAMES_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32*cdf0e10cSrcweir // my own includes 33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <classes/framecontainer.hxx> 36*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 37*cdf0e10cSrcweir #include <macros/generic.hxx> 38*cdf0e10cSrcweir #include <macros/xinterface.hxx> 39*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 40*cdf0e10cSrcweir #include <macros/debug.hxx> 41*cdf0e10cSrcweir #include <general.h> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 44*cdf0e10cSrcweir // interface includes 45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 46*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/frame/XFrames.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 51*cdf0e10cSrcweir // other includes 52*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 53*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 54*cdf0e10cSrcweir #include <cppuhelper/weakref.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 57*cdf0e10cSrcweir // namespace 58*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir namespace framework{ 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 63*cdf0e10cSrcweir // exported const 64*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 67*cdf0e10cSrcweir // exported definitions 68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir /*-************************************************************************************************************//** 71*cdf0e10cSrcweir @short implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services 72*cdf0e10cSrcweir @descr Use this class as helper for these interfaces. We share mutex and framecontainer with ouer owner. 73*cdf0e10cSrcweir The framecontainer is a member of it from type "FrameContainer". That means; 74*cdf0e10cSrcweir we have the same information as ouer owner. In current implementation we use mutex and lock-mechanism 75*cdf0e10cSrcweir to prevent against compete access. In future we plan support of semaphore! 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir @devstatus deprecated 78*cdf0e10cSrcweir @implements XInterface 79*cdf0e10cSrcweir XFrames 80*cdf0e10cSrcweir XIndexAccess 81*cdf0e10cSrcweir XElementAccess 82*cdf0e10cSrcweir @base OWeakObject 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir @ATTENTION Don't use this class as direct member - use it dynamicly. Do not derive from this class. 85*cdf0e10cSrcweir We hold a weakreference to ouer owner not to ouer superclass. 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir @devstatus deprecated 88*cdf0e10cSrcweir *//*-*************************************************************************************************************/ 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir class OFrames : private ThreadHelpBase , // Must be the first of baseclasses - Is neccessary for right initialization of objects! 91*cdf0e10cSrcweir public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrames > 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 94*cdf0e10cSrcweir // public methods 95*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir public: 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 100*cdf0e10cSrcweir // constructor / destructor 101*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir /*-****************************************************************************************************//** 104*cdf0e10cSrcweir @short standard ctor 105*cdf0e10cSrcweir @descr These initialize a new instance of this class with all needed informations for work. 106*cdf0e10cSrcweir We share framecontainer with owner implementation! It's a threadsafe container. 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir @seealso - 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir @param "xFactory" , reference to factory which has created ouer owner(!). We can use these to create new uno-services. 111*cdf0e10cSrcweir @param "xOwner" , reference to ouer owner. We hold a wekreference to prevent us against cross-references! 112*cdf0e10cSrcweir @param "pFrameContainer" , pointer to shared framecontainer of owner. It's valid only, if weakreference is valid! 113*cdf0e10cSrcweir @return - 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir @onerror - 116*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir OFrames( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 119*cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xOwner , 120*cdf0e10cSrcweir FrameContainer* pFrameContainer ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 123*cdf0e10cSrcweir // XFrames 124*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir /*-****************************************************************************************************//** 127*cdf0e10cSrcweir @short append frame to container 128*cdf0e10cSrcweir @descr We share the container with ouer owner. We can do this only, if no lock is set on container. 129*cdf0e10cSrcweir Valid references are accepted only! 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir @seealso class FrameContainer 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir @param "xFrame", reference to an existing frame to append. 134*cdf0e10cSrcweir @return - 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir @onerror We do nothing in release or throw an assert in debug version. 137*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir /*-****************************************************************************************************//** 142*cdf0e10cSrcweir @short remove frame from container 143*cdf0e10cSrcweir @descr This is the companion to append(). We only accept valid references and don't work, if 144*cdf0e10cSrcweir a lock is set. 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir @seealso class FrameContainer 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir @param "xFrame", reference to an existing frame to remove. 149*cdf0e10cSrcweir @return - 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir @onerror We do nothing in release or throw an assert in debug version. 152*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /*-****************************************************************************************************//** 157*cdf0e10cSrcweir @short return list of all applicable frames for given flags 158*cdf0e10cSrcweir @descr Call these to get a list of all frames, which are match with given search flags. 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir @seealso - 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir @param "nSearchFlag", flags to search right frames. 163*cdf0e10cSrcweir @return A list of founded frames. 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir @onerror An empty list is returned. 166*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 171*cdf0e10cSrcweir // XIndexAccess 172*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir /*-****************************************************************************************************//** 175*cdf0e10cSrcweir @short get count of all current frames in container 176*cdf0e10cSrcweir @descr This is the beginning of full index-access. With a count you can step over all items in container. 177*cdf0e10cSrcweir Next call shuo�d be getByIndex(). But these mechanism works only, if no lock in container is set! 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir @seealso class FrameContainer 180*cdf0e10cSrcweir @seealso method getByIndex() 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir @param - 183*cdf0e10cSrcweir @return Count of current items in container. 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir @onerror If a lock is set, we return 0 for prevent further access! 186*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir /*-****************************************************************************************************//** 191*cdf0e10cSrcweir @short get specified container item by index 192*cdf0e10cSrcweir @descr If you called getCount() successful - this method return the specified element as an Any. 193*cdf0e10cSrcweir You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown. 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir @seealso class FrameContainer 196*cdf0e10cSrcweir @seealso method getCount() 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir @param "nIndex", valid index to get container item. 199*cdf0e10cSrcweir @return A container item (specified by index) wrapped in an Any. 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir @onerror If a lock is set, we return an empty Any! 202*cdf0e10cSrcweir @onerror If index out of range, an IndexOutOfBoundsException is thrown. 203*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw( css::lang::IndexOutOfBoundsException , 206*cdf0e10cSrcweir css::lang::WrappedTargetException , 207*cdf0e10cSrcweir css::uno::RuntimeException ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 210*cdf0e10cSrcweir // XElementAccess 211*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir /*-****************************************************************************************************//** 214*cdf0e10cSrcweir @short get uno-type of all container items 215*cdf0e10cSrcweir @descr In current implementation type is fixed to XFrame! 216*cdf0e10cSrcweir (container-lock is ignored) 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir @seealso - 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir @param - 221*cdf0e10cSrcweir @return A uno-type descriptor. 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir @onerror - 224*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException ); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir /*-****************************************************************************************************//** 229*cdf0e10cSrcweir @short get fill state of current container 230*cdf0e10cSrcweir @descr Call these to get information about, if items exist in container or not. 231*cdf0e10cSrcweir (container-lock is ignored) 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir @seealso - 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir @param - 236*cdf0e10cSrcweir @return sal_True, if container contains some items. 237*cdf0e10cSrcweir @return sal_False, otherwise. 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir @onerror We return sal_False. 240*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 245*cdf0e10cSrcweir // protected methods 246*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir protected: 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir /*-****************************************************************************************************//** 251*cdf0e10cSrcweir @short standard destructor 252*cdf0e10cSrcweir @descr This method destruct an instance of this class and clear some member. 253*cdf0e10cSrcweir This method is protected, because its not allowed to use this class as a member! 254*cdf0e10cSrcweir You MUST use a dynamical instance (pointer). That's the reason for a protected dtor. 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir @seealso - 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir @param - 259*cdf0e10cSrcweir @return - 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir @onerror - 262*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir virtual ~OFrames(); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir /*-****************************************************************************************************//** 267*cdf0e10cSrcweir @short reset instance to default values 268*cdf0e10cSrcweir @descr There are two ways to delete an instance of this class.<BR> 269*cdf0e10cSrcweir 1) delete with destructor<BR> 270*cdf0e10cSrcweir 2) dispose from parent or factory ore ...<BR> 271*cdf0e10cSrcweir This method do the same for both ways! It free used memory and release references ... 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir @seealso method dispose() (if it exist!) 274*cdf0e10cSrcweir @seealso destructor ~TaskEnumeration() 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir @param - 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir @return - 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir @onerror - 281*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir virtual void impl_resetObject(); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 286*cdf0e10cSrcweir // private methods 287*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir private: 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir /*-****************************************************************************************************//** 292*cdf0e10cSrcweir @short append one sequence to another 293*cdf0e10cSrcweir @descr There is no operation to add to sequences! Use this helper-method to do this. 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir @seealso class Sequence 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir @param "seqDestination", reference to sequence on which operation will append the other sequence. 298*cdf0e10cSrcweir @param "seqSource" , reference to sequence for append. 299*cdf0e10cSrcweir @return "seqDestination" is parameter AND return value at the same time. 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir @onerror - 302*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir void impl_appendSequence( css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqDestination , 305*cdf0e10cSrcweir const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqSource ); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 308*cdf0e10cSrcweir // debug methods 309*cdf0e10cSrcweir // (should be private everyway!) 310*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir /*-****************************************************************************************************//** 313*cdf0e10cSrcweir @short debug-method to check incoming parameter of some other mehods of this class 314*cdf0e10cSrcweir @descr The following methods are used to check parameters for other methods 315*cdf0e10cSrcweir of this class. The return value is used directly for an ASSERT(...). 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir @seealso ASSERTs in implementation! 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir @param references to checking variables 320*cdf0e10cSrcweir @return sal_False ,on invalid parameter 321*cdf0e10cSrcweir @return sal_True ,otherwise 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir @onerror - 324*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir private: 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_OFramesCtor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 331*cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xOwner , 332*cdf0e10cSrcweir FrameContainer* pFrameContainer ); 333*cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_append ( const css::uno::Reference< css::frame::XFrame >& xFrame ); 334*cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_remove ( const css::uno::Reference< css::frame::XFrame >& xFrame ); 335*cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_queryFrames ( sal_Int32 nSearchFlags ); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir #endif // #ifdef ENABLE_ASSERTIONS 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 340*cdf0e10cSrcweir // variables 341*cdf0e10cSrcweir // (should be private everyway!) 342*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir private: 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// reference to global servicemanager 347*cdf0e10cSrcweir css::uno::WeakReference< css::frame::XFrame > m_xOwner ; /// reference to owner of this instance (Hold no hard reference!) 348*cdf0e10cSrcweir FrameContainer* m_pFrameContainer ; /// with owner shared list to hold all direct childs of an XFramesSupplier 349*cdf0e10cSrcweir sal_Bool m_bRecursiveSearchProtection ; /// flag to protect against recursive searches of frames at parents 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir }; // class OFrames 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir } // namespace framework 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_ 356