diff options
author | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-19 13:15:59 +0000 |
---|---|---|
committer | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-19 13:15:59 +0000 |
commit | 99af0f64f69c502d2162e883fdca3ae4b856f5b7 (patch) | |
tree | 9ed5b7366120bdd27570cdc1ef41ccc7f850bc67 /ext | |
parent | 2b94347ae8ac1f77a4c5fc2be4a255eaf475bdf8 (diff) | |
download | ruby-99af0f64f69c502d2162e883fdca3ae4b856f5b7.tar.gz ruby-99af0f64f69c502d2162e883fdca3ae4b856f5b7.tar.xz ruby-99af0f64f69c502d2162e883fdca3ae4b856f5b7.zip |
support some kind of method of word. [ruby-Bugs#3237]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/win32ole/tests/test_propertyputref.rb | 2 | ||||
-rw-r--r-- | ext/win32ole/tests/test_word.rb | 37 | ||||
-rw-r--r-- | ext/win32ole/tests/testall.rb | 1 | ||||
-rw-r--r-- | ext/win32ole/win32ole.c | 27 |
4 files changed, 52 insertions, 15 deletions
diff --git a/ext/win32ole/tests/test_propertyputref.rb b/ext/win32ole/tests/test_propertyputref.rb index 742a53b57..befc35ca9 100644 --- a/ext/win32ole/tests/test_propertyputref.rb +++ b/ext/win32ole/tests/test_propertyputref.rb @@ -5,7 +5,7 @@ class TestWIN32OLE_PROPERTYPUTREF < Test::Unit::TestCase def setup begin @sapi = WIN32OLE.new('SAPI.SpVoice') - rescue WIN32OLERuntimeErro + rescue WIN32OLERuntimeError @sapi = nil end end diff --git a/ext/win32ole/tests/test_word.rb b/ext/win32ole/tests/test_word.rb new file mode 100644 index 000000000..764af437d --- /dev/null +++ b/ext/win32ole/tests/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 < 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 diff --git a/ext/win32ole/tests/testall.rb b/ext/win32ole/tests/testall.rb index 51727d874..d45541f57 100644 --- a/ext/win32ole/tests/testall.rb +++ b/ext/win32ole/tests/testall.rb @@ -11,4 +11,5 @@ require "testVARIANT" require "testNIL2VTEMPTY" require "test_ole_methods.rb" require "test_propertyputref.rb" +require "test_word.rb" # require "testOLEEVENT" diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 96a2c096e..6b7d2569d 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -78,7 +78,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "0.6.8" +#define WIN32OLE_VERSION "0.6.9" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -2101,6 +2101,18 @@ ole_invoke(argc, argv, self, wFlags) &IID_NULL, lcid, wFlags, &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]); @@ -2127,19 +2139,6 @@ ole_invoke(argc, argv, self, wFlags) } } - /* 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) { - memset(&excepinfo, 0, sizeof(EXCEPINFO)); - VariantInit(&result); - 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) { |