1*234bd5c5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*234bd5c5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*234bd5c5SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*234bd5c5SAndrew Rist * distributed with this work for additional information 6*234bd5c5SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*234bd5c5SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*234bd5c5SAndrew Rist * "License"); you may not use this file except in compliance 9*234bd5c5SAndrew Rist * with the License. You may obtain a copy of the License at 10*234bd5c5SAndrew Rist * 11*234bd5c5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*234bd5c5SAndrew Rist * 13*234bd5c5SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*234bd5c5SAndrew Rist * software distributed under the License is distributed on an 15*234bd5c5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*234bd5c5SAndrew Rist * KIND, either express or implied. See the License for the 17*234bd5c5SAndrew Rist * specific language governing permissions and limitations 18*234bd5c5SAndrew Rist * under the License. 19*234bd5c5SAndrew Rist * 20*234bd5c5SAndrew Rist *************************************************************/ 21*234bd5c5SAndrew Rist 22*234bd5c5SAndrew Rist 23cdf0e10cSrcweir #ifndef SB_UNO_OBJ 24cdf0e10cSrcweir #define SB_UNO_OBJ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <basic/sbxobj.hxx> 27cdf0e10cSrcweir #include <basic/sbxmeth.hxx> 28cdf0e10cSrcweir #include <basic/sbxprop.hxx> 29cdf0e10cSrcweir #include <basic/sbxfac.hxx> 30cdf0e10cSrcweir #ifndef __SBX_SBX_HXX //autogen 31cdf0e10cSrcweir #include <basic/sbx.hxx> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp> 34cdf0e10cSrcweir #include <com/sun/star/beans/XExactName.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospectionAccess.hpp> 36cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospection.hpp> 37cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 38cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlClass.hpp> 39cdf0e10cSrcweir #include <com/sun/star/reflection/XServiceTypeDescription2.hpp> 40cdf0e10cSrcweir #include <com/sun/star/reflection/XSingletonTypeDescription.hpp> 41cdf0e10cSrcweir #include <rtl/ustring.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir class SbUnoObject: public SbxObject 44cdf0e10cSrcweir { 45cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > mxUnoAccess; 46cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMaterialHolder > mxMaterialHolder; 47cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > mxInvocation; 48cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactName; 49cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactNameInvocation; 50cdf0e10cSrcweir sal_Bool bNeedIntrospection; 51cdf0e10cSrcweir sal_Bool bNativeCOMObject; 52cdf0e10cSrcweir ::com::sun::star::uno::Any maTmpUnoObj; // Only to save obj for doIntrospection! 53cdf0e10cSrcweir 54cdf0e10cSrcweir // Hilfs-Methode zum Anlegen der dbg_-Properties 55cdf0e10cSrcweir void implCreateDbgProperties( void ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir // Hilfs-Methode zum Anlegen aller Properties und Methoden 58cdf0e10cSrcweir // (Beim on-demand-Mechanismus erforderlich fuer die dbg_-Properties) 59cdf0e10cSrcweir void implCreateAll( void ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir public: 62cdf0e10cSrcweir static bool getDefaultPropName( SbUnoObject* pUnoObj, String& sDfltProp ); 63cdf0e10cSrcweir TYPEINFO(); 64cdf0e10cSrcweir SbUnoObject( const String& aName_, const ::com::sun::star::uno::Any& aUnoObj_ ); 65cdf0e10cSrcweir ~SbUnoObject(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // #76470 Introspection on Demand durchfuehren 68cdf0e10cSrcweir void doIntrospection( void ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir // Find ueberladen, um z.B. NameAccess zu unterstuetzen 71cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir // Force creation of all properties for debugging createAllProperties(void)74cdf0e10cSrcweir void createAllProperties( void ) 75cdf0e10cSrcweir { implCreateAll(); } 76cdf0e10cSrcweir 77cdf0e10cSrcweir // Wert rausgeben 78cdf0e10cSrcweir ::com::sun::star::uno::Any getUnoAny( void ); getIntrospectionAccess(void)79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > getIntrospectionAccess( void ) { return mxUnoAccess; } getInvocation(void)80cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > getInvocation( void ) { return mxInvocation; } 81cdf0e10cSrcweir 82cdf0e10cSrcweir void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); 83cdf0e10cSrcweir isNativeCOMObject(void)84cdf0e10cSrcweir bool isNativeCOMObject( void ) 85cdf0e10cSrcweir { return bNativeCOMObject; } 86cdf0e10cSrcweir }; 87cdf0e10cSrcweir SV_DECL_IMPL_REF(SbUnoObject); 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir // #67781 Rueckgabewerte der Uno-Methoden loeschen 91cdf0e10cSrcweir void clearUnoMethods( void ); 92cdf0e10cSrcweir void clearUnoMethodsForBasic( StarBASIC* pBasic ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir class SbUnoMethod : public SbxMethod 95cdf0e10cSrcweir { 96cdf0e10cSrcweir friend class SbUnoObject; 97cdf0e10cSrcweir friend void clearUnoMethods( void ); 98cdf0e10cSrcweir friend void clearUnoMethodsForBasic( StarBASIC* pBasic ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > m_xUnoMethod; 101cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::reflection::ParamInfo >* pParamInfoSeq; 102cdf0e10cSrcweir 103cdf0e10cSrcweir // #67781 Verweis auf vorige und naechste Methode in der Methoden-Liste 104cdf0e10cSrcweir SbUnoMethod* pPrev; 105cdf0e10cSrcweir SbUnoMethod* pNext; 106cdf0e10cSrcweir 107cdf0e10cSrcweir bool mbInvocation; // Method is based on invocation 108cdf0e10cSrcweir bool mbDirectInvocation; // Method should be used with XDirectInvocation interface 109cdf0e10cSrcweir 110cdf0e10cSrcweir public: 111cdf0e10cSrcweir TYPEINFO(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir SbUnoMethod( const String& aName_, SbxDataType eSbxType, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > xUnoMethod_, 114cdf0e10cSrcweir bool bInvocation, 115cdf0e10cSrcweir bool bDirect = false ); 116cdf0e10cSrcweir virtual ~SbUnoMethod(); 117cdf0e10cSrcweir virtual SbxInfo* GetInfo(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::reflection::ParamInfo >& getParamInfos( void ); 120cdf0e10cSrcweir isInvocationBased(void)121cdf0e10cSrcweir bool isInvocationBased( void ) 122cdf0e10cSrcweir { return mbInvocation; } needsDirectInvocation(void)123cdf0e10cSrcweir bool needsDirectInvocation( void ) 124cdf0e10cSrcweir { return mbDirectInvocation; } 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir 127cdf0e10cSrcweir 128cdf0e10cSrcweir class SbUnoProperty : public SbxProperty 129cdf0e10cSrcweir { 130cdf0e10cSrcweir friend class SbUnoObject; 131cdf0e10cSrcweir 132cdf0e10cSrcweir // Daten der Uno-Property 133cdf0e10cSrcweir ::com::sun::star::beans::Property aUnoProp; 134cdf0e10cSrcweir sal_Int32 nId; 135cdf0e10cSrcweir 136cdf0e10cSrcweir bool mbInvocation; // Property is based on invocation 137cdf0e10cSrcweir 138cdf0e10cSrcweir virtual ~SbUnoProperty(); 139cdf0e10cSrcweir public: 140cdf0e10cSrcweir TYPEINFO(); 141cdf0e10cSrcweir SbUnoProperty( const String& aName_, SbxDataType eSbxType, 142cdf0e10cSrcweir const ::com::sun::star::beans::Property& aUnoProp_, sal_Int32 nId_, bool bInvocation ); 143cdf0e10cSrcweir isInvocationBased(void)144cdf0e10cSrcweir bool isInvocationBased( void ) 145cdf0e10cSrcweir { return mbInvocation; } 146cdf0e10cSrcweir }; 147cdf0e10cSrcweir 148cdf0e10cSrcweir // Factory-Klasse fuer das Anlegen von Uno-Structs per DIM AS NEW 149cdf0e10cSrcweir class SbUnoFactory : public SbxFactory 150cdf0e10cSrcweir { 151cdf0e10cSrcweir public: 152cdf0e10cSrcweir virtual SbxBase* Create( sal_uInt16 nSbxId, sal_uInt32 = SBXCR_SBX ); 153cdf0e10cSrcweir virtual SbxObject* CreateObject( const String& ); 154cdf0e10cSrcweir }; 155cdf0e10cSrcweir 156cdf0e10cSrcweir // Wrapper fuer eine Uno-Klasse 157cdf0e10cSrcweir class SbUnoClass : public SbxObject 158cdf0e10cSrcweir { 159cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > m_xClass; 160cdf0e10cSrcweir 161cdf0e10cSrcweir public: 162cdf0e10cSrcweir TYPEINFO(); SbUnoClass(const String & aName_)163cdf0e10cSrcweir SbUnoClass( const String& aName_ ) 164cdf0e10cSrcweir : SbxObject( aName_ ) 165cdf0e10cSrcweir {} SbUnoClass(const String & aName_,const::com::sun::star::uno::Reference<::com::sun::star::reflection::XIdlClass> & xClass_)166cdf0e10cSrcweir SbUnoClass( const String& aName_, const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass >& xClass_ ) 167cdf0e10cSrcweir : SbxObject( aName_ ) 168cdf0e10cSrcweir , m_xClass( xClass_ ) 169cdf0e10cSrcweir {} 170cdf0e10cSrcweir //~SbUnoClass(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // Find ueberladen, um Elemente on Demand anzulegen 173cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir // Wert rausgeben getUnoClass(void)176cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass >& getUnoClass( void ) { return m_xClass; } 177cdf0e10cSrcweir 178cdf0e10cSrcweir //void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); 179cdf0e10cSrcweir }; 180cdf0e10cSrcweir SV_DECL_IMPL_REF(SbUnoClass); 181cdf0e10cSrcweir 182cdf0e10cSrcweir 183cdf0e10cSrcweir // Funktion, um einen globalen Bezeichner im 184cdf0e10cSrcweir // UnoScope zu suchen und fuer Sbx zu wrappen 185cdf0e10cSrcweir SbUnoClass* findUnoClass( const String& rName ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir 188cdf0e10cSrcweir // Wrapper for UNO Service 189cdf0e10cSrcweir class SbUnoService : public SbxObject 190cdf0e10cSrcweir { 191cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceTypeDescription2 > m_xServiceTypeDesc; 192cdf0e10cSrcweir bool m_bNeedsInit; 193cdf0e10cSrcweir 194cdf0e10cSrcweir public: 195cdf0e10cSrcweir TYPEINFO(); SbUnoService(const String & aName_,const::com::sun::star::uno::Reference<::com::sun::star::reflection::XServiceTypeDescription2> & xServiceTypeDesc)196cdf0e10cSrcweir SbUnoService( const String& aName_, 197cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceTypeDescription2 >& xServiceTypeDesc ) 198cdf0e10cSrcweir : SbxObject( aName_ ) 199cdf0e10cSrcweir , m_xServiceTypeDesc( xServiceTypeDesc ) 200cdf0e10cSrcweir , m_bNeedsInit( true ) 201cdf0e10cSrcweir {} 202cdf0e10cSrcweir 203cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); 206cdf0e10cSrcweir }; 207cdf0e10cSrcweir SV_DECL_IMPL_REF(SbUnoService); 208cdf0e10cSrcweir 209cdf0e10cSrcweir SbUnoService* findUnoService( const String& rName ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir 212cdf0e10cSrcweir void clearUnoServiceCtors( void ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir class SbUnoServiceCtor : public SbxMethod 215cdf0e10cSrcweir { 216cdf0e10cSrcweir friend class SbUnoService; 217cdf0e10cSrcweir friend void clearUnoServiceCtors( void ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > m_xServiceCtorDesc; 220cdf0e10cSrcweir 221cdf0e10cSrcweir SbUnoServiceCtor* pPrev; 222cdf0e10cSrcweir SbUnoServiceCtor* pNext; 223cdf0e10cSrcweir 224cdf0e10cSrcweir public: 225cdf0e10cSrcweir TYPEINFO(); 226cdf0e10cSrcweir 227cdf0e10cSrcweir SbUnoServiceCtor( const String& aName_, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > xServiceCtorDesc ); 228cdf0e10cSrcweir virtual ~SbUnoServiceCtor(); 229cdf0e10cSrcweir virtual SbxInfo* GetInfo(); 230cdf0e10cSrcweir getServiceCtorDesc(void)231cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > getServiceCtorDesc( void ) 232cdf0e10cSrcweir { return m_xServiceCtorDesc; } 233cdf0e10cSrcweir }; 234cdf0e10cSrcweir 235cdf0e10cSrcweir 236cdf0e10cSrcweir // Wrapper for UNO Singleton 237cdf0e10cSrcweir class SbUnoSingleton : public SbxObject 238cdf0e10cSrcweir { 239cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription > m_xSingletonTypeDesc; 240cdf0e10cSrcweir 241cdf0e10cSrcweir public: 242cdf0e10cSrcweir TYPEINFO(); 243cdf0e10cSrcweir SbUnoSingleton( const String& aName_, 244cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription >& xSingletonTypeDesc ); 245cdf0e10cSrcweir 246cdf0e10cSrcweir void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); 247cdf0e10cSrcweir }; 248cdf0e10cSrcweir SV_DECL_IMPL_REF(SbUnoSingleton); 249cdf0e10cSrcweir 250cdf0e10cSrcweir SbUnoSingleton* findUnoSingleton( const String& rName ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir 253cdf0e10cSrcweir // #105565 Special Object to wrap a strongly typed Uno Any 254cdf0e10cSrcweir class SbUnoAnyObject: public SbxObject 255cdf0e10cSrcweir { 256cdf0e10cSrcweir ::com::sun::star::uno::Any mVal; 257cdf0e10cSrcweir 258cdf0e10cSrcweir public: SbUnoAnyObject(const::com::sun::star::uno::Any & rVal)259cdf0e10cSrcweir SbUnoAnyObject( const ::com::sun::star::uno::Any& rVal ) 260cdf0e10cSrcweir : SbxObject( String() ) 261cdf0e10cSrcweir , mVal( rVal ) 262cdf0e10cSrcweir {} 263cdf0e10cSrcweir getValue(void)264cdf0e10cSrcweir const ::com::sun::star::uno::Any& getValue( void ) 265cdf0e10cSrcweir { return mVal; } 266cdf0e10cSrcweir 267cdf0e10cSrcweir TYPEINFO(); 268cdf0e10cSrcweir }; 269cdf0e10cSrcweir 270cdf0e10cSrcweir 271cdf0e10cSrcweir // #112509 Special SbxArray to transport named parameters for calls 272cdf0e10cSrcweir // to OLEAutomation objects through the UNO OLE automation bridge 273cdf0e10cSrcweir 274cdf0e10cSrcweir class AutomationNamedArgsSbxArray : public SbxArray 275cdf0e10cSrcweir { 276cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > maNameSeq; 277cdf0e10cSrcweir public: 278cdf0e10cSrcweir TYPEINFO(); AutomationNamedArgsSbxArray(sal_Int32 nSeqSize)279cdf0e10cSrcweir AutomationNamedArgsSbxArray( sal_Int32 nSeqSize ) 280cdf0e10cSrcweir : maNameSeq( nSeqSize ) 281cdf0e10cSrcweir {} 282cdf0e10cSrcweir getNames(void)283cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString >& getNames( void ) 284cdf0e10cSrcweir { return maNameSeq; } 285cdf0e10cSrcweir }; 286cdf0e10cSrcweir 287cdf0e10cSrcweir 288cdf0e10cSrcweir class StarBASIC; 289cdf0e10cSrcweir 290cdf0e10cSrcweir // Impl-Methoden fuer RTL 291cdf0e10cSrcweir void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 292cdf0e10cSrcweir void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 293cdf0e10cSrcweir void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 294cdf0e10cSrcweir void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 295cdf0e10cSrcweir void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 296cdf0e10cSrcweir void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 297cdf0e10cSrcweir void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 298cdf0e10cSrcweir void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 299cdf0e10cSrcweir void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ); 300cdf0e10cSrcweir 301cdf0e10cSrcweir void disposeComVariablesForBasic( StarBASIC* pBasic ); 302cdf0e10cSrcweir void clearNativeObjectWrapperVector( void ); 303cdf0e10cSrcweir 304cdf0e10cSrcweir 305cdf0e10cSrcweir //======================================================================== 306cdf0e10cSrcweir // #118116 Collection object 307cdf0e10cSrcweir 308cdf0e10cSrcweir class BasicCollection : public SbxObject 309cdf0e10cSrcweir { 310cdf0e10cSrcweir friend class SbiRuntime; 311cdf0e10cSrcweir SbxArrayRef xItemArray; 312cdf0e10cSrcweir static SbxInfoRef xAddInfo; 313cdf0e10cSrcweir static SbxInfoRef xItemInfo; 314cdf0e10cSrcweir 315cdf0e10cSrcweir void Initialize(); 316cdf0e10cSrcweir virtual ~BasicCollection(); 317cdf0e10cSrcweir virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, 318cdf0e10cSrcweir const SfxHint& rHint, const TypeId& rHintType ); 319cdf0e10cSrcweir sal_Int32 implGetIndex( SbxVariable* pIndexVar ); 320cdf0e10cSrcweir sal_Int32 implGetIndexForName( const String& rName ); 321cdf0e10cSrcweir void CollAdd( SbxArray* pPar_ ); 322cdf0e10cSrcweir void CollItem( SbxArray* pPar_ ); 323cdf0e10cSrcweir void CollRemove( SbxArray* pPar_ ); 324cdf0e10cSrcweir 325cdf0e10cSrcweir public: 326cdf0e10cSrcweir TYPEINFO(); 327cdf0e10cSrcweir BasicCollection( const String& rClassname ); 328cdf0e10cSrcweir virtual SbxVariable* Find( const String&, SbxClassType ); 329cdf0e10cSrcweir virtual void Clear(); 330cdf0e10cSrcweir }; 331cdf0e10cSrcweir 332cdf0e10cSrcweir #endif 333cdf0e10cSrcweir 334cdf0e10cSrcweir 335