// This class wraps an IDispatch and maps XInvocation calls to IDispatch calls on the wrapped object. // If m_TypeDescription is set then this class represents a UNO interface implemented in a COM component. // The interface is not a real interface in terms of an abstract class but is realized through IDispatch. class IUnknownWrapper : public WeakImplHelper< XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod, XDirectInvocation, XAutomationInvocation >,
// XBridgeSupplier2 // This interface is implemented to provide a safe way to obtain the original // IUnknown or IDispatch within the function anyToVariant. The function asks // every UNO object for its XBridgeSupplier2 and if it is available uses it to convert // the object with its own supplier. virtual Any SAL_CALL createBridge( const Any& modelDepObject, const Sequence< sal_Int8 >& aProcessId,
sal_Int16 sourceModelType,
sal_Int16 destModelType ) override;
Any invokeWithDispIdComTlb(FuncDesc& aFuncDesc, const OUString& sFuncName, const Sequence< Any >& Params,
Sequence< sal_Int16 >& OutParamIndex,
Sequence< Any >& OutParam);
protected:
virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName, const Sequence< Any >& Params,
Sequence<sal_Int16 >& OutParamIndex,
Sequence< Any >& OutParam); // Is used for OleObjectFactory service virtual Any invokeWithDispIdComTlb(const OUString& sFuncName, const Sequence< Any >& Params,
Sequence< sal_Int16 >& OutParamIndex,
Sequence< Any >& OutParam);
/**Obtains a FUNCDESC structure for a function. FillstheFUNCDESCstructureifITypeInfoprovidesinformationfor thefunctionofnamesFuncNameorpFuncDescwillnotbefilledin. MaythrowaBridgeRuntimeError.
*/ void getFuncDesc(const OUString & sFuncName, FUNCDESC ** pFuncDesc); /**Obtains a FUNCDESC structures or a VARDESC structure foraproperty.pFuncDescPutmayalsocontain astructurefora"propertyputref"operation.IfpFuncDesccontainsa "putref"or"put"FUNCDESCdependsonwhatwasfoundfirstinthetype description. FillstheFUNCDESCstructureifITypeInfoprovidesinformationfor therespectivepropertyfunctionsorthestructureswillnotbefilledin. MaythrowaBridgeRuntimeError.
*/ void getPropDesc(const OUString & sFuncName, FUNCDESC ** pFuncDescGet,
FUNCDESC** pFuncDescPut, VARDESC ** pVarDesc); // These functions are for the case if an object of this class wraps an IDispatch // object that implements UNO interfaces. In that case the member m_seqTypes // is set through XInitialization::initialize. void getMethodInfo(std::u16string_view sName, TypeDescription& methodDescription); // After return attributInfo contains typelib_InterfaceAttributeTypeDescription::pAttributeTypeRef void getAttributeInfo(std::u16string_view sName, TypeDescription& attributeInfo); // used by get MethodInfo
TypeDescription getInterfaceMemberDescOfCurrentCall(std::u16string_view sName); /** Returns always a valid ITypeInfo interface or throws a BridgeRuntimeError. ThereturnedinterfacedoesnotneedtobeAddRef'edaslongasitislocally used.Theinterfaceiskeptintheinstanceofthisclass.
*/
ITypeInfo* getTypeInfo();
/** Returns the DISPID for a function or property name. If true is returned then idcontainsavalidDISPID.
*/
/** Gets the element type in a VARIANT like style. E.g. if desc->lptdesc contains aVT_PTRthanitisreplacedbyVT_BYREFandVT_SAFEARRAYisreplacedbyVT_ARRAY IftheTYPEDESCdescribesanSAFEARRAYthenvarTypeisacombinationofVT_ARRAY andtheelementtype. TheargumentdescmustbeobtainedfromFUNCDESC::lprgelemdescParam[i].tdescwhere FUNCDESCwasobtainedfromtheITypeInfobelongingtowrappedIDispatch.
*/
VARTYPE getElementTypeDesc( const TYPEDESC *desc); /** Iterates over all functions and put the names and indices into the map m_mapComFuncoftypeTLBFuncIndexMap. Callthefunctioneverytimebeforeaccessingthemap. ThrowsaBridgeRuntimeErroronfailure.
*/ void buildComTlbIndex();
/** Returns a FUNCDESC structure which contains type information about the currentXInvocation::invokecall.TheFUNCDESCeitherdescribesamethod, apropertyputorapropertygetoperation. Itusesthetypescom.sun.star.bridge.oleautomation.PropertyPutArgument whichcanbe containedinthesequenceofin-argumentsofinvoketodetermineifthecallis apropertyputorpropertygetoperation. IfnoadequateFUNCDESCwasfound,anIllegalArgumentExceptionisthrown. ThereforeitissafetoassumethatthereturnedFUNCDESC*isnotNULL.
// Finds out whether the wrapped IDispatch is a JScript Object. This is // done by // asking for the property "_environment". If it has the value "JScript" // (case insensitive) then the IDispatch is considered a JScript object. bool isJScriptObject();
// If UNO interfaces are implemented in JScript objects, VB or C++ COM objects // and those are passed as parameter to a UNO interface function, then // the IDispatch* are wrapped by objects of this class. Assuming that the functions // implemented by the IDispatch object returns another UNO interface then // it has to be wrapped to this type. But this is only possible if an object of this // wrapper class knows what type it is representing. The member m_TypeDescription holds this // information. // m_TypeDescription is only useful when an object wraps an IDispatch object that implements // a UNO interface. The value is set during a call to XInitialization::initialize.
Sequence<Type> m_seqTypes;
CComPtr<IUnknown> m_spUnknown;
CComPtr<IDispatch> m_spDispatch;
OUString m_sTypeName; // is "" ( not initialised ), "IDispatch" ( we have no idea ) or "SomeLibrary.SomeTypeName" if we managed to get a type /** This value is set during XInitialization::initialize. It indicates that the COM interface wastransportedasVT_DISPATCHinaVARIANTratherthanaVT_UNKNOWN
*/ bool m_bOriginalDispatch;
DispIdMap m_dispIdMap;
Reference<XIdlClass>* m_pxIdlClass;
// used by isJScriptObject enum JScriptDetermination{ JScriptUndefined=0, NoJScript, IsJScript};
JScriptDetermination m_eJScript; // The map is filled by buildComTlbIndex // It maps Uno Function names to an index which is used in ITypeInfo::GetFuncDesc
TLBFuncIndexMap m_mapComFunc; // used for synchronizing the computation of the content for m_mapComFunc bool m_bComTlbIndexInit; // Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo
CComPtr< ITypeInfo > m_spTypeInfo;
OUString m_sDefaultMember; bool m_bHasDfltMethod; bool m_bHasDfltProperty;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.