From 24f4ad95920746ebc6cfc6f2ab86f65fb53345ca Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 23 Jun 2002 14:10:32 +0000 Subject: [PATCH] Applied patch [ 546335 ] Added Automation types and array access git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/ole/automtn.h | 5 +++ src/msw/ole/automtn.cpp | 68 +++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/ole/automtn.h b/include/wx/msw/ole/automtn.h index 9e35455a54..f8af916877 100644 --- a/include/wx/msw/ole/automtn.h +++ b/include/wx/msw/ole/automtn.h @@ -55,6 +55,7 @@ public: // Invoke a member function wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]); + wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args); // Convenience function wxVariant CallMethod(const wxString& method, @@ -64,11 +65,13 @@ public: // Get/Put property wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const; + wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const; wxVariant GetProperty(const wxString& property, const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant, const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant, const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant); + bool wxAutomationObject::PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args); bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ; bool PutProperty(const wxString& property, const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant, @@ -80,10 +83,12 @@ public: // on the pointer, though this could be implicit by constructing an wxAutomationObject // with it and letting the destructor call Release. WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const; + WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const; // A way of initialising another wxAutomationObject with a dispatch object, // without having to deal with nasty IDispatch pointers. bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const; + bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const; public: WXIDISPATCH* m_dispatchPtr; diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp index ac4e48776d..44ddb88ab9 100644 --- a/src/msw/ole/automtn.cpp +++ b/src/msw/ole/automtn.cpp @@ -267,6 +267,16 @@ wxVariant wxAutomationObject::CallMethod(const wxString& member, int noArgs, wxV return retVariant; } +wxVariant wxAutomationObject::CallMethodArray(const wxString& member, int noArgs, const wxVariant **args) +{ + wxVariant retVariant; + if (!Invoke(member, DISPATCH_METHOD, retVariant, noArgs, NULL, args)) + { + retVariant.MakeNull(); + } + return retVariant; +} + wxVariant wxAutomationObject::CallMethod(const wxString& member, const wxVariant& arg1, const wxVariant& arg2, const wxVariant& arg3, const wxVariant& arg4, @@ -314,6 +324,15 @@ wxVariant wxAutomationObject::CallMethod(const wxString& member, } // Get/Set property +wxVariant wxAutomationObject::GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const +{ + wxVariant retVariant; + if (!Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args)) + { + retVariant.MakeNull(); + } + return retVariant; +} wxVariant wxAutomationObject::GetProperty(const wxString& property, int noArgs, wxVariant args[]) const { wxVariant retVariant; @@ -380,6 +399,16 @@ bool wxAutomationObject::PutProperty(const wxString& property, int noArgs, wxVar return TRUE; } +bool wxAutomationObject::PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args) +{ + wxVariant retVariant; + if (!Invoke(property, DISPATCH_PROPERTYPUT, retVariant, noArgs, NULL, args)) + { + return FALSE; + } + return TRUE; +} + bool wxAutomationObject::PutProperty(const wxString& property, const wxVariant& arg1, const wxVariant& arg2, const wxVariant& arg3, const wxVariant& arg4, @@ -442,6 +471,25 @@ WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, i return (WXIDISPATCH*) NULL; } +// Uses DISPATCH_PROPERTYGET +// and returns a dispatch pointer. The calling code should call Release +// on the pointer, though this could be implicit by constructing an wxAutomationObject +// with it and letting the destructor call Release. +WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const +{ + wxVariant retVariant; + if (Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args)) + { + if (retVariant.GetType() == wxT("void*")) + { + return (WXIDISPATCH*) retVariant.GetVoidPtr(); + } + } + + return (WXIDISPATCH*) NULL; +} + + // A way of initialising another wxAutomationObject with a dispatch object bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, wxVariant args[]) const { @@ -455,6 +503,19 @@ bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& prop return FALSE; } +// A way of initialising another wxAutomationObject with a dispatch object +bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const +{ + WXIDISPATCH* dispatch = GetDispatchProperty(property, noArgs, args); + if (dispatch) + { + obj.SetDispatchPtr(dispatch); + return TRUE; + } + else + return FALSE; +} + // Get a dispatch pointer from the current object associated // with a class id bool wxAutomationObject::GetInstance(const wxString& classId) const @@ -527,7 +588,12 @@ bool ConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant) wxString type(variant.GetType()); - if (type == wxT("long")) + if (type == wxT("char")) + { + oleVariant.vt=VT_I1; // Signed Char + oleVariant.cVal=variant.GetChar(); + } + else if (type == wxT("long")) { oleVariant.vt = VT_I4; oleVariant.lVal = variant.GetLong() ; -- 2.45.2