1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_ 25*b1cdbd2cSJim Jagielski #define __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 28*b1cdbd2cSJim Jagielski // my own includes 29*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski #include <threadhelp/threadhelpbase.hxx> 32*b1cdbd2cSJim Jagielski #include <macros/generic.hxx> 33*b1cdbd2cSJim Jagielski #include <macros/xinterface.hxx> 34*b1cdbd2cSJim Jagielski #include <macros/xtypeprovider.hxx> 35*b1cdbd2cSJim Jagielski #include <macros/debug.hxx> 36*b1cdbd2cSJim Jagielski #include <general.h> 37*b1cdbd2cSJim Jagielski 38*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 39*b1cdbd2cSJim Jagielski // interface includes 40*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 41*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XFramesSupplier.hpp> 42*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XEnumerationAccess.hpp> 43*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XElementAccess.hpp> 44*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XEnumeration.hpp> 45*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XDesktop.hpp> 46*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XComponent.hpp> 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 49*b1cdbd2cSJim Jagielski // other includes 50*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 51*b1cdbd2cSJim Jagielski #include <cppuhelper/implbase1.hxx> 52*b1cdbd2cSJim Jagielski #include <cppuhelper/weakref.hxx> 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 55*b1cdbd2cSJim Jagielski // namespace 56*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 57*b1cdbd2cSJim Jagielski 58*b1cdbd2cSJim Jagielski namespace framework{ 59*b1cdbd2cSJim Jagielski 60*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 61*b1cdbd2cSJim Jagielski // exported const 62*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 63*b1cdbd2cSJim Jagielski 64*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 65*b1cdbd2cSJim Jagielski // exported definitions 66*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________ 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//** 69*b1cdbd2cSJim Jagielski @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components 70*b1cdbd2cSJim Jagielski @descr We share mutex and framecontainer with ouer owner and have full access to his child tasks. 71*b1cdbd2cSJim Jagielski (Ouer owner can be the Desktop only!) We create oneway enumerations on demand. These "lists" 72*b1cdbd2cSJim Jagielski can be used for one time only. Step during the list from first to last element. 73*b1cdbd2cSJim Jagielski (The type of created enumerations is OComponentEnumeration.) 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski @implements XInterface 76*b1cdbd2cSJim Jagielski XTypeProvider 77*b1cdbd2cSJim Jagielski XEnumerationAccess 78*b1cdbd2cSJim Jagielski XElementAccess 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski @base ThreadHelpBase 81*b1cdbd2cSJim Jagielski OWeakObject 82*b1cdbd2cSJim Jagielski 83*b1cdbd2cSJim Jagielski @devstatus ready to use 84*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/ 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski class OComponentAccess : private ThreadHelpBase , // Must be the first of baseclasses - Is neccessary for right initialization of objects! 87*b1cdbd2cSJim Jagielski public ::cppu::WeakImplHelper1< ::com::sun::star::container::XEnumerationAccess > 88*b1cdbd2cSJim Jagielski { 89*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 90*b1cdbd2cSJim Jagielski // public methods 91*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 92*b1cdbd2cSJim Jagielski 93*b1cdbd2cSJim Jagielski public: 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 96*b1cdbd2cSJim Jagielski // constructor / destructor 97*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 100*b1cdbd2cSJim Jagielski @short constructor to initialize this instance 101*b1cdbd2cSJim Jagielski @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a 102*b1cdbd2cSJim Jagielski snapshot of the components of current tasks under the desktop. 103*b1cdbd2cSJim Jagielski But we need a instance to create more then one enumerations at different times! 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski @seealso class Desktop 106*b1cdbd2cSJim Jagielski @seealso class OComponentEnumeration 107*b1cdbd2cSJim Jagielski 108*b1cdbd2cSJim Jagielski @param "xOwner" is a reference to ouer owner and must be the desktop! 109*b1cdbd2cSJim Jagielski @return - 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski @onerror Do nothing and reset this object to default with an empty list. 112*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski OComponentAccess( const css::uno::Reference< css::frame::XDesktop >& xOwner ); 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 117*b1cdbd2cSJim Jagielski // XEnumerationAccess 118*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 121*b1cdbd2cSJim Jagielski @short create a new enumeration of components 122*b1cdbd2cSJim Jagielski @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration. 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski @seealso interface XEnumerationAccess 125*b1cdbd2cSJim Jagielski @seealso interface XEnumeration 126*b1cdbd2cSJim Jagielski @seealso class Desktop 127*b1cdbd2cSJim Jagielski 128*b1cdbd2cSJim Jagielski @param - 129*b1cdbd2cSJim Jagielski @return If the desktop and some components exist => a valid reference to an enumeration<BR> 130*b1cdbd2cSJim Jagielski An NULL-reference, other way. 131*b1cdbd2cSJim Jagielski 132*b1cdbd2cSJim Jagielski @onerror - 133*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 134*b1cdbd2cSJim Jagielski 135*b1cdbd2cSJim Jagielski virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw( css::uno::RuntimeException ); 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 138*b1cdbd2cSJim Jagielski // XElementAccess 139*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------------------------------------------- 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 142*b1cdbd2cSJim Jagielski @short get the type of elements in enumeration 143*b1cdbd2cSJim Jagielski @descr - 144*b1cdbd2cSJim Jagielski 145*b1cdbd2cSJim Jagielski @seealso interface XElementAccess 146*b1cdbd2cSJim Jagielski @seealso class OComponentEnumeration 147*b1cdbd2cSJim Jagielski 148*b1cdbd2cSJim Jagielski @param - 149*b1cdbd2cSJim Jagielski @return The uno-type XComponent. 150*b1cdbd2cSJim Jagielski 151*b1cdbd2cSJim Jagielski @onerror - 152*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 153*b1cdbd2cSJim Jagielski 154*b1cdbd2cSJim Jagielski virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException ); 155*b1cdbd2cSJim Jagielski 156*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 157*b1cdbd2cSJim Jagielski @short get state of componentlist of enumeration. 158*b1cdbd2cSJim Jagielski @descr - 159*b1cdbd2cSJim Jagielski 160*b1cdbd2cSJim Jagielski @seealso interface XElementAccess 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski @param - 163*b1cdbd2cSJim Jagielski @return sal_True ,if more then 0 elements exist. 164*b1cdbd2cSJim Jagielski @return sal_False ,otherwise. 165*b1cdbd2cSJim Jagielski 166*b1cdbd2cSJim Jagielski @onerror - 167*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 168*b1cdbd2cSJim Jagielski 169*b1cdbd2cSJim Jagielski virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException ); 170*b1cdbd2cSJim Jagielski 171*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 172*b1cdbd2cSJim Jagielski // protected methods 173*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski protected: 176*b1cdbd2cSJim Jagielski 177*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 178*b1cdbd2cSJim Jagielski @short standard destructor 179*b1cdbd2cSJim Jagielski @descr This method destruct an instance of this class and clear some member. 180*b1cdbd2cSJim Jagielski Don't use an instance of this class as normal member. Use it dynamicly with a pointer. 181*b1cdbd2cSJim Jagielski We hold a weakreference to ouer owner and not to ouer superclass! 182*b1cdbd2cSJim Jagielski Thats the reason for a protected dtor. 183*b1cdbd2cSJim Jagielski 184*b1cdbd2cSJim Jagielski @seealso class Desktop 185*b1cdbd2cSJim Jagielski 186*b1cdbd2cSJim Jagielski @param - 187*b1cdbd2cSJim Jagielski @return - 188*b1cdbd2cSJim Jagielski 189*b1cdbd2cSJim Jagielski @onerror - 190*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 191*b1cdbd2cSJim Jagielski 192*b1cdbd2cSJim Jagielski virtual ~OComponentAccess(); 193*b1cdbd2cSJim Jagielski 194*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 195*b1cdbd2cSJim Jagielski // private methods 196*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 197*b1cdbd2cSJim Jagielski 198*b1cdbd2cSJim Jagielski private: 199*b1cdbd2cSJim Jagielski 200*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 201*b1cdbd2cSJim Jagielski @short recursive method (!) to collect all components of all frames from the subtree of given node 202*b1cdbd2cSJim Jagielski @descr This is neccessary to create the enumeration. 203*b1cdbd2cSJim Jagielski 204*b1cdbd2cSJim Jagielski @seealso method createEnumeration 205*b1cdbd2cSJim Jagielski 206*b1cdbd2cSJim Jagielski @param "xNode" , root of subtree and start point of search 207*b1cdbd2cSJim Jagielski @param "seqComponents", result list of search. We cant use a return value, we search recursive 208*b1cdbd2cSJim Jagielski and must collect all informations. 209*b1cdbd2cSJim Jagielski @return - 210*b1cdbd2cSJim Jagielski 211*b1cdbd2cSJim Jagielski @onerror - 212*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 213*b1cdbd2cSJim Jagielski 214*b1cdbd2cSJim Jagielski void impl_collectAllChildComponents( const css::uno::Reference< css::frame::XFramesSupplier >& xNode , 215*b1cdbd2cSJim Jagielski css::uno::Sequence< css::uno::Reference< css::lang::XComponent > >& seqComponents ); 216*b1cdbd2cSJim Jagielski 217*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 218*b1cdbd2cSJim Jagielski @short get the component of a frame 219*b1cdbd2cSJim Jagielski @descr The component of a frame can be the window, the controller or the model. 220*b1cdbd2cSJim Jagielski 221*b1cdbd2cSJim Jagielski @seealso method createEnumeration 222*b1cdbd2cSJim Jagielski 223*b1cdbd2cSJim Jagielski @param "xFrame", frame which contains the component 224*b1cdbd2cSJim Jagielski @return A reference to the component of given frame. 225*b1cdbd2cSJim Jagielski 226*b1cdbd2cSJim Jagielski @onerror A null reference is returned. 227*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 228*b1cdbd2cSJim Jagielski 229*b1cdbd2cSJim Jagielski css::uno::Reference< css::lang::XComponent > impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; 230*b1cdbd2cSJim Jagielski 231*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 232*b1cdbd2cSJim Jagielski // debug methods 233*b1cdbd2cSJim Jagielski // (should be private everyway!) 234*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 235*b1cdbd2cSJim Jagielski 236*b1cdbd2cSJim Jagielski /*-****************************************************************************************************//** 237*b1cdbd2cSJim Jagielski @short debug-method to check incoming parameter of some other mehods of this class 238*b1cdbd2cSJim Jagielski @descr The following methods are used to check parameters for other methods 239*b1cdbd2cSJim Jagielski of this class. The return value is used directly for an ASSERT(...). 240*b1cdbd2cSJim Jagielski 241*b1cdbd2cSJim Jagielski @seealso ASSERTs in implementation! 242*b1cdbd2cSJim Jagielski 243*b1cdbd2cSJim Jagielski @param references to checking variables 244*b1cdbd2cSJim Jagielski @return sal_False ,on invalid parameter. 245*b1cdbd2cSJim Jagielski @return sal_True ,otherwise 246*b1cdbd2cSJim Jagielski 247*b1cdbd2cSJim Jagielski @onerror - 248*b1cdbd2cSJim Jagielski *//*-*****************************************************************************************************/ 249*b1cdbd2cSJim Jagielski 250*b1cdbd2cSJim Jagielski #ifdef ENABLE_ASSERTIONS 251*b1cdbd2cSJim Jagielski 252*b1cdbd2cSJim Jagielski private: 253*b1cdbd2cSJim Jagielski 254*b1cdbd2cSJim Jagielski static sal_Bool impldbg_checkParameter_OComponentAccessCtor( const css::uno::Reference< css::frame::XDesktop >& xOwner ); 255*b1cdbd2cSJim Jagielski 256*b1cdbd2cSJim Jagielski #endif // #ifdef ENABLE_ASSERTIONS 257*b1cdbd2cSJim Jagielski 258*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 259*b1cdbd2cSJim Jagielski // variables 260*b1cdbd2cSJim Jagielski // (should be private everyway!) 261*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------------------------------------- 262*b1cdbd2cSJim Jagielski 263*b1cdbd2cSJim Jagielski private: 264*b1cdbd2cSJim Jagielski 265*b1cdbd2cSJim Jagielski css::uno::WeakReference< css::frame::XDesktop > m_xOwner ; /// weak reference to the desktop object! 266*b1cdbd2cSJim Jagielski 267*b1cdbd2cSJim Jagielski }; // class OComponentAccess 268*b1cdbd2cSJim Jagielski 269*b1cdbd2cSJim Jagielski } // namespace framework 270*b1cdbd2cSJim Jagielski 271*b1cdbd2cSJim Jagielski #endif // #ifndef __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_ 272