1998-12-08 18:54:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/msw/ole/automtn.h
|
1998-12-08 18:54:05 +00:00
|
|
|
// Purpose: OLE automation utilities
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 11/6/98
|
|
|
|
// Copyright: (c) 1998, Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-12-08 18:54:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_AUTOMTN_H_
|
|
|
|
#define _WX_AUTOMTN_H_
|
|
|
|
|
2006-09-24 13:12:56 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_OLE_AUTOMATION
|
|
|
|
|
1998-12-08 18:54:05 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/variant.h"
|
|
|
|
|
|
|
|
typedef void WXIDISPATCH;
|
|
|
|
typedef unsigned short* WXBSTR;
|
2012-08-05 22:44:31 +00:00
|
|
|
typedef unsigned long WXLCID;
|
1998-12-08 18:54:05 +00:00
|
|
|
|
1999-02-07 17:11:44 +00:00
|
|
|
#ifdef GetObject
|
|
|
|
#undef GetObject
|
|
|
|
#endif
|
|
|
|
|
2010-11-26 13:30:37 +00:00
|
|
|
// Flags used with wxAutomationObject::GetInstance()
|
|
|
|
enum wxAutomationInstanceFlags
|
|
|
|
{
|
|
|
|
// Only use the existing instance, never create a new one.
|
|
|
|
wxAutomationInstance_UseExistingOnly = 0,
|
|
|
|
|
|
|
|
// Create a new instance if there are no existing ones.
|
2011-02-19 12:33:08 +00:00
|
|
|
wxAutomationInstance_CreateIfNeeded = 1,
|
|
|
|
|
|
|
|
// Do not log errors if we failed to get the existing instance because none
|
|
|
|
// is available.
|
|
|
|
wxAutomationInstance_SilentIfNone = 2
|
2010-11-26 13:30:37 +00:00
|
|
|
};
|
|
|
|
|
1998-12-08 18:54:05 +00:00
|
|
|
/*
|
|
|
|
* wxAutomationObject
|
|
|
|
* Wraps up an IDispatch pointer and invocation; does variant conversion.
|
|
|
|
*/
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxAutomationObject: public wxObject
|
1998-12-08 18:54:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxAutomationObject();
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Set/get dispatch pointer
|
2009-01-25 12:04:25 +00:00
|
|
|
void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; }
|
|
|
|
WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
|
|
|
|
bool IsOk() const { return m_dispatchPtr != NULL; }
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Get a dispatch pointer from the current object associated
|
2010-11-26 13:30:25 +00:00
|
|
|
// with a ProgID, such as "Excel.Application"
|
2010-11-26 13:30:37 +00:00
|
|
|
bool GetInstance(const wxString& progId,
|
|
|
|
int flags = wxAutomationInstance_CreateIfNeeded) const;
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2010-11-26 13:30:37 +00:00
|
|
|
// Get a dispatch pointer from a new instance of the class
|
2010-11-26 13:30:25 +00:00
|
|
|
bool CreateInstance(const wxString& progId) const;
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Low-level invocation function. Pass either an array of variants,
|
|
|
|
// or an array of pointers to variants.
|
1998-12-08 18:54:05 +00:00
|
|
|
bool Invoke(const wxString& member, int action,
|
|
|
|
wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const;
|
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Invoke a member function
|
|
|
|
wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
|
|
|
|
wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args);
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Convenience function
|
|
|
|
wxVariant CallMethod(const wxString& method,
|
|
|
|
const wxVariant& arg1 = wxNullVariant, const wxVariant& arg2 = wxNullVariant,
|
|
|
|
const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
|
|
|
|
const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// Get/Put property
|
2009-01-19 13:55:27 +00:00
|
|
|
wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
|
2004-08-16 12:45:46 +00:00
|
|
|
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);
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2002-06-26 07:33:02 +00:00
|
|
|
bool PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args);
|
1998-12-08 18:54:05 +00:00
|
|
|
bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ;
|
2004-08-16 12:45:46 +00:00
|
|
|
bool PutProperty(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);
|
|
|
|
|
|
|
|
// 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.
|
1998-12-08 18:54:05 +00:00
|
|
|
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const;
|
2002-06-23 14:10:32 +00:00
|
|
|
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const;
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2004-08-16 12:45:46 +00:00
|
|
|
// A way of initialising another wxAutomationObject with a dispatch object,
|
|
|
|
// without having to deal with nasty IDispatch pointers.
|
2009-01-19 13:55:27 +00:00
|
|
|
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
|
2004-08-16 12:45:46 +00:00
|
|
|
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2012-07-31 10:31:55 +00:00
|
|
|
// Returns the locale identifier used in automation calls. The default is
|
|
|
|
// LOCALE_SYSTEM_DEFAULT. Objects obtained by GetObject() inherit the
|
|
|
|
// locale identifier from the one that created them.
|
2012-08-05 22:44:31 +00:00
|
|
|
WXLCID GetLCID() const;
|
2012-07-31 10:31:55 +00:00
|
|
|
|
|
|
|
// Sets the locale identifier to be used in automation calls performed by
|
|
|
|
// this object. The default is LOCALE_SYSTEM_DEFAULT.
|
2012-08-05 22:44:31 +00:00
|
|
|
void SetLCID(WXLCID lcid);
|
2012-07-31 10:31:55 +00:00
|
|
|
|
2013-10-14 15:08:35 +00:00
|
|
|
// Returns the flags used for conversions between wxVariant and OLE
|
2013-11-12 18:06:37 +00:00
|
|
|
// VARIANT, see wxOleConvertVariantFlags. The default value is
|
2013-10-14 15:08:35 +00:00
|
|
|
// wxOleConvertVariant_Default but all the objects obtained by GetObject()
|
|
|
|
// inherit the flags from the one that created them.
|
|
|
|
long GetConvertVariantFlags() const;
|
|
|
|
|
|
|
|
// Sets the flags used for conversions between wxVariant and OLE VARIANT,
|
2013-11-12 18:06:37 +00:00
|
|
|
// see wxOleConvertVariantFlags (default is wxOleConvertVariant_Default.
|
2013-10-14 15:08:35 +00:00
|
|
|
void SetConvertVariantFlags(long flags);
|
|
|
|
|
2012-07-31 10:31:55 +00:00
|
|
|
public: // public for compatibility only, don't use m_dispatchPtr directly.
|
1998-12-08 18:54:05 +00:00
|
|
|
WXIDISPATCH* m_dispatchPtr;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
2012-07-31 10:31:55 +00:00
|
|
|
private:
|
2012-08-05 22:44:31 +00:00
|
|
|
WXLCID m_lcid;
|
2013-10-14 15:08:35 +00:00
|
|
|
long m_convertVariantFlags;
|
2012-07-31 10:31:55 +00:00
|
|
|
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxAutomationObject);
|
1998-12-08 18:54:05 +00:00
|
|
|
};
|
|
|
|
|
2006-09-24 13:12:56 +00:00
|
|
|
#endif // wxUSE_OLE_AUTOMATION
|
1998-12-08 18:54:05 +00:00
|
|
|
|
2006-09-24 13:12:56 +00:00
|
|
|
#endif // _WX_AUTOMTN_H_
|