Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49264 Signed-off-by: Aaro Altonen a.altonen@hotmail.com --- dlls/msado15/command.c | 30 +++++++++++++++++++++++------- dlls/msado15/tests/msado15.c | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c index 9081f1554f..eb7b3a035e 100644 --- a/dlls/msado15/command.c +++ b/dlls/msado15/command.c @@ -31,9 +31,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msado15);
struct command { - _Command Command_iface; - LONG ref; - CommandTypeEnum type; + _Command Command_iface; + LONG ref; + CommandTypeEnum type; + BSTR text; };
static inline struct command *impl_from_Command( _Command *iface ) @@ -79,6 +80,7 @@ static ULONG WINAPI command_Release( _Command *iface ) if (!ref) { TRACE( "destroying %p\n", command ); + heap_free( command->text ); heap_free( command ); } return ref; @@ -137,14 +139,27 @@ static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT con
static HRESULT WINAPI command_get_CommandText( _Command *iface, BSTR *text ) { - FIXME( "%p, %p\n", iface, text ); - return E_NOTIMPL; + struct command *command = impl_from_Command( iface ); + BSTR cmd_text = NULL; + + TRACE( "%p, %p\n", command, text ); + + if (command->text && !(cmd_text = SysAllocString( command->text ))) return E_OUTOFMEMORY; + *text = cmd_text; + return S_OK; }
static HRESULT WINAPI command_put_CommandText( _Command *iface, BSTR text ) { - FIXME( "%p, %s\n", iface, debugstr_w(text) ); - return E_NOTIMPL; + struct command *command = impl_from_Command( iface ); + WCHAR *source = NULL; + + TRACE( "%p, %s\n", command, debugstr_w( text ) ); + + if (text && !(source = strdupW( text ))) return E_OUTOFMEMORY; + heap_free( command->text ); + command->text = source; + return S_OK; }
static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout ) @@ -327,6 +342,7 @@ HRESULT Command_create( void **obj ) if (!(command = heap_alloc( sizeof(*command) ))) return E_OUTOFMEMORY; command->Command_iface.lpVtbl = &command_vtbl; command->type = adCmdUnknown; + command->text = NULL; command->ref = 1;
*obj = &command->Command_iface; diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index b17430a93d..0125f228b2 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -743,6 +743,7 @@ static void test_Command(void) Command15 *command15; Command25 *command25; CommandTypeEnum cmd_type = adCmdUnspecified; + BSTR cmd_text = (BSTR)"test";
hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command ); ok( hr == S_OK, "got %08x\n", hr ); @@ -771,6 +772,31 @@ static void test_Command(void) hr = _Command_put_CommandType( command, 0xdeadbeef ); ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08x\n", hr );
+ hr = _Command_get_CommandText( command, &cmd_text ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( !cmd_text, "got %s\n", cmd_text ); + + hr = _Command_put_CommandText( command, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + cmd_text = SysAllocString( L"" ); + hr = _Command_put_CommandText( command, cmd_text ); + ok( hr == S_OK, "got %08x\n", hr ); + SysFreeString( cmd_text ); + + hr = _Command_get_CommandText( command, &cmd_text ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( cmd_text && !*cmd_text, "got %p\n", cmd_text ); + + cmd_text = SysAllocString( L"test" ); + hr = _Command_put_CommandText( command, cmd_text ); + ok( hr == S_OK, "got %08x\n", hr ); + SysFreeString( cmd_text ); + + hr = _Command_get_CommandText( command, &cmd_text ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) ); + _Command_Release( command ); }