Allow setting LCID used by wxAutomationObject.
Default user-locale-dependent LCID may be inappropriate for some situations, notably Microsoft Excel uses localized formula names for non-English LCIDs. So add a way to change the LCID to use at wxAutomationObject level while preserving the old behaviour by default. Closes #14540. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72265 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -547,6 +547,7 @@ wxGTK:
|
||||
wxMSW:
|
||||
|
||||
- Add support for CURRENCY and SCODE types to OLE Automation helpers (PB).
|
||||
- Allow setting LCID used by wxAutomationObject (PB).
|
||||
|
||||
|
||||
2.9.4: (released 2012-07-09)
|
||||
|
@@ -106,9 +106,21 @@ public:
|
||||
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
|
||||
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
|
||||
|
||||
public:
|
||||
// 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.
|
||||
LCID GetLCID() const;
|
||||
|
||||
// Sets the locale identifier to be used in automation calls performed by
|
||||
// this object. The default is LOCALE_SYSTEM_DEFAULT.
|
||||
void SetLCID(LCID lcid);
|
||||
|
||||
public: // public for compatibility only, don't use m_dispatchPtr directly.
|
||||
WXIDISPATCH* m_dispatchPtr;
|
||||
|
||||
private:
|
||||
LCID m_lcid;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxAutomationObject);
|
||||
};
|
||||
|
||||
|
@@ -429,5 +429,30 @@ public:
|
||||
You may need to cast from IDispatch* to WXIDISPATCH* when calling this function.
|
||||
*/
|
||||
void SetDispatchPtr(WXIDISPATCH* dispatchPtr);
|
||||
|
||||
/**
|
||||
Returns the locale identifier used in automation calls.
|
||||
|
||||
The default is LOCALE_SYSTEM_DEFAULT but the objects obtained by
|
||||
GetObject() inherit the locale identifier from the one that created
|
||||
them.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
LCID GetLCID() const;
|
||||
|
||||
/**
|
||||
Sets the locale identifier to be used in automation calls performed by
|
||||
this object.
|
||||
|
||||
The default value is LOCALE_SYSTEM_DEFAULT.
|
||||
|
||||
Notice that any automation objects created by this one inherit the same
|
||||
LCID.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void SetLCID(LCID lcid);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -70,6 +70,7 @@ ShowException(const wxString& member,
|
||||
wxAutomationObject::wxAutomationObject(WXIDISPATCH* dispatchPtr)
|
||||
{
|
||||
m_dispatchPtr = dispatchPtr;
|
||||
m_lcid = LOCALE_SYSTEM_DEFAULT;
|
||||
}
|
||||
|
||||
wxAutomationObject::~wxAutomationObject()
|
||||
@@ -161,7 +162,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
|
||||
// We rely on the fact that wxBasicString is
|
||||
// just BSTR with some methods here.
|
||||
reinterpret_cast<BSTR *>(&argNames[0]),
|
||||
1 + namedArgCount, LOCALE_SYSTEM_DEFAULT, &dispIds[0]);
|
||||
1 + namedArgCount, m_lcid, &dispIds[0]);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ShowException(member, hr);
|
||||
@@ -194,7 +195,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
|
||||
EXCEPINFO excep;
|
||||
wxZeroMemory(excep);
|
||||
|
||||
hr = ((IDispatch*)m_dispatchPtr)->Invoke(dispIds[0], IID_NULL, LOCALE_SYSTEM_DEFAULT,
|
||||
hr = ((IDispatch*)m_dispatchPtr)->Invoke(dispIds[0], IID_NULL, m_lcid,
|
||||
(WORD)action, &dispparams, vReturnPtr, &excep, &uiArgErr);
|
||||
|
||||
if (FAILED(hr))
|
||||
@@ -467,6 +468,7 @@ bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& prop
|
||||
if (dispatch)
|
||||
{
|
||||
obj.SetDispatchPtr(dispatch);
|
||||
obj.SetLCID(GetLCID());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -480,6 +482,7 @@ bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& prop
|
||||
if (dispatch)
|
||||
{
|
||||
obj.SetDispatchPtr(dispatch);
|
||||
obj.SetLCID(GetLCID());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -589,6 +592,16 @@ bool wxAutomationObject::CreateInstance(const wxString& progId) const
|
||||
return m_dispatchPtr != NULL;
|
||||
}
|
||||
|
||||
LCID wxAutomationObject::GetLCID() const
|
||||
{
|
||||
return m_lcid;
|
||||
}
|
||||
|
||||
void wxAutomationObject::SetLCID(LCID lcid)
|
||||
{
|
||||
m_lcid = lcid;
|
||||
}
|
||||
|
||||
static void
|
||||
ShowException(const wxString& member,
|
||||
HRESULT hr,
|
||||
|
Reference in New Issue
Block a user