ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
24 participants
322 discussions
Start a n
N
ew thread
[reactos] 01/01: [RPCRT4_WINETEST] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e797f0ae7622bd5577e0…
commit 9e797f0ae7622bd5577e042d60a95fabe99438d3 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:12:54 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:12:54 2019 +0100 [RPCRT4_WINETEST] Sync with Wine Staging 4.18. CORE-16441 --- modules/rostests/winetests/rpcrt4/CMakeLists.txt | 10 +- modules/rostests/winetests/rpcrt4/server.c | 337 ++++++++++++++++++--- modules/rostests/winetests/rpcrt4/server.idl | 70 ++++- .../rostests/winetests/rpcrt4/server_interp.idl | 26 ++ 4 files changed, 403 insertions(+), 40 deletions(-) diff --git a/modules/rostests/winetests/rpcrt4/CMakeLists.txt b/modules/rostests/winetests/rpcrt4/CMakeLists.txt index 4eeac9d3af2..e92f9bbfad0 100644 --- a/modules/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/modules/rostests/winetests/rpcrt4/CMakeLists.txt @@ -8,10 +8,14 @@ add_definitions( include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(OLD_IDL_FLAGS ${IDL_FLAGS}) -set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_) +set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_ -Os --prefix-client=mixed_) add_rpc_files(client server.idl) add_rpc_files(server server.idl) set(IDL_FLAGS ${OLD_IDL_FLAGS}) +set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_ -Oicf --prefix-client=interp_) +add_rpc_files(client server_interp.idl) +add_rpc_files(server server_interp.idl) +set(IDL_FLAGS ${OLD_IDL_FLAGS}) add_rpcproxy_files(cstub.idl) list(APPEND SOURCE @@ -25,7 +29,9 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cstub_p.c ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${CMAKE_CURRENT_BINARY_DIR}/server_c.c - ${CMAKE_CURRENT_BINARY_DIR}/server_s.c) + ${CMAKE_CURRENT_BINARY_DIR}/server_s.c + ${CMAKE_CURRENT_BINARY_DIR}/server_interp_c.c + ${CMAKE_CURRENT_BINARY_DIR}/server_interp_s.c) if(MSVC) # The nmake generator misses this dependency, so set it explicitly until this bug is fixed. diff --git a/modules/rostests/winetests/rpcrt4/server.c b/modules/rostests/winetests/rpcrt4/server.c index 2a66a38aab3..592ee9d9a90 100644 --- a/modules/rostests/winetests/rpcrt4/server.c +++ b/modules/rostests/winetests/rpcrt4/server.c @@ -27,6 +27,8 @@ #include <netfw.h> #include "wine/test.h" #include "server_s.h" +#define SKIP_TYPE_DECLS +#include "server_interp_s.h" #include "server_defines.h" #include <stddef.h> @@ -53,12 +55,213 @@ static RPC_STATUS (WINAPI *pRpcServerRegisterAuthInfoA)(RPC_CSTR, ULONG, RPC_AUT static char *domain_and_user; +static int (__cdecl *int_return)(void); +static int (__cdecl *square)(int x); +static int (__cdecl *sum)(int x, int y); +static signed char (__cdecl *sum_char)(signed char x, signed char y); +static short (__cdecl *sum_short)(short x, short y); +static int (__cdecl *sum_float)(float x, float y); +static int (__cdecl *sum_double_int)(int x, double y); +static hyper (__cdecl *sum_hyper)(hyper x, hyper y); +static int (__cdecl *sum_hyper_int)(hyper x, hyper y); +static int (__cdecl *sum_char_hyper)(signed char x, hyper y); +static void (__cdecl *square_out)(int x, int *y); +static void (__cdecl *square_ref)(int *x); +static int (__cdecl *str_length)(const char *s); +static int (__cdecl *str_t_length)(str_t s); +static int (__cdecl *cstr_length)(const char *s, int n); +static int (__cdecl *dot_self)(vector_t *v); +static double (__cdecl *square_half)(double x, double *y); +static float (__cdecl *square_half_float)(float x, float *y); +static LONG (__cdecl *square_half_long)(LONG x, LONG *y); +static int (__cdecl *sum_fixed_array)(int a[5]); +static int (__cdecl *pints_sum)(pints_t *pints); +static double (__cdecl *ptypes_sum)(ptypes_t *ptypes); +static int (__cdecl *dot_pvectors)(pvectors_t *pvectors); +static int (__cdecl *sum_sp)(sp_t *sp); +static double (__cdecl *square_sun)(sun_t *su); +static int (__cdecl *test_list_length)(test_list_t *ls); +static int (__cdecl *sum_fixed_int_3d)(int m[2][3][4]); +static int (__cdecl *sum_conf_array)(int x[], int n); +static int (__cdecl *sum_conf_ptr_by_conf_ptr)(int n1, int *n2_then_x1, int *x2); +static int (__cdecl *sum_unique_conf_array)(int x[], int n); +static int (__cdecl *sum_unique_conf_ptr)(int *x, int n); +static int (__cdecl *sum_var_array)(int x[20], int n); +static int (__cdecl *dot_two_vectors)(vector_t vs[2]); +static void (__cdecl *get_number_array)(int x[20], int *n); +static int (__cdecl *sum_cs)(cs_t *cs); +static int (__cdecl *sum_cps)(cps_t *cps); +static int (__cdecl *sum_cpsc)(cpsc_t *cpsc); +static int (__cdecl *get_cpsc)(int n, cpsc_t *cpsc); +static int (__cdecl *sum_complex_array)(int n, refpint_t pi[]); +static int (__cdecl *square_puint)(puint_t p); +static int (__cdecl *sum_puints)(puints_t *p); +static int (__cdecl *sum_cpuints)(cpuints_t *p); +static int (__cdecl *dot_copy_vectors)(vector_t u, vector_t v); +static double (__cdecl *square_encu)(encu_t *eu); +static double (__cdecl *square_unencu)(int t, unencu_t *eu); +static int (__cdecl *sum_parr)(int *a[3]); +static int (__cdecl *sum_pcarr)(int *a[], int n); +static int (__cdecl *enum_ord)(e_t e); +static double (__cdecl *square_encue)(encue_t *eue); +static void (__cdecl *check_se2)(se_t *s); +static int (__cdecl *sum_toplev_conf_2n)(int *x, int n); +static int (__cdecl *sum_toplev_conf_cond)(int *x, int a, int b, int c); +static int (__cdecl *square_test_us)(test_us_t *tus); +static double (__cdecl *sum_aligns)(aligns_t *a); +static int (__cdecl *sum_padded)(padded_t *p); +static int (__cdecl *sum_padded2)(padded_t ps[2]); +static int (__cdecl *sum_padded_conf)(padded_t *ps, int n); +static int (__cdecl *sum_bogus)(bogus_t *b); +static void (__cdecl *check_null)(int *null); +static int (__cdecl *str_struct_len)(str_struct_t *s); +static int (__cdecl *wstr_struct_len)(wstr_struct_t *s); +static int (__cdecl *sum_doub_carr)(doub_carr_t *dc); +static void (__cdecl *make_pyramid_doub_carr)(unsigned char n, doub_carr_t **dc); +static unsigned (__cdecl *hash_bstr)(bstr_t s); +static void (__cdecl *get_a_bstr)(bstr_t *s); +static void (__cdecl *get_name)(name_t *name); +static void (__cdecl *get_names)(int *n, str_array_t *names); +static void (__cdecl *get_namesw)(int *n, wstr_array_t *names); +static int (__cdecl *sum_pcarr2)(int n, int **pa); +static int (__cdecl *sum_L1_norms)(int n, vector_t *vs); +static s123_t* (__cdecl *get_s123)(void); +static void (__cdecl *get_numbers)(int length, int size, pints_t pn[]); +static void (__cdecl *get_numbers_struct)(numbers_struct_t **ns); +static str_t (__cdecl *get_filename)(void); +static rint_t (__cdecl *echo_ranged_int)(int i, int j, int k); +static rint_t (__cdecl *echo_ranged_int2)(int i); +static void (__cdecl *get_ranged_enum)(renum_t *re); +static void (__cdecl *context_handle_test)(void); +static void (__cdecl *full_pointer_test)(int *a, int *b); +static void (__cdecl *full_pointer_null_test)(int *a, int *b); +static void (__cdecl *authinfo_test)(unsigned int protseq, int secure); +static void (__cdecl *stop)(void); +static void (__cdecl *stop_autolisten)(void); +static void (__cdecl *ip_test)(ipu_t *a); +static int (__cdecl *sum_ptr_array)(int *a[2]); +static int (__cdecl *sum_array_ptr)(int (*a)[2]); +static ctx_handle_t (__cdecl *get_handle)(void); +static void (__cdecl *get_handle_by_ptr)(ctx_handle_t *r); +static void (__cdecl *test_handle)(ctx_handle_t ctx_handle); + +#define SERVER_FUNCTIONS \ + X(int_return) \ + X(square) \ + X(sum) \ + X(sum_char) \ + X(sum_short) \ + X(sum_float) \ + X(sum_double_int) \ + X(sum_hyper) \ + X(sum_hyper_int) \ + X(sum_char_hyper) \ + X(square_out) \ + X(square_ref) \ + X(str_length) \ + X(str_t_length) \ + X(cstr_length) \ + X(dot_self) \ + X(square_half) \ + X(square_half_float) \ + X(square_half_long) \ + X(sum_fixed_array) \ + X(pints_sum) \ + X(ptypes_sum) \ + X(dot_pvectors) \ + X(sum_sp) \ + X(square_sun) \ + X(test_list_length) \ + X(sum_fixed_int_3d) \ + X(sum_conf_array) \ + X(sum_conf_ptr_by_conf_ptr) \ + X(sum_unique_conf_array) \ + X(sum_unique_conf_ptr) \ + X(sum_var_array) \ + X(dot_two_vectors) \ + X(get_number_array) \ + X(sum_cs) \ + X(sum_cps) \ + X(sum_cpsc) \ + X(get_cpsc) \ + X(sum_complex_array) \ + X(square_puint) \ + X(sum_puints) \ + X(sum_cpuints) \ + X(dot_copy_vectors) \ + X(square_encu) \ + X(square_unencu) \ + X(sum_parr) \ + X(sum_pcarr) \ + X(enum_ord) \ + X(square_encue) \ + X(check_se2) \ + X(sum_toplev_conf_2n) \ + X(sum_toplev_conf_cond) \ + X(square_test_us) \ + X(sum_aligns) \ + X(sum_padded) \ + X(sum_padded2) \ + X(sum_padded_conf) \ + X(sum_bogus) \ + X(check_null) \ + X(str_struct_len) \ + X(wstr_struct_len) \ + X(sum_doub_carr) \ + X(make_pyramid_doub_carr) \ + X(hash_bstr) \ + X(get_a_bstr) \ + X(get_name) \ + X(get_names) \ + X(get_namesw) \ + X(sum_pcarr2) \ + X(sum_L1_norms) \ + X(get_s123) \ + X(get_numbers) \ + X(get_numbers_struct) \ + X(get_filename) \ + X(echo_ranged_int) \ + X(echo_ranged_int2) \ + X(get_ranged_enum) \ + X(context_handle_test) \ + X(full_pointer_test) \ + X(full_pointer_null_test) \ + X(authinfo_test) \ + X(stop) \ + X(stop_autolisten) \ + X(ip_test) \ + X(sum_ptr_array) \ + X(sum_array_ptr) \ + X(get_handle) \ + X(get_handle_by_ptr) \ + X(test_handle) + /* type check statements generated in header file */ fnprintf *p_printf = printf; static const WCHAR helloW[] = { 'H','e','l','l','o',0 }; static const WCHAR worldW[] = { 'W','o','r','l','d','!',0 }; +static BOOL is_interp; + +static void set_interp_interface(void) +{ + is_interp = TRUE; + +#define X(name) name = interp_##name; + SERVER_FUNCTIONS +#undef X +} + +static void set_mixed_interface(void) +{ + is_interp = FALSE; + +#define X(name) name = mixed_##name; + SERVER_FUNCTIONS +#undef X +} + static void InitFunctionPointers(void) { HMODULE hrpcrt4 = GetModuleHandleA("rpcrt4.dll"); @@ -871,6 +1074,26 @@ int __cdecl s_sum_array_ptr(int (*a)[2]) return (*a)[0] + (*a)[1]; } +ctx_handle_t __cdecl s_get_handle(void) +{ + return (ctx_handle_t)0xdeadbeef; +} + +void __cdecl s_get_handle_by_ptr(ctx_handle_t *r) +{ + *r = (ctx_handle_t)0xdeadbeef; +} + +void __cdecl s_test_handle(ctx_handle_t ctx_handle) +{ + ok(ctx_handle == (ctx_handle_t)0xdeadbeef, "Unexpected ctx_handle %p\n", ctx_handle); +} + +void __RPC_USER ctx_handle_t_rundown(ctx_handle_t ctx_handle) +{ + ok(ctx_handle == (ctx_handle_t)0xdeadbeef, "Unexpected ctx_handle %p\n", ctx_handle); +} + static void make_cmdline(char buffer[MAX_PATH], const char *test) { @@ -1043,9 +1266,11 @@ basic_tests(void) check_null(NULL); + if (!is_interp || sizeof(void*) != 8) { /* broken in widl for win64 */ str = get_filename(); ok(!strcmp(str, __FILE__), "get_filename() returned %s instead of %s\n", str, __FILE__); midl_user_free(str); + } x = echo_ranged_int(0,0,0); ok(x == 0, "echo_ranged_int() returned %d instead of 0\n", x); @@ -1323,6 +1548,7 @@ pointer_tests(void) ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name); HeapFree(GetProcessHeap(), 0, name.name); + if (!is_interp) { /* broken in widl */ n = -1; names = NULL; get_names(&n, &names); @@ -1342,10 +1568,13 @@ pointer_tests(void) MIDL_user_free(namesw[0]); MIDL_user_free(namesw[1]); MIDL_user_free(namesw); + } } + if (!is_interp) { /* broken in widl */ pa2 = a; ok(sum_pcarr2(4, &pa2) == 10, "RPC sum_pcarr2\n"); + } s123 = get_s123(); ok(s123->f1 == 1 && s123->f2 == 2 && s123->f3 == 3, "RPC get_s123\n"); @@ -1606,6 +1835,16 @@ void __cdecl s_authinfo_test(unsigned int protseq, int secure) } } +static void test_handle_return(void) +{ + ctx_handle_t handle, handle2; + + handle = get_handle(); + test_handle(handle); + get_handle_by_ptr(&handle2); + test_handle(handle2); +} + static void run_tests(void) { @@ -1614,6 +1853,7 @@ run_tests(void) pointer_tests(); array_tests(); context_handle_test(); + test_handle_return(); } static void @@ -1669,81 +1909,96 @@ client(const char *test) if (strcmp(test, "tcp_basic") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, iptcp, address, port, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); run_tests(); authinfo_test(RPC_PROTSEQ_TCP, 0); - test_is_server_listening2(IServer_IfHandle, RPC_S_OK, RPC_S_ACCESS_DENIED); + test_is_server_listening2(IMixedServer_IfHandle, RPC_S_OK, RPC_S_ACCESS_DENIED); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } else if (strcmp(test, "tcp_secure") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, iptcp, address, port, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); - set_auth_info(IServer_IfHandle); + set_auth_info(IMixedServer_IfHandle); authinfo_test(RPC_PROTSEQ_TCP, 1); - test_is_server_listening(IServer_IfHandle, RPC_S_ACCESS_DENIED); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_ACCESS_DENIED); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } else if (strcmp(test, "ncalrpc_basic") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, ncalrpc, NULL, guid, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); run_tests(); /* can cause RPC_X_BAD_STUB_DATA exception */ authinfo_test(RPC_PROTSEQ_LRPC, 0); - test_is_server_listening(IServer_IfHandle, RPC_S_OK); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } else if (strcmp(test, "ncalrpc_autolisten") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, ncalrpc, NULL, guid, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); run_tests(); authinfo_test(RPC_PROTSEQ_LRPC, 0); todo_wine - test_is_server_listening(IServer_IfHandle, RPC_S_NOT_LISTENING); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_NOT_LISTENING); stop_autolisten(); ok(int_return() == INT_CODE, "RPC int_return\n"); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } else if (strcmp(test, "ncalrpc_secure") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, ncalrpc, NULL, guid, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); - set_auth_info(IServer_IfHandle); + set_auth_info(IMixedServer_IfHandle); authinfo_test(RPC_PROTSEQ_LRPC, 1); - test_is_server_listening(IServer_IfHandle, RPC_S_OK); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } else if (strcmp(test, "np_basic") == 0) { ok(RPC_S_OK == RpcStringBindingComposeA(NULL, np, address_np, pipe, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); - test_is_server_listening(IServer_IfHandle, RPC_S_OK); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); run_tests(); authinfo_test(RPC_PROTSEQ_NMP, 0); - test_is_server_listening(IServer_IfHandle, RPC_S_OK); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); stop(); - test_is_server_listening(IServer_IfHandle, RPC_S_NOT_LISTENING); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_NOT_LISTENING); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); + } + else if (strcmp(test, "np_basic_interp") == 0) + { + set_interp_interface(); + + ok(RPC_S_OK == RpcStringBindingComposeA(NULL, np, address_np, pipe, NULL, &binding), "RpcStringBindingCompose\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IInterpServer_IfHandle), "RpcBindingFromStringBinding\n"); + + test_is_server_listening(IInterpServer_IfHandle, RPC_S_OK); + run_tests(); + authinfo_test(RPC_PROTSEQ_NMP, 0); + test_is_server_listening(IInterpServer_IfHandle, RPC_S_OK); + + ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IInterpServer_IfHandle), "RpcBindingFree\n"); } } @@ -1777,13 +2032,22 @@ server(void) if (pRpcServerRegisterIfEx) { trace("Using RpcServerRegisterIfEx\n"); - status = pRpcServerRegisterIfEx(s_IServer_v0_0_s_ifspec, NULL, NULL, + status = pRpcServerRegisterIfEx(s_IMixedServer_v0_0_s_ifspec, NULL, NULL, + RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %d\n", status); + status = pRpcServerRegisterIfEx(s_IInterpServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %d\n", status); } else - status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + { + status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + status = RpcServerRegisterIf(s_IInterpServer_v0_0_s_ifspec, NULL, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + } test_is_server_listening(NULL, RPC_S_NOT_LISTENING); status = RpcServerListen(1, 20, TRUE); ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); @@ -1807,7 +2071,10 @@ server(void) skip("lrpc tests skipped due to earlier failure\n"); if (np_status == RPC_S_OK) + { + run_client("np_basic_interp"); run_client("np_basic"); + } else { skip("np_basic tests skipped due to earlier failure\n"); @@ -1817,6 +2084,7 @@ server(void) ret = WaitForSingleObject(stop_event, 1000); ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); + /* if the stop event didn't fire then RpcMgmtWaitServerListen will wait * forever, so don't bother calling it in this case */ if (ret == WAIT_OBJECT_0) @@ -1830,14 +2098,14 @@ server(void) if (pRpcServerRegisterIfEx) { - status = pRpcServerRegisterIfEx(s_IServer_v0_0_s_ifspec, NULL, NULL, + status = pRpcServerRegisterIfEx(s_IMixedServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH | RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf() failed: %u\n", status); run_client("ncalrpc_autolisten"); - status = RpcServerUnregisterIf(s_IServer_v0_0_s_ifspec, NULL, TRUE); + status = RpcServerUnregisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, TRUE); ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %u\n", status); } @@ -1848,14 +2116,14 @@ static DWORD WINAPI listen_test_client_thread(void *binding) { RPC_STATUS status; - status = RpcBindingFromStringBindingA(binding, &IServer_IfHandle); + status = RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle); ok(status == RPC_S_OK, "RpcBindingFromStringBinding\n"); - test_is_server_listening(IServer_IfHandle, RPC_S_OK); + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); stop(); trace("stopped\n"); - status = RpcBindingFree(&IServer_IfHandle); + status = RpcBindingFree(&IMixedServer_IfHandle); ok(status == RPC_S_OK, "RpcBindingFree\n"); return 0; } @@ -1930,7 +2198,7 @@ static void test_server_listening(void) status = RpcServerUseProtseqEpA(np, 0, pipe, NULL); ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", status); - status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL); + status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); test_is_server_listening(NULL, RPC_S_NOT_LISTENING); @@ -2009,7 +2277,7 @@ static void run_server(HANDLE ready_event) status = RpcServerUseProtseqEpA(np, 0, pipe, NULL); ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", status); - status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL); + status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); test_is_server_listening(NULL, RPC_S_NOT_LISTENING); @@ -2052,7 +2320,7 @@ static void test_reconnect(void) server_process = create_server_process(); ok(RPC_S_OK == RpcStringBindingComposeA(NULL, np, address_np, pipe, NULL, &binding), "RpcStringBindingCompose\n"); - ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); for (i = 0; i < ARRAY_SIZE(threads); i++) { @@ -2082,7 +2350,7 @@ static void test_reconnect(void) ok(CloseHandle(server_process), "CloseHandle\n"); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); - ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); } static BOOL is_process_elevated(void) @@ -2214,6 +2482,7 @@ START_TEST(server) BOOL firewall_enabled = is_firewall_enabled(), firewall_disabled = FALSE; InitFunctionPointers(); + set_mixed_interface(); ok(!GetUserNameExA(NameSamCompatible, NULL, &size), "GetUserNameExA\n"); domain_and_user = HeapAlloc(GetProcessHeap(), 0, size); diff --git a/modules/rostests/winetests/rpcrt4/server.idl b/modules/rostests/winetests/rpcrt4/server.idl index 7d89445f729..afda2eddd04 100644 --- a/modules/rostests/winetests/rpcrt4/server.idl +++ b/modules/rostests/winetests/rpcrt4/server.idl @@ -25,6 +25,19 @@ import "objidl.idl"; #include "server_defines.h" +#ifndef IFACE_NAME +#define IFACE_NAME IMixedServer +#endif + +#ifndef IFACE_HANDLE +#define IFACE_HANDLE IMixedServer_IfHandle +#endif + +#ifndef ISERVER_UUID +#define ISERVER_UUID 00000000-4114-0704-2301-000000000000 +#endif + +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct tag_vector { int x; @@ -33,17 +46,19 @@ typedef struct tag_vector } vector_t; typedef int fnprintf(const char *format, ...); +cpp_quote("#endif") [ - uuid(00000000-4114-0704-2301-000000000000), - implicit_handle(handle_t IServer_IfHandle) + uuid(ISERVER_UUID), + implicit_handle(handle_t IFACE_HANDLE) ] -interface IServer +interface IFACE_NAME { cpp_quote("#if 0") typedef wchar_t WCHAR; cpp_quote("#endif") +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef [string] char *str_t; typedef [string] WCHAR *wstr_t; @@ -80,6 +95,7 @@ cpp_quote("#endif") int s; } sun_t; +cpp_quote("#endif") int int_return(void); int square(int x); @@ -105,6 +121,7 @@ cpp_quote("#endif") double ptypes_sum(ptypes_t *ptypes); int dot_pvectors(pvectors_t *pvectors); +cpp_quote("#ifndef SKIP_TYPE_DECLS") /* don't use this anywhere except in sp_t */ typedef struct { @@ -116,10 +133,12 @@ cpp_quote("#endif") int x; sp_inner_t *s; } sp_t; +cpp_quote("#endif") int sum_sp(sp_t *sp); double square_sun(sun_t *su); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct test_list { int t; @@ -131,6 +150,7 @@ cpp_quote("#endif") } test_list_t; typedef [ref] int *refpint_t; +cpp_quote("#endif") int test_list_length(test_list_t *ls); int sum_fixed_int_3d(int m[2][3][4]); @@ -142,6 +162,7 @@ cpp_quote("#endif") int dot_two_vectors(vector_t vs[2]); void get_number_array([out, length_is(*n)] int x[20], [out] int *n); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { int n; @@ -163,6 +184,7 @@ cpp_quote("#endif") int b; int c; } cpsc_t; +cpp_quote("#endif") int sum_cs(cs_t *cs); int sum_cps(cps_t *cps); @@ -170,9 +192,12 @@ cpp_quote("#endif") int get_cpsc(int n, [out] cpsc_t *cpsc ); int sum_complex_array(int n, [size_is(n)] refpint_t pi[]); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef [wire_marshal(int)] void *puint_t; +cpp_quote("#endif") int square_puint(puint_t p); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { [size_is(n)] puint_t *ps; @@ -185,11 +210,13 @@ cpp_quote("#endif") [size_is(n)] puint_t *ps; char n; } cpuints_t; +cpp_quote("#endif") int sum_puints(puints_t *p); int sum_cpuints(cpuints_t *p); int dot_copy_vectors(vector_t u, vector_t v); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct wire_us *wire_us_t; typedef [wire_marshal(wire_us_t)] struct us us_t; struct us @@ -204,9 +231,11 @@ cpp_quote("#endif") { us_t us; } test_us_t; +cpp_quote("#endif") int square_test_us(test_us_t *tus); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef union encu switch (int t) { case ENCU_I: int i; @@ -237,6 +266,7 @@ cpp_quote("#endif") { e_t f; } se_t; +cpp_quote("#endif") double square_encu(encu_t *eu); double square_unencu(int t, [switch_is(t)] unencu_t *eu); @@ -249,6 +279,7 @@ cpp_quote("#endif") int sum_toplev_conf_2n([size_is(n * 2)] int *x, int n); int sum_toplev_conf_cond([size_is(c ? a : b)] int *x, int a, int b, int c); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { char c; @@ -256,19 +287,23 @@ cpp_quote("#endif") short s; double d; } aligns_t; +cpp_quote("#endif") double sum_aligns(aligns_t *a); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { int i; char c; } padded_t; +cpp_quote("#endif") int sum_padded(padded_t *p); int sum_padded2(padded_t ps[2]); int sum_padded_conf([size_is(n)] padded_t *ps, int n); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { int *p1; @@ -281,10 +316,12 @@ cpp_quote("#endif") int *p3; char c; } bogus_t; +cpp_quote("#endif") int sum_bogus(bogus_t *b); void check_null([unique] int *null); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { str_t s; @@ -294,10 +331,12 @@ cpp_quote("#endif") { wstr_t s; } wstr_struct_t; +cpp_quote("#endif") int str_struct_len(str_struct_t *s); int wstr_struct_len(wstr_struct_t *s); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { unsigned int n; @@ -309,10 +348,12 @@ cpp_quote("#endif") int n; [size_is(n)] doub_carr_1_t *a[]; } doub_carr_t; +cpp_quote("#endif") int sum_doub_carr(doub_carr_t *dc); void make_pyramid_doub_carr(unsigned char n, [out] doub_carr_t **dc); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { short n; @@ -321,23 +362,29 @@ cpp_quote("#endif") typedef [unique] user_bstr_t *wire_bstr_t; typedef [wire_marshal(wire_bstr_t)] short *bstr_t; +cpp_quote("#endif") unsigned hash_bstr(bstr_t s); void get_a_bstr([out]bstr_t *s); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { [string, size_is(size)] char *name; unsigned int size; } name_t; +cpp_quote("#endif") void get_name([in,out] name_t *name); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef char **str_array_t; - void get_names([out] int *n, [out, string, size_is(,*n)] str_array_t *names); typedef WCHAR **wstr_array_t; +cpp_quote("#endif") + void get_names([out] int *n, [out, string, size_is(,*n)] str_array_t *names); void get_namesw([out] int *n, [out, string, size_is(,*n)] wstr_array_t *names); int sum_pcarr2(int n, [size_is(, n)] int **pa); int sum_L1_norms(int n, [size_is(n)] vector_t *vs); +cpp_quote("#ifndef SKIP_TYPE_DECLS") /* Don't use this except in the get_s123 test. */ typedef struct { @@ -345,23 +392,27 @@ cpp_quote("#endif") int f2; int f3; } s123_t; +cpp_quote("#endif") /* Make sure WIDL generates a type format string for a previously unseen type as a return value. */ s123_t *get_s123(void); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef struct { unsigned int length; unsigned int size; [size_is(size), length_is(length)] pints_t numbers[]; } numbers_struct_t; +cpp_quote("#endif") void get_numbers([in] int length, [in] int size, [out, length_is(length), size_is(size)] pints_t pn[]); void get_numbers_struct([out] numbers_struct_t **ns); str_t get_filename(void); +cpp_quote("#ifndef SKIP_TYPE_DECLS") enum renum { RE0, @@ -373,6 +424,7 @@ cpp_quote("#endif") const int RE_MAX = RE3; typedef [range(RE_MIN, RE_MAX)] enum renum renum_t; typedef [range(0, 100)] int rint_t; +cpp_quote("#endif") rint_t echo_ranged_int([range(0, 10)] int i, [range(0, 20)] int j, [range(0, 100)] int k); rint_t echo_ranged_int2([range(0, 40)] int i); void get_ranged_enum([out] renum_t *re); @@ -387,13 +439,23 @@ cpp_quote("#endif") void stop(void); void stop_autolisten(void); +cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef union ipu switch(int t) { default: IStream *stream; } ipu_t; +cpp_quote("#endif") void ip_test([in] ipu_t *a); int sum_ptr_array([in] int *a[2]); int sum_array_ptr([in] int (*a)[2]); + +cpp_quote("#ifndef SKIP_TYPE_DECLS") + typedef [context_handle] void *ctx_handle_t; +cpp_quote("#endif") + + ctx_handle_t get_handle(); + void get_handle_by_ptr([out] ctx_handle_t *r); + void test_handle(ctx_handle_t ctx_handle); } diff --git a/modules/rostests/winetests/rpcrt4/server_interp.idl b/modules/rostests/winetests/rpcrt4/server_interp.idl new file mode 100644 index 00000000000..befa31f4bfe --- /dev/null +++ b/modules/rostests/winetests/rpcrt4/server_interp.idl @@ -0,0 +1,26 @@ +/* + * Copyright 2019 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep client +#pragma makedep server + +#define IFACE_NAME IInterpServer +#define IFACE_HANDLE IInterpServer_IfHandle +#define ISERVER_UUID 00000000-4114-0704-2301-000000000001 + +#include "server.idl"
5 years, 1 month
1
0
0
0
[reactos] 01/01: [PSDK] Update rpcndr.h. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=392821caeae2d78bb8c0d…
commit 392821caeae2d78bb8c0d8652619a7d718f179db Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:12:08 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:12:08 2019 +0100 [PSDK] Update rpcndr.h. CORE-16441 --- sdk/include/psdk/rpcndr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/psdk/rpcndr.h b/sdk/include/psdk/rpcndr.h index bc06335c675..1380c81f51f 100644 --- a/sdk/include/psdk/rpcndr.h +++ b/sdk/include/psdk/rpcndr.h @@ -141,7 +141,7 @@ void __RPC_USER MIDL_user_free(void *); (RpcExceptionCode() == RPC_X_BAD_STUB_DATA) || \ (RpcExceptionCode() == RPC_S_INVALID_BOUND)) -typedef struct tagNDR_SCONTEXT +typedef struct _NDR_SCONTEXT { void *pad[2]; void *userContext;
5 years, 1 month
1
0
0
0
[reactos] 01/01: [INCLUDE/WINE] Add __FINALLY_CTX in the context of our PSEH library. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c41dde9a2bc22075488f5…
commit c41dde9a2bc22075488f5e07c1715fd158b015bd Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:11:45 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:11:45 2019 +0100 [INCLUDE/WINE] Add __FINALLY_CTX in the context of our PSEH library. CORE-16441 --- sdk/include/reactos/wine/exception.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/include/reactos/wine/exception.h b/sdk/include/reactos/wine/exception.h index 5a5e7f7e9dd..b16d502f826 100644 --- a/sdk/include/reactos/wine/exception.h +++ b/sdk/include/reactos/wine/exception.h @@ -60,6 +60,7 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD #define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER) #define __ENDTRY _SEH2_END #define __FINALLY(func) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); } +#define __FINALLY_CTX(func, ctx) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination(), ctx); }; _SEH2_END #ifndef GetExceptionCode #define GetExceptionCode() _SEH2_GetExceptionCode()
5 years, 1 month
1
0
0
0
[reactos] 01/01: [RICHED20_WINETEST] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=76cf09cfea15911082245…
commit 76cf09cfea15911082245a65547fb67512b710ce Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:11:20 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:11:20 2019 +0100 [RICHED20_WINETEST] Sync with Wine Staging 4.18. CORE-16441 --- modules/rostests/winetests/riched20/editor.c | 202 ++++++++----- modules/rostests/winetests/riched20/richole.c | 403 ++++++++++++-------------- modules/rostests/winetests/riched20/txtsrv.c | 228 ++++++++++----- 3 files changed, 485 insertions(+), 348 deletions(-) diff --git a/modules/rostests/winetests/riched20/editor.c b/modules/rostests/winetests/riched20/editor.c index 6712ab1a150..28f9849cba0 100644 --- a/modules/rostests/winetests/riched20/editor.c +++ b/modules/rostests/winetests/riched20/editor.c @@ -340,14 +340,12 @@ static void test_EM_FINDTEXT(BOOL unicode) hwndRichEdit = new_richedit(NULL); /* Empty rich edit control */ - run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, - sizeof(find_tests)/sizeof(struct find_s), unicode); + run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests), unicode); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack); /* Haystack text */ - run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, - sizeof(find_tests2)/sizeof(struct find_s), unicode); + run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2), unicode); /* Setting a format on an arbitrary range should have no effect in search results. This tests correct offset reporting across runs. */ @@ -359,8 +357,7 @@ static void test_EM_FINDTEXT(BOOL unicode) SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); /* Haystack text, again */ - run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, - sizeof(find_tests2)/sizeof(struct find_s), unicode); + run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, ARRAY_SIZE(find_tests2), unicode); /* Yet another range */ cf2.dwMask = CFM_BOLD | cf2.dwMask; @@ -369,8 +366,7 @@ static void test_EM_FINDTEXT(BOOL unicode) SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); /* Haystack text, again */ - run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, - sizeof(find_tests2)/sizeof(struct find_s), unicode); + run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, ARRAY_SIZE(find_tests2), unicode); DestroyWindow(hwndRichEdit); } @@ -404,7 +400,7 @@ static void test_EM_GETLINE(void) SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text); memset(origdest, 0xBB, nBuf); - for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++) + for (i = 0; i < ARRAY_SIZE(gl); i++) { int nCopied; int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text)); @@ -509,7 +505,7 @@ static void test_EM_LINELENGTH(void) {15, 4}, /* Line 3: |wine */ }; SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1); - for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) { + for (i = 0; i < ARRAY_SIZE(offset_test1); i++) { result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0); ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n", offset_test1[i][0], result, offset_test1[i][1]); @@ -755,6 +751,8 @@ static void test_EM_SETCHARFORMAT(void) HWND hwndRichEdit = new_richedit(NULL); CHARFORMAT2A cf2; CHARFORMAT2W cfW; + CHARFORMATA cf1a; + CHARFORMATW cf1w; int rc = 0; int tested_effects[] = { CFE_BOLD, @@ -1342,6 +1340,23 @@ static void test_EM_SETCHARFORMAT(void) ok(cf2.dwEffects & CFE_UNDERLINE, "got %08x\n", cf2.dwEffects); ok(cf2.bUnderlineType == CFU_UNDERLINEDOUBLE, "got %x\n", cf2.bUnderlineType); + /* Check setting CFM_ALL2/CFM_EFFECTS2 in CHARFORMAT(A/W). */ + memset(&cf1a, 0, sizeof(CHARFORMATA)); + memset(&cf1w, 0, sizeof(CHARFORMATW)); + cf1a.cbSize = sizeof(CHARFORMATA); + cf1w.cbSize = sizeof(CHARFORMATW); + cf1a.dwMask = cf1w.dwMask = CFM_ALL2; + cf1a.dwEffects = cf1w.dwEffects = CFM_EFFECTS2; + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1a); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1a); + /* flags only valid for CHARFORMAT2 should be masked out */ + ok((cf1a.dwMask & (CFM_ALL2 & ~CFM_ALL)) == 0, "flags were not masked out\n"); + ok((cf1a.dwEffects & (CFM_EFFECTS2 & ~CFM_EFFECTS)) == 0, "flags were not masked out\n"); + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1w); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1w); + ok((cf1w.dwMask & (CFM_ALL2 & ~CFM_ALL)) == 0, "flags were not masked out\n"); + ok((cf1w.dwEffects & (CFM_EFFECTS2 & ~CFM_EFFECTS)) == 0, "flags were not masked out\n"); + DestroyWindow(hwndRichEdit); } @@ -2049,7 +2064,7 @@ static void test_EM_AUTOURLDETECT(void) urlRet=SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, (WPARAM)"h", (LPARAM)"h"); ok(urlRet==E_INVALIDARG, "Bad wParam2: urlRet is: %d\n", urlRet); /* for each url, check the text to see if CFE_LINK effect is present */ - for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) { + for (i = 0; i < ARRAY_SIZE(urls); i++) { SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, FALSE, 0); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)urls[i].text); @@ -2063,10 +2078,10 @@ static void test_EM_AUTOURLDETECT(void) DestroyWindow(hwndRichEdit); /* Test detection of URLs within normal text - WM_SETTEXT case. */ - for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) { + for (i = 0; i < ARRAY_SIZE(urls); i++) { hwndRichEdit = new_richedit(parent); - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2117,7 +2132,7 @@ static void test_EM_AUTOURLDETECT(void) } } - for (j = 0; j < sizeof(templates_non_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_non_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2158,7 +2173,7 @@ static void test_EM_AUTOURLDETECT(void) } } - for (j = 0; j < sizeof(templates_xten_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_xten_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2213,7 +2228,7 @@ static void test_EM_AUTOURLDETECT(void) } } - for (j = 0; j < sizeof(templates_neutral_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_neutral_delim); j++) { char * at_pos, * end_pos; int at_offset; int end_offset; @@ -2421,7 +2436,7 @@ static void test_EM_AUTOURLDETECT(void) */ /* Set entire text in one go, like WM_SETTEXT */ - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2476,7 +2491,7 @@ static void test_EM_AUTOURLDETECT(void) } /* Set selection with X to the URL */ - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2530,7 +2545,7 @@ static void test_EM_AUTOURLDETECT(void) } /* Set selection with X to the first character of the URL, then the rest */ - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2598,7 +2613,7 @@ static void test_EM_AUTOURLDETECT(void) hwndRichEdit = new_richedit(parent); /* Set selection with X to the URL */ - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -2649,7 +2664,7 @@ static void test_EM_AUTOURLDETECT(void) } /* Set selection with X to the first character of the URL, then the rest */ - for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) { + for (j = 0; j < ARRAY_SIZE(templates_delim); j++) { char * at_pos; int at_offset; int end_offset; @@ -4933,7 +4948,7 @@ static void test_EM_EXSETSEL(void) { HWND hwndRichEdit = new_richedit(NULL); int i; - const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s); + const int num_tests = ARRAY_SIZE(exsetsel_tests); /* sending some text to the window */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection"); @@ -4955,7 +4970,7 @@ static void test_EM_EXSETSEL(void) /* Test with multibyte character */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"abcdef\x8e\xf0ghijk"); /* 012345 6 78901 */ - cr.cpMin = 4, cr.cpMax = 8; + cr.cpMin = 4; cr.cpMax = 8; result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&cr); ok(result == 8, "EM_EXSETSEL return %ld expected 8\n", result); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, sizeof(bufA), (LPARAM)bufA); @@ -4988,7 +5003,7 @@ static void test_EM_SETSEL(void) char buffA[32] = {0}; HWND hwndRichEdit = new_richedit(NULL); int i; - const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s); + const int num_tests = ARRAY_SIZE(exsetsel_tests); /* sending some text to the window */ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection"); @@ -5623,7 +5638,7 @@ static void test_EM_FORMATRANGE(void) SendMessageA(hwndRichEdit, EM_FORMATRANGE, FALSE, 0); - for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++) + for (i = 0; i < ARRAY_SIZE(fmtstrings); i++) { GETTEXTLENGTHEX gtl; SIZE stringsize; @@ -5758,6 +5773,30 @@ static DWORD CALLBACK test_EM_STREAMIN_esCallback_UTF8Split(DWORD_PTR dwCookie, return 0; } +static DWORD CALLBACK test_EM_STREAMIN_null_bytes(DWORD_PTR cookie, BYTE *buf, LONG size, LONG *written) +{ + DWORD *phase = (DWORD *)cookie; + + if (*phase == 0) + { + static const char first[] = "{\\rtf1\\ansi{Th\0is"; + *written = sizeof(first); + memcpy(buf, first, *written); + } + else if (*phase == 1) + { + static const char second[] = " is a test}}"; + *written = sizeof(second); + memcpy(buf, second, *written); + } + else + *written = 0; + + ++*phase; + + return 0; +} + struct StringWithLength { int length; char *buffer; @@ -5831,7 +5870,7 @@ static void test_EM_STREAMIN(void) }; const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' }; - int length5 = sizeof(streamText5) / sizeof(WCHAR); + int length5 = ARRAY_SIZE(streamText5); struct StringWithLength cookieForStream5 = { sizeof(streamText5), (char *)streamText5, @@ -6044,6 +6083,17 @@ static void test_EM_STREAMIN(void) result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (!strcmp(buffer, "line1"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); + + /* Test 0-bytes inside text */ + hwndRichEdit = new_richedit_with_style(NULL, 0); + phase = 0; + es.dwCookie = (DWORD_PTR)&phase; + es.dwError = 0; + es.pfnCallback = test_EM_STREAMIN_null_bytes; + result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 16, "got %ld, expected %d\n", result, 16); + result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); + ok (!strcmp(buffer, "Th is is a test"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); } static void test_EM_StreamIn_Undo(void) @@ -6868,7 +6918,7 @@ static void test_EN_LINK(void) GetCursorPos(&orig_cursor_pos); SetCursorPos(0, 0); - for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++) { link_notify_test("cursor position simulated", i, hwnd, parent, link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam, @@ -6878,7 +6928,7 @@ static void test_EN_LINK(void) ClientToScreen(hwnd, &cursor_screen_pos); SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y); - for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++) { link_notify_test("cursor position set", i, hwnd, parent, link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam, @@ -8178,7 +8228,7 @@ static void test_EM_FINDWORDBREAK_W(void) int i; HWND hwndRichEdit = new_richeditW(NULL); ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n"); - for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++) { WCHAR wbuf[2]; int result; @@ -8212,7 +8262,7 @@ static void test_EM_FINDWORDBREAK_A(void) HWND hwndRichEdit = new_richedit(NULL); ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n"); - for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++) { int result; char buf[2]; @@ -8228,12 +8278,21 @@ static void test_EM_FINDWORDBREAK_A(void) DestroyWindow(hwndRichEdit); } +static void format_test_result(char *target, const char *src) +{ + int i; + for (i = 0; i < strlen(src); i++) + sprintf(target + 2*i, "%02x", src[i] & 0xFF); + target[2*i] = 0; +} + /* * This test attempts to show the effect of enter on a richedit * control v1.0 inserts CRLF whereas for higher versions it only * inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT * and also shows that GT_USECRLF has no effect in richedit 1.0, but * does for higher. The same test is cloned in riched32 and riched20. + * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions */ static void test_enter(void) { @@ -8254,15 +8313,14 @@ static void test_enter(void) char expectedbuf[1024]; char resultbuf[1024]; HWND hwndRichEdit = new_richedit(NULL); - UINT i,j; - - for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) { - - char buf[1024] = {0}; - LRESULT result; - GETTEXTEX getText; - const char *expected; + UINT i; + char buf[1024] = {0}; + GETTEXTEX getText = {sizeof(buf)}; + LRESULT result; + const char *expected; + for (i = 0; i < ARRAY_SIZE(testenteritems); i++) + { /* Set the text to the initial text */ result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)testenteritems[i].initialtext); ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); @@ -8276,12 +8334,8 @@ static void test_enter(void) result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buf); expected = testenteritems[i].expectedwmtext; - resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected); result = strcmp(expected, buf); ok (result == 0, @@ -8289,21 +8343,14 @@ static void test_enter(void) i, resultbuf, expectedbuf); /* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */ - getText.cb = sizeof(buf); getText.flags = GT_DEFAULT; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedemtext; - resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected); result = strcmp(expected, buf); ok (result == 0, @@ -8311,21 +8358,14 @@ static void test_enter(void) i, resultbuf, expectedbuf); /* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */ - getText.cb = sizeof(buf); getText.flags = GT_USECRLF; - getText.codepage = CP_ACP; - getText.lpDefaultChar = NULL; - getText.lpUsedDefChar = NULL; + getText.codepage = CP_ACP; buf[0] = 0x00; result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); expected = testenteritems[i].expectedemtextcrlf; - resultbuf[0]=0x00; - for (j = 0; j < (UINT)result; j++) - sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF); - expectedbuf[0] = '\0'; - for (j = 0; j < strlen(expected); j++) - sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] & 0xFF); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, expected); result = strcmp(expected, buf); ok (result == 0, @@ -8333,6 +8373,34 @@ static void test_enter(void) i, resultbuf, expectedbuf); } + /* Show that WM_CHAR is handled differently from WM_KEYDOWN */ + getText.flags = GT_DEFAULT; + getText.codepage = CP_ACP; + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0); + + result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 2, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T\r"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + + result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)""); + ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result); + SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0); + SendMessageW(hwndRichEdit, WM_CHAR, '\r', 0); + + result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf); + ok(result == 1, "Got %d\n", (int)result); + format_test_result(resultbuf, buf); + format_test_result(expectedbuf, "T"); + result = strcmp(resultbuf, expectedbuf); + ok (result == 0, "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n", i, resultbuf, expectedbuf); + DestroyWindow(hwndRichEdit); } @@ -8538,7 +8606,7 @@ static void test_alignment_style(void) EDITSTREAM es; int i; - for (i = 0; i < sizeof(align_style) / sizeof(align_style[0]); i++) + for (i = 0; i < ARRAY_SIZE(align_style); i++) { DWORD dwStyle, new_align; @@ -8646,8 +8714,8 @@ static void test_rtf(void) result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es ); ok( result == 11, "got %ld\n", result ); - result = SendMessageW( edit, WM_GETTEXT, sizeof(buf)/sizeof(buf[0]), (LPARAM)buf ); - ok( result == sizeof(expect_specials)/sizeof(expect_specials[0]), "got %ld\n", result ); + result = SendMessageW( edit, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf ); + ok( result == ARRAY_SIZE(expect_specials), "got %ld\n", result ); ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) ); /* Show that \rtlpar propagates to the second paragraph and is diff --git a/modules/rostests/winetests/riched20/richole.c b/modules/rostests/winetests/riched20/richole.c index 617d1f978bb..492bdc3fa9a 100644 --- a/modules/rostests/winetests/riched20/richole.c +++ b/modules/rostests/winetests/riched20/richole.c @@ -113,10 +113,36 @@ static ULONG get_refcount(IUnknown *iface) return IUnknown_Release(iface); } +#define CHECK_TYPEINFO(disp,expected_riid) _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__) +static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line) +{ + ITypeInfo *typeinfo; + TYPEATTR *typeattr; + UINT count; + HRESULT hr; + + count = 10; + hr = IDispatch_GetTypeInfoCount(disp, &count); + ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(count == 1, "got wrong count: %u.\n", count); + + hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo); + ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08x.\n", hr); + + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); + ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, expected_riid), + "Unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid)); + + ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); + ITypeInfo_Release(typeinfo); +} + static void test_Interfaces(void) { IRichEditOle *reOle = NULL, *reOle1 = NULL; ITextDocument *txtDoc = NULL; + ITextDocument2Old *txtDoc2Old = NULL; ITextSelection *txtSel = NULL, *txtSel2; IUnknown *punk; HRESULT hres; @@ -144,6 +170,7 @@ static void test_Interfaces(void) (void **) &txtDoc); ok(hres == S_OK, "IRichEditOle_QueryInterface\n"); ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n"); + CHECK_TYPEINFO(txtDoc, &IID_ITextDocument); hres = ITextDocument_GetSelection(txtDoc, NULL); ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres); @@ -195,6 +222,16 @@ static void test_Interfaces(void) hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk); ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n"); + hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old); + ok(hres == S_OK, "IRichEditOle_QueryInterface\n"); + ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n"); + ok((ITextDocument *)txtDoc2Old == txtDoc, "interface pointer isn't equal.\n"); + EXPECT_REF(txtDoc2Old, 5); + EXPECT_REF(reOle, 5); + CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument); + + ITextDocument2Old_Release(txtDoc2Old); + ITextDocument_Release(txtDoc); IRichEditOle_Release(reOle); refcount = IRichEditOle_Release(reOle); @@ -207,6 +244,19 @@ static void test_Interfaces(void) ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n"); ITextSelection_Release(txtSel); + + w = new_richedit(NULL); + res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle); + ok(res, "SendMessage\n"); + ok(reOle != NULL, "EM_GETOLEINTERFACE\n"); + + hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old); + ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres); + ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n"); + CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument); + ITextDocument2Old_Release(txtDoc2Old); + IRichEditOle_Release(reOle); + DestroyWindow(w); } static void test_ITextDocument_Open(void) @@ -247,8 +297,8 @@ static void test_ITextDocument_Open(void) tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead }; - int tomNumSingle = sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]); - int tomNumMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]); + int tomNumSingle = ARRAY_SIZE(tomConstantsSingle); + int tomNumMulti = ARRAY_SIZE(tomConstantsMulti); int i; V_VT(&testfile) = VT_BSTR; @@ -481,21 +531,21 @@ static void test_GetText(void) SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); /* ITextSelection */ - first = 0, lim = 4; + first = 0; lim = 4; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = 4, lim = 0; + first = 4; lim = 0; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = 1, lim = 1; + first = 1; lim = 1; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); @@ -507,35 +557,35 @@ static void test_GetText(void) ok(hres == E_INVALIDARG, "ITextSelection_GetText\n"); } - first = 8, lim = 12; + first = 8; lim = 12; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = 8, lim = 13; + first = 8; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = 12, lim = 13; + first = 12; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = 0, lim = -1; + first = 0; lim = -1; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); ok(!lstrcmpW(bstr, bufW4), "got wrong text: %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); - first = -1, lim = 9; + first = -1; lim = 9; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_GetText(txtSel, &bstr); ok(hres == S_OK, "ITextSelection_GetText\n"); @@ -707,7 +757,7 @@ static void test_ITextRange_GetChar(void) ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); - first = 0, lim = 0; + first = 0; lim = 0; create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); @@ -719,7 +769,7 @@ static void test_ITextRange_GetChar(void) ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); - first = 12, lim = 12; + first = 12; lim = 12; create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); @@ -731,7 +781,7 @@ static void test_ITextRange_GetChar(void) ITextRange_Release(txtRge); release_interfaces(&w, &reOle, &txtDoc, NULL); - first = 13, lim = 13; + first = 13; lim = 13; create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); @@ -745,7 +795,7 @@ static void test_ITextRange_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 12, lim = 12; + first = 12; lim = 12; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); hres = ITextRange_GetChar(txtRge, NULL); @@ -803,15 +853,19 @@ static void test_ITextRange_ScrollIntoView(void) /* Scroll to the top. */ check_range(w, txtDoc, 0, 1, tomStart, 0); + check_range(w, txtDoc, 0, 1, tomEnd, 0); /* Scroll to the bottom. */ check_range(w, txtDoc, 19, 20, tomStart, 1); + check_range(w, txtDoc, 19, 20, tomEnd, 1); /* Back up to the top. */ check_range(w, txtDoc, 0, 1, tomStart, 0); + check_range(w, txtDoc, 0, 1, tomEnd, 0); /* Large range */ check_range(w, txtDoc, 0, 20, tomStart, 0); + check_range(w, txtDoc, 0, 20, tomEnd, 1); hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); @@ -835,28 +889,28 @@ static void test_ITextSelection_GetChar(void) create_interfaces(&w, &reOle, &txtDoc, &txtSel); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 0, lim = 4; + first = 0; lim = 4; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); ok(pch == 'T', "got wrong char: %c\n", pch); - first = 0, lim = 0; + first = 0; lim = 0; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); ok(pch == 'T', "got wrong char: %c\n", pch); - first = 12, lim = 12; + first = 12; lim = 12; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); ok(hres == S_OK, "ITextSelection_GetChar\n"); ok(pch == '\r', "got wrong char: %c\n", pch); - first = 13, lim = 13; + first = 13; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); pch = 0xdeadbeef; hres = ITextSelection_GetChar(txtSel, &pch); @@ -890,7 +944,7 @@ static void test_ITextRange_GetStart_GetEnd(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 1, lim = 6; + first = 1; lim = 6; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); start = 0xdeadbeef; @@ -903,7 +957,7 @@ static void test_ITextRange_GetStart_GetEnd(void) ok(end == 6, "got wrong end value: %d\n", end); ITextRange_Release(txtRge); - first = 6, lim = 1; + first = 6; lim = 1; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); start = 0xdeadbeef; @@ -916,7 +970,7 @@ static void test_ITextRange_GetStart_GetEnd(void) ok(end == 6, "got wrong end value: %d\n", end); ITextRange_Release(txtRge); - first = -1, lim = 13; + first = -1; lim = 13; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); start = 0xdeadbeef; @@ -929,7 +983,7 @@ static void test_ITextRange_GetStart_GetEnd(void) ok(end == 13, "got wrong end value: %d\n", end); ITextRange_Release(txtRge); - first = 13, lim = 13; + first = 13; lim = 13; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); start = 0xdeadbeef; @@ -1109,7 +1163,7 @@ static void test_ITextSelection_GetStart_GetEnd(void) create_interfaces(&w, &reOle, &txtDoc, &txtSel); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 2, lim = 5; + first = 2; lim = 5; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); @@ -1120,7 +1174,7 @@ static void test_ITextSelection_GetStart_GetEnd(void) ok(hres == S_OK, "ITextSelection_GetEnd\n"); ok(end == 5, "got wrong end value: %d\n", end); - first = 5, lim = 2; + first = 5; lim = 2; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); @@ -1131,7 +1185,7 @@ static void test_ITextSelection_GetStart_GetEnd(void) ok(hres == S_OK, "ITextSelection_GetEnd\n"); ok(end == 5, "got wrong end value: %d\n", end); - first = 0, lim = -1; + first = 0; lim = -1; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); @@ -1142,7 +1196,7 @@ static void test_ITextSelection_GetStart_GetEnd(void) ok(hres == S_OK, "ITextSelection_GetEnd\n"); ok(end == 13, "got wrong end value: %d\n", end); - first = 13, lim = 13; + first = 13; lim = 13; SendMessageA(w, EM_SETSEL, first, lim); start = 0xdeadbeef; hres = ITextSelection_GetStart(txtSel, &start); @@ -1315,7 +1369,7 @@ static void test_ITextRange_GetDuplicate(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 0, lim = 4; + first = 0; lim = 4; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres); @@ -1358,7 +1412,7 @@ static void test_ITextRange_Collapse(void) create_interfaces(&w, &reOle, &txtDoc, NULL); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 4, lim = 8; + first = 4; lim = 8; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); hres = ITextRange_Collapse(txtRge, tomTrue); @@ -1420,7 +1474,7 @@ static void test_ITextRange_Collapse(void) ok(end == 4, "got wrong end value: %d\n", end); ITextRange_Release(txtRge); - first = 6, lim = 6; + first = 6; lim = 6; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); hres = ITextRange_Collapse(txtRge, tomEnd); @@ -1433,7 +1487,7 @@ static void test_ITextRange_Collapse(void) ok(end == 6, "got wrong end value: %d\n", end); ITextRange_Release(txtRge); - first = 8, lim = 8; + first = 8; lim = 8; hres = ITextDocument_Range(txtDoc, first, lim, &txtRge); ok(hres == S_OK, "got 0x%08x\n", hres); hres = ITextRange_Collapse(txtRge, tomStart); @@ -1469,7 +1523,7 @@ static void test_ITextSelection_Collapse(void) create_interfaces(&w, &reOle, &txtDoc, &txtSel); SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - first = 4, lim = 8; + first = 4; lim = 8; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomTrue); ok(hres == S_OK, "ITextSelection_Collapse\n"); @@ -1506,7 +1560,7 @@ static void test_ITextSelection_Collapse(void) ok(start == 4, "got wrong start value: %d\n", start); ok(end == 4, "got wrong end value: %d\n", end); - first = 6, lim = 6; + first = 6; lim = 6; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomEnd); ok(hres == S_FALSE, "ITextSelection_Collapse\n"); @@ -1514,7 +1568,7 @@ static void test_ITextSelection_Collapse(void) ok(start == 6, "got wrong start value: %d\n", start); ok(end == 6, "got wrong end value: %d\n", end); - first = 8, lim = 8; + first = 8; lim = 8; SendMessageA(w, EM_SETSEL, first, lim); hres = ITextSelection_Collapse(txtSel, tomStart); ok(hres == S_FALSE, "ITextSelection_Collapse\n"); @@ -3278,6 +3332,61 @@ static void test_InsertObject(void) /* received_reo4 didn't be zeroed in E_INVALIDARG case */ CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); + SendMessageA(hwnd, EM_SETSEL, 0, 1); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 1; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + + SendMessageA(hwnd, EM_SETSEL, 1, 2); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3); + + SendMessageA(hwnd, EM_SETSEL, 2, 3); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); + + SendMessageA(hwnd, EM_SETSEL, 0, 2); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + + SendMessageA(hwnd, EM_SETSEL, 1, 3); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3); + + SendMessageA(hwnd, EM_SETSEL, 2, 0); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + + SendMessageA(hwnd, EM_SETSEL, 0, 6); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + + SendMessageA(hwnd, EM_SETSEL, 4, 5); + received_reo4.cbStruct = sizeof(received_reo4); + received_reo4.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + release_interfaces(&hwnd, &reole, &doc, NULL); } @@ -3481,6 +3590,51 @@ static void _check_selection(ITextSelection *selection, LONG expected_start, LON expected_end, value); } +static void test_ITextRange_SetRange(void) +{ + static const CHAR test_text1[] = "TestSomeText"; + ITextDocument *txtDoc = NULL; + IRichEditOle *reOle = NULL; + ITextRange *txtRge = NULL; + HRESULT hr; + HWND w; + + create_interfaces(&w, &reOle, &txtDoc, NULL); + SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); + ITextDocument_Range(txtDoc, 0, 0, &txtRge); + + hr = ITextRange_SetRange(txtRge, 2, 4); + ok(hr == S_OK, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 2, 4); + + hr = ITextRange_SetRange(txtRge, 2, 4); + ok(hr == S_FALSE, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 2, 4); + + hr = ITextRange_SetRange(txtRge, 4, 2); + ok(hr == S_FALSE, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 2, 4); + + hr = ITextRange_SetRange(txtRge, 14, 14); + ok(hr == S_OK, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 12, 12); + + hr = ITextRange_SetRange(txtRge, 15, 15); + ok(hr == S_FALSE, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 12, 12); + + hr = ITextRange_SetRange(txtRge, 14, 1); + ok(hr == S_OK, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 1, 13); + + hr = ITextRange_SetRange(txtRge, -1, 4); + ok(hr == S_OK, "got 0x%08x.\n", hr); + CHECK_RANGE(txtRge, 0, 4); + + ITextRange_Release(txtRge); + release_interfaces(&w, &reOle, &txtDoc, NULL); +} + static void test_Expand(void) { static const char test_text1[] = "TestSomeText"; @@ -3922,183 +4076,6 @@ static void test_ITextRange_GetPara(void) ITextPara_Release(txtPara); } -static void test_ITextRange_GetText(void) -{ - HWND w; - IRichEditOle *reOle = NULL; - ITextDocument *txtDoc = NULL; - ITextRange *txtRge = NULL; - HRESULT hres; - BSTR bstr = NULL; - static const CHAR test_text1[] = "TestSomeText"; - static const WCHAR bufW1[] = {'T', 'e', 's', 't', 0}; - static const WCHAR bufW2[] = {'T', 'e', 'x', 't', '\r', 0}; - static const WCHAR bufW3[] = {'T', 'e', 'x', 't', 0}; - static const WCHAR bufW4[] = {'T', 'e', 's', 't', 'S', 'o', 'm', - 'e', 'T', 'e', 'x', 't', '\r', 0}; - static const WCHAR bufW5[] = {'\r', 0}; - - -#define TEST_TXTRGE_GETTEXT(first, lim, expected_string) \ - create_interfaces(&w, &reOle, &txtDoc, NULL); \ - SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); \ - ITextDocument_Range(txtDoc, first, lim, &txtRge); \ - hres = ITextRange_GetText(txtRge, &bstr); \ - ok(hres == S_OK, "ITextRange_GetText\n"); \ - ok(!lstrcmpW(bstr, expected_string), "got wrong text: %s\n", wine_dbgstr_w(bstr)); \ - SysFreeString(bstr); \ - ITextRange_Release(txtRge); \ - release_interfaces(&w, &reOle, &txtDoc, NULL); - - TEST_TXTRGE_GETTEXT(0, 4, bufW1) - TEST_TXTRGE_GETTEXT(4, 0, bufW1) - TEST_TXTRGE_GETTEXT(8, 12, bufW3) - TEST_TXTRGE_GETTEXT(8, 13, bufW2) - TEST_TXTRGE_GETTEXT(12, 13, bufW5) - TEST_TXTRGE_GETTEXT(0, 13, bufW4) - TEST_TXTRGE_GETTEXT(1, 1, NULL) -} - -static void test_ITextRange_SetRange(void) -{ - HWND w; - IRichEditOle *reOle = NULL; - ITextDocument *txtDoc = NULL; - ITextRange *txtRge = NULL; - HRESULT hres; - int start, end; - static const CHAR test_text1[] = "TestSomeText"; - - create_interfaces(&w, &reOle, &txtDoc, NULL); - SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - ITextDocument_Range(txtDoc, 0, 0, &txtRge); - -#define TEST_TXTRGE_SETRANGE(first, lim, expected_start, expected_end, expected_return) \ - hres = ITextRange_SetRange(txtRge, first, lim); \ - ok(hres == expected_return, "ITextRange_SetRange\n"); \ - ITextRange_GetStart(txtRge, &start); \ - ITextRange_GetEnd(txtRge, &end); \ - ok(start == expected_start, "got wrong start value: %d\n", start); \ - ok(end == expected_end, "got wrong end value: %d\n", end); - - TEST_TXTRGE_SETRANGE(2, 4, 2, 4, S_OK) - TEST_TXTRGE_SETRANGE(2, 4, 2, 4, S_FALSE) - TEST_TXTRGE_SETRANGE(4, 2, 2, 4, S_FALSE) - TEST_TXTRGE_SETRANGE(14, 14, 12, 12, S_OK) - TEST_TXTRGE_SETRANGE(15, 15, 12, 12, S_FALSE) - TEST_TXTRGE_SETRANGE(14, 1, 1, 13, S_OK) - TEST_TXTRGE_SETRANGE(-1, 4, 0, 4, S_OK) - - ITextRange_Release(txtRge); - release_interfaces(&w, &reOle, &txtDoc, NULL); -} - -static void test_ITextRange_IsEqual2(void) -{ - HWND w; - IRichEditOle *reOle = NULL; - ITextDocument *txtDoc = NULL; - ITextRange *txtRge1 = NULL, *txtRge2 = NULL; - HRESULT hres; - static const CHAR test_text1[] = "TestSomeText"; - LONG res; - - create_interfaces(&w, &reOle, &txtDoc, NULL); - SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - ITextDocument_Range(txtDoc, 2, 4, &txtRge1); - ITextDocument_Range(txtDoc, 2, 4, &txtRge2); - -#define TEST_TXTRGE_ISEQUAL(expected_hres, expected_res) \ - hres = ITextRange_IsEqual(txtRge1, txtRge2, &res); \ - ok(hres == expected_hres, "ITextRange_IsEqual\n"); \ - ok(res == expected_res, "got wrong return value: %d\n", res); - - TEST_TXTRGE_ISEQUAL(S_OK, tomTrue) - ITextRange_SetRange(txtRge2, 1, 2); - TEST_TXTRGE_ISEQUAL(S_FALSE, tomFalse) - - ITextRange_SetRange(txtRge1, 1, 1); - ITextRange_SetRange(txtRge2, 2, 2); - TEST_TXTRGE_ISEQUAL(S_FALSE, tomFalse) - - ITextRange_SetRange(txtRge2, 1, 1); - TEST_TXTRGE_ISEQUAL(S_OK, tomTrue) - - hres = ITextRange_IsEqual(txtRge1, txtRge1, &res); - ok(hres == S_OK, "ITextRange_IsEqual\n"); - ok(res == tomTrue, "got wrong return value: %d\n", res); - - hres = ITextRange_IsEqual(txtRge1, txtRge2, NULL); - ok(hres == S_OK, "ITextRange_IsEqual\n"); - - hres = ITextRange_IsEqual(txtRge1, NULL, NULL); - ok(hres == S_FALSE, "ITextRange_IsEqual\n"); - - ITextRange_Release(txtRge1); - ITextRange_Release(txtRge2); - release_interfaces(&w, &reOle, &txtDoc, NULL); -} - -static void test_ITextRange_GetStoryLength(void) -{ - HWND w; - IRichEditOle *reOle = NULL; - ITextDocument *txtDoc = NULL; - ITextRange *txtRge = NULL; - HRESULT hres; - LONG count; - static const CHAR test_text1[] = "TestSomeText"; - int len = strlen(test_text1) + 1; - - create_interfaces(&w, &reOle, &txtDoc, NULL); - SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - ITextDocument_Range(txtDoc, 0, 0, &txtRge); - - hres = ITextRange_GetStoryLength(txtRge, &count); - ok(hres == S_OK, "ITextRange_GetStoryLength\n"); - ok(count == len, "got wrong length: %d\n", count); - - ITextRange_SetRange(txtRge, 1, 2); - hres = ITextRange_GetStoryLength(txtRge, &count); - ok(hres == S_OK, "ITextRange_GetStoryLength\n"); - ok(count == len, "got wrong length: %d\n", count); - - hres = ITextRange_GetStoryLength(txtRge, NULL); - ok(hres == E_INVALIDARG, "ITextRange_GetStoryLength\n"); - - ITextRange_Release(txtRge); - release_interfaces(&w, &reOle, &txtDoc, NULL); -} - -static void test_ITextSelection_GetStoryLength(void) -{ - HWND w; - IRichEditOle *reOle = NULL; - ITextDocument *txtDoc = NULL; - ITextSelection *txtSel = NULL; - HRESULT hres; - LONG count; - static const CHAR test_text1[] = "TestSomeText"; - int len = strlen(test_text1) + 1; - - create_interfaces(&w, &reOle, &txtDoc, &txtSel); - SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); - - hres = ITextSelection_GetStoryLength(txtSel, &count); - ok(hres == S_OK, "ITextSelection_GetStoryLength\n"); - ok(count == len, "got wrong length: %d\n", count); - - SendMessageA(w, EM_SETSEL, 1, 2); - hres = ITextSelection_GetStoryLength(txtSel, &count); - ok(hres == S_OK, "ITextSelection_GetStoryLength\n"); - ok(count == len, "got wrong length: %d\n", count); - - hres = ITextSelection_GetStoryLength(txtSel, NULL); - ok(hres == E_INVALIDARG, "ITextSelection_GetStoryLength\n"); - - release_interfaces(&w, &reOle, &txtDoc, &txtSel); -} - START_TEST(richole) { /* Must explicitly LoadLibrary(). The test has no references to functions in @@ -4115,21 +4092,17 @@ START_TEST(richole) test_ITextSelection_SetEnd(); test_ITextSelection_Collapse(); test_ITextSelection_GetFont(); - test_ITextSelection_GetStoryLength(); test_ITextDocument_Range(); test_ITextRange_GetChar(); test_ITextRange_ScrollIntoView(); test_ITextRange_GetStart_GetEnd(); + test_ITextRange_SetRange(); test_ITextRange_GetDuplicate(); test_ITextRange_SetStart(); test_ITextRange_SetEnd(); test_ITextRange_Collapse(); test_ITextRange_GetFont(); test_ITextRange_GetPara(); - test_ITextRange_GetText(); - test_ITextRange_SetRange(); - test_ITextRange_IsEqual2(); - test_ITextRange_GetStoryLength(); test_GetClientSite(); test_IOleWindow_GetWindow(); test_IOleInPlaceSite_GetWindow(); diff --git a/modules/rostests/winetests/riched20/txtsrv.c b/modules/rostests/winetests/riched20/txtsrv.c index 88b5adf13cc..5a59c871815 100644 --- a/modules/rostests/winetests/riched20/txtsrv.c +++ b/modules/rostests/winetests/riched20/txtsrv.c @@ -48,7 +48,7 @@ static PCreateTextServices pCreateTextServices; /* Use a special table for x86 machines to convert the thiscall * calling convention. This isn't needed on other platforms. */ -#ifdef __i386__ +#if defined(__i386__) && !defined(__MINGW32__) static ITextServicesVtbl itextServicesStdcallVtbl; #define TXTSERV_VTABLE(This) (&itextServicesStdcallVtbl) #else /* __i386__ */ @@ -85,6 +85,7 @@ typedef struct ITextHostTestImpl { ITextHost ITextHost_iface; LONG refCount; + CHARFORMAT2W char_format; } ITextHostTestImpl; static inline ITextHostTestImpl *impl_from_ITextHost(ITextHost *iface) @@ -534,7 +535,7 @@ typedef struct static void setup_thiscall_wrappers(void) { -#ifdef __i386__ +#if defined(__i386__) && !defined(__MINGW32__) void** pVtable; void** pVtableEnd; THISCALL_TO_STDCALL_THUNK *thunk; @@ -600,6 +601,21 @@ static void setup_thiscall_wrappers(void) #endif /* __i386__ */ } +static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf) +{ + LOGFONTW lf; + + GetObjectW(hf, sizeof(lf), &lf); + lstrcpyW(cf->szFaceName, lf.lfFaceName); + cf->yHeight = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY)); + if (lf.lfWeight > FW_NORMAL) cf->dwEffects |= CFE_BOLD; + if (lf.lfItalic) cf->dwEffects |= CFE_ITALIC; + if (lf.lfUnderline) cf->dwEffects |= CFE_UNDERLINE; + if (lf.lfStrikeOut) cf->dwEffects |= CFE_SUBSCRIPT; + cf->bPitchAndFamily = lf.lfPitchAndFamily; + cf->bCharSet = lf.lfCharSet; +} + /*************************************************************************/ /* Conformance test functions. */ @@ -609,6 +625,7 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) ITextHostTestImpl *dummyTextHost; IUnknown *init; HRESULT result; + HFONT hf; dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost)); if (dummyTextHost == NULL) { @@ -617,6 +634,11 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) } dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl; dummyTextHost->refCount = 1; + memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format)); + dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format); + dummyTextHost->char_format.dwMask = CFM_ALL2; + hf = GetStockObject(DEFAULT_GUI_FONT); + hf_to_cf(hf, &dummyTextHost->char_format); /* MSDN states that an IUnknown object is returned by CreateTextServices which is then queried to obtain a @@ -682,6 +704,8 @@ static void test_TxSetText(void) ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0, "String returned differs\n"); + SysFreeString(rettext); + /* Null-pointer should behave the same as empty-string */ hres = ITextServices_TxSetText(txtserv, 0); @@ -697,81 +721,68 @@ static void test_TxSetText(void) ITextHost_Release(host); } +#define CHECK_TXGETNATURALSIZE(res,width,height,hdc,rect,string) \ + _check_txgetnaturalsize(res, width, height, hdc, rect, string, __LINE__) +static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hdc, RECT rect, LPCWSTR string, int line) +{ + RECT expected_rect = rect; + LONG expected_width, expected_height; + + DrawTextW(hdc, string, -1, &expected_rect, DT_LEFT | DT_CALCRECT | DT_NOCLIP | DT_EDITCONTROL | DT_WORDBREAK); + expected_width = expected_rect.right - expected_rect.left; + expected_height = expected_rect.bottom - expected_rect.top; + ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res); + ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1, + "got wrong width: %d, expected: %d {+1}.\n", width, expected_width); + ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n", + height, expected_height); +} + static void test_TxGetNaturalSize(void) { ITextServices *txtserv; ITextHost *host; HRESULT result; - BOOL ret; - - /* This value is used when calling TxGetNaturalSize. MSDN says - that this is not supported however a null pointer cannot be - used as it will cause a segmentation violation. The values in - the structure being pointed to are required to be INT_MAX - otherwise calculations can give wrong values. */ - const SIZEL psizelExtent = {INT_MAX,INT_MAX}; - - static const WCHAR oneA[] = {'A',0}; - - /* Results of measurements */ - LONG xdim, ydim; - - /* The device context to do the tests in */ + SIZEL extent; + static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0}; + LONG width, height; HDC hdcDraw; - - /* Variables with the text metric information */ - INT charwidth_caps_text[26]; - TEXTMETRICA tmInfo_text; + HWND hwnd; + RECT rect; + CHARFORMAT2W cf; + LRESULT lresult; + HFONT hf; if (!init_texthost(&txtserv, &host)) return; - hdcDraw = GetDC(NULL); - SaveDC(hdcDraw); - - /* Populate the metric strucs */ + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE, + 0, 0, 100, 100, 0, 0, 0, NULL); + hdcDraw = GetDC(hwnd); SetMapMode(hdcDraw,MM_TEXT); - GetTextMetricsA(hdcDraw, &tmInfo_text); - SetLastError(0xdeadbeef); - ret = GetCharWidth32A(hdcDraw,'A','Z',charwidth_caps_text); - if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - win_skip("GetCharWidth32 is not available\n"); - goto cleanup; - } - - /* Make measurements in MM_TEXT */ - SetMapMode(hdcDraw,MM_TEXT); - xdim = 0; ydim = 0; - - result = ITextServices_TxSetText(txtserv, oneA); - ok(result == S_OK, "ITextServices_TxSetText failed (result = %x)\n", result); - if (result != S_OK) { - skip("Could not set text\n"); - goto cleanup; - } - - SetLastError(0xdeadbeef); - result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, - hdcDraw, NULL, NULL, - TXTNS_FITTOCONTENT, &psizelExtent, - &xdim, &ydim); - todo_wine ok(result == S_OK || broken(result == E_FAIL), /* WINXP Arabic Language */ - "TxGetNaturalSize gave unexpected return value (result = %x)\n", result); - if (result == S_OK) { - todo_wine ok(ydim == tmInfo_text.tmHeight, - "Height calculated incorrectly (expected %d, got %d)\n", - tmInfo_text.tmHeight, ydim); - /* The native DLL adds one pixel extra when calculating widths. */ - todo_wine ok(xdim >= charwidth_caps_text[0] && xdim <= charwidth_caps_text[0] + 1, - "Width calculated incorrectly (expected %d {+1}, got %d)\n", - charwidth_caps_text[0], xdim); - } else - skip("TxGetNaturalSize measurements not performed (xdim = %d, ydim = %d, result = %x, error = %x)\n", - xdim, ydim, result, GetLastError()); - -cleanup: - RestoreDC(hdcDraw,1); - ReleaseDC(NULL,hdcDraw); + GetClientRect(hwnd, &rect); + + memset(&cf, 0, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_ALL2; + hf = GetStockObject(DEFAULT_GUI_FONT); + hf_to_cf(hf, &cf); + result = ITextServices_TxSendMessage(txtserv, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf, &lresult); + ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); + SelectObject(hdcDraw, hf); + + result = ITextServices_TxSetText(txtserv, test_text); + ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08x.\n", result); + + extent.cx = -1; extent.cy = -1; + width = rect.right - rect.left; + height = 0; + result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL, + TXTNS_FITTOCONTENT, &extent, &width, &height); + todo_wine CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text); + + ReleaseDC(hwnd, hdcDraw); + DestroyWindow(hwnd); ITextServices_Release(txtserv); ITextHost_Release(host); } @@ -894,6 +905,7 @@ static void test_QueryInterface(void) HRESULT hres; IRichEditOle *reole, *txtsrv_reole; ITextDocument *txtdoc, *txtsrv_txtdoc; + ITextDocument2Old *txtdoc2old, *txtsrv_txtdoc2old; ULONG refcount; if(!init_texthost(&txtserv, &host)) @@ -920,6 +932,17 @@ static void test_QueryInterface(void) ITextDocument_Release(txtdoc); refcount = get_refcount((IUnknown *)txtserv); ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old); + ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtsrv_reole); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + + ITextDocument2Old_Release(txtdoc2old); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); IRichEditOle_Release(txtsrv_reole); refcount = get_refcount((IUnknown *)txtserv); ok(refcount == 1, "got wrong ref count: %d\n", refcount); @@ -946,6 +969,77 @@ static void test_QueryInterface(void) refcount = get_refcount((IUnknown *)txtserv); ok(refcount == 1, "got wrong ref count: %d\n", refcount); + /* ITextDocument2Old */ + hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old); + ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + + hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole); + ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08x\n", hres); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); + ok(refcount == 3, "got wrong ref count: %d\n", refcount); + + IRichEditOle_Release(reole); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 2, "got wrong ref count: %d\n", refcount); + ITextDocument2Old_Release(txtsrv_txtdoc2old); + refcount = get_refcount((IUnknown *)txtserv); + ok(refcount == 1, "got wrong ref count: %d\n", refcount); + + ITextServices_Release(txtserv); + ITextHost_Release(host); +} + +static void test_default_format(void) +{ + ITextServices *txtserv; + ITextHost *host; + HRESULT result; + LRESULT lresult; + CHARFORMAT2W cf2; + const CHARFORMATW *host_cf; + DWORD expected_effects; + + if (!init_texthost(&txtserv, &host)) + return; + + cf2.cbSize = sizeof(CHARFORMAT2W); + result = ITextServices_TxSendMessage(txtserv, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2, &lresult); + ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); + + ITextHostImpl_TxGetCharFormat(host, &host_cf); + ok(!lstrcmpW(host_cf->szFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName)); + ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %d, expected %d.\n", cf2.yHeight, host_cf->yHeight); + expected_effects = (cf2.dwEffects & ~(CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR)); + ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %x, expected %x.\n", cf2.dwEffects, expected_effects); + ok(cf2.bPitchAndFamily == host_cf->bPitchAndFamily, "got wrong bPitchAndFamily: %x, expected %x.\n", + cf2.bPitchAndFamily, host_cf->bPitchAndFamily); + ok(cf2.bCharSet == host_cf->bCharSet, "got wrong bCharSet: %x, expected %x.\n", cf2.bCharSet, host_cf->bCharSet); + + ITextServices_Release(txtserv); + ITextHost_Release(host); +} + +static void test_TxGetScroll(void) +{ + ITextServices *txtserv; + ITextHost *host; + HRESULT ret; + + if (!init_texthost(&txtserv, &host)) + return; + + ret = ITextServices_TxGetHScroll(txtserv, NULL, NULL, NULL, NULL, NULL); + ok(ret == S_OK, "ITextSerHices_GetVScroll failed: 0x%08x.\n", ret); + + ret = ITextServices_TxGetVScroll(txtserv, NULL, NULL, NULL, NULL, NULL); + ok(ret == S_OK, "ITextServices_GetVScroll failed: 0x%08x.\n", ret); + ITextServices_Release(txtserv); ITextHost_Release(host); } @@ -980,6 +1074,8 @@ START_TEST( txtsrv ) test_TxGetNaturalSize(); test_TxDraw(); test_QueryInterface(); + test_default_format(); + test_TxGetScroll(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); }
5 years, 1 month
1
0
0
0
[reactos] 01/01: [RICHED20] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=661b8a2a05f70f5d2eddc…
commit 661b8a2a05f70f5d2eddc0fdf089f003e84c79bc Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:10:55 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:10:55 2019 +0100 [RICHED20] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/riched20/caret.c | 68 +++++++++------- dll/win32/riched20/context.c | 5 +- dll/win32/riched20/editor.c | 181 +++++++++++++++++++++++-------------------- dll/win32/riched20/editor.h | 19 +++-- dll/win32/riched20/editstr.h | 8 +- dll/win32/riched20/paint.c | 50 +++++------- dll/win32/riched20/para.c | 7 +- dll/win32/riched20/precomp.h | 2 - dll/win32/riched20/richole.c | 57 ++++++-------- dll/win32/riched20/run.c | 25 +++--- dll/win32/riched20/style.c | 131 ++++++++++++++++++------------- dll/win32/riched20/table.c | 3 +- dll/win32/riched20/txthost.c | 37 +-------- dll/win32/riched20/txtsrv.c | 40 +--------- dll/win32/riched20/wrap.c | 5 +- dll/win32/riched20/writer.c | 19 ++--- media/doc/README.WINE | 2 +- 17 files changed, 307 insertions(+), 352 deletions(-) diff --git a/dll/win32/riched20/caret.c b/dll/win32/riched20/caret.c index ad72511da46..212c9e9f992 100644 --- a/dll/win32/riched20/caret.c +++ b/dll/win32/riched20/caret.c @@ -122,8 +122,14 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) return length; } - -int ME_SetSelection(ME_TextEditor *editor, int from, int to) +/****************************************************************** + * set_selection_cursors + * + * Updates the selection cursors. + * + * Note that this does not invalidate either the old or the new selections. + */ +int set_selection_cursors(ME_TextEditor *editor, int from, int to) { int selectionEnd = 0; const int len = ME_GetTextLength(editor); @@ -139,7 +145,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to) { ME_SetCursorToStart(editor, &editor->pCursors[1]); ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE); - ME_InvalidateSelection(editor); return len + 1; } @@ -165,7 +170,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to) end --; } editor->pCursors[1] = editor->pCursors[0]; - ME_Repaint(editor); } return end; } @@ -194,7 +198,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to) { ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE); editor->pCursors[1] = editor->pCursors[0]; - ME_InvalidateSelection(editor); return len; } @@ -266,36 +269,47 @@ void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, return; } - -void -ME_MoveCaret(ME_TextEditor *editor) +void create_caret(ME_TextEditor *editor) { int x, y, height; ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); - if(editor->bHaveFocus && !ME_IsSelection(editor)) - { - x = min(x, editor->rcFormat.right-1); - ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height); - ITextHost_TxSetCaretPos(editor->texthost, x, y); - } + ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height); + editor->caret_height = height; + editor->caret_hidden = TRUE; } +void show_caret(ME_TextEditor *editor) +{ + ITextHost_TxShowCaret(editor->texthost, TRUE); + editor->caret_hidden = FALSE; +} -void ME_ShowCaret(ME_TextEditor *ed) +void hide_caret(ME_TextEditor *editor) { - ME_MoveCaret(ed); - if(ed->bHaveFocus && !ME_IsSelection(ed)) - ITextHost_TxShowCaret(ed->texthost, TRUE); + /* calls to HideCaret are cumulative; do so only once */ + if (!editor->caret_hidden) + { + ITextHost_TxShowCaret(editor->texthost, FALSE); + editor->caret_hidden = TRUE; + } } -void ME_HideCaret(ME_TextEditor *ed) +void update_caret(ME_TextEditor *editor) { - if(!ed->bHaveFocus || ME_IsSelection(ed)) + int x, y, height; + + if (!editor->bHaveFocus) return; + if (!ME_IsSelection(editor)) { - ITextHost_TxShowCaret(ed->texthost, FALSE); - DestroyCaret(); + ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); + if (height != editor->caret_height) create_caret(editor); + x = min(x, editor->rcFormat.right-1); + ITextHost_TxSetCaretPos(editor->texthost, x, y); + show_caret(editor); } + else + hide_caret(editor); } BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, @@ -1200,8 +1214,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) } } ME_InvalidateSelection(editor); - ITextHost_TxShowCaret(editor->texthost, FALSE); - ME_ShowCaret(editor); + update_caret(editor); ME_SendSelChange(editor); } @@ -1233,8 +1246,7 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y) } ME_InvalidateSelection(editor); - ITextHost_TxShowCaret(editor->texthost, FALSE); - ME_ShowCaret(editor); + update_caret(editor); ME_SendSelChange(editor); } @@ -1627,9 +1639,9 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl) ME_InvalidateSelection(editor); ME_Repaint(editor); - ITextHost_TxShowCaret(editor->texthost, FALSE); + hide_caret(editor); ME_EnsureVisible(editor, &tmp_curs); - ME_ShowCaret(editor); + update_caret(editor); ME_SendSelChange(editor); return success; } diff --git a/dll/win32/riched20/context.c b/dll/win32/riched20/context.c index 2cdaeff328a..66066b39e67 100644 --- a/dll/win32/riched20/context.c +++ b/dll/win32/riched20/context.c @@ -27,6 +27,8 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) c->pt.x = 0; c->pt.y = 0; c->rcView = editor->rcFormat; + c->current_style = NULL; + c->orig_font = NULL; if (hDC) { c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX); c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY); @@ -41,5 +43,6 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) void ME_DestroyContext(ME_Context *c) { - if (c->hDC) ITextHost_TxReleaseDC(c->editor->texthost, c->hDC); + select_style( c, NULL ); + if (c->hDC) ITextHost_TxReleaseDC( c->editor->texthost, c->hDC ); } diff --git a/dll/win32/riched20/editor.c b/dll/win32/riched20/editor.c index c4ae49766ef..5ad25869997 100644 --- a/dll/win32/riched20/editor.c +++ b/dll/win32/riched20/editor.c @@ -1128,6 +1128,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB LPOLECLIENTSITE lpClientSite = NULL; LPDATAOBJECT lpDataObject = NULL; LPOLECACHE lpOleCache = NULL; + LPRICHEDITOLE lpReOle = NULL; STGMEDIUM stgm; FORMATETC fm; CLSID clsid; @@ -1160,7 +1161,8 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB } if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK && - IRichEditOle_GetClientSite(editor->reOle, &lpClientSite) == S_OK && + IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (void**)&lpReOle) == S_OK && + IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK && IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK && IOleObject_GetUserClassID(lpObject, &clsid) == S_OK && IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK && @@ -1192,6 +1194,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB if (lpStorage) IStorage_Release(lpStorage); if (lpDataObject) IDataObject_Release(lpDataObject); if (lpOleCache) IOleCache_Release(lpOleCache); + if (lpReOle) IRichEditOle_Release(lpReOle); return hr; } @@ -1623,7 +1626,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre } else { style = editor->pBuffer->pDefaultStyle; ME_AddRefStyle(style); - ME_SetSelection(editor, 0, 0); + set_selection_cursors(editor, 0, 0); ME_InternalDeleteText(editor, &editor->pCursors[1], ME_GetTextLength(editor), FALSE); from = to = 0; @@ -1757,9 +1760,9 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre cf.dwMask = CFM_ALL2; ME_MoveCursorChars(editor, &lastcharCursor, -1, FALSE); ME_GetCharFormat(editor, &lastcharCursor, &linebreakCursor, &cf); - ME_SetSelection(editor, newto, -1); + set_selection_cursors(editor, newto, -1); ME_SetSelectionCharFormat(editor, &cf); - ME_SetSelection(editor, newto, newto); + set_selection_cursors(editor, newto, newto); ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE); ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE); @@ -1782,7 +1785,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ERR("EM_STREAMIN without SF_TEXT or SF_RTF\n"); /* put the cursor at the top */ if (!(format & SFF_SELECTION)) - ME_SetSelection(editor, 0, 0); + set_selection_cursors(editor, 0, 0); ME_CursorFromCharOfs(editor, from, &start); ME_UpdateLinkAttribute(editor, &start, to - from); } @@ -1803,9 +1806,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre if (!(format & SFF_SELECTION)) { ME_ClearTempStyle(editor); } - ITextHost_TxShowCaret(editor->texthost, FALSE); - ME_MoveCaret(editor); - ITextHost_TxShowCaret(editor->texthost, TRUE); + update_caret(editor); ME_SendSelChange(editor); ME_SendRequestResize(editor, FALSE); @@ -1929,7 +1930,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurStart + nMatched ), text[nMatched], (flags & FR_MATCHCASE))) { - if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) + if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar)) break; nMatched++; @@ -1953,7 +1954,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH else wNextChar = ' '; - if (isalnumW(wNextChar)) + if (iswalnum(wNextChar)) break; } @@ -2013,7 +2014,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 ), text[nLen - nMatched - 1], (flags & FR_MATCHCASE) )) { - if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) + if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar)) break; nMatched++; @@ -2039,7 +2040,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH else wPrevChar = ' '; - if (isalnumW(wPrevChar)) + if (iswalnum(wPrevChar)) break; } @@ -2150,17 +2151,16 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText, } } -static int handle_EM_EXSETSEL( ME_TextEditor *editor, int to, int from ) +int set_selection( ME_TextEditor *editor, int to, int from ) { int end; TRACE("%d - %d\n", to, from ); - ME_InvalidateSelection( editor ); - end = ME_SetSelection( editor, to, from ); - ME_InvalidateSelection( editor ); - ITextHost_TxShowCaret( editor->texthost, FALSE ); - ME_ShowCaret( editor ); + if (!editor->bHideSelection) ME_InvalidateSelection( editor ); + end = set_selection_cursors( editor, to, from ); + if (!editor->bHideSelection) ME_InvalidateSelection( editor ); + update_caret( editor ); ME_SendSelChange( editor ); return end; @@ -2686,7 +2686,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) case 'A': if (ctrl_is_down) { - handle_EM_EXSETSEL( editor, 0, -1 ); + set_selection( editor, 0, -1 ); return TRUE; } break; @@ -3119,6 +3119,8 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) ed->bHaveFocus = FALSE; ed->bDialogMode = FALSE; ed->bMouseCaptured = FALSE; + ed->caret_hidden = FALSE; + ed->caret_height = 0; for (i=0; i<HFONT_CACHE_SIZE; i++) { ed->pFontCache[i].nRefs = 0; @@ -3219,7 +3221,7 @@ void ME_DestroyEditor(ME_TextEditor *editor) ITextHost_Release(editor->texthost); if (editor->reOle) { - IRichEditOle_Release(editor->reOle); + IUnknown_Release(editor->reOle); editor->reOle = NULL; } OleUninitialize(); @@ -3530,10 +3532,59 @@ static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode) ME_CommitUndo(editor); ME_WrapMarkedParagraphs(editor); - ME_MoveCaret(editor); + update_caret(editor); return 0; } +static LRESULT handle_EM_SETCHARFORMAT( ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in ) +{ + CHARFORMAT2W fmt; + BOOL changed = TRUE; + ME_Cursor start, end; + + if (!cfany_to_cf2w( &fmt, fmt_in )) return 0; + + if (flags & SCF_ALL) + { + if (editor->mode & TM_PLAINTEXT) + { + ME_SetDefaultCharFormat( editor, &fmt ); + } + else + { + ME_SetCursorToStart( editor, &start ); + ME_SetCharFormat( editor, &start, NULL, &fmt ); + editor->nModifyStep = 1; + } + } + else if (flags & SCF_SELECTION) + { + if (editor->mode & TM_PLAINTEXT) return 0; + if (flags & SCF_WORD) + { + end = editor->pCursors[0]; + ME_MoveCursorWords( editor, &end, +1 ); + start = end; + ME_MoveCursorWords( editor, &start, -1 ); + ME_SetCharFormat( editor, &start, &end, &fmt ); + } + changed = ME_IsSelection( editor ); + ME_SetSelectionCharFormat( editor, &fmt ); + if (changed) editor->nModifyStep = 1; + } + else /* SCF_DEFAULT */ + { + ME_SetDefaultCharFormat( editor, &fmt ); + } + + ME_CommitUndo( editor ); + if (changed) + { + ME_WrapMarkedParagraphs( editor ); + ME_UpdateScrollBar( editor ); + } + return 1; +} #define UNSUPPORTED_MSG(e) \ case e: \ @@ -3682,7 +3733,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ME_CommitUndo(editor); ME_WrapMarkedParagraphs(editor); ME_UpdateScrollBar(editor); - ME_Repaint(editor); return TRUE; } @@ -3750,7 +3800,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, } case EM_SETSEL: { - return handle_EM_EXSETSEL( editor, wParam, lParam ); + return set_selection( editor, wParam, lParam ); } case EM_SETSCROLLPOS: { @@ -3775,7 +3825,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, { CHARRANGE range = *(CHARRANGE *)lParam; - return handle_EM_EXSETSEL( editor, range.cpMin, range.cpMax ); + return set_selection( editor, range.cpMin, range.cpMax ); } case EM_SHOWSCROLLBAR: { @@ -3935,46 +3985,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, case EM_GETEVENTMASK: return editor->nEventMask; case EM_SETCHARFORMAT: - { - CHARFORMAT2W p; - BOOL bRepaint = TRUE; - if (!cfany_to_cf2w(&p, (CHARFORMAT2W *)lParam)) - return 0; - if (wParam & SCF_ALL) { - if (editor->mode & TM_PLAINTEXT) { - ME_SetDefaultCharFormat(editor, &p); - } else { - ME_Cursor start; - ME_SetCursorToStart(editor, &start); - ME_SetCharFormat(editor, &start, NULL, &p); - editor->nModifyStep = 1; - } - } else if (wParam & SCF_SELECTION) { - if (editor->mode & TM_PLAINTEXT) - return 0; - if (wParam & SCF_WORD) { - ME_Cursor start; - ME_Cursor end = editor->pCursors[0]; - ME_MoveCursorWords(editor, &end, +1); - start = end; - ME_MoveCursorWords(editor, &start, -1); - ME_SetCharFormat(editor, &start, &end, &p); - } - bRepaint = ME_IsSelection(editor); - ME_SetSelectionCharFormat(editor, &p); - if (bRepaint) editor->nModifyStep = 1; - } else { /* SCF_DEFAULT */ - ME_SetDefaultCharFormat(editor, &p); - } - ME_CommitUndo(editor); - if (bRepaint) - { - ME_WrapMarkedParagraphs(editor); - ME_UpdateScrollBar(editor); - ME_Repaint(editor); - } - return 1; - } + return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam ); case EM_GETCHARFORMAT: { CHARFORMAT2W tmp, *dst = (CHARFORMAT2W *)lParam; @@ -3996,7 +4007,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); ME_WrapMarkedParagraphs(editor); ME_UpdateScrollBar(editor); - ME_Repaint(editor); ME_CommitUndo(editor); return result; } @@ -4116,7 +4126,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, TRACE("WM_SETTEXT - NULL\n"); ME_SetCursorToStart(editor, &cursor); ME_UpdateLinkAttribute(editor, &cursor, INT_MAX); - ME_SetSelection(editor, 0, 0); + set_selection_cursors(editor, 0, 0); editor->nModifyStep = 0; ME_CommitUndo(editor); ME_EmptyUndoStack(editor); @@ -4512,7 +4522,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, break; case WM_SETFOCUS: editor->bHaveFocus = TRUE; - ME_ShowCaret(editor); + create_caret(editor); + update_caret(editor); ME_SendOldNotify(editor, EN_SETFOCUS); if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL)) ME_InvalidateSelection( editor ); @@ -4521,7 +4532,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ME_CommitUndo(editor); /* End coalesced undos for typed characters */ editor->bHaveFocus = FALSE; editor->wheel_remain = 0; - ME_HideCaret(editor); + hide_caret(editor); + DestroyCaret(); ME_SendOldNotify(editor, EN_KILLFOCUS); if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL)) ME_InvalidateSelection( editor ); @@ -4805,7 +4817,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, HeapFree(GetProcessHeap(), 0, lpCompStr); if (dwIndex == GCS_COMPSTR) - ME_SetSelection(editor,editor->imeStartIndex, + set_selection_cursors(editor,editor->imeStartIndex, editor->imeStartIndex + dwBufLen/sizeof(WCHAR)); } ME_ReleaseStyle(style); @@ -4824,9 +4836,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, if (!editor->reOle) if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle)) return 0; - *(LPVOID *)lParam = editor->reOle; - IRichEditOle_AddRef(editor->reOle); - return 1; + if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK) + return 1; + return 0; } case EM_GETPASSWORDCHAR: { @@ -4975,41 +4987,46 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, { case WM_PAINT: { - HDC hDC; + HDC hdc; RECT rc; PAINTSTRUCT ps; + HBRUSH old_brush; - hDC = BeginPaint(editor->hWnd, &ps); + update_caret(editor); + hdc = BeginPaint(editor->hWnd, &ps); if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE)) ME_SendOldNotify(editor, EN_UPDATE); + old_brush = SelectObject(hdc, editor->hbrBackground); + /* Erase area outside of the formatting rectangle */ if (ps.rcPaint.top < editor->rcFormat.top) { rc = ps.rcPaint; rc.bottom = editor->rcFormat.top; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.top = editor->rcFormat.top; } if (ps.rcPaint.bottom > editor->rcFormat.bottom) { rc = ps.rcPaint; rc.top = editor->rcFormat.bottom; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.bottom = editor->rcFormat.bottom; } if (ps.rcPaint.left < editor->rcFormat.left) { rc = ps.rcPaint; rc.right = editor->rcFormat.left; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.left = editor->rcFormat.left; } if (ps.rcPaint.right > editor->rcFormat.right) { rc = ps.rcPaint; rc.left = editor->rcFormat.right; - FillRect(hDC, &rc, editor->hbrBackground); + PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); ps.rcPaint.right = editor->rcFormat.right; } - ME_PaintContent(editor, hDC, &ps.rcPaint); + ME_PaintContent(editor, hdc, &ps.rcPaint); + SelectObject(hdc, old_brush); EndPaint(editor->hWnd, &ps); return 0; } @@ -5283,7 +5300,7 @@ LRESULT WINAPI REExtendedRegisterClass(void) return result; } -static int wchar_comp( const void *key, const void *elem ) +static int __cdecl wchar_comp( const void *key, const void *elem ) { return *(const WCHAR *)key - *(const WCHAR *)elem; } @@ -5332,7 +5349,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, while (cursor.nOffset < run_len) { c = str[cursor.nOffset]; - if (!isspaceW( c ) && !isurlneutral( c )) + if (!iswspace( c ) && !isurlneutral( c )) { *candidate_min = cursor; candidateStarted = TRUE; @@ -5352,7 +5369,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, while (cursor.nOffset < run_len) { c = str[cursor.nOffset]; - if (isspaceW( c )) + if (iswspace( c )) { if (quoted && c != '\r') { diff --git a/dll/win32/riched20/editor.h b/dll/win32/riched20/editor.h index b9dc4ec74f9..2bd06be2cf6 100644 --- a/dll/win32/riched20/editor.h +++ b/dll/win32/riched20/editor.h @@ -21,7 +21,6 @@ #pragma once #include "editstr.h" -#include "wine/unicode.h" struct _RTF_Info; @@ -56,8 +55,7 @@ void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN; void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN; ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN; ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN; -HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN; -void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) DECLSPEC_HIDDEN; +void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN; void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN; void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN; void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN; @@ -107,7 +105,7 @@ static inline int ME_IsWSpace(WCHAR ch) static inline int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive) { - return caseSensitive ? (a == b) : (toupperW(a) == toupperW(b)); + return caseSensitive ? (a == b) : (towupper(a) == towupper(b)); } /* note: those two really return the first matching offset (starting from EOS)+1 @@ -152,11 +150,12 @@ void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_ /* caret.c */ void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN; -int ME_SetSelection(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN; +int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN; BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN; -void ME_HideCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -void ME_ShowCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; -void ME_MoveCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN; +void hide_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; +void show_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; +void update_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; +void create_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN; BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact) DECLSPEC_HIDDEN; void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) DECLSPEC_HIDDEN; void ME_MouseMove(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN; @@ -241,7 +240,6 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPE void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN; void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN; void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN; -void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN; /* editor.c */ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; @@ -258,6 +256,7 @@ void ME_RTFSpecialCharHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN; extern BOOL me_debug DECLSPEC_HIDDEN; void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN; +int set_selection( ME_TextEditor *editor, int to, int from ) DECLSPEC_HIDDEN; /* table.c */ BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN; @@ -279,7 +278,7 @@ void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef) DECLSPEC_ /* txthost.c */ ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; -#ifdef __i386__ /* Use wrappers to perform thiscall on i386 */ +#if defined(__i386__) && !defined(__MINGW32__) /* Use wrappers to perform thiscall on i386 */ #define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl) #else /* __i386__ */ #define TXTHOST_VTABLE(This) (This)->lpVtbl diff --git a/dll/win32/riched20/editstr.h b/dll/win32/riched20/editstr.h index 96c9a1f644b..a2e6f8584b7 100644 --- a/dll/win32/riched20/editstr.h +++ b/dll/win32/riched20/editstr.h @@ -51,7 +51,7 @@ #include "wine/heap.h" #include "wine/list.h" -#ifdef __i386__ +#if defined(__i386__) && !defined(__MINGW32__) extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN; #endif /* __i386__ */ @@ -385,7 +385,7 @@ typedef struct tagME_TextEditor { HWND hWnd, hwndParent; ITextHost *texthost; - IRichEditOle *reOle; + IUnknown *reOle; BOOL bEmulateVersion10; ME_TextBuffer *pBuffer; ME_Cursor *pCursors; @@ -442,6 +442,8 @@ typedef struct tagME_TextEditor /* Cache previously set scrollbar info */ SCROLLINFO vert_si, horz_si; + int caret_height; + BOOL caret_hidden; BOOL bMouseCaptured; int wheel_remain; struct list style_list; @@ -455,6 +457,8 @@ typedef struct tagME_Context RECT rcView; SIZE dpi; int nAvailWidth; + ME_Style *current_style; + HFONT orig_font; /* those are valid inside ME_WrapTextParagraph and related */ ME_TextEditor *editor; diff --git a/dll/win32/riched20/paint.c b/dll/win32/riched20/paint.c index e2ccef4fbf7..72128072380 100644 --- a/dll/win32/riched20/paint.c +++ b/dll/win32/riched20/paint.c @@ -43,7 +43,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) ME_InitContext(&c, editor, hDC); SetBkMode(hDC, TRANSPARENT); - ME_MoveCaret(editor); + item = editor->pBuffer->pFirst->next; /* This context point is an offset for the paragraph positions stored * during wrapping. It shouldn't be modified during painting. */ @@ -87,7 +87,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) IntersectRect(&rc, &rc, rcUpdate); if (!IsRectEmpty(&rc)) - FillRect(hDC, &rc, c.editor->hbrBackground); + PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth) @@ -291,11 +291,10 @@ static void draw_space( ME_Context *c, ME_Run *run, int x, int y, { COLORREF text_color = get_text_color( c, run->style, selected ); COLORREF old_text, old_back; - HFONT old_font = NULL; int y_offset = calc_y_offset( c, run->style ); static const WCHAR space[1] = {' '}; - old_font = ME_SelectStyleFont( c, run->style ); + select_style( c, run->style ); old_text = SetTextColor( hdc, text_color ); if (selected) old_back = SetBkColor( hdc, back_color ); @@ -303,7 +302,6 @@ static void draw_space( ME_Context *c, ME_Run *run, int x, int y, if (selected) SetBkColor( hdc, old_back ); SetTextColor( hdc, old_text ); - ME_UnselectStyleFont( c, run->style, old_font ); draw_underline( c, run, x, y - y_offset, text_color ); } @@ -371,7 +369,6 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x, int y, int nSelFrom, int nSelTo, int ymin, int cy) { HDC hDC = c->hDC; - HGDIOBJ hOldFont; int yOffset = 0; BOOL selected = (nSelFrom < run->len && nSelTo >= 0 && nSelFrom < nSelTo && !c->editor->bHideSelection && @@ -404,7 +401,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x, int y, } } - hOldFont = ME_SelectStyleFont( c, run->style ); + select_style( c, run->style ); if (sel_rgn) ExtSelectClipRgn( hDC, sel_rgn, RGN_DIFF ); @@ -431,8 +428,6 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x, int y, if (old_style_selected) PatBlt( hDC, sel_rect.left, ymin, sel_rect.right - sel_rect.left, cy, DSTINVERT ); - - ME_UnselectStyleFont(c, run->style, hOldFont); } static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) { @@ -603,7 +598,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.top = y; bounds->top = ME_twips2pointsY(c, para->fmt.dySpaceBefore); rc.bottom = y + bounds->top + top_border; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } if (para->fmt.dwMask & PFM_SPACEAFTER) @@ -613,7 +608,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.bottom = y + para->nHeight; bounds->bottom = ME_twips2pointsY(c, para->fmt.dySpaceAfter); rc.top = rc.bottom - bounds->bottom - bottom_border; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } /* Native richedit doesn't support paragraph borders in v1.0 - 4.1, @@ -652,7 +647,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.right = rc.left + border_width; rc.top = y + bounds->top; rc.bottom = y + para->nHeight - bounds->bottom; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); MoveToEx(c->hDC, c->pt.x + pen_width + 1, y + bounds->top + DD(4), NULL); LineTo(c->hDC, c->pt.x + pen_width + 1, y + para->nHeight - bounds->bottom - DD(8)); } @@ -667,7 +662,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT rc.right = rc.left + pen_width; rc.top = y + bounds->top; rc.bottom = y + para->nHeight - bounds->bottom; - FillRect(c->hDC, &rc, c->editor->hbrBackground); + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); MoveToEx(c->hDC, rightEdge - 1 - pen_width - 1, y + bounds->top + DD(4), NULL); LineTo(c->hDC, rightEdge - 1 - pen_width - 1, y + para->nHeight - bounds->bottom - DD(8)); } @@ -731,9 +726,8 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph) rc.top = top + width; width = cell->yTextOffset - width; rc.bottom = rc.top + width; - if (width) { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + if (width) + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); } /* Draw cell borders. * The order borders are draw in is left, top, bottom, right in order @@ -901,13 +895,12 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem *paragraph) static void draw_para_number( ME_Context *c, ME_DisplayItem *p ) { ME_Paragraph *para = &p->member.para; - HFONT old_font; int x, y; COLORREF old_text; if (para->fmt.wNumbering) { - old_font = ME_SelectStyleFont( c, para->para_num.style ); + select_style( c, para->para_num.style ); old_text = SetTextColor( c->hDC, get_text_color( c, para->para_num.style, FALSE ) ); x = c->pt.x + para->para_num.pt.x; @@ -916,7 +909,6 @@ static void draw_para_number( ME_Context *c, ME_DisplayItem *p ) ExtTextOutW( c->hDC, x, y, 0, NULL, para->para_num.text->szData, para->para_num.text->nLen, NULL ); SetTextColor( c->hDC, old_text ); - ME_UnselectStyleFont( c, para->para_num.style, old_font ); } } @@ -974,18 +966,18 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rc.bottom = y + p->member.row.nHeight; } visible = RectVisible(c->hDC, &rc); - if (visible) { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + if (visible) + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); if (bounds.right) { /* If scrolled to the right past the end of the text, then * there may be space to the right of the paragraph border. */ - RECT rcAfterBrdr = rc; - rcAfterBrdr.left = rc.right + bounds.right; - rcAfterBrdr.right = c->rcView.right; - if (RectVisible(c->hDC, &rcAfterBrdr)) - FillRect(c->hDC, &rcAfterBrdr, c->editor->hbrBackground); + RECT after_bdr = rc; + after_bdr.left = rc.right + bounds.right; + after_bdr.right = c->rcView.right; + if (RectVisible(c->hDC, &after_bdr)) + PatBlt(c->hDC, after_bdr.left, after_bdr.top, after_bdr.right - after_bdr.left, + after_bdr.bottom - after_bdr.top, PATCOPY); } if (me_debug) { @@ -1034,9 +1026,7 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) rc.top = c->pt.y + para->pt.y + para->nHeight; rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight; if (RectVisible(c->hDC, &rc)) - { - FillRect(c->hDC, &rc, c->editor->hbrBackground); - } + PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY); break; default: break; diff --git a/dll/win32/riched20/para.c b/dll/win32/riched20/para.c index 6eec6b5906b..1ba2a7ac541 100644 --- a/dll/win32/riched20/para.c +++ b/dll/win32/riched20/para.c @@ -312,7 +312,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num ) { case PFN_ARABIC: default: - p += sprintfW( p, fmtW, num ); + p += swprintf( p, fmtW, num ); break; case PFN_LCLETTER: @@ -399,9 +399,9 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) static const WCHAR bullet_font[] = {'S','y','m','b','o','l',0}; static const WCHAR bullet_str[] = {0xb7, 0}; static const WCHAR spaceW[] = {' ', 0}; - HFONT old_font; SIZE sz; + if (!para->fmt.wNumbering) return; if (para->para_num.style && para->para_num.text) return; if (!para->para_num.style) @@ -432,12 +432,11 @@ void para_num_init( ME_Context *c, ME_Paragraph *para ) para->para_num.text = ME_MakeStringConst( bullet_str, 1 ); } - old_font = ME_SelectStyleFont( c, para->para_num.style ); + select_style( c, para->para_num.style ); GetTextExtentPointW( c->hDC, para->para_num.text->szData, para->para_num.text->nLen, &sz ); para->para_num.width = sz.cx; GetTextExtentPointW( c->hDC, spaceW, 1, &sz ); para->para_num.width += sz.cx; - ME_UnselectStyleFont( c, para->para_num.style, old_font ); } void para_num_clear( struct para_num *pn ) diff --git a/dll/win32/riched20/precomp.h b/dll/win32/riched20/precomp.h index b492ada0979..1e8a99192f2 100644 --- a/dll/win32/riched20/precomp.h +++ b/dll/win32/riched20/precomp.h @@ -2,8 +2,6 @@ #ifndef _RICHED20_PRECOMP_H #define _RICHED20_PRECOMP_H -#include <wine/config.h> - #define WIN32_NO_STATUS #define _INC_WINDOWS #define COM_NO_WINDOWS_H diff --git a/dll/win32/riched20/richole.c b/dll/win32/riched20/richole.c index 88ce7b6bfb0..3bfc4663a28 100644 --- a/dll/win32/riched20/richole.c +++ b/dll/win32/riched20/richole.c @@ -372,7 +372,7 @@ static inline BOOL is_equal_textfont_prop_value(enum textfont_prop_id propid, te case FONT_WEIGHT: return left->l == right->l; case FONT_NAME: - return !strcmpW(left->str, right->str); + return !wcscmp(left->str, right->str); case FONT_POSITION: case FONT_SIZE: case FONT_SPACING: @@ -1399,6 +1399,16 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob, else reobj = cursor.pRun->member.run.reobj; } + else if (iob == REO_IOB_SELECTION) + { + ME_Cursor *from, *to; + + ME_GetSelection(This->editor, &from, &to); + if (!from->pRun->member.run.reobj) + return E_INVALIDARG; + else + reobj = from->pRun->member.run.reobj; + } else { if (iob > IRichEditOle_GetObjectCount(me)) @@ -1686,7 +1696,7 @@ static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR str) } /* it's safer not to rely on stored BSTR length */ - len = strlenW(str); + len = lstrlenW(str); cursor = editor->pCursors[0]; ME_CursorFromCharOfs(editor, This->start, &editor->pCursors[0]); style = ME_GetInsertStyle(editor, 0); @@ -2027,6 +2037,7 @@ static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG unit, LONG inde static void cp2range(ME_TextEditor *editor, LONG *cp1, LONG *cp2) { int len = ME_GetTextLength(editor) + 1; + *cp1 = max(*cp1, 0); *cp2 = max(*cp2, 0); *cp1 = min(*cp1, len); @@ -2146,7 +2157,7 @@ static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me) if (!This->child.reole) return CO_E_RELEASED; - ME_SetSelection(This->child.reole->editor, This->start, This->end); + set_selection(This->child.reole->editor, This->start, This->end); return S_OK; } @@ -2506,6 +2517,10 @@ static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value) ME_CursorFromCharOfs(editor, This->start, &cursor); ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height); break; + case tomEnd: + ME_CursorFromCharOfs(editor, This->end, &cursor); + ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height); + break; default: FIXME("bStart value %d not handled\n", value); return E_NOTIMPL; @@ -2715,10 +2730,6 @@ static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, pFont); - - if (This->range && !get_range_reole(This->range)) - return CO_E_RELEASED; - return E_NOTIMPL; } @@ -2726,10 +2737,6 @@ static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, ret); - - if (This->range && !get_range_reole(This->range)) - return CO_E_RELEASED; - return E_NOTIMPL; } @@ -2737,10 +2744,6 @@ static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG * { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p %p): stub\n", This, font, ret); - - if (This->range && !get_range_reole(This->range)) - return CO_E_RELEASED; - return E_NOTIMPL; } @@ -2914,10 +2917,6 @@ static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, value); - - if (This->range && !get_range_reole(This->range)) - return CO_E_RELEASED; - return E_NOTIMPL; } @@ -2925,10 +2924,6 @@ static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%d): stub\n", This, value); - - if (This->range && !get_range_reole(This->range)) - return CO_E_RELEASED; - return E_NOTIMPL; } @@ -4754,7 +4749,7 @@ static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR str) return CO_E_RELEASED; editor = This->reOle->editor; - len = strlenW(str); + len = lstrlenW(str); ME_GetSelectionOfs(editor, &from, &to); ME_ReplaceSel(editor, FALSE, str, len); @@ -4866,7 +4861,7 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG value) ME_GetSelectionOfs(This->reOle->editor, &start, &end); hr = textrange_setstart(This->reOle, value, &start, &end); if (hr == S_OK) - ME_SetSelection(This->reOle->editor, start, end); + set_selection(This->reOle->editor, start, end); return hr; } @@ -4901,7 +4896,7 @@ static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG value) ME_GetSelectionOfs(This->reOle->editor, &start, &end); hr = textrange_setend(This->reOle, value, &start, &end); if (hr == S_OK) - ME_SetSelection(This->reOle->editor, start, end); + set_selection(This->reOle->editor, start, end); return hr; } @@ -5020,7 +5015,7 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart) ME_GetSelectionOfs(This->reOle->editor, &start, &end); hres = range_Collapse(bStart, &start, &end); if (SUCCEEDED(hres)) - ME_SetSelection(This->reOle->editor, start, end); + set_selection(This->reOle->editor, start, end); return hres; } @@ -5712,7 +5707,7 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *p reo->outer_unk = outer_unk; else reo->outer_unk = &reo->IUnknown_inner; - *ppvObj = &reo->IRichEditOle_iface; + *ppvObj = &reo->IUnknown_inner; return 1; } @@ -5932,9 +5927,3 @@ void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) IOleClientSite_AddRef(dst->polesite); } } - -void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj) -{ - IRichEditOleImpl *This = impl_from_IRichEditOle(iface); - *ppvObj = &This->ITextDocument2Old_iface; -} diff --git a/dll/win32/riched20/run.c b/dll/win32/riched20/run.c index b9e1269fe8f..3912384451c 100644 --- a/dll/win32/riched20/run.c +++ b/dll/win32/riched20/run.c @@ -464,7 +464,6 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BO ME_String *mask_text = NULL; WCHAR *str; int fit = 0; - HGDIOBJ hOldFont; SIZE sz, sz2, sz3; if (!run->len || cx <= 0) return 0; @@ -503,7 +502,7 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BO else str = get_text( run, 0 ); - hOldFont = ME_SelectStyleFont(c, run->style); + select_style(c, run->style); GetTextExtentExPointW(c->hDC, str, run->len, cx, &fit, NULL, &sz); if (closest && fit != run->len) @@ -516,7 +515,6 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BO ME_DestroyString( mask_text ); - ME_UnselectStyleFont(c, run->style, hOldFont); return fit; } @@ -538,15 +536,16 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, B */ static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size) { - HGDIOBJ hOldFont; - if (c->hDC) { - hOldFont = ME_SelectStyleFont(c, s); - GetTextExtentPoint32W(c->hDC, szText, nChars, size); - ME_UnselectStyleFont(c, s, hOldFont); - } else { - size->cx = 0; - size->cy = 0; - } + if (c->hDC) + { + select_style( c, s ); + GetTextExtentPoint32W( c->hDC, szText, nChars, size ); + } + else + { + size->cx = 0; + size->cy = 0; + } } /****************************************************************************** @@ -867,7 +866,7 @@ void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from, { if (!(tmp.dwMask & CFM_FACE)) pFmt->dwMask &= ~CFM_FACE; - else if (lstrcmpW(pFmt->szFaceName, tmp.szFaceName) || + else if (wcscmp(pFmt->szFaceName, tmp.szFaceName) || pFmt->bPitchAndFamily != tmp.bPitchAndFamily) pFmt->dwMask &= ~CFM_FACE; } diff --git a/dll/win32/riched20/style.c b/dll/win32/riched20/style.c index c3f3fc3f9a9..8b9c2126b1b 100644 --- a/dll/win32/riched20/style.c +++ b/dll/win32/riched20/style.c @@ -85,6 +85,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName)); WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), NULL, NULL); t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */ + t->dwMask &= CFM_ALL; + t->dwEffects &= CFM_EFFECTS; return TRUE; } if (to->cbSize == sizeof(CHARFORMATW)) @@ -92,6 +94,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) CHARFORMATW *t = (CHARFORMATW *)to; CopyMemory(t, from, sizeof(*t)); t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */ + t->dwMask &= CFM_ALL; + t->dwEffects &= CFM_EFFECTS; return TRUE; } if (to->cbSize == sizeof(CHARFORMAT2A)) @@ -348,62 +352,11 @@ static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2) { if (memcmp(p1, p2, sizeof(LOGFONTW)-sizeof(p1->lfFaceName))) return FALSE; - if (lstrcmpW(p1->lfFaceName, p2->lfFaceName)) + if (wcscmp(p1->lfFaceName, p2->lfFaceName)) return FALSE; return TRUE; } -HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) -{ - HFONT hOldFont; - LOGFONTW lf; - int i, nEmpty, nAge = 0x7FFFFFFF; - ME_FontCacheItem *item; - assert(s); - - ME_LogFontFromStyle(c, &lf, s); - - for (i=0; i<HFONT_CACHE_SIZE; i++) - c->editor->pFontCache[i].nAge++; - for (i=0, nEmpty=-1, nAge=0; i<HFONT_CACHE_SIZE; i++) - { - item = &c->editor->pFontCache[i]; - if (!item->nRefs) - { - if (item->nAge > nAge) - nEmpty = i, nAge = item->nAge; - } - if (item->hFont && ME_IsFontEqual(&item->lfSpecs, &lf)) - break; - } - if (i < HFONT_CACHE_SIZE) /* found */ - { - item = &c->editor->pFontCache[i]; - TRACE_(richedit_style)("font reused %d\n", i); - item->nRefs++; - } - else - { - item = &c->editor->pFontCache[nEmpty]; /* this legal even when nEmpty == -1, as we don't dereference it */ - - assert(nEmpty != -1); /* otherwise we leak cache entries or get too many fonts at once*/ - if (item->hFont) { - TRACE_(richedit_style)("font deleted %d\n", nEmpty); - DeleteObject(item->hFont); - item->hFont = NULL; - } - item->hFont = CreateFontIndirectW(&lf); - TRACE_(richedit_style)("font created %d\n", nEmpty); - item->nRefs = 1; - item->lfSpecs = lf; - } - s->font_cache = item; - hOldFont = SelectObject(c->hDC, item->hFont); - /* should be cached too, maybe ? */ - GetTextMetricsW(c->hDC, &s->tm); - return hOldFont; -} - static void release_font_cache(ME_FontCacheItem *item) { if (item->nRefs > 0) @@ -413,11 +366,77 @@ static void release_font_cache(ME_FontCacheItem *item) } } -void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) +void select_style( ME_Context *c, ME_Style *s ) { - SelectObject(c->hDC, hOldFont); - release_font_cache(s->font_cache); - s->font_cache = NULL; + HFONT old_font; + LOGFONTW lf; + int i, empty, age = 0x7FFFFFFF; + ME_FontCacheItem *item; + + if (c->current_style == s) return; + + if (s) + { + ME_LogFontFromStyle( c, &lf, s ); + + for (i = 0; i < HFONT_CACHE_SIZE; i++) + c->editor->pFontCache[i].nAge++; + for (i = 0, empty = -1, age = 0; i < HFONT_CACHE_SIZE; i++) + { + item = &c->editor->pFontCache[i]; + if (!item->nRefs) + { + if (item->nAge > age) + { + empty = i; + age = item->nAge; + } + } + + if (item->hFont && ME_IsFontEqual( &item->lfSpecs, &lf )) + break; + } + + if (i < HFONT_CACHE_SIZE) /* found */ + { + item = &c->editor->pFontCache[i]; + TRACE_(richedit_style)( "font reused %d\n", i ); + item->nRefs++; + } + else + { + assert(empty != -1); + item = &c->editor->pFontCache[empty]; + if (item->hFont) + { + TRACE_(richedit_style)( "font deleted %d\n", empty ); + DeleteObject(item->hFont); + item->hFont = NULL; + } + item->hFont = CreateFontIndirectW( &lf ); + TRACE_(richedit_style)( "font created %d\n", empty ); + item->nRefs = 1; + item->lfSpecs = lf; + } + s->font_cache = item; + old_font = SelectObject( c->hDC, item->hFont ); + GetTextMetricsW( c->hDC, &s->tm ); + if (!c->orig_font) c->orig_font = old_font; + } + else + { + SelectObject( c->hDC, c->orig_font ); + c->orig_font = NULL; + } + + if (c->current_style) + { + release_font_cache( c->current_style->font_cache ); + c->current_style->font_cache = NULL; + } + c->current_style = s; + + return; } void ME_DestroyStyle(ME_Style *s) diff --git a/dll/win32/riched20/table.c b/dll/win32/riched20/table.c index 7e8d7ffacb3..1b4b9143d16 100644 --- a/dll/win32/riched20/table.c +++ b/dll/win32/riched20/table.c @@ -613,8 +613,7 @@ void ME_TabPressedInTable(ME_TextEditor *editor, BOOL bSelectedRow) } ME_InvalidateSelection(editor); ME_Repaint(editor); - ITextHost_TxShowCaret(editor->texthost, FALSE); - ME_ShowCaret(editor); + update_caret(editor); ME_SendSelChange(editor); } diff --git a/dll/win32/riched20/txthost.c b/dll/win32/riched20/txthost.c index d709502a1ec..5cdb8c06fd1 100644 --- a/dll/win32/riched20/txthost.c +++ b/dll/win32/riched20/txthost.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #define COBJMACROS #include "editor.h" @@ -28,6 +25,7 @@ #include "richole.h" #include "imm.h" #include "textserv.h" +#include "wine/asm.h" #include "wine/debug.h" #include "editstr.h" @@ -497,37 +495,6 @@ DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *i *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */ return S_OK; } - - -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define THISCALL(func) (void *) __thiscall_ ## func -#ifdef _MSC_VER -#define DEFINE_THISCALL_WRAPPER(func,args) \ - __declspec(naked) HRESULT __thiscall_##func(void) \ - { \ - __asm pop eax \ - __asm push ecx \ - __asm push eax \ - __asm jmp func \ - } -#else /* _MSC_VER */ -#define DEFINE_THISCALL_WRAPPER(func,args) \ - extern HRESULT __thiscall_ ## func(void); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) -#endif /* _MSC_VER */ - -#else /* __i386__ */ - -#define THISCALL(func) func -#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ - -#endif /* __i386__ */ - DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4) DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8) DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12) @@ -568,7 +535,7 @@ DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4) DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8) DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8) -#ifdef __i386__ /* thiscall functions are i386-specific */ +#if defined(__i386__) && !defined(__MINGW32__) /* thiscall functions are i386-specific */ #define STDCALL(func) (void *) __stdcall_ ## func #ifdef _MSC_VER diff --git a/dll/win32/riched20/txtsrv.c b/dll/win32/riched20/txtsrv.c index 73815fbbd1f..ca38f5c72a9 100644 --- a/dll/win32/riched20/txtsrv.c +++ b/dll/win32/riched20/txtsrv.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #define COBJMACROS #include "editor.h" @@ -30,38 +27,10 @@ #include "tom.h" #include "imm.h" #include "textserv.h" +#include "wine/asm.h" #include "wine/debug.h" #include "editstr.h" -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define THISCALL(func) (void *) __thiscall_ ## func -#ifdef _MSC_VER -#define DEFINE_THISCALL_WRAPPER(func,args) \ - __declspec(naked) HRESULT __thiscall_##func(void) \ - { \ - __asm pop eax \ - __asm push ecx \ - __asm push eax \ - __asm jmp func \ - } -#else /* _MSC_VER */ -#define DEFINE_THISCALL_WRAPPER(func,args) \ - extern HRESULT __thiscall_ ## func(void); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) -#endif /* _MSC_VER */ - -#else /* __i386__ */ - -#define THISCALL(func) func -#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ - -#endif /* __i386__ */ - WINE_DEFAULT_DEBUG_CHANNEL(richedit); typedef struct ITextServicesImpl { @@ -95,10 +64,7 @@ static HRESULT WINAPI ITextServicesImpl_QueryInterface(IUnknown *iface, REFIID r if (!This->editor->reOle) if (!CreateIRichEditOle(This->outer_unk, This->editor, (void **)(&This->editor->reOle))) return E_OUTOFMEMORY; - if (IsEqualIID(riid, &IID_ITextDocument) || IsEqualIID(riid, &IID_ITextDocument2Old)) - ME_GetITextDocument2OldInterface(This->editor->reOle, ppv); - else - *ppv = This->editor->reOle; + return IUnknown_QueryInterface(This->editor->reOle, riid, ppv); } else { *ppv = NULL; FIXME("Unknown interface: %s\n", debugstr_guid(riid)); @@ -312,7 +278,7 @@ DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface, LPCWSTR ME_InternalDeleteText(This->editor, &cursor, ME_GetTextLength(This->editor), FALSE); if(pszText) ME_InsertTextFromCursor(This->editor, 0, pszText, -1, This->editor->pBuffer->pDefaultStyle); - ME_SetSelection(This->editor, 0, 0); + set_selection_cursors(This->editor, 0, 0); This->editor->nModifyStep = 0; OleFlushClipboard(); ME_EmptyUndoStack(This->editor); diff --git a/dll/win32/riched20/wrap.c b/dll/win32/riched20/wrap.c index a66137d42c9..c3b5883dbf1 100644 --- a/dll/win32/riched20/wrap.c +++ b/dll/win32/riched20/wrap.c @@ -65,7 +65,6 @@ static BOOL get_run_glyph_buffers( ME_Run *run ) static HRESULT shape_run( ME_Context *c, ME_Run *run ) { HRESULT hr; - HFONT old_font; int i; if (!run->glyphs) @@ -82,7 +81,7 @@ static HRESULT shape_run( ME_Context *c, ME_Run *run ) run->clusters = heap_alloc( run->max_clusters * sizeof(WORD) ); } - old_font = ME_SelectStyleFont( c, run->style ); + select_style( c, run->style ); while (1) { hr = ScriptShape( c->hDC, &run->style->script_cache, get_text( run, 0 ), run->len, run->max_glyphs, @@ -103,8 +102,6 @@ static HRESULT shape_run( ME_Context *c, ME_Run *run ) run->nWidth += run->advances[i]; } - ME_UnselectStyleFont( c, run->style, old_font ); - return hr; } diff --git a/dll/win32/riched20/writer.c b/dll/win32/riched20/writer.c index 2bd97d8db25..94001ee44b2 100644 --- a/dll/win32/riched20/writer.c +++ b/dll/win32/riched20/writer.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #define NONAMELESSUNION #include "editor.h" @@ -123,17 +120,17 @@ ME_StreamOutMove(ME_OutStream *pStream, const char *buffer, int len) } -static BOOL +static BOOL WINAPIV ME_StreamOutPrint(ME_OutStream *pStream, const char *format, ...) { char string[STREAMOUT_BUFFER_SIZE]; /* This is going to be enough */ int len; - va_list valist; + __ms_va_list valist; - va_start(valist, format); + __ms_va_start(valist, format); len = vsnprintf(string, sizeof(string), format, valist); - va_end(valist); - + __ms_va_end(valist); + return ME_StreamOutMove(pStream, string, len); } @@ -245,7 +242,7 @@ static void add_font_to_fonttbl( ME_OutStream *stream, ME_Style *style ) { for (i = 0; i < stream->nFontTblLen; i++) if (table[i].bCharSet == charset - && (table[i].szFaceName == face || !lstrcmpW(table[i].szFaceName, face))) + && (table[i].szFaceName == face || !wcscmp(table[i].szFaceName, face))) break; if (i == stream->nFontTblLen && i < STREAMOUT_FONTTBL_SIZE) @@ -270,7 +267,7 @@ static BOOL find_font_in_fonttbl( ME_OutStream *stream, CHARFORMAT2W *fmt, unsig for (i = 0; i < stream->nFontTblLen; i++) { if (facename == stream->fonttbl[i].szFaceName - || !lstrcmpW(facename, stream->fonttbl[i].szFaceName)) + || !wcscmp(facename, stream->fonttbl[i].szFaceName)) if (!(fmt->dwMask & CFM_CHARSET) || fmt->bCharSet == stream->fonttbl[i].bCharSet) { @@ -841,7 +838,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt) } } - if (strcmpW(old_fmt->szFaceName, fmt->szFaceName) || + if (wcscmp(old_fmt->szFaceName, fmt->szFaceName) || old_fmt->bCharSet != fmt->bCharSet) { if (find_font_in_fonttbl( pStream, fmt, &i )) diff --git a/media/doc/README.WINE b/media/doc/README.WINE index ab56c63fc48..b390f9e7bbc 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -159,7 +159,7 @@ dll/win32/qmgrprxy # Synced to WineStaging-2.9 dll/win32/query # Synced to WineStaging-4.18 dll/win32/rasapi32 # Synced to WineStaging-3.3 dll/win32/resutils # Synced to WineStaging-3.3 -dll/win32/riched20 # Synced to WineStaging-4.0 +dll/win32/riched20 # Synced to WineStaging-4.18 dll/win32/riched32 # Synced to WineStaging-3.3 dll/win32/rpcrt4 # Synced to WineStaging-4.0 dll/win32/rsabase # Synced to WineStaging-3.3
5 years, 1 month
1
0
0
0
[reactos] 01/01: [QUERY] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80f091fc693fc24328b46…
commit 80f091fc693fc24328b463f05bf8749ea1bd03fc Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:10:28 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:10:28 2019 +0100 [QUERY] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/query/query_main.c | 1 - media/doc/README.WINE | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dll/win32/query/query_main.c b/dll/win32/query/query_main.c index c6dde22a887..b93973addea 100644 --- a/dll/win32/query/query_main.c +++ b/dll/win32/query/query_main.c @@ -20,7 +20,6 @@ #define COBJMACROS -#include "config.h" #include <stdarg.h> diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 3835269c8a9..ab56c63fc48 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -156,7 +156,7 @@ dll/win32/propsys # Synced to WineStaging-4.18 dll/win32/pstorec # Synced to WineStaging-3.3 dll/win32/qmgr # Synced to WineStaging-4.18 dll/win32/qmgrprxy # Synced to WineStaging-2.9 -dll/win32/query # Synced to WineStaging-3.3 +dll/win32/query # Synced to WineStaging-4.18 dll/win32/rasapi32 # Synced to WineStaging-3.3 dll/win32/resutils # Synced to WineStaging-3.3 dll/win32/riched20 # Synced to WineStaging-4.0
5 years, 1 month
1
0
0
0
[reactos] 01/01: [QMGR] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e3bf841067ab9a2bdc5c7…
commit e3bf841067ab9a2bdc5c704c864024d564e47e7a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:10:04 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:10:04 2019 +0100 [QMGR] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/qmgr/file.c | 2 +- dll/win32/qmgr/job.c | 4 ++-- dll/win32/qmgr/qmgr.h | 13 ++++++------- media/doc/README.WINE | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dll/win32/qmgr/file.c b/dll/win32/qmgr/file.c index dbdfc97bcc2..73b5992c087 100644 --- a/dll/win32/qmgr/file.c +++ b/dll/win32/qmgr/file.c @@ -459,7 +459,7 @@ static BOOL transfer_file_local(BackgroundCopyFileImpl *file, const WCHAR *tmpna transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRING); - if (strlenW(file->info.RemoteName) > 7 && !memicmpW(file->info.RemoteName, fileW, 7)) + if (lstrlenW(file->info.RemoteName) > 7 && !_wcsnicmp(file->info.RemoteName, fileW, 7)) ptr = file->info.RemoteName + 7; else ptr = file->info.RemoteName; diff --git a/dll/win32/qmgr/job.c b/dll/win32/qmgr/job.c index a12e5111c52..0eef3361d46 100644 --- a/dll/win32/qmgr/job.c +++ b/dll/win32/qmgr/job.c @@ -599,7 +599,7 @@ static HRESULT WINAPI BackgroundCopyJob_SetDescription( if (!Val) return E_INVALIDARG; - len = strlenW(Val); + len = lstrlenW(Val); if (len > max_description_len) return BG_E_STRING_TOO_LONG; EnterCriticalSection(&This->cs); @@ -612,7 +612,7 @@ static HRESULT WINAPI BackgroundCopyJob_SetDescription( { HeapFree(GetProcessHeap(), 0, This->description); if ((This->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)))) - strcpyW(This->description, Val); + lstrcpyW(This->description, Val); else hr = E_OUTOFMEMORY; } diff --git a/dll/win32/qmgr/qmgr.h b/dll/win32/qmgr/qmgr.h index 2bc5b8b9615..87f8307a426 100644 --- a/dll/win32/qmgr/qmgr.h +++ b/dll/win32/qmgr/qmgr.h @@ -31,7 +31,6 @@ #include <string.h> #include "wine/list.h" -#include "wine/unicode.h" /* Background copy job vtbl and related data */ typedef struct @@ -118,15 +117,15 @@ BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_ST /* Little helper functions */ static inline WCHAR *strdupW(const WCHAR *src) { - WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR)); - if (dst) strcpyW(dst, src); + WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR)); + if (dst) lstrcpyW(dst, src); return dst; } static inline WCHAR *co_strdupW(const WCHAR *src) { - WCHAR *dst = CoTaskMemAlloc((strlenW(src) + 1) * sizeof(WCHAR)); - if (dst) strcpyW(dst, src); + WCHAR *dst = CoTaskMemAlloc((lstrlenW(src) + 1) * sizeof(WCHAR)); + if (dst) lstrcpyW(dst, src); return dst; } @@ -136,10 +135,10 @@ static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret) if (!ret) return E_INVALIDARG; - len = strlenW(str); + len = lstrlenW(str); *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR)); if (!*ret) return E_OUTOFMEMORY; - strcpyW(*ret, str); + lstrcpyW(*ret, str); return S_OK; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 2ac9a1e0072..3835269c8a9 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -154,7 +154,7 @@ dll/win32/powrprof # Forked at Wine-1.0rc5 dll/win32/printui # Synced to WineStaging-4.18 dll/win32/propsys # Synced to WineStaging-4.18 dll/win32/pstorec # Synced to WineStaging-3.3 -dll/win32/qmgr # Synced to WineStaging-4.0 +dll/win32/qmgr # Synced to WineStaging-4.18 dll/win32/qmgrprxy # Synced to WineStaging-2.9 dll/win32/query # Synced to WineStaging-3.3 dll/win32/rasapi32 # Synced to WineStaging-3.3
5 years, 1 month
1
0
0
0
[reactos] 01/01: [PROPSYS_WINETEST] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b1ad5055dc2e5749e8def…
commit b1ad5055dc2e5749e8defe762a78144f37cd63b9 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:09:40 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:09:40 2019 +0100 [PROPSYS_WINETEST] Sync with Wine Staging 4.18. CORE-16441 --- modules/rostests/winetests/propsys/propstore.c | 114 ++++++++ modules/rostests/winetests/propsys/propsys.c | 348 ++++++++++++++++++++++++- 2 files changed, 456 insertions(+), 6 deletions(-) diff --git a/modules/rostests/winetests/propsys/propstore.c b/modules/rostests/winetests/propsys/propstore.c index 3fe8613a8b8..5aeb562cf27 100644 --- a/modules/rostests/winetests/propsys/propstore.c +++ b/modules/rostests/winetests/propsys/propstore.c @@ -34,6 +34,16 @@ #include "initguid.h" DEFINE_GUID(PKEY_WineTest, 0x7b317433, 0xdfa3, 0x4c44, 0xad, 0x3e, 0x2f, 0x80, 0x4b, 0x90, 0xdb, 0xf4); +DEFINE_GUID(DUMMY_GUID1, 0x12345678, 0x1234,0x1234, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19); + +#define EXPECT_REF(obj,ref) _expect_ref((IUnknown *)obj, ref, __LINE__) +static void _expect_ref(IUnknown *obj, ULONG ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); +} static void test_inmemorystore(void) { @@ -249,12 +259,116 @@ static void test_persistserialized(void) IPersistSerializedPropStorage_Release(serialized); } +static void test_PSCreateMemoryPropertyStore(void) +{ + IPropertyStore *propstore, *propstore1; + IPersistSerializedPropStorage *serialized; + IPropertyStoreCache *propstorecache; + HRESULT hr; + + /* PSCreateMemoryPropertyStore(&IID_IPropertyStore, NULL); crashes */ + + hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore); + ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr); + ok(propstore != NULL, "got %p.\n", propstore); + EXPECT_REF(propstore, 1); + + hr = PSCreateMemoryPropertyStore(&IID_IPersistSerializedPropStorage, (void **)&serialized); + todo_wine ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr); + todo_wine ok(serialized != NULL, "got %p.\n", serialized); + EXPECT_REF(propstore, 1); + if(serialized) + { + EXPECT_REF(serialized, 1); + IPersistSerializedPropStorage_Release(serialized); + } + + hr = PSCreateMemoryPropertyStore(&IID_IPropertyStoreCache, (void **)&propstorecache); + ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr); + ok(propstorecache != NULL, "got %p.\n", propstore); + ok(propstorecache != (IPropertyStoreCache *)propstore, "pointer are equal: %p, %p.\n", propstorecache, propstore); + EXPECT_REF(propstore, 1); + EXPECT_REF(propstorecache, 1); + + hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore1); + ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr); + ok(propstore1 != NULL, "got %p.\n", propstore); + ok(propstore1 != propstore, "pointer are equal: %p, %p.\n", propstore1, propstore); + EXPECT_REF(propstore, 1); + EXPECT_REF(propstore1, 1); + EXPECT_REF(propstorecache, 1); + + IPropertyStore_Release(propstore1); + IPropertyStore_Release(propstore); + IPropertyStoreCache_Release(propstorecache); +} + +static void test_propertystore(void) +{ + IPropertyStore *propstore; + HRESULT hr; + PROPVARIANT propvar, ret_propvar; + PROPERTYKEY propkey; + DWORD count = 0; + + hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore); + ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr); + ok(propstore != NULL, "got %p.\n", propstore); + + hr = IPropertyStore_GetCount(propstore, &count); + ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08x.\n", hr); + ok(!count, "got wrong property count: %d, expected 0.\n", count); + + PropVariantInit(&propvar); + propvar.vt = VT_I4; + U(propvar).lVal = 123; + propkey.fmtid = DUMMY_GUID1; + propkey.pid = PID_FIRST_USABLE; + hr = IPropertyStore_SetValue(propstore, &propkey, &propvar); + ok(hr == S_OK, "IPropertyStore_SetValue failed: 0x%08x.\n", hr); + hr = IPropertyStore_Commit(propstore); + ok(hr == S_OK, "IPropertyStore_Commit failed: 0x%08x.\n", hr); + hr = IPropertyStore_GetCount(propstore, &count); + ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08x.\n", hr); + ok(count == 1, "got wrong property count: %d, expected 1.\n", count); + PropVariantInit(&ret_propvar); + ret_propvar.vt = VT_I4; + hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar); + ok(hr == S_OK, "IPropertyStore_GetValue failed: 0x%08x.\n", hr); + ok(ret_propvar.vt == VT_I4, "got wrong property type: %x.\n", ret_propvar.vt); + ok(U(ret_propvar).lVal == 123, "got wrong value: %d, expected 123.\n", U(ret_propvar).lVal); + PropVariantClear(&propvar); + PropVariantClear(&ret_propvar); + + PropVariantInit(&propvar); + propkey.fmtid = DUMMY_GUID1; + propkey.pid = PID_FIRST_USABLE; + hr = IPropertyStore_SetValue(propstore, &propkey, &propvar); + ok(hr == S_OK, "IPropertyStore_SetValue failed: 0x%08x.\n", hr); + hr = IPropertyStore_Commit(propstore); + ok(hr == S_OK, "IPropertyStore_Commit failed: 0x%08x.\n", hr); + hr = IPropertyStore_GetCount(propstore, &count); + ok(hr == S_OK, "IPropertyStore_GetCount failed: 0x%08x.\n", hr); + ok(count == 1, "got wrong property count: %d, expected 1.\n", count); + PropVariantInit(&ret_propvar); + hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar); + ok(hr == S_OK, "IPropertyStore_GetValue failed: 0x%08x.\n", hr); + ok(ret_propvar.vt == VT_EMPTY, "got wrong property type: %x.\n", ret_propvar.vt); + ok(!U(ret_propvar).lVal, "got wrong value: %d, expected 0.\n", U(ret_propvar).lVal); + PropVariantClear(&propvar); + PropVariantClear(&ret_propvar); + + IPropertyStore_Release(propstore); +} + START_TEST(propstore) { CoInitialize(NULL); test_inmemorystore(); test_persistserialized(); + test_PSCreateMemoryPropertyStore(); + test_propertystore(); CoUninitialize(); } diff --git a/modules/rostests/winetests/propsys/propsys.c b/modules/rostests/winetests/propsys/propsys.c index 34c51b382bb..77ffe05f6d9 100644 --- a/modules/rostests/winetests/propsys/propsys.c +++ b/modules/rostests/winetests/propsys/propsys.c @@ -32,6 +32,7 @@ #include "initguid.h" #include "propsys.h" #include "propvarutil.h" +#include "strsafe.h" #include "wine/test.h" DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); @@ -567,7 +568,7 @@ static void test_PropVariantToGUID(void) hres = PropVariantToGUID(&propvar, &guid); ok(hres == S_OK, "PropVariantToGUID failed %x\n", hres); - ok(!memcmp(&IID_NULL, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&IID_NULL, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); PropVariantClear(&propvar); hres = InitPropVariantFromGUIDAsString(&dummy_guid, &propvar); @@ -575,7 +576,7 @@ static void test_PropVariantToGUID(void) hres = PropVariantToGUID(&propvar, &guid); ok(hres == S_OK, "PropVariantToGUID failed %x\n", hres); - ok(!memcmp(&dummy_guid, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); ok(propvar.vt == VT_LPWSTR, "incorrect PROPVARIANT type: %d\n", propvar.vt); propvar.u.pwszVal[1] = 'd'; @@ -583,7 +584,7 @@ static void test_PropVariantToGUID(void) propvar.u.pwszVal[3] = 'a'; hres = PropVariantToGUID(&propvar, &guid); ok(hres == S_OK, "PropVariantToGUID failed %x\n", hres); - ok(!memcmp(&dummy_guid, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); propvar.u.pwszVal[1] = 'z'; hres = PropVariantToGUID(&propvar, &guid); @@ -596,7 +597,7 @@ static void test_PropVariantToGUID(void) hres = VariantToGUID(&var, &guid); ok(hres == S_OK, "VariantToGUID failed %x\n", hres); - ok(!memcmp(&IID_NULL, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&IID_NULL, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); VariantClear(&var); hres = InitVariantFromGUIDAsString(&dummy_guid, &var); @@ -604,7 +605,7 @@ static void test_PropVariantToGUID(void) hres = VariantToGUID(&var, &guid); ok(hres == S_OK, "VariantToGUID failed %x\n", hres); - ok(!memcmp(&dummy_guid, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); ok(V_VT(&var) == VT_BSTR, "incorrect VARIANT type: %d\n", V_VT(&var)); V_BSTR(&var)[1] = 'z'; @@ -617,7 +618,14 @@ static void test_PropVariantToGUID(void) V_VT(&var) = VT_EMPTY; hres = PropVariantToGUID(&propvar, &guid); ok(hres == S_OK, "PropVariantToGUID failed %x\n", hres); - ok(!memcmp(&dummy_guid, &guid, sizeof(GUID)), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); + PropVariantClear(&propvar); + + memset(&guid, 0, sizeof(guid)); + InitPropVariantFromCLSID(&dummy_guid, &propvar); + hres = PropVariantToGUID(&propvar, &guid); + ok(hres == S_OK, "PropVariantToGUID failed %x\n", hres); + ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); PropVariantClear(&propvar); } @@ -641,11 +649,18 @@ static void test_PropVariantToStringAlloc(void) ok(!lstrcmpW(str, topicW), "got %s\n", wine_dbgstr_w(str)); CoTaskMemFree(str); PropVariantClear(&prop); + + prop.vt = VT_EMPTY; + hres = PropVariantToStringAlloc(&prop, &str); + ok(hres == S_OK, "returned %x\n", hres); + ok(!lstrcmpW(str, emptyW), "got %s\n", wine_dbgstr_w(str)); + CoTaskMemFree(str); } static void test_PropVariantCompare(void) { PROPVARIANT empty, null, emptyarray, i2_0, i2_2, i4_large, i4_largeneg, i4_2, str_2, str_02, str_b; + PROPVARIANT clsid_null, clsid, clsid2, r4_0, r4_2, r8_0, r8_2; INT res; static const WCHAR str_2W[] = {'2', 0}; static const WCHAR str_02W[] = {'0', '2', 0}; @@ -690,6 +705,20 @@ static void test_PropVariantCompare(void) str_02.u.bstrVal = SysAllocString(str_02W); str_b.vt = VT_BSTR; str_b.u.bstrVal = SysAllocString(str_bW); + clsid_null.vt = VT_CLSID; + clsid_null.u.puuid = NULL; + clsid.vt = VT_CLSID; + clsid.u.puuid = (GUID *)&dummy_guid; + clsid2.vt = VT_CLSID; + clsid2.u.puuid = (GUID *)&GUID_NULL; + r4_0.vt = VT_R4; + r4_0.u.fltVal = 0.0f; + r4_2.vt = VT_R4; + r4_2.u.fltVal = 2.0f; + r8_0.vt = VT_R8; + r8_0.u.dblVal = 0.0; + r8_2.vt = VT_R8; + r8_2.u.dblVal = 2.0; res = PropVariantCompareEx(&empty, &empty, 0, 0); ok(res == 0, "res=%i\n", res); @@ -758,6 +787,57 @@ static void test_PropVariantCompare(void) res = PropVariantCompareEx(&i4_large, &str_b, 0, 0); todo_wine ok(res == -5 /* ??? */, "res=%i\n", res); + /* VT_CLSID */ + res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid_null, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid2, 0, 0); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid2, &clsid, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid_null, 0, 0); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid_null, &clsid, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&clsid, &clsid_null, 0, PVCF_TREATEMPTYASGREATERTHAN); + ok(res == -1, "res=%i\n", res); + + /* VT_R4/VT_R8 */ + res = PropVariantCompareEx(&r4_0, &r8_0, 0, 0); +todo_wine + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&r4_0, &r4_0, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&r4_0, &r4_2, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&r4_2, &r4_0, 0, 0); + ok(res == 1, "res=%i\n", res); + + res = PropVariantCompareEx(&r8_0, &r8_0, 0, 0); + ok(res == 0, "res=%i\n", res); + + res = PropVariantCompareEx(&r8_0, &r8_2, 0, 0); + ok(res == -1, "res=%i\n", res); + + res = PropVariantCompareEx(&r8_2, &r8_0, 0, 0); + ok(res == 1, "res=%i\n", res); + SysFreeString(str_2.u.bstrVal); SysFreeString(str_02.u.bstrVal); SysFreeString(str_b.u.bstrVal); @@ -1248,6 +1328,259 @@ static void test_InitPropVariantFromCLSID(void) PropVariantClear(&propvar); } +static void test_PropVariantToDouble(void) +{ + PROPVARIANT propvar; + double value; + HRESULT hr; + + PropVariantInit(&propvar); + propvar.vt = VT_R8; + propvar.u.dblVal = 15.0; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 15.0, "Unexpected value: %f.\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_I4; + propvar.u.lVal = 123; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 123.0, "Unexpected value: %f.\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_I4; + propvar.u.lVal = -256; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == -256, "Unexpected value: %f\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_I8; + propvar.u.lVal = 65536; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 65536.0, "Unexpected value: %f.\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_I8; + propvar.u.lVal = -321; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 4294966975.0, "Unexpected value: %f.\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_UI4; + propvar.u.ulVal = 6; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 6.0, "Unexpected value: %f.\n", value); + + PropVariantClear(&propvar); + propvar.vt = VT_UI8; + propvar.u.uhVal.QuadPart = 8; + hr = PropVariantToDouble(&propvar, &value); + ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr); + ok(value == 8.0, "Unexpected value: %f.\n", value); +} + +static void test_PropVariantToString(void) +{ + PROPVARIANT propvar; + static CHAR string[] = "Wine"; + static WCHAR stringW[] = {'W','i','n','e',0}; + WCHAR bufferW[256] = {0}; + HRESULT hr; + + PropVariantInit(&propvar); + propvar.vt = VT_EMPTY; + U(propvar).pwszVal = stringW; + bufferW[0] = 65; + hr = PropVariantToString(&propvar, bufferW, 0); + ok(hr == E_INVALIDARG, "PropVariantToString should fail: 0x%08x.\n", hr); + ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_EMPTY; + U(propvar).pwszVal = stringW; + bufferW[0] = 65; + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_NULL; + U(propvar).pwszVal = stringW; + bufferW[0] = 65; + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + ok(!bufferW[0], "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_I4; + U(propvar).lVal = 22; + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + todo_wine ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + todo_wine ok(!strcmp_wa(bufferW, "22"), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_LPWSTR; + U(propvar).pwszVal = stringW; + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + + PropVariantInit(&propvar); + propvar.vt = VT_LPSTR; + U(propvar).pszVal = string; + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + + PropVariantInit(&propvar); + propvar.vt = VT_LPWSTR; + U(propvar).pwszVal = stringW; + hr = PropVariantToString(&propvar, bufferW, 4); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "PropVariantToString returned: 0x%08x.\n", hr); + ok(!memcmp(bufferW, stringW, 4), "got wrong string.\n"); + memset(bufferW, 0, sizeof(bufferW)); + + PropVariantInit(&propvar); + propvar.vt = VT_LPSTR; + U(propvar).pszVal = string; + hr = PropVariantToString(&propvar, bufferW, 4); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "PropVariantToString returned: 0x%08x.\n", hr); + ok(!memcmp(bufferW, stringW, 4), "got wrong string.\n"); + memset(bufferW, 0, sizeof(bufferW)); + + PropVariantInit(&propvar); + propvar.vt = VT_BSTR; + propvar.u.bstrVal = SysAllocString(stringW); + hr = PropVariantToString(&propvar, bufferW, ARRAY_SIZE(bufferW)); + ok(hr == S_OK, "PropVariantToString failed: 0x%08x.\n", hr); + ok(!lstrcmpW(bufferW, stringW), "got wrong string: \"%s\".\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + SysFreeString(propvar.u.bstrVal); +} + +static void test_PropVariantToBuffer(void) +{ + PROPVARIANT propvar; + HRESULT hr; + UINT8 data[] = {1,2,3,4,5,6,7,8,9,10}; + INT8 data_int8[] = {1,2,3,4,5,6,7,8,9,10}; + SAFEARRAY *sa; + SAFEARRAYBOUND sabound; + void *pdata; + UINT8 buffer[256]; + + hr = InitPropVariantFromBuffer(data, 10, &propvar); + ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08x.\n", hr); + hr = PropVariantToBuffer(&propvar, NULL, 0); /* crash when cb isn't zero */ + ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08x.\n", hr); + PropVariantClear(&propvar); + + hr = InitPropVariantFromBuffer(data, 10, &propvar); + ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08x.\n", hr); + hr = PropVariantToBuffer(&propvar, buffer, 10); + ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08x.\n", hr); + ok(!memcmp(buffer, data, 10) && !buffer[10], "got wrong buffer.\n"); + memset(buffer, 0, sizeof(buffer)); + PropVariantClear(&propvar); + + hr = InitPropVariantFromBuffer(data, 10, &propvar); + ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08x.\n", hr); + buffer[0] = 99; + hr = PropVariantToBuffer(&propvar, buffer, 11); + ok(hr == E_FAIL, "PropVariantToBuffer returned: 0x%08x.\n", hr); + ok(buffer[0] == 99, "got wrong buffer.\n"); + memset(buffer, 0, sizeof(buffer)); + PropVariantClear(&propvar); + + hr = InitPropVariantFromBuffer(data, 10, &propvar); + ok(hr == S_OK, "InitPropVariantFromBuffer failed 0x%08x.\n", hr); + hr = PropVariantToBuffer(&propvar, buffer, 9); + ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08x.\n", hr); + ok(!memcmp(buffer, data, 9) && !buffer[9], "got wrong buffer.\n"); + memset(buffer, 0, sizeof(buffer)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_ARRAY|VT_UI1; + sabound.lLbound = 0; + sabound.cElements = sizeof(data); + sa = NULL; + sa = SafeArrayCreate(VT_UI1, 1, &sabound); + ok(sa != NULL, "SafeArrayCreate failed.\n"); + hr = SafeArrayAccessData(sa, &pdata); + ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08x.\n", hr); + memcpy(pdata, data, sizeof(data)); + hr = SafeArrayUnaccessData(sa); + ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08x.\n", hr); + U(propvar).parray = sa; + buffer[0] = 99; + hr = PropVariantToBuffer(&propvar, buffer, 11); + todo_wine ok(hr == E_FAIL, "PropVariantToBuffer returned: 0x%08x.\n", hr); + ok(buffer[0] == 99, "got wrong buffer.\n"); + memset(buffer, 0, sizeof(buffer)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_ARRAY|VT_UI1; + sabound.lLbound = 0; + sabound.cElements = sizeof(data); + sa = NULL; + sa = SafeArrayCreate(VT_UI1, 1, &sabound); + ok(sa != NULL, "SafeArrayCreate failed.\n"); + hr = SafeArrayAccessData(sa, &pdata); + ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08x.\n", hr); + memcpy(pdata, data, sizeof(data)); + hr = SafeArrayUnaccessData(sa); + ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08x.\n", hr); + U(propvar).parray = sa; + hr = PropVariantToBuffer(&propvar, buffer, sizeof(data)); + todo_wine ok(hr == S_OK, "PropVariantToBuffer failed: 0x%08x.\n", hr); + todo_wine ok(!memcmp(buffer, data, 10) && !buffer[10], "got wrong buffer.\n"); + memset(buffer, 0, sizeof(buffer)); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_VECTOR|VT_I1; + U(propvar).caub.pElems = CoTaskMemAlloc(sizeof(data_int8)); + U(propvar).caub.cElems = sizeof(data_int8); + memcpy(U(propvar).caub.pElems, data_int8, sizeof(data_int8)); + hr = PropVariantToBuffer(&propvar, buffer, sizeof(data_int8)); + ok(hr == E_INVALIDARG, "PropVariantToBuffer failed: 0x%08x.\n", hr); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_ARRAY|VT_I1; + sabound.lLbound = 0; + sabound.cElements = sizeof(data_int8); + sa = NULL; + sa = SafeArrayCreate(VT_I1, 1, &sabound); + ok(sa != NULL, "SafeArrayCreate failed.\n"); + hr = SafeArrayAccessData(sa, &pdata); + ok(hr == S_OK, "SafeArrayAccessData failed: 0x%08x.\n", hr); + memcpy(pdata, data_int8, sizeof(data_int8)); + hr = SafeArrayUnaccessData(sa); + ok(hr == S_OK, "SafeArrayUnaccessData failed: 0x%08x.\n", hr); + U(propvar).parray = sa; + hr = PropVariantToBuffer(&propvar, buffer, sizeof(data_int8)); + ok(hr == E_INVALIDARG, "PropVariantToBuffer failed: 0x%08x.\n", hr); + PropVariantClear(&propvar); +} + START_TEST(propsys) { test_PSStringFromPropertyKey(); @@ -1263,4 +1596,7 @@ START_TEST(propsys) test_PropVariantToBoolean(); test_PropVariantToStringWithDefault(); test_InitPropVariantFromCLSID(); + test_PropVariantToDouble(); + test_PropVariantToString(); + test_PropVariantToBuffer(); }
5 years, 1 month
1
0
0
0
[reactos] 01/01: [PSDK] Update propsys.idl and propvarutil.h. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7eba2742d2c12d43b0289…
commit 7eba2742d2c12d43b02897d72bf1785f4998ae36 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:09:13 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:09:13 2019 +0100 [PSDK] Update propsys.idl and propvarutil.h. CORE-16441 --- sdk/include/psdk/propsys.idl | 1 + sdk/include/psdk/propvarutil.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sdk/include/psdk/propsys.idl b/sdk/include/psdk/propsys.idl index 04d3fbf8a1b..bdd67fa6a59 100644 --- a/sdk/include/psdk/propsys.idl +++ b/sdk/include/psdk/propsys.idl @@ -799,6 +799,7 @@ cpp_quote("#define PKEY_PIDSTR_MAX 10") cpp_quote("#define GUIDSTRING_MAX 39") cpp_quote("#define PKEYSTR_MAX (GUIDSTRING_MAX + 1 + PKEY_PIDSTR_MAX)") +cpp_quote("HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID,void **);") cpp_quote("HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY,LPWSTR,UINT);") cpp_quote("HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR,PROPERTYKEY*);") cpp_quote("HRESULT WINAPI PSGetPropertyDescription(REFPROPERTYKEY,REFIID,void **);") diff --git a/sdk/include/psdk/propvarutil.h b/sdk/include/psdk/propvarutil.h index 0285cafbb4f..e0a21faf8c7 100644 --- a/sdk/include/psdk/propvarutil.h +++ b/sdk/include/psdk/propvarutil.h @@ -22,6 +22,10 @@ #include <shtypes.h> #include <shlwapi.h> +#ifdef __cplusplus +extern "C" { +#endif + enum tagPROPVAR_CHANGE_FLAGS { PVCHF_DEFAULT = 0x00000000, @@ -71,6 +75,7 @@ HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid); INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2, PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags); +HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret); HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret); HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret); HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret); @@ -78,6 +83,8 @@ HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret); HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret); HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret); HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret); +HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb); +HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch); PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault); HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret); @@ -117,7 +124,12 @@ inline HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar) return S_OK; } -#endif +#endif /* NO_PROPVAR_INLINES */ +#endif /* __cplusplus */ + + +#ifdef __cplusplus +} #endif #endif /* __WINE_PROPVARUTIL_H */
5 years, 1 month
1
0
0
0
[reactos] 01/01: [PROPSYS] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a93b822da23477d28518d…
commit a93b822da23477d28518d23bd582bcdf0da494c1 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 23 12:08:50 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 23 12:08:50 2019 +0100 [PROPSYS] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/propsys/precomp.h | 4 +- dll/win32/propsys/propstore.c | 2 - dll/win32/propsys/propsys.spec | 8 +-- dll/win32/propsys/propsys_main.c | 20 +++++-- dll/win32/propsys/propvar.c | 117 +++++++++++++++++++++++++++++++++------ media/doc/README.WINE | 2 +- 6 files changed, 120 insertions(+), 33 deletions(-) diff --git a/dll/win32/propsys/precomp.h b/dll/win32/propsys/precomp.h index 74eabdd3cfc..1f432757e3a 100644 --- a/dll/win32/propsys/precomp.h +++ b/dll/win32/propsys/precomp.h @@ -2,8 +2,6 @@ #ifndef _PROPSYS_PRECOMP_H_ #define _PROPSYS_PRECOMP_H_ -#include <wine/config.h> - #include <stdarg.h> #define WIN32_NO_STATUS @@ -15,11 +13,11 @@ #include <windef.h> #include <winbase.h> +#include <winnls.h> #include <objbase.h> #include <propsys.h> #include <wine/debug.h> -#include <wine/unicode.h> #include "propsys_private.h" diff --git a/dll/win32/propsys/propstore.c b/dll/win32/propsys/propstore.c index 9c848fcaba6..6212f293123 100644 --- a/dll/win32/propsys/propstore.c +++ b/dll/win32/propsys/propstore.c @@ -19,7 +19,6 @@ */ #define COBJMACROS -#include "config.h" #include <stdarg.h> @@ -29,7 +28,6 @@ #include "rpcproxy.h" #include "propsys.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "wine/list.h" #include "initguid.h" diff --git a/dll/win32/propsys/propsys.spec b/dll/win32/propsys/propsys.spec index f4960063938..19e16aedc1e 100644 --- a/dll/win32/propsys/propsys.spec +++ b/dll/win32/propsys/propsys.spec @@ -66,7 +66,7 @@ @ stub PSCoerceToCanonicalValue @ stub PSCreateAdapterFromPropertyStore @ stub PSCreateDelayedMultiplexPropertyStore -@ stub PSCreateMemoryPropertyStore +@ stdcall PSCreateMemoryPropertyStore(ptr ptr) @ stub PSCreateMultiplexPropertyStore @ stub PSCreatePropertyChangeArray @ stub PSCreatePropertyStoreFromObject @@ -112,8 +112,8 @@ @ stub PropVariantToBooleanVector @ stub PropVariantToBooleanVectorAlloc @ stub PropVariantToBooleanWithDefault -@ stub PropVariantToBuffer -@ stub PropVariantToDouble +@ stdcall PropVariantToBuffer(ptr ptr long) +@ stdcall PropVariantToDouble(ptr ptr) @ stub PropVariantToDoubleVector @ stub PropVariantToDoubleVectorAlloc @ stub PropVariantToDoubleWithDefault @@ -134,7 +134,7 @@ @ stub PropVariantToInt64VectorAlloc @ stub PropVariantToInt64WithDefault @ stub PropVariantToStrRet -@ stub PropVariantToString +@ stdcall PropVariantToString(ptr ptr long) @ stdcall PropVariantToStringAlloc(ptr ptr) @ stub PropVariantToStringVector @ stub PropVariantToStringVectorAlloc diff --git a/dll/win32/propsys/propsys_main.c b/dll/win32/propsys/propsys_main.c index 1dbaee433f6..6f7dc8a397c 100644 --- a/dll/win32/propsys/propsys_main.c +++ b/dll/win32/propsys/propsys_main.c @@ -20,9 +20,11 @@ */ #define COBJMACROS -#include "config.h" #include <stdarg.h> +#ifdef __REACTOS__ +#include <wchar.h> +#endif #include "windef.h" #include "winbase.h" @@ -30,7 +32,6 @@ #include "rpcproxy.h" #include "propsys.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "propsys_private.h" @@ -307,7 +308,7 @@ HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch return E_NOT_SUFFICIENT_BUFFER; } - sprintfW(psz, guid_fmtW, pkey->fmtid.Data1, pkey->fmtid.Data2, + swprintf(psz, guid_fmtW, pkey->fmtid.Data1, pkey->fmtid.Data2, pkey->fmtid.Data3, pkey->fmtid.Data4[0], pkey->fmtid.Data4[1], pkey->fmtid.Data4[2], pkey->fmtid.Data4[3], pkey->fmtid.Data4[4], pkey->fmtid.Data4[5], pkey->fmtid.Data4[6], pkey->fmtid.Data4[7]); @@ -317,11 +318,11 @@ HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch *p++ = ' '; cch -= GUIDSTRING_MAX - 1 + 1; - len = sprintfW(pidW, pid_fmtW, pkey->pid); + len = swprintf(pidW, pid_fmtW, pkey->pid); if (cch >= len + 1) { - strcpyW(p, pidW); + lstrcpyW(p, pidW); return S_OK; } else @@ -497,7 +498,7 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey) } /* Overflow is not checked. */ - while (isdigitW(*pszString)) + while (iswdigit(*pszString)) { pkey->pid *= 10; pkey->pid += (*pszString - '0'); @@ -509,3 +510,10 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey) return S_OK; } + +HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv) +{ + TRACE("(%s, %p)\n", debugstr_guid(riid), ppv); + + return PropertyStore_CreateInstance(NULL, riid, ppv); +} diff --git a/dll/win32/propsys/propvar.c b/dll/win32/propsys/propvar.c index 05ded2e154e..f03dc148435 100644 --- a/dll/win32/propsys/propvar.c +++ b/dll/win32/propsys/propvar.c @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" #include <stdarg.h> #include <stdio.h> @@ -34,9 +32,9 @@ #include "winuser.h" #include "shlobj.h" #include "propvarutil.h" +#include "strsafe.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(propsys); @@ -123,12 +121,18 @@ static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits, case VT_BSTR: { WCHAR *end; - *res = strtolW(pv->u.pwszVal, &end, 0); + *res = wcstol(pv->u.pwszVal, &end, 0); if (pv->u.pwszVal == end) return DISP_E_TYPEMISMATCH; src_signed = *res < 0; break; } + case VT_R8: + { + src_signed = TRUE; + *res = pv->u.dblVal; + break; + } default: FIXME("unhandled vt %d\n", pv->vt); return E_NOTIMPL; @@ -155,6 +159,18 @@ static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits, return S_OK; } +HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret) +{ + LONGLONG res; + HRESULT hr; + + TRACE("(%p, %p)\n", propvarIn, ret); + + hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res); + if (SUCCEEDED(hr)) *ret = (double)res; + return hr; +} + HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret) { LONGLONG res; @@ -187,7 +203,7 @@ HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret) TRACE("%p,%p\n", propvarIn, ret); hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res); - if (SUCCEEDED(hr)) *ret = (LONGLONG)res; + if (SUCCEEDED(hr)) *ret = res; return hr; } @@ -287,6 +303,56 @@ HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret) return hr; } +HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb) +{ + HRESULT hr = S_OK; + + TRACE("(%p, %p, %d)\n", propvarIn, ret, cb); + + switch(propvarIn->vt) + { + case VT_VECTOR|VT_UI1: + if(cb > propvarIn->u.caub.cElems) + return E_FAIL; + memcpy(ret, propvarIn->u.caub.pElems, cb); + break; + case VT_ARRAY|VT_UI1: + FIXME("Unsupported type: VT_ARRAY|VT_UI1\n"); + hr = E_NOTIMPL; + break; + default: + WARN("Unexpected type: %x\n", propvarIn->vt); + hr = E_INVALIDARG; + } + + return hr; +} + + +HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch) +{ + HRESULT hr; + WCHAR *stringW = NULL; + + TRACE("(%p, %p, %d)\n", propvarIn, ret, cch); + + ret[0] = '\0'; + + if(!cch) + return E_INVALIDARG; + + hr = PropVariantToStringAlloc(propvarIn, &stringW); + if(SUCCEEDED(hr)) + { + if(lstrlenW(stringW) >= cch) + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + lstrcpynW(ret, stringW, cch); + CoTaskMemFree(stringW); + } + + return hr; +} + HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret) { WCHAR *res = NULL; @@ -296,6 +362,7 @@ HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret) switch(propvarIn->vt) { + case VT_EMPTY: case VT_NULL: res = CoTaskMemAlloc(1*sizeof(WCHAR)); res[0] = '\0'; @@ -517,7 +584,7 @@ static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str) '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X', '%','0','2','X','%','0','2','X','%','0','2','X','}',0}; - sprintfW(str, format, guid->Data1, guid->Data2, guid->Data3, + swprintf(str, format, guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); } @@ -694,7 +761,10 @@ HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid) case VT_BSTR: return PROPVAR_WCHARToGUID(ppropvar->u.bstrVal, SysStringLen(ppropvar->u.bstrVal), guid); case VT_LPWSTR: - return PROPVAR_WCHARToGUID(ppropvar->u.pwszVal, strlenW(ppropvar->u.pwszVal), guid); + return PROPVAR_WCHARToGUID(ppropvar->u.pwszVal, lstrlenW(ppropvar->u.pwszVal), guid); + case VT_CLSID: + memcpy(guid, ppropvar->u.puuid, sizeof(*ppropvar->u.puuid)); + return S_OK; default: FIXME("unsupported vt: %d\n", ppropvar->vt); @@ -734,6 +804,9 @@ static BOOL isemptyornull(const PROPVARIANT *propvar) } return i == propvar->u.parray->cDims; } + if (propvar->vt == VT_CLSID) + return !propvar->u.puuid; + /* FIXME: vectors, byrefs, errors? */ return FALSE; } @@ -770,7 +843,7 @@ INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2 else propvar2_converted = propvar2; -#define CMP_INT_VALUE(var) do { \ +#define CMP_NUM_VALUE(var) do { \ if (propvar1->u.var > propvar2_converted->u.var) \ res = 1; \ else if (propvar1->u.var < propvar2_converted->u.var) \ @@ -782,28 +855,34 @@ INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2 switch (propvar1->vt) { case VT_I1: - CMP_INT_VALUE(cVal); + CMP_NUM_VALUE(cVal); break; case VT_UI1: - CMP_INT_VALUE(bVal); + CMP_NUM_VALUE(bVal); break; case VT_I2: - CMP_INT_VALUE(iVal); + CMP_NUM_VALUE(iVal); break; case VT_UI2: - CMP_INT_VALUE(uiVal); + CMP_NUM_VALUE(uiVal); break; case VT_I4: - CMP_INT_VALUE(lVal); + CMP_NUM_VALUE(lVal); break; case VT_UI4: - CMP_INT_VALUE(uiVal); + CMP_NUM_VALUE(uiVal); break; case VT_I8: - CMP_INT_VALUE(hVal.QuadPart); + CMP_NUM_VALUE(hVal.QuadPart); break; case VT_UI8: - CMP_INT_VALUE(uhVal.QuadPart); + CMP_NUM_VALUE(uhVal.QuadPart); + break; + case VT_R4: + CMP_NUM_VALUE(fltVal); + break; + case VT_R8: + CMP_NUM_VALUE(dblVal); break; case VT_BSTR: case VT_LPWSTR: @@ -820,8 +899,12 @@ INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2 else res = lstrcmpA(propvar1->u.pszVal, propvar2_converted->u.pszVal); break; + case VT_CLSID: + res = memcmp(propvar1->u.puuid, propvar2->u.puuid, sizeof(*propvar1->u.puuid)); + if (res) res = res > 0 ? 1 : -1; + break; default: - FIXME("vartype %d not handled\n", propvar1->vt); + FIXME("vartype %#x not handled\n", propvar1->vt); res = -1; break; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index b2ba781f32c..2ac9a1e0072 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -152,7 +152,7 @@ dll/win32/pdh # Synced to WineStaging-4.18 dll/win32/pidgen # Synced to WineStaging-4.18 dll/win32/powrprof # Forked at Wine-1.0rc5 dll/win32/printui # Synced to WineStaging-4.18 -dll/win32/propsys # Synced to WineStaging-4.0 +dll/win32/propsys # Synced to WineStaging-4.18 dll/win32/pstorec # Synced to WineStaging-3.3 dll/win32/qmgr # Synced to WineStaging-4.0 dll/win32/qmgrprxy # Synced to WineStaging-2.9
5 years, 1 month
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
...
33
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Results per page:
10
25
50
100
200