]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow setting LCID used by wxAutomationObject.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 31 Jul 2012 10:31:55 +0000 (10:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 31 Jul 2012 10:31:55 +0000 (10:31 +0000)
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

docs/changes.txt
include/wx/msw/ole/automtn.h
interface/wx/msw/ole/automtn.h
src/msw/ole/automtn.cpp

index 8d14d1b2689ba8e717beabf704256794f3dfbc47..29f4ca057ad3f392673c0ee85c1add2aa85ee897 100644 (file)
@@ -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)
index d38de41be7c8af4be0d92a64fe1450209ef463e5..4f7ea97dd7078af9ee2063b3da5b99c58c58c03f 100644 (file)
@@ -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);
 };
 
index e30c984754dd50665bfa3bd56e6666357dbcde9c..9e7f3287a8ad23a96df5e207459703996bcbaaef 100644 (file)
@@ -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);
+
 };
 
index 10e9063a735ebec499f598e91c3997d38cbc1f2a..9c3600dd121e7466eb8dc6826db39611750372ed 100644 (file)
@@ -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,