summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-25 08:21:29 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-25 08:21:29 +0000
commitafdc2b89bd11699fc44a473c8f890e175c728f52 (patch)
treea2e40fb9f75a690826c4856180fbd99d5d96b8a4
parent38321af30c6c797262c1e8c24da74d979dc88028 (diff)
support some kind of method of word. [ruby-Bugs#3237]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/win32ole/win32ole.c27
-rw-r--r--test/win32ole/test_word.rb37
3 files changed, 57 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index e202497c9a..7b67dd6e39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jun 25 17:18:33 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * ext/win32ole/win32ole.c(ole_invoke): support some kind of
+ method of word. [ruby-Bugs#3237]
+
+ * test/win32ole/test_word.rb: ditto.
+
Sat Jun 24 23:37:41 2006 Tanaka Akira <akr@m17n.org>
* eval.c (rb_eval): use rb_ary_new2 instead of rb_ary_new4 to avoid
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 6384c9e2cf..0381bb2003 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -79,7 +79,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.7.8"
+#define WIN32OLE_VERSION "0.7.9"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -2420,6 +2420,18 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
&op.dp, &result,
&excepinfo, &argErr);
+ /* mega kludge. if a method in WORD is called and we ask
+ * for a result when one is not returned then
+ * hResult == DISP_E_EXCEPTION. this only happens on
+ * functions whose DISPID > 0x8000 */
+ if ((hr == DISP_E_EXCEPTION || hr == DISP_E_MEMBERNOTFOUND) && DispID > 0x8000) {
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, NULL,
+ &excepinfo, &argErr);
+
+ }
for(i = cNamedArgs; i < op.dp.cArgs; i++) {
n = op.dp.cArgs - i + cNamedArgs - 1;
VariantClear(&op.dp.rgvarg[n]);
@@ -2447,19 +2459,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
}
}
- /* mega kludge. if a method in WORD is called and we ask
- * for a result when one is not returned then
- * hResult == DISP_E_EXCEPTION. this only happens on
- * functions whose DISPID > 0x8000 */
- if (hr == DISP_E_EXCEPTION && DispID > 0x8000) {
- VariantInit(&result);
- memset(&excepinfo, 0, sizeof(EXCEPINFO));
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
- &IID_NULL, lcid, wFlags,
- &op.dp, &result,
- &excepinfo, &argErr);
-
- }
}
/* clear dispatch parameter */
if(op.dp.cArgs > cNamedArgs) {
diff --git a/test/win32ole/test_word.rb b/test/win32ole/test_word.rb
new file mode 100644
index 0000000000..49904809ae
--- /dev/null
+++ b/test/win32ole/test_word.rb
@@ -0,0 +1,37 @@
+#
+# This is test for [ruby-Bugs#3237]
+#
+begin
+ require 'win32ole'
+rescue LoadError
+end
+require "test/unit"
+
+if defined?(WIN32OLE)
+ class TestWIN32OLE_WORD < Test::Unit::TestCase
+
+ def setup
+ begin
+ @obj = WIN32OLE.new('Word.Application')
+ rescue WIN32OLERuntimeError
+ @obj = nil
+ end
+ end
+
+ def test_ole_methods
+ if @obj
+ @obj.visible = true
+ @obj.wordbasic.disableAutoMacros(true)
+ assert(true)
+ end
+ end
+
+ def teardown
+ if @obj
+ @obj.quit
+ @obj = nil
+ end
+ end
+
+ end
+end