From aff59389658461630206c3683d84bd754555bc30 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 9 Oct 2020 18:57:15 +1100 Subject: [PATCH] msado15: Implement _Command get/putref ActiveConnection. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/msado15/command.c | 20 ++++++++++++++++---- dlls/msado15/tests/msado15.c | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c index eb7b3a035eb..d19108a1a25 100644 --- a/dlls/msado15/command.c +++ b/dlls/msado15/command.c @@ -35,6 +35,7 @@ struct command LONG ref; CommandTypeEnum type; BSTR text; + _Connection *connection; }; static inline struct command *impl_from_Command( _Command *iface ) @@ -80,6 +81,7 @@ static ULONG WINAPI command_Release( _Command *iface ) if (!ref) { TRACE( "destroying %p\n", command ); + if (command->connection) _Connection_Release(command->connection); heap_free( command->text ); heap_free( command ); } @@ -121,14 +123,23 @@ static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **prop static HRESULT WINAPI command_get_ActiveConnection( _Command *iface, _Connection **connection ) { - FIXME( "%p, %p\n", iface, connection ); - return E_NOTIMPL; + struct command *command = impl_from_Command( iface ); + TRACE( "%p, %p\n", iface, connection ); + + *connection = command->connection; + if (command->connection) _Connection_AddRef(command->connection); + return S_OK; } static HRESULT WINAPI command_putref_ActiveConnection( _Command *iface, _Connection *connection ) { - FIXME( "%p, %p\n", iface, connection ); - return E_NOTIMPL; + struct command *command = impl_from_Command( iface ); + TRACE( "%p, %p\n", iface, connection ); + + if (command->connection) _Connection_Release(command->connection); + command->connection = connection; + if (command->connection) _Connection_AddRef(command->connection); + return S_OK; } static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection ) @@ -343,6 +354,7 @@ HRESULT Command_create( void **obj ) command->Command_iface.lpVtbl = &command_vtbl; command->type = adCmdUnknown; command->text = NULL; + command->connection = NULL; command->ref = 1; *obj = &command->Command_iface; diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index efcee58c561..378c2eb918c 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -850,6 +850,7 @@ static void test_Command(void) Command25 *command25; CommandTypeEnum cmd_type = adCmdUnspecified; BSTR cmd_text = (BSTR)"test"; + _Connection *connection; hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command ); ok( hr == S_OK, "got %08x\n", hr ); @@ -903,6 +904,14 @@ static void test_Command(void) ok( hr == S_OK, "got %08x\n", hr ); ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) ); + connection = (_Connection*)0xdeadbeef; + hr = _Command_get_ActiveConnection( command, &connection ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( connection == NULL, "got %p\n", connection ); + + hr = _Command_putref_ActiveConnection( command, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + _Command_Release( command ); }