ReactOS 0.4.16-dev-125-g798ea90
richole.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <initguid.h>
#include <ole2.h>
#include <richedit.h>
#include <richole.h>
#include <tom.h>
#include <wine/test.h>
Include dependency graph for richole.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown*)obj, ref, __LINE__)
 
#define CHECK_TYPEINFO(disp, expected_riid)   _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__)
 
#define MAX_BUF_LEN   1024
 
#define CHECK_REOBJECT_STRUCT(reobj, poleobj, pstg, polesite, user)    _check_reobject_struct(reobj, poleobj, pstg, polesite, user, __LINE__)
 
#define RESET_RANGE(range, start, end)    _reset_range(range, start, end, __LINE__)
 
#define CHECK_RANGE(range, expected_start, expected_end)    _check_range(range, expected_start, expected_end, __LINE__)
 
#define RESET_SELECTION(selection, start, end)    _reset_selection(selection, start, end, __LINE__)
 
#define CHECK_SELECTION(selection, expected_start, expected_end)    _check_selection(selection, expected_start, expected_end, __LINE__)
 
#define TEST_TXTRGE_SETSTART(cp, expected_start, expected_end)
 
#define TEST_TXTRGE_SETEND(cp, expected_start, expected_end)
 
#define TEST_TXTSEL_SETSTART(cp, expected_start, expected_end)
 
#define TEST_TXTSEL_SETEND(cp, expected_start, expected_end)
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static HWND new_window (LPCSTR lpClassName, DWORD dwStyle, HWND parent)
 
static HWND new_richedit (HWND parent)
 
static BOOL touch_file (LPCWSTR filename)
 
static BOOL is_existing_file (LPCWSTR filename)
 
static void create_interfaces (HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
 
static void release_interfaces (HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
 
static ULONG get_refcount (IUnknown *iface)
 
static void _check_typeinfo (IDispatch *disp, REFIID expected_riid, int line)
 
static void test_Interfaces (void)
 
static void test_ITextDocument_Open (void)
 
static void test_GetText (void)
 
static void test_ITextDocument_Range (void)
 
static void test_ITextRange_GetChar (void)
 
static void check_range (HWND w, ITextDocument *doc, int first, int lim, LONG bStart, int expected_nonzero)
 
static void test_ITextRange_ScrollIntoView (void)
 
static void test_ITextSelection_GetChar (void)
 
static void test_ITextRange_GetStart_GetEnd (void)
 
static void test_ITextSelection_GetStart_GetEnd (void)
 
static void test_ITextRange_GetDuplicate (void)
 
static void test_ITextRange_Collapse (void)
 
static void test_ITextSelection_Collapse (void)
 
static void test_GetClientSite (void)
 
static void test_IOleWindow_GetWindow (void)
 
static void test_IOleInPlaceSite_GetWindow (void)
 
static void test_GetFont (void)
 
static void test_GetPara (void)
 
static void test_dispatch (void)
 
static void test_detached_font_getters (ITextFont *font, BOOL duplicate)
 
static void test_textfont_global_defaults (ITextFont *font)
 
static void test_textfont_undefined (ITextFont *font)
 
static FLOAT twips_to_points (LONG value)
 
static void test_ITextFont (void)
 
static void test_Delete (void)
 
static void test_SetText (void)
 
static void test_InRange (void)
 
static void test_ITextRange_IsEqual (void)
 
static void test_Select (void)
 
static void test_GetStoryType (void)
 
static void test_SetFont (void)
 
static void fill_reobject_struct (REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
 
static void _check_reobject_struct (REOBJECT reobj, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line)
 
static void test_InsertObject (void)
 
static void test_GetStoryLength (void)
 
static void test_ITextSelection_GetDuplicate (void)
 
static void _reset_range (ITextRange *range, LONG start, LONG end, int line)
 
static void _check_range (ITextRange *range, LONG expected_start, LONG expected_end, int line)
 
static void _reset_selection (ITextSelection *selection, LONG start, LONG end, int line)
 
static void _check_selection (ITextSelection *selection, LONG expected_start, LONG expected_end, int line)
 
static void test_ITextRange_SetRange (void)
 
static void test_Expand (void)
 
static void test_MoveEnd (void)
 
static void test_ITextRange_SetStart (void)
 
static void test_ITextRange_SetEnd (void)
 
static void test_ITextSelection_SetStart (void)
 
static void test_ITextSelection_SetEnd (void)
 
static void test_ITextRange_GetFont (void)
 
static void test_ITextSelection_GetFont (void)
 
static void test_ITextRange_GetPara (void)
 
 START_TEST (richole)
 

Variables

static HMODULE hmoduleRichEdit
 
static const WCHAR sysW [] = {'S','y','s','t','e','m',0}
 

Macro Definition Documentation

◆ CHECK_RANGE

#define CHECK_RANGE (   range,
  expected_start,
  expected_end 
)     _check_range(range, expected_start, expected_end, __LINE__)

Definition at line 3547 of file richole.c.

◆ CHECK_REOBJECT_STRUCT

#define CHECK_REOBJECT_STRUCT (   reobj,
  poleobj,
  pstg,
  polesite,
  user 
)     _check_reobject_struct(reobj, poleobj, pstg, polesite, user, __LINE__)

Definition at line 3206 of file richole.c.

◆ CHECK_SELECTION

#define CHECK_SELECTION (   selection,
  expected_start,
  expected_end 
)     _check_selection(selection, expected_start, expected_end, __LINE__)

Definition at line 3576 of file richole.c.

◆ CHECK_TYPEINFO

#define CHECK_TYPEINFO (   disp,
  expected_riid 
)    _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__)

Definition at line 116 of file richole.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file richole.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown*)obj, ref, __LINE__)

Definition at line 42 of file richole.c.

◆ MAX_BUF_LEN

#define MAX_BUF_LEN   1024

◆ RESET_RANGE

#define RESET_RANGE (   range,
  start,
  end 
)     _reset_range(range, start, end, __LINE__)

Definition at line 3535 of file richole.c.

◆ RESET_SELECTION

#define RESET_SELECTION (   selection,
  start,
  end 
)     _reset_selection(selection, start, end, __LINE__)

Definition at line 3564 of file richole.c.

◆ TEST_TXTRGE_SETEND

#define TEST_TXTRGE_SETEND (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextRange_SetEnd(txtRge, cp); \
ok(hres == S_OK, "ITextRange_SetEnd\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);
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
POINT cp
Definition: magnifier.c:59
HRESULT hres
Definition: protocol.c:465

◆ TEST_TXTRGE_SETSTART

#define TEST_TXTRGE_SETSTART (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextRange_SetStart(txtRge, cp); \
ok(hres == S_OK, "ITextRange_SetStart\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_TXTSEL_SETEND

#define TEST_TXTSEL_SETEND (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextSelection_SetEnd(txtSel, cp); \
ok(hres == S_OK, "ITextSelection_SetEnd\n"); \
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:2000

◆ TEST_TXTSEL_SETSTART

#define TEST_TXTSEL_SETSTART (   cp,
  expected_start,
  expected_end 
)
Value:
hres = ITextSelection_SetStart(txtSel, cp); \
ok(hres == S_OK, "ITextSelection_SetStart\n"); \
SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
ok(start == expected_start, "got wrong start value: %d\n", start); \
ok(end == expected_end, "got wrong end value: %d\n", end);

Function Documentation

◆ _check_range()

static void _check_range ( ITextRange range,
LONG  expected_start,
LONG  expected_end,
int  line 
)
static

Definition at line 3549 of file richole.c.

3550{
3551 HRESULT hr;
3552 LONG value;
3553
3554 hr = ITextRange_GetStart(range, &value);
3555 ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3556 ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3557 expected_start, value);
3558 hr = ITextRange_GetEnd(range, &value);
3559 ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3560 ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3561 expected_end, value);
3562}
#define ok_(x1, x2)
Definition: atltest.h:61
GLenum GLint * range
Definition: glext.h:7539
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
Definition: parser.c:49
Definition: pdh_main.c:94

◆ _check_reobject_struct()

static void _check_reobject_struct ( REOBJECT  reobj,
LPOLEOBJECT  poleobj,
LPSTORAGE  pstg,
LPOLECLIENTSITE  polesite,
DWORD  user,
int  line 
)
static

Definition at line 3208 of file richole.c.

3210{
3211 ok_(__FILE__,line)(reobj.poleobj == poleobj, "got wrong object interface.\n");
3212 ok_(__FILE__,line)(reobj.pstg == pstg, "got wrong storage interface.\n");
3213 ok_(__FILE__,line)(reobj.polesite == polesite, "got wrong site interface.\n");
3214 ok_(__FILE__,line)(reobj.dwUser == user, "got wrong user-defined value.\n");
3215}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
DWORD dwUser
Definition: richole.idl:67
LPSTORAGE pstg
Definition: richole.idl:62
LPOLEOBJECT poleobj
Definition: richole.idl:61
LPOLECLIENTSITE polesite
Definition: richole.idl:63

◆ _check_selection()

static void _check_selection ( ITextSelection selection,
LONG  expected_start,
LONG  expected_end,
int  line 
)
static

Definition at line 3578 of file richole.c.

3579{
3580 HRESULT hr;
3581 LONG value;
3582
3583 hr = ITextSelection_GetStart(selection, &value);
3584 ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3585 ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3586 expected_start, value);
3587 hr = ITextSelection_GetEnd(selection, &value);
3588 ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3589 ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3590 expected_end, value);
3591}
int selection
Definition: ctm.c:92

◆ _check_typeinfo()

static void _check_typeinfo ( IDispatch disp,
REFIID  expected_riid,
int  line 
)
static

Definition at line 117 of file richole.c.

118{
120 TYPEATTR *typeattr;
121 UINT count;
122 HRESULT hr;
123
124 count = 10;
125 hr = IDispatch_GetTypeInfoCount(disp, &count);
126 ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08x.\n", hr);
127 ok_(__FILE__,line)(count == 1, "got wrong count: %u.\n", count);
128
129 hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo);
130 ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08x.\n", hr);
131
132 hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr);
133 ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08x.\n", hr);
134 ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, expected_riid),
135 "Unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid));
136
137 ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
138 ITypeInfo_Release(typeinfo);
139}
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int UINT
Definition: ndis.h:50
#define LOCALE_SYSTEM_DEFAULT
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197

◆ _expect_ref()

static void _expect_ref ( IUnknown obj,
ULONG  ref,
int  line 
)
static

Definition at line 43 of file richole.c.

44{
45 ULONG rc;
46 IUnknown_AddRef(obj);
47 rc = IUnknown_Release(obj);
48 ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
49}
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ _reset_range()

static void _reset_range ( ITextRange range,
LONG  start,
LONG  end,
int  line 
)
static

Definition at line 3537 of file richole.c.

3538{
3539 HRESULT hr;
3540
3541 hr = ITextRange_SetStart(range, start);
3542 ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3543 hr = ITextRange_SetEnd(range, end);
3544 ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3545}

◆ _reset_selection()

static void _reset_selection ( ITextSelection selection,
LONG  start,
LONG  end,
int  line 
)
static

Definition at line 3566 of file richole.c.

3567{
3568 HRESULT hr;
3569
3570 hr = ITextSelection_SetStart(selection, start);
3571 ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3572 hr = ITextSelection_SetEnd(selection, end);
3573 ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3574}

◆ check_range()

static void check_range ( HWND  w,
ITextDocument doc,
int  first,
int  lim,
LONG  bStart,
int  expected_nonzero 
)
static

Definition at line 816 of file richole.c.

818{
819 SCROLLINFO si;
820 ITextRange *txtRge = NULL;
822
823 si.cbSize = sizeof(SCROLLINFO);
824 si.fMask = SIF_POS | SIF_RANGE;
825
826 hres = ITextDocument_Range(doc, first, lim, &txtRge);
827 ok(hres == S_OK, "got 0x%08x\n", hres);
828 hres = ITextRange_ScrollIntoView(txtRge, bStart);
829 ok(hres == S_OK, "got 0x%08x\n", hres);
830 GetScrollInfo(w, SB_VERT, &si);
831 if (expected_nonzero) {
832 ok(si.nPos != 0,
833 "Scrollbar at 0, should be >0. (TextRange %d-%d, scroll range %d-%d.)\n",
834 first, lim, si.nMin, si.nMax);
835 } else {
836 ok(si.nPos == 0,
837 "Scrollbar at %d, should be 0. (TextRange %d-%d, scroll range %d-%d.)\n",
838 si.nPos, first, lim, si.nMin, si.nMax);
839 }
840}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
const GLint * first
Definition: glext.h:5794
struct tagSCROLLINFO SCROLLINFO
#define SIF_RANGE
Definition: winuser.h:1238
#define SB_VERT
Definition: winuser.h:553
#define SIF_POS
Definition: winuser.h:1237
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)

Referenced by test_ITextRange_ScrollIntoView().

◆ create_interfaces()

static void create_interfaces ( HWND w,
IRichEditOle **  reOle,
ITextDocument **  txtDoc,
ITextSelection **  txtSel 
)
static

◆ DEFINE_GUID()

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ fill_reobject_struct()

static void fill_reobject_struct ( REOBJECT reobj,
LONG  cp,
LPOLEOBJECT  poleobj,
LPSTORAGE  pstg,
LPOLECLIENTSITE  polesite,
LONG  sizel_cx,
LONG  sizel_cy,
DWORD  aspect,
DWORD  flags,
DWORD  user 
)
static

Definition at line 3189 of file richole.c.

3192{
3193 reobj->cbStruct = sizeof(*reobj);
3194 reobj->clsid = CLSID_NULL;
3195 reobj->cp = cp;
3196 reobj->poleobj = poleobj;
3197 reobj->pstg = pstg;
3198 reobj->polesite = polesite;
3199 reobj->sizel.cx = sizel_cx;
3200 reobj->sizel.cy = sizel_cy;
3201 reobj->dvaspect = aspect;
3202 reobj->dwFlags = flags;
3203 reobj->dwUser = user;
3204}
GLbitfield flags
Definition: glext.h:7161
#define CLSID_NULL
Definition: guiddef.h:99
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
CLSID clsid
Definition: richole.idl:60
DWORD dwFlags
Definition: richole.idl:66
DWORD dvaspect
Definition: richole.idl:65
DWORD cbStruct
Definition: richole.idl:58
LONG cp
Definition: richole.idl:59
SIZEL sizel
Definition: richole.idl:64

Referenced by test_InsertObject().

◆ get_refcount()

static ULONG get_refcount ( IUnknown iface)
static

Definition at line 110 of file richole.c.

111{
112 IUnknown_AddRef(iface);
113 return IUnknown_Release(iface);
114}

Referenced by test_GetClientSite(), test_ITextRange_GetFont(), test_ITextRange_GetPara(), and test_ITextSelection_GetFont().

◆ is_existing_file()

static BOOL is_existing_file ( LPCWSTR  filename)
static

Definition at line 78 of file richole.c.

79{
81
85 return FALSE;
87 return TRUE;
88}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
const char * filename
Definition: ioapi.h:137
Definition: fci.c:127

Referenced by test_ITextDocument_Open().

◆ new_richedit()

static HWND new_richedit ( HWND  parent)
static

Definition at line 60 of file richole.c.

61{
63}
r parent
Definition: btrfs.c:3010
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
Definition: richole.c:51
#define ES_MULTILINE
Definition: pedump.c:667
#define RICHEDIT_CLASS20A
Definition: richedit.h:43

Referenced by create_interfaces(), and test_Interfaces().

◆ new_window()

static HWND new_window ( LPCSTR  lpClassName,
DWORD  dwStyle,
HWND  parent 
)
static

Definition at line 51 of file richole.c.

52{
53 HWND hwnd = CreateWindowA(lpClassName, NULL,
55 0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL);
56 ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError());
57 return hwnd;
58}
static HMODULE hmoduleRichEdit
Definition: richole.c:36
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_HSCROLL
Definition: pedump.c:628
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318

Referenced by new_richedit().

◆ release_interfaces()

◆ START_TEST()

START_TEST ( richole  )

Definition at line 4079 of file richole.c.

4080{
4081 /* Must explicitly LoadLibrary(). The test has no references to functions in
4082 * RICHED20.DLL, so the linker doesn't actually link to it. */
4083 hmoduleRichEdit = LoadLibraryA("riched20.dll");
4084 ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
4085
4088 test_GetText();
4109 test_GetFont();
4110 test_GetPara();
4111 test_dispatch();
4113 test_Delete();
4114 test_SetText();
4115 test_InRange();
4117 test_Select();
4119 test_SetFont();
4123 test_Expand();
4124 test_MoveEnd();
4125}
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_Interfaces(void)
Definition: richole.c:141
static void test_Expand(void)
Definition: richole.c:3638
static void test_SetText(void)
Definition: richole.c:2690
static void test_ITextSelection_GetDuplicate(void)
Definition: richole.c:3461
static void test_ITextSelection_SetStart(void)
Definition: richole.c:3878
static void test_ITextSelection_GetStart_GetEnd(void)
Definition: richole.c:1153
static void test_GetPara(void)
Definition: richole.c:1839
static void test_GetClientSite(void)
Definition: richole.c:1590
static void test_GetStoryLength(void)
Definition: richole.c:3393
static void test_ITextSelection_GetFont(void)
Definition: richole.c:3988
static void test_IOleInPlaceSite_GetWindow(void)
Definition: richole.c:1693
static void test_ITextRange_GetDuplicate(void)
Definition: richole.c:1359
static void test_Delete(void)
Definition: richole.c:2635
static void test_ITextSelection_GetChar(void)
Definition: richole.c:878
static void test_InRange(void)
Definition: richole.c:2777
static void test_ITextRange_GetFont(void)
Definition: richole.c:3942
static void test_GetStoryType(void)
Definition: richole.c:3046
static void test_ITextRange_GetStart_GetEnd(void)
Definition: richole.c:934
static void test_ITextRange_IsEqual(void)
Definition: richole.c:2887
static void test_ITextRange_SetStart(void)
Definition: richole.c:3811
static void test_ITextDocument_Open(void)
Definition: richole.c:262
static void test_ITextRange_Collapse(void)
Definition: richole.c:1402
static void test_MoveEnd(void)
Definition: richole.c:3697
static void test_IOleWindow_GetWindow(void)
Definition: richole.c:1665
static void test_ITextRange_ScrollIntoView(void)
Definition: richole.c:842
static void test_ITextSelection_SetEnd(void)
Definition: richole.c:3910
static void test_dispatch(void)
Definition: richole.c:1923
static void test_ITextSelection_Collapse(void)
Definition: richole.c:1513
static void test_Select(void)
Definition: richole.c:3002
static void test_ITextRange_SetRange(void)
Definition: richole.c:3593
static void test_GetFont(void)
Definition: richole.c:1721
static void test_ITextRange_SetEnd(void)
Definition: richole.c:3844
static void test_ITextFont(void)
Definition: richole.c:2294
static void test_ITextRange_GetChar(void)
Definition: richole.c:737
static void test_GetText(void)
Definition: richole.c:510
static void test_InsertObject(void)
Definition: richole.c:3217
static void test_ITextRange_GetPara(void)
Definition: richole.c:4033
static void test_SetFont(void)
Definition: richole.c:3102
static void test_ITextDocument_Range(void)
Definition: richole.c:695

◆ test_Delete()

static void test_Delete ( void  )
static

Definition at line 2635 of file richole.c.

2636{
2637 static const CHAR test_text1[] = "TestSomeText";
2638 IRichEditOle *reOle = NULL;
2639 ITextDocument *doc = NULL;
2640 ITextRange *range, *range2;
2641 LONG value;
2642 HRESULT hr;
2643 HWND hwnd;
2644
2645 create_interfaces(&hwnd, &reOle, &doc, NULL);
2646 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2647
2648 hr = ITextDocument_Range(doc, 0, 4, &range);
2649 ok(hr == S_OK, "got 0x%08x\n", hr);
2650
2651 hr = ITextDocument_Range(doc, 1, 2, &range2);
2652 ok(hr == S_OK, "got 0x%08x\n", hr);
2653
2654 hr = ITextRange_GetEnd(range, &value);
2655 ok(hr == S_OK, "got 0x%08x\n", hr);
2656 ok(value == 4, "got %d\n", value);
2657
2658 /* unit type doesn't matter is count is 0 */
2659 value = 0;
2660 hr = ITextRange_Delete(range2, tomSentence, 0, &value);
2661todo_wine {
2662 ok(hr == S_OK, "got 0x%08x\n", hr);
2663 ok(value == 1, "got %d\n", value);
2664}
2665 value = 1;
2666 hr = ITextRange_Delete(range2, tomCharacter, 0, &value);
2667todo_wine {
2668 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2669 ok(value == 0, "got %d\n", value);
2670}
2671 hr = ITextRange_GetEnd(range, &value);
2672 ok(hr == S_OK, "got 0x%08x\n", hr);
2674 ok(value == 3, "got %d\n", value);
2675
2676 hr = ITextRange_GetStart(range2, &value);
2677 ok(hr == S_OK, "got 0x%08x\n", hr);
2678 ok(value == 1, "got %d\n", value);
2679
2680 hr = ITextRange_GetEnd(range2, &value);
2681 ok(hr == S_OK, "got 0x%08x\n", hr);
2683 ok(value == 1, "got %d\n", value);
2684
2685 ITextRange_Release(range);
2686 ITextRange_Release(range2);
2687 release_interfaces(&hwnd, &reOle, &doc, NULL);
2688}
#define todo_wine
Definition: custom.c:89
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
@ tomSentence
Definition: tom.idl:120
@ tomCharacter
Definition: tom.idl:118
#define S_FALSE
Definition: winerror.h:2357
#define WM_SETTEXT
Definition: winuser.h:1620
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_detached_font_getters()

static void test_detached_font_getters ( ITextFont font,
BOOL  duplicate 
)
static

Definition at line 1970 of file richole.c.

1971{
1972 HRESULT hr, hrexp = duplicate ? S_OK : CO_E_RELEASED;
1973 LONG value;
1974 float size;
1975 BSTR str;
1976
1977 hr = ITextFont_GetBold(font, NULL);
1978 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1979
1980 hr = ITextFont_GetBold(font, &value);
1981 ok(hr == hrexp, "got 0x%08x\n", hr);
1982
1983 hr = ITextFont_GetForeColor(font, NULL);
1984 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1985
1986 hr = ITextFont_GetForeColor(font, &value);
1987 ok(hr == hrexp, "got 0x%08x\n", hr);
1988
1989 hr = ITextFont_GetItalic(font, NULL);
1990 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1991
1992 hr = ITextFont_GetItalic(font, &value);
1993 ok(hr == hrexp, "got 0x%08x\n", hr);
1994
1995 hr = ITextFont_GetLanguageID(font, NULL);
1996 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1997
1998 hr = ITextFont_GetLanguageID(font, &value);
1999 ok(hr == hrexp, "got 0x%08x\n", hr);
2000
2001 hr = ITextFont_GetName(font, NULL);
2002 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2003
2004 hr = ITextFont_GetName(font, &str);
2005 ok(hr == hrexp, "got 0x%08x\n", hr);
2006
2007 hr = ITextFont_GetSize(font, NULL);
2008 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2009
2010 hr = ITextFont_GetSize(font, &size);
2011 ok(hr == hrexp, "got 0x%08x\n", hr);
2012
2013 hr = ITextFont_GetStrikeThrough(font, NULL);
2014 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2015
2016 hr = ITextFont_GetStrikeThrough(font, &value);
2017 ok(hr == hrexp, "got 0x%08x\n", hr);
2018
2019 hr = ITextFont_GetSubscript(font, NULL);
2020 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2021
2022 hr = ITextFont_GetSubscript(font, &value);
2023 ok(hr == hrexp, "got 0x%08x\n", hr);
2024
2025 hr = ITextFont_GetSuperscript(font, NULL);
2026 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2027
2028 hr = ITextFont_GetSuperscript(font, &value);
2029 ok(hr == hrexp, "got 0x%08x\n", hr);
2030
2031 hr = ITextFont_GetUnderline(font, NULL);
2032 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2033
2034 hr = ITextFont_GetUnderline(font, &value);
2035 ok(hr == hrexp, "got 0x%08x\n", hr);
2036}
#define E_INVALIDARG
Definition: ddrawi.h:101
OLECHAR * BSTR
Definition: compat.h:2293
GLsizeiptr size
Definition: glext.h:5919
Definition: mk_font.cpp:20
const WCHAR * str
#define CO_E_RELEASED
Definition: winerror.h:2818

Referenced by test_ITextFont().

◆ test_dispatch()

static void test_dispatch ( void  )
static

Definition at line 1923 of file richole.c.

1924{
1925 static const WCHAR testnameW[] = {'G','e','t','T','e','x','t',0};
1926 static const WCHAR testname2W[] = {'T','e','x','t',0};
1927 IRichEditOle *reOle = NULL;
1928 ITextDocument *doc = NULL;
1930 WCHAR *nameW;
1931 DISPID dispid;
1932 HRESULT hr;
1933 UINT count;
1934 HWND hwnd;
1935
1936 create_interfaces(&hwnd, &reOle, &doc, NULL);
1937
1938 range = NULL;
1939 hr = ITextDocument_Range(doc, 0, 0, &range);
1940 ok(hr == S_OK, "got 0x%08x\n", hr);
1941 ok(range != NULL, "got %p\n", range);
1942
1943 dispid = 123;
1944 nameW = (WCHAR*)testnameW;
1945 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1946 ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
1947 ok(dispid == DISPID_UNKNOWN, "got %d\n", dispid);
1948
1949 dispid = 123;
1950 nameW = (WCHAR*)testname2W;
1951 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1952 ok(hr == S_OK, "got 0x%08x\n", hr);
1953 ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1954
1955 release_interfaces(&hwnd, &reOle, &doc, NULL);
1956
1957 /* try dispatch methods on detached range */
1958 hr = ITextRange_GetTypeInfoCount(range, &count);
1959 ok(hr == S_OK, "got 0x%08x\n", hr);
1960
1961 dispid = 123;
1962 nameW = (WCHAR*)testname2W;
1963 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1964 ok(hr == S_OK, "got 0x%08x\n", hr);
1965 ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1966
1967 ITextRange_Release(range);
1968}
static const WCHAR nameW[]
Definition: main.c:49
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define LOCALE_USER_DEFAULT
#define IID_NULL
Definition: guiddef.h:98
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_Expand()

static void test_Expand ( void  )
static

Definition at line 3638 of file richole.c.

3639{
3640 static const char test_text1[] = "TestSomeText";
3641 IRichEditOle *reole = NULL;
3642 ITextDocument *doc = NULL;
3645 LONG value;
3646 HRESULT hr;
3647 HWND hwnd;
3648
3649 create_interfaces(&hwnd, &reole, &doc, &selection);
3650 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3651 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3652
3653 hr = ITextDocument_Range(doc, 0, 4, &range);
3654 ok(hr == S_OK, "got 0x%08x\n", hr);
3655
3656 hr = ITextRange_Expand(range, tomStory, NULL);
3657 ok(hr == S_OK, "got 0x%08x\n", hr);
3658 CHECK_RANGE(range, 0, 13);
3659
3660 hr = ITextSelection_Expand(selection, tomStory, NULL);
3661 ok(hr == S_OK, "got 0x%08x\n", hr);
3662 CHECK_SELECTION(selection, 0, 13);
3663
3664 RESET_RANGE(range, 1, 2);
3666
3667 value = 0;
3668 hr = ITextRange_Expand(range, tomStory, &value);
3669 ok(hr == S_OK, "got 0x%08x\n", hr);
3670 ok(value == 12, "got %d\n", value);
3671 CHECK_RANGE(range, 0, 13);
3672
3673 value = 0;
3674 hr = ITextSelection_Expand(selection, tomStory, &value);
3675 ok(hr == S_OK, "got 0x%08x\n", hr);
3676 ok(value == 12, "got %d\n", value);
3677 CHECK_SELECTION(selection, 0, 13);
3678
3679 release_interfaces(&hwnd, &reole, &doc, NULL);
3680
3681 hr = ITextRange_Expand(range, tomStory, NULL);
3682 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3683
3684 hr = ITextRange_Expand(range, tomStory, &value);
3685 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3686
3687 hr = ITextSelection_Expand(selection, tomStory, NULL);
3688 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3689
3690 hr = ITextSelection_Expand(selection, tomStory, &value);
3691 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3692
3693 ITextSelection_Release(selection);
3694 ITextRange_Release(range);
3695}
#define RESET_RANGE(range, start, end)
Definition: richole.c:3535
#define CHECK_SELECTION(selection, expected_start, expected_end)
Definition: richole.c:3576
#define CHECK_RANGE(range, expected_start, expected_end)
Definition: richole.c:3547
#define RESET_SELECTION(selection, start, end)
Definition: richole.c:3564
@ tomStory
Definition: tom.idl:123
#define EM_SETSEL
Definition: winuser.h:2021

Referenced by START_TEST().

◆ test_GetClientSite()

static void test_GetClientSite ( void  )
static

Definition at line 1590 of file richole.c.

1591{
1592 HWND w;
1593 IRichEditOle *reOle = NULL, *reOle1 = NULL;
1594 ITextDocument *txtDoc = NULL;
1595 IOleClientSite *clientSite = NULL, *clientSite1 = NULL, *clientSite2 = NULL;
1596 IOleWindow *oleWin = NULL, *oleWin1 = NULL;
1597 IOleInPlaceSite *olePlace = NULL, *olePlace1 = NULL;
1598 HRESULT hres;
1599 LONG refcount1, refcount2;
1600
1601 create_interfaces(&w, &reOle, &txtDoc, NULL);
1602 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1603 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1604 EXPECT_REF(clientSite, 1);
1605
1606 hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1);
1607 ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres);
1608
1609 hres = IRichEditOle_GetClientSite(reOle, &clientSite1);
1610 ok(hres == S_OK, "got 0x%08x\n", hres);
1611 ok(clientSite != clientSite1, "got %p, %p\n", clientSite, clientSite1);
1612 IOleClientSite_Release(clientSite1);
1613
1614 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1);
1615 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1616 ok(clientSite == clientSite1, "Should not return a new pointer.\n");
1617 EXPECT_REF(clientSite, 2);
1618
1619 /* IOleWindow interface */
1620 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1621 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1622 refcount1 = get_refcount((IUnknown *)clientSite);
1623 refcount2 = get_refcount((IUnknown *)oleWin);
1624 ok(refcount1 == refcount2, "got wrong ref count.\n");
1625
1626 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1);
1627 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1628 ok(oleWin == oleWin1, "Should not return a new pointer.\n");
1629 refcount1 = get_refcount((IUnknown *)clientSite);
1630 refcount2 = get_refcount((IUnknown *)oleWin);
1631 ok(refcount1 == refcount2, "got wrong ref count.\n");
1632
1633 hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2);
1634 ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1635 ok(clientSite2 == clientSite1, "got wrong pointer\n");
1636
1637 /* IOleInPlaceSite interface */
1638 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1639 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1640 refcount1 = get_refcount((IUnknown *)olePlace);
1641 refcount2 = get_refcount((IUnknown *)clientSite);
1642 ok(refcount1 == refcount2, "got wrong ref count.\n");
1643
1644 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace1);
1645 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1646 ok(olePlace == olePlace1, "Should not return a new pointer.\n");
1647 IOleInPlaceSite_Release(olePlace1);
1648
1649 hres = IOleWindow_QueryInterface(oleWin, &IID_IOleInPlaceSite, (void **)&olePlace1);
1650 ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1651 refcount1 = get_refcount((IUnknown *)olePlace1);
1652 refcount2 = get_refcount((IUnknown *)oleWin);
1653 ok(refcount1 == refcount2, "got wrong ref count.\n");
1654
1655 IOleInPlaceSite_Release(olePlace1);
1656 IOleInPlaceSite_Release(olePlace);
1657 IOleWindow_Release(oleWin1);
1658 IOleWindow_Release(oleWin);
1659 IOleClientSite_Release(clientSite2);
1660 IOleClientSite_Release(clientSite1);
1661 IOleClientSite_Release(clientSite);
1662 release_interfaces(&w, &reOle, &txtDoc, NULL);
1663}
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
static ULONG get_refcount(IUnknown *iface)
Definition: richole.c:110
const GUID IID_IOleInPlaceSite
const GUID IID_IOleWindow
const GUID IID_IOleClientSite
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by START_TEST().

◆ test_GetFont()

static void test_GetFont ( void  )
static

Definition at line 1721 of file richole.c.

1722{
1723 static const CHAR test_text1[] = "TestSomeText";
1724 IRichEditOle *reOle = NULL;
1725 ITextDocument *doc = NULL;
1728 ITextFont *font, *font2;
1730 LONG value;
1731 float size;
1732 HRESULT hr;
1733 HWND hwnd;
1734 BOOL ret;
1735
1736 create_interfaces(&hwnd, &reOle, &doc, NULL);
1737 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1738
1739 hr = ITextDocument_GetSelection(doc, &selection);
1740 ok(hr == S_OK, "got 0x%08x\n", hr);
1741 hr = ITextSelection_GetFont(selection, &font);
1742 ok(hr == S_OK, "got 0x%08x\n", hr);
1743 hr = ITextSelection_GetFont(selection, &font2);
1744 ok(hr == S_OK, "got 0x%08x\n", hr);
1745 ok(font != font2, "got %p, %p\n", font, font2);
1746 ITextFont_Release(font2);
1747 ITextFont_Release(font);
1748 ITextSelection_Release(selection);
1749
1750 EXPECT_REF(reOle, 3);
1751 EXPECT_REF(doc, 3);
1752
1753 hr = ITextDocument_Range(doc, 0, 4, &range);
1754 ok(hr == S_OK, "got 0x%08x\n", hr);
1755
1756 EXPECT_REF(reOle, 3);
1757 EXPECT_REF(doc, 3);
1758 EXPECT_REF(range, 1);
1759
1760 hr = ITextRange_GetFont(range, NULL);
1761 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1762
1763 hr = ITextRange_GetFont(range, &font);
1764 ok(hr == S_OK, "got 0x%08x\n", hr);
1765
1766 EXPECT_REF(reOle, 3);
1767 EXPECT_REF(doc, 3);
1768 EXPECT_REF(range, 2);
1769 EXPECT_REF(font, 1);
1770
1771 hr = ITextRange_GetFont(range, &font2);
1772 ok(hr == S_OK, "got 0x%08x\n", hr);
1773 ok(font != font2, "got %p, %p\n", font, font2);
1774
1775 EXPECT_REF(reOle, 3);
1776 EXPECT_REF(doc, 3);
1777 EXPECT_REF(range, 3);
1778 EXPECT_REF(font, 1);
1779 EXPECT_REF(font2, 1);
1780
1781 ITextFont_Release(font2);
1782
1783 /* set different font style within a range */
1784 hr = ITextFont_GetItalic(font, NULL);
1785 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1786
1787 hr = ITextFont_GetSize(font, NULL);
1788 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1789
1790 size = 0.0;
1791 hr = ITextFont_GetSize(font, &size);
1792 ok(hr == S_OK, "got 0x%08x\n", hr);
1793 ok(size > 0.0, "size %.2f\n", size);
1794
1795 value = 0;
1796 hr = ITextFont_GetLanguageID(font, &value);
1797 ok(hr == S_OK, "got 0x%08x\n", hr);
1798 ok(value == GetSystemDefaultLCID(), "got lcid %x, user lcid %x\n", value,
1800
1801 /* range is non-italic */
1802 value = tomTrue;
1803 hr = ITextFont_GetItalic(font, &value);
1804 ok(hr == S_OK, "got 0x%08x\n", hr);
1805 ok(value == tomFalse, "got %d\n", value);
1806
1807 cf.cbSize = sizeof(CHARFORMAT2A);
1808 cf.dwMask = CFM_ITALIC|CFM_SIZE;
1809 cf.dwEffects = CFE_ITALIC;
1810 cf.yHeight = 24.0;
1811
1812 SendMessageA(hwnd, EM_SETSEL, 2, 3);
1814 ok(ret, "got %d\n", ret);
1815
1816 /* now range is partially italicized */
1817 value = tomFalse;
1818 hr = ITextFont_GetItalic(font, &value);
1819 ok(hr == S_OK, "got 0x%08x\n", hr);
1820 ok(value == tomUndefined, "got %d\n", value);
1821
1822 size = 0.0;
1823 hr = ITextFont_GetSize(font, &size);
1824 ok(hr == S_OK, "got 0x%08x\n", hr);
1825 ok(size == tomUndefined, "size %.2f\n", size);
1826
1827 ITextFont_Release(font);
1828 release_interfaces(&hwnd, &reOle, &doc, NULL);
1829
1830 hr = ITextRange_GetFont(range, NULL);
1831 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1832
1833 hr = ITextRange_GetFont(range, &font2);
1834 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1835
1836 ITextRange_Release(range);
1837}
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CFE_ITALIC
Definition: richedit.h:407
#define SCF_SELECTION
Definition: richedit.h:235
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define CFM_ITALIC
Definition: richedit.h:333
#define CFM_SIZE
Definition: richedit.h:362
struct _charformat2a CHARFORMAT2A
@ tomTrue
Definition: tom.idl:29
@ tomFalse
Definition: tom.idl:28
@ tomUndefined
Definition: tom.idl:30
int ret

Referenced by START_TEST().

◆ test_GetPara()

static void test_GetPara ( void  )
static

Definition at line 1839 of file richole.c.

1840{
1841 static const CHAR test_text1[] = "TestSomeText";
1842 IRichEditOle *reOle = NULL;
1843 ITextDocument *doc = NULL;
1846 ITextPara *para, *para2;
1847 HRESULT hr;
1848 HWND hwnd;
1849
1850 create_interfaces(&hwnd, &reOle, &doc, &selection);
1851 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1852
1853 EXPECT_REF(reOle, 3);
1854 EXPECT_REF(doc, 3);
1855
1856 hr = ITextDocument_Range(doc, 0, 4, &range);
1857 ok(hr == S_OK, "got 0x%08x\n", hr);
1858
1859 EXPECT_REF(reOle, 3);
1860 EXPECT_REF(doc, 3);
1861 EXPECT_REF(range, 1);
1862
1863 hr = ITextRange_GetPara(range, NULL);
1864 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1865
1866 hr = ITextRange_GetPara(range, &para);
1867 ok(hr == S_OK, "got 0x%08x\n", hr);
1868
1869 EXPECT_REF(reOle, 3);
1870 EXPECT_REF(doc, 3);
1871 EXPECT_REF(range, 2);
1872 EXPECT_REF(para, 1);
1873
1874 hr = ITextRange_GetPara(range, &para2);
1875 ok(hr == S_OK, "got 0x%08x\n", hr);
1876 ok(para != para2, "got %p, %p\n", para, para2);
1877
1878 EXPECT_REF(reOle, 3);
1879 EXPECT_REF(doc, 3);
1880 EXPECT_REF(range, 3);
1881 EXPECT_REF(para, 1);
1882 EXPECT_REF(para2, 1);
1883
1884 ITextPara_Release(para);
1885 ITextPara_Release(para2);
1886
1887 EXPECT_REF(reOle, 3);
1888 EXPECT_REF(doc, 3);
1890
1891 hr = ITextSelection_GetPara(selection, &para);
1892 ok(hr == S_OK, "got 0x%08x\n", hr);
1893
1894 EXPECT_REF(reOle, 3);
1895 EXPECT_REF(doc, 3);
1897 EXPECT_REF(para, 1);
1898
1899 hr = ITextSelection_GetPara(selection, &para2);
1900 ok(hr == S_OK, "got 0x%08x\n", hr);
1901 ok(para != para2, "got %p, %p\n", para, para2);
1902
1903 ITextPara_Release(para);
1904 ITextPara_Release(para2);
1905 release_interfaces(&hwnd, &reOle, &doc, NULL);
1906
1907 hr = ITextRange_GetPara(range, NULL);
1908 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1909
1910 hr = ITextRange_GetPara(range, &para);
1911 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1912
1913 hr = ITextSelection_GetPara(selection, NULL);
1914 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1915
1916 hr = ITextSelection_GetPara(selection, &para);
1917 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1918
1919 ITextSelection_Release(selection);
1920 ITextRange_Release(range);
1921}

Referenced by START_TEST().

◆ test_GetStoryLength()

static void test_GetStoryLength ( void  )
static

Definition at line 3393 of file richole.c.

3394{
3395 static const CHAR test_text1[] = "TestSomeText";
3396 IRichEditOle *reOle = NULL;
3397 ITextDocument *doc = NULL;
3400 LONG value;
3401 HRESULT hr;
3402 HWND hwnd;
3403
3404 create_interfaces(&hwnd, &reOle, &doc, &selection);
3405 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3406 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3407
3408 hr = ITextDocument_Range(doc, 0, 4, &range);
3409 ok(hr == S_OK, "got 0x%08x\n", hr);
3410
3411 hr = ITextRange_GetStoryLength(range, NULL);
3412 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3413
3414 value = 0;
3415 hr = ITextRange_GetStoryLength(range, &value);
3416 ok(hr == S_OK, "got 0x%08x\n", hr);
3417 ok(value == 13, "got %d\n", value);
3418
3419 hr = ITextSelection_GetStoryLength(selection, NULL);
3420 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3421
3422 value = 0;
3423 hr = ITextSelection_GetStoryLength(selection, &value);
3424 ok(hr == S_OK, "got 0x%08x\n", hr);
3425 ok(value == 13, "got %d\n", value);
3426
3428
3429 value = 0;
3430 hr = ITextRange_GetStoryLength(range, &value);
3431 ok(hr == S_OK, "got 0x%08x\n", hr);
3432 ok(value == 1, "got %d\n", value);
3433
3434 value = 0;
3435 hr = ITextSelection_GetStoryLength(selection, &value);
3436 ok(hr == S_OK, "got 0x%08x\n", hr);
3437 ok(value == 1, "got %d\n", value);
3438
3439 release_interfaces(&hwnd, &reOle, &doc, NULL);
3440
3441 hr = ITextRange_GetStoryLength(range, NULL);
3442 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3443
3444 value = 100;
3445 hr = ITextRange_GetStoryLength(range, &value);
3446 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3447 ok(value == 100, "got %d\n", value);
3448
3449 hr = ITextSelection_GetStoryLength(selection, NULL);
3450 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3451
3452 value = 100;
3453 hr = ITextSelection_GetStoryLength(selection, &value);
3454 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3455 ok(value == 100, "got %d\n", value);
3456
3457 ITextSelection_Release(selection);
3458 ITextRange_Release(range);
3459}

Referenced by START_TEST().

◆ test_GetStoryType()

static void test_GetStoryType ( void  )
static

Definition at line 3046 of file richole.c.

3047{
3048 static const CHAR test_text1[] = "TestSomeText";
3049 IRichEditOle *reOle = NULL;
3050 ITextDocument *doc = NULL;
3053 LONG value;
3054 HRESULT hr;
3055 HWND hwnd;
3056
3057 create_interfaces(&hwnd, &reOle, &doc, &selection);
3058 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3059 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3060
3061 hr = ITextDocument_Range(doc, 0, 4, &range);
3062 ok(hr == S_OK, "got 0x%08x\n", hr);
3063
3064 hr = ITextRange_GetStoryType(range, NULL);
3065 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3066
3068 hr = ITextRange_GetStoryType(range, &value);
3069 ok(hr == S_OK, "got 0x%08x\n", hr);
3070 ok(value == tomUnknownStory, "got %d\n", value);
3071
3072 hr = ITextSelection_GetStoryType(selection, NULL);
3073 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3074
3076 hr = ITextSelection_GetStoryType(selection, &value);
3077 ok(hr == S_OK, "got 0x%08x\n", hr);
3078 ok(value == tomUnknownStory, "got %d\n", value);
3079
3080 release_interfaces(&hwnd, &reOle, &doc, NULL);
3081
3082 hr = ITextRange_GetStoryType(range, NULL);
3083 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3084
3085 value = 123;
3086 hr = ITextRange_GetStoryType(range, &value);
3087 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3088 ok(value == 123, "got %d\n", value);
3089
3090 hr = ITextSelection_GetStoryType(selection, NULL);
3091 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3092
3093 value = 123;
3094 hr = ITextSelection_GetStoryType(selection, &value);
3095 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3096 ok(value == 123, "got %d\n", value);
3097
3098 ITextRange_Release(range);
3099 ITextSelection_Release(selection);
3100}
@ tomUnknownStory
Definition: tom.idl:139
@ tomTextFrameStory
Definition: tom.idl:144

Referenced by START_TEST().

◆ test_GetText()

static void test_GetText ( void  )
static

Definition at line 510 of file richole.c.

511{
512 HWND w;
513 IRichEditOle *reOle = NULL;
514 ITextDocument *txtDoc = NULL;
515 ITextSelection *txtSel = NULL;
517 BSTR bstr = NULL;
518 int first, lim;
519 static const CHAR test_text1[] = "TestSomeText";
520 static const WCHAR bufW1[] = {'T', 'e', 's', 't', 0};
521 static const WCHAR bufW2[] = {'T', 'e', 'x', 't', '\r', 0};
522 static const WCHAR bufW3[] = {'T', 'e', 'x', 't', 0};
523 static const WCHAR bufW4[] = {'T', 'e', 's', 't', 'S', 'o', 'm',
524 'e', 'T', 'e', 'x', 't', '\r', 0};
525 static const WCHAR bufW5[] = {'\r', 0};
526 static const WCHAR bufW6[] = {'T','e','s','t','S','o','m','e','T',0};
527 BOOL is64bit = sizeof(void *) > sizeof(int);
529
530 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
531 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
532
533 /* ITextSelection */
534 first = 0; lim = 4;
536 hres = ITextSelection_GetText(txtSel, &bstr);
537 ok(hres == S_OK, "ITextSelection_GetText\n");
538 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
539 SysFreeString(bstr);
540
541 first = 4; lim = 0;
543 hres = ITextSelection_GetText(txtSel, &bstr);
544 ok(hres == S_OK, "ITextSelection_GetText\n");
545 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
546 SysFreeString(bstr);
547
548 first = 1; lim = 1;
550 hres = ITextSelection_GetText(txtSel, &bstr);
551 ok(hres == S_OK, "ITextSelection_GetText\n");
552 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
553
554 if (!is64bit)
555 {
556 hres = ITextSelection_GetText(txtSel, NULL);
557 ok(hres == E_INVALIDARG, "ITextSelection_GetText\n");
558 }
559
560 first = 8; lim = 12;
562 hres = ITextSelection_GetText(txtSel, &bstr);
563 ok(hres == S_OK, "ITextSelection_GetText\n");
564 ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
565 SysFreeString(bstr);
566
567 first = 8; lim = 13;
569 hres = ITextSelection_GetText(txtSel, &bstr);
570 ok(hres == S_OK, "ITextSelection_GetText\n");
571 ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
572 SysFreeString(bstr);
573
574 first = 12; lim = 13;
576 hres = ITextSelection_GetText(txtSel, &bstr);
577 ok(hres == S_OK, "ITextSelection_GetText\n");
578 ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
579 SysFreeString(bstr);
580
581 first = 0; lim = -1;
583 hres = ITextSelection_GetText(txtSel, &bstr);
584 ok(hres == S_OK, "ITextSelection_GetText\n");
585 ok(!lstrcmpW(bstr, bufW4), "got wrong text: %s\n", wine_dbgstr_w(bstr));
586 SysFreeString(bstr);
587
588 first = -1; lim = 9;
590 hres = ITextSelection_GetText(txtSel, &bstr);
591 ok(hres == S_OK, "ITextSelection_GetText\n");
592 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
593
594 /* ITextRange */
595 hres = ITextDocument_Range(txtDoc, 0, 4, &range);
596 ok(hres == S_OK, "got 0x%08x\n", hres);
597 hres = ITextRange_GetText(range, &bstr);
598 ok(hres == S_OK, "got 0x%08x\n", hres);
599 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
600
601 SysFreeString(bstr);
602 ITextRange_Release(range);
603
604 hres = ITextDocument_Range(txtDoc, 4, 0, &range);
605 ok(hres == S_OK, "got 0x%08x\n", hres);
606 hres = ITextRange_GetText(range, &bstr);
607 ok(hres == S_OK, "got 0x%08x\n", hres);
608 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
609
610 SysFreeString(bstr);
611 ITextRange_Release(range);
612
613 hres = ITextDocument_Range(txtDoc, 1, 1, &range);
614 ok(hres == S_OK, "got 0x%08x\n", hres);
615 hres = ITextRange_GetText(range, &bstr);
616 ok(hres == S_OK, "got 0x%08x\n", hres);
617 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
618 if (!is64bit)
619 {
620 hres = ITextRange_GetText(range, NULL);
621 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
622 }
623 ITextRange_Release(range);
624
625 hres = ITextDocument_Range(txtDoc, 8, 12, &range);
626 ok(hres == S_OK, "got 0x%08x\n", hres);
627 hres = ITextRange_GetText(range, &bstr);
628 ok(hres == S_OK, "got 0x%08x\n", hres);
629 ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
630
631 SysFreeString(bstr);
632 ITextRange_Release(range);
633
634 hres = ITextDocument_Range(txtDoc, 8, 13, &range);
635 ok(hres == S_OK, "got 0x%08x\n", hres);
636 hres = ITextRange_GetText(range, &bstr);
637 ok(hres == S_OK, "got 0x%08x\n", hres);
638 ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
639
640 SysFreeString(bstr);
641 ITextRange_Release(range);
642
643 hres = ITextDocument_Range(txtDoc, 12, 13, &range);
644 ok(hres == S_OK, "got 0x%08x\n", hres);
645 hres = ITextRange_GetText(range, &bstr);
646 ok(hres == S_OK, "got 0x%08x\n", hres);
647 ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
648
649 SysFreeString(bstr);
650 ITextRange_Release(range);
651
652 hres = ITextDocument_Range(txtDoc, 0, -1, &range);
653 ok(hres == S_OK, "got 0x%08x\n", hres);
654 hres = ITextRange_GetText(range, &bstr);
655 ok(hres == S_OK, "got 0x%08x\n", hres);
656 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
657 ITextRange_Release(range);
658
659 hres = ITextDocument_Range(txtDoc, -1, 9, &range);
660 ok(hres == S_OK, "got 0x%08x\n", hres);
661 hres = ITextRange_GetText(range, &bstr);
662 ok(hres == S_OK, "got 0x%08x\n", hres);
663 ok(!lstrcmpW(bstr, bufW6), "got wrong text: %s\n", wine_dbgstr_w(bstr));
664
665 SysFreeString(bstr);
666
667 release_interfaces(&w, &reOle, &txtDoc, NULL);
668
669 /* detached selection/range */
670 if (is64bit) {
671 bstr = (void*)0xdeadbeef;
672 hres = ITextSelection_GetText(txtSel, &bstr);
673 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
675 ok(bstr == NULL, "got %p\n", bstr);
676
677 bstr = (void*)0xdeadbeef;
678 hres = ITextRange_GetText(range, &bstr);
679 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
681 ok(bstr == NULL, "got %p\n", bstr);
682 }
683 else {
684 hres = ITextSelection_GetText(txtSel, NULL);
685 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
686
687 hres = ITextRange_GetText(range, NULL);
688 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
689 }
690
691 ITextRange_Release(range);
692 ITextSelection_Release(txtSel);
693}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
#define wine_dbgstr_w
Definition: kernel32.h:34
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271

Referenced by START_TEST().

◆ test_InRange()

static void test_InRange ( void  )
static

Definition at line 2777 of file richole.c.

2778{
2779 static const CHAR test_text1[] = "TestSomeText";
2780 ITextRange *range, *range2, *range3;
2781 IRichEditOle *reOle = NULL;
2782 ITextDocument *doc = NULL;
2784 LONG value;
2785 HRESULT hr;
2786 HWND hwnd;
2787
2788 create_interfaces(&hwnd, &reOle, &doc, &selection);
2789 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2790 SendMessageA(hwnd, EM_SETSEL, 1, 2);
2791
2792 hr = ITextDocument_Range(doc, 0, 4, &range);
2793 ok(hr == S_OK, "got 0x%08x\n", hr);
2794
2795 hr = ITextDocument_Range(doc, 0, 4, &range2);
2796 ok(hr == S_OK, "got 0x%08x\n", hr);
2797
2798 /* matches selection */
2799 hr = ITextDocument_Range(doc, 1, 2, &range3);
2800 ok(hr == S_OK, "got 0x%08x\n", hr);
2801
2802 hr = ITextRange_InRange(range, NULL, NULL);
2803 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2804
2805 value = tomTrue;
2806 hr = ITextRange_InRange(range, NULL, &value);
2807 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2808 ok(value == tomFalse, "got %d\n", value);
2809
2810 hr = ITextRange_InRange(range, range2, NULL);
2811 ok(hr == S_OK, "got 0x%08x\n", hr);
2812
2813 value = tomFalse;
2814 hr = ITextRange_InRange(range, range2, &value);
2815 ok(hr == S_OK, "got 0x%08x\n", hr);
2816 ok(value == tomTrue, "got %d\n", value);
2817
2818 /* selection */
2819 hr = ITextSelection_InRange(selection, NULL, NULL);
2820 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2821
2822 value = tomTrue;
2823 hr = ITextSelection_InRange(selection, NULL, &value);
2824 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2825 ok(value == tomFalse, "got %d\n", value);
2826
2827 hr = ITextSelection_InRange(selection, range2, NULL);
2828 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2829
2830 value = tomTrue;
2831 hr = ITextSelection_InRange(selection, range2, &value);
2832 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2833 ok(value == tomFalse, "got %d\n", value);
2834
2835 value = tomTrue;
2836 hr = ITextSelection_InRange(selection, range3, &value);
2837 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2838 ok(value == tomFalse, "got %d\n", value);
2839
2840 /* seems to work on ITextSelection ranges only */
2841 value = tomFalse;
2842 hr = ITextSelection_InRange(selection, (ITextRange*)selection, &value);
2843 ok(hr == S_OK, "got 0x%08x\n", hr);
2844 ok(value == tomTrue, "got %d\n", value);
2845
2846 release_interfaces(&hwnd, &reOle, &doc, NULL);
2847
2848 hr = ITextRange_InRange(range, NULL, NULL);
2849 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2850
2851 value = tomTrue;
2852 hr = ITextRange_InRange(range, NULL, &value);
2853 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2854 ok(value == tomFalse, "got %d\n", value);
2855
2856 hr = ITextRange_InRange(range, range2, NULL);
2857 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2858
2859 value = tomTrue;
2860 hr = ITextRange_InRange(range, range2, &value);
2861 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2862 ok(value == tomFalse, "got %d\n", value);
2863
2864 /* selection */
2865 hr = ITextSelection_InRange(selection, NULL, NULL);
2866 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2867
2868 value = tomTrue;
2869 hr = ITextSelection_InRange(selection, NULL, &value);
2870 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2871 ok(value == tomFalse, "got %d\n", value);
2872
2873 hr = ITextSelection_InRange(selection, range2, NULL);
2874 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2875
2876 value = tomTrue;
2877 hr = ITextSelection_InRange(selection, range2, &value);
2878 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2879 ok(value == tomFalse, "got %d\n", value);
2880
2881 ITextRange_Release(range);
2882 ITextRange_Release(range2);
2883 ITextRange_Release(range3);
2884 ITextSelection_Release(selection);
2885}

Referenced by START_TEST().

◆ test_InsertObject()

static void test_InsertObject ( void  )
static

Definition at line 3217 of file richole.c.

3218{
3219 static CHAR test_text1[] = "abcdefg";
3220 IRichEditOle *reole = NULL;
3221 ITextDocument *doc = NULL;
3222 IOleClientSite *clientsite;
3223 REOBJECT reo1, reo2, reo3, received_reo1, received_reo2, received_reo3, received_reo4;
3224 HRESULT hr;
3225 HWND hwnd;
3226 LONG count;
3227
3228 create_interfaces(&hwnd, &reole, &doc, NULL);
3229 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3230
3231 hr = IRichEditOle_InsertObject(reole, NULL);
3232 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3233
3234 /* insert object1 in (0, 1)*/
3235 SendMessageA(hwnd, EM_SETSEL, 0, 1);
3236 hr = IRichEditOle_GetClientSite(reole, &clientsite);
3237 ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3238 fill_reobject_struct(&reo1, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1);
3239 hr = IRichEditOle_InsertObject(reole, &reo1);
3240 ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3241 count = IRichEditOle_GetObjectCount(reole);
3242 ok(count == 1, "got wrong object count: %d\n", count);
3243 IOleClientSite_Release(clientsite);
3244
3245 /* insert object2 in (2, 3)*/
3246 SendMessageA(hwnd, EM_SETSEL, 2, 3);
3247 hr = IRichEditOle_GetClientSite(reole, &clientsite);
3248 ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3249 fill_reobject_struct(&reo2, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 2);
3250 hr = IRichEditOle_InsertObject(reole, &reo2);
3251 ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3252 count = IRichEditOle_GetObjectCount(reole);
3253 ok(count == 2, "got wrong object count: %d\n", count);
3254 IOleClientSite_Release(clientsite);
3255
3256 /* insert object3 in (1, 2)*/
3257 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3258 hr = IRichEditOle_GetClientSite(reole, &clientsite);
3259 ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr);
3260 fill_reobject_struct(&reo3, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 3);
3261 hr = IRichEditOle_InsertObject(reole, &reo3);
3262 ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr);
3263 count = IRichEditOle_GetObjectCount(reole);
3264 ok(count == 3, "got wrong object count: %d\n", count);
3265 IOleClientSite_Release(clientsite);
3266
3267 /* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */
3268 received_reo1.cbStruct = sizeof(received_reo1);
3269 hr = IRichEditOle_GetObject(reole, 0, &received_reo1, REO_GETOBJ_ALL_INTERFACES);
3270 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3271 CHECK_REOBJECT_STRUCT(received_reo1, NULL, NULL, reo1.polesite, 1);
3272
3273 received_reo2.cbStruct = sizeof(received_reo2);
3274 hr = IRichEditOle_GetObject(reole, 1, &received_reo2, REO_GETOBJ_ALL_INTERFACES);
3275 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3276 CHECK_REOBJECT_STRUCT(received_reo2, NULL, NULL, reo3.polesite, 3);
3277
3278 received_reo3.cbStruct = sizeof(received_reo3);
3279 hr = IRichEditOle_GetObject(reole, 2, &received_reo3, REO_GETOBJ_ALL_INTERFACES);
3280 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3281 CHECK_REOBJECT_STRUCT(received_reo3, NULL, NULL, reo2.polesite, 2);
3282
3283 hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES);
3284 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3285
3286 received_reo4.cbStruct = 0;
3287 hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3288 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3289
3290 received_reo4.cbStruct = sizeof(received_reo4);
3291 hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_PSTG);
3292 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3293 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2);
3294
3295 hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_POLESITE);
3296 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3297 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3298
3299 hr = IRichEditOle_GetObject(reole, 4, &received_reo4, REO_GETOBJ_POLESITE);
3300 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3301
3302 hr = IRichEditOle_GetObject(reole, 1024, &received_reo4, REO_GETOBJ_POLESITE);
3303 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3304
3305 /* received_reo4 will be zeroed before be used */
3306 hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_NO_INTERFACES);
3307 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3308 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2);
3309
3310 received_reo4.cbStruct = sizeof(received_reo4);
3311 received_reo4.cp = 0;
3312 hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3313 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3314 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3315
3316 received_reo4.cbStruct = sizeof(received_reo4);
3317 received_reo4.cp = 1;
3318 hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3319 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3320 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3321
3322 received_reo4.cbStruct = sizeof(received_reo4);
3323 received_reo4.cp = 2;
3324 hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3325 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3326 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3327
3328 received_reo4.cbStruct = sizeof(received_reo4);
3329 received_reo4.cp = 4;
3330 hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3331 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3332 /* received_reo4 didn't be zeroed in E_INVALIDARG case */
3333 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3334
3335 SendMessageA(hwnd, EM_SETSEL, 0, 1);
3336 received_reo4.cbStruct = sizeof(received_reo4);
3337 received_reo4.cp = 1;
3338 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3339 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3340 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3341
3342 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3343 received_reo4.cbStruct = sizeof(received_reo4);
3344 received_reo4.cp = 0;
3345 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3346 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3347 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3348
3349 SendMessageA(hwnd, EM_SETSEL, 2, 3);
3350 received_reo4.cbStruct = sizeof(received_reo4);
3351 received_reo4.cp = 0;
3352 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3353 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3354 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
3355
3356 SendMessageA(hwnd, EM_SETSEL, 0, 2);
3357 received_reo4.cbStruct = sizeof(received_reo4);
3358 received_reo4.cp = 0;
3359 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3360 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3361 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3362
3363 SendMessageA(hwnd, EM_SETSEL, 1, 3);
3364 received_reo4.cbStruct = sizeof(received_reo4);
3365 received_reo4.cp = 0;
3366 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3367 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3368 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3);
3369
3370 SendMessageA(hwnd, EM_SETSEL, 2, 0);
3371 received_reo4.cbStruct = sizeof(received_reo4);
3372 received_reo4.cp = 0;
3373 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3374 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3375 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3376
3377 SendMessageA(hwnd, EM_SETSEL, 0, 6);
3378 received_reo4.cbStruct = sizeof(received_reo4);
3379 received_reo4.cp = 0;
3380 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3381 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3382 CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1);
3383
3384 SendMessageA(hwnd, EM_SETSEL, 4, 5);
3385 received_reo4.cbStruct = sizeof(received_reo4);
3386 received_reo4.cp = 0;
3387 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES);
3388 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3389
3390 release_interfaces(&hwnd, &reole, &doc, NULL);
3391}
static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
Definition: richole.c:3189
#define CHECK_REOBJECT_STRUCT(reobj, poleobj, pstg, polesite, user)
Definition: richole.c:3206

Referenced by START_TEST().

◆ test_Interfaces()

static void test_Interfaces ( void  )
static

Definition at line 141 of file richole.c.

142{
143 IRichEditOle *reOle = NULL, *reOle1 = NULL;
144 ITextDocument *txtDoc = NULL;
145 ITextDocument2Old *txtDoc2Old = NULL;
146 ITextSelection *txtSel = NULL, *txtSel2;
147 IUnknown *punk;
149 LRESULT res;
150 HWND w;
151 ULONG refcount;
152
154 if (!w) {
155 skip("Couldn't create window\n");
156 return;
157 }
158
160 ok(res, "SendMessage\n");
161 ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
162 EXPECT_REF(reOle, 2);
163
164 res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle1);
165 ok(res == 1, "SendMessage\n");
166 ok(reOle1 == reOle, "Should not return a new IRichEditOle interface\n");
167 EXPECT_REF(reOle, 3);
168
169 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument,
170 (void **) &txtDoc);
171 ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
172 ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n");
173 CHECK_TYPEINFO(txtDoc, &IID_ITextDocument);
174
175 hres = ITextDocument_GetSelection(txtDoc, NULL);
176 ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres);
177
178 EXPECT_REF(txtDoc, 4);
179
180 hres = ITextDocument_GetSelection(txtDoc, &txtSel);
181 ok(hres == S_OK, "got 0x%08x\n", hres);
182
183 EXPECT_REF(txtDoc, 4);
184 EXPECT_REF(txtSel, 2);
185
186 hres = ITextDocument_GetSelection(txtDoc, &txtSel2);
187 ok(hres == S_OK, "got 0x%08x\n", hres);
188 ok(txtSel2 == txtSel, "got %p, %p\n", txtSel, txtSel2);
189
190 EXPECT_REF(txtDoc, 4);
191 EXPECT_REF(txtSel, 3);
192
193 ITextSelection_Release(txtSel2);
194
195 punk = NULL;
196 hres = ITextSelection_QueryInterface(txtSel, &IID_ITextSelection, (void **) &punk);
197 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
198 ok(punk != NULL, "ITextSelection_QueryInterface\n");
199 IUnknown_Release(punk);
200
201 punk = NULL;
202 hres = ITextSelection_QueryInterface(txtSel, &IID_ITextRange, (void **) &punk);
203 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
204 ok(punk != NULL, "ITextSelection_QueryInterface\n");
205 IUnknown_Release(punk);
206
207 punk = NULL;
208 hres = ITextSelection_QueryInterface(txtSel, &IID_IDispatch, (void **) &punk);
209 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
210 ok(punk != NULL, "ITextSelection_QueryInterface\n");
211 IUnknown_Release(punk);
212
213 punk = NULL;
214 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleClientSite, (void **) &punk);
215 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
216
217 punk = NULL;
218 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleWindow, (void **) &punk);
219 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
220
221 punk = NULL;
222 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk);
223 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
224
225 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
226 ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
227 ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
228 ok((ITextDocument *)txtDoc2Old == txtDoc, "interface pointer isn't equal.\n");
229 EXPECT_REF(txtDoc2Old, 5);
230 EXPECT_REF(reOle, 5);
231 CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
232
233 ITextDocument2Old_Release(txtDoc2Old);
234
235 ITextDocument_Release(txtDoc);
236 IRichEditOle_Release(reOle);
237 refcount = IRichEditOle_Release(reOle);
238 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
240
241 /* Methods should return CO_E_RELEASED if the backing document has
242 been released. One test should suffice. */
243 hres = ITextSelection_CanEdit(txtSel, NULL);
244 ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n");
245
246 ITextSelection_Release(txtSel);
247
250 ok(res, "SendMessage\n");
251 ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
252
253 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
254 ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
255 ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
256 CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
257 ITextDocument2Old_Release(txtDoc2Old);
258 IRichEditOle_Release(reOle);
260}
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define CHECK_TYPEINFO(disp, expected_riid)
Definition: richole.c:116
const GUID IID_IDispatch
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by START_TEST().

◆ test_IOleInPlaceSite_GetWindow()

static void test_IOleInPlaceSite_GetWindow ( void  )
static

Definition at line 1693 of file richole.c.

1694{
1695 HWND w;
1696 IRichEditOle *reOle = NULL;
1697 ITextDocument *txtDoc = NULL;
1698 IOleClientSite *clientSite = NULL;
1699 IOleInPlaceSite *olePlace = NULL;
1700 HRESULT hres;
1701 HWND hwnd;
1702
1703 create_interfaces(&w, &reOle, &txtDoc, NULL);
1704 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1705 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1706
1707 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1708 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1709 hres = IOleInPlaceSite_GetWindow(olePlace, &hwnd);
1710 ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1711 ok(w == hwnd, "got wrong pointer.\n");
1712
1713 hres = IOleInPlaceSite_GetWindow(olePlace, NULL);
1714 ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1715
1716 IOleInPlaceSite_Release(olePlace);
1717 IOleClientSite_Release(clientSite);
1718 release_interfaces(&w, &reOle, &txtDoc, NULL);
1719}

Referenced by START_TEST().

◆ test_IOleWindow_GetWindow()

static void test_IOleWindow_GetWindow ( void  )
static

Definition at line 1665 of file richole.c.

1666{
1667 HWND w;
1668 IRichEditOle *reOle = NULL;
1669 ITextDocument *txtDoc = NULL;
1670 IOleClientSite *clientSite = NULL;
1671 IOleWindow *oleWin = NULL;
1672 HRESULT hres;
1673 HWND hwnd;
1674
1675 create_interfaces(&w, &reOle, &txtDoc, NULL);
1676 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1677 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1678
1679 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1680 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1681 hres = IOleWindow_GetWindow(oleWin, &hwnd);
1682 ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1683 ok(w == hwnd, "got wrong pointer\n");
1684
1685 hres = IOleWindow_GetWindow(oleWin, NULL);
1686 ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1687
1688 IOleWindow_Release(oleWin);
1689 IOleClientSite_Release(clientSite);
1690 release_interfaces(&w, &reOle, &txtDoc, NULL);
1691}

Referenced by START_TEST().

◆ test_ITextDocument_Open()

static void test_ITextDocument_Open ( void  )
static

Definition at line 262 of file richole.c.

263{
264 IRichEditOle *reOle = NULL;
265 ITextDocument *txtDoc = NULL;
266 ITextSelection *txtSel = NULL;
268 HWND w;
270 VARIANT testfile;
271 WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0};
272 int result;
273 DWORD dw;
274 static const CHAR chACP[] = "TestSomeText";
275 static const CHAR chUTF8[] = "\xef\xbb\xbfTextWithUTF8BOM";
276 static const WCHAR chUTF16[] = {0xfeff, 'T', 'e', 's', 't', 'S', 'o', 'm',
277 'e', 'T', 'e', 'x', 't', 0};
278
279#define MAX_BUF_LEN 1024
280 CHAR bufACP[MAX_BUF_LEN];
281 WCHAR bufUnicode[MAX_BUF_LEN];
282
283 static const int tomConstantsSingle[] =
284 {
288 };
289
290 static const int tomConstantsMulti[] =
291 {
298 };
299
300 int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
301 int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
302 int i;
303
304 V_VT(&testfile) = VT_BSTR;
305 V_BSTR(&testfile) = SysAllocString(filename);
306
307 for(i=0; i < tomNumSingle; i++)
308 {
310 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
311 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_ACP);
312 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
313 tomConstantsSingle[i], hres);
314 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
316
318 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
319 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_UTF8);
320 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
321 tomConstantsSingle[i], hres);
322 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
324 }
325
326 for(i=0; i < tomNumMulti; i++)
327 {
329 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
330 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_ACP);
331 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
332 tomConstantsMulti[i], hres);
333 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
335
337 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
338 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_UTF8);
339 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
340 tomConstantsMulti[i], hres);
341 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
343 }
344
345 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
346 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_ACP);
347 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
348 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
349 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
351
352 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
353 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_UTF8);
354 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
355 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
356 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
358
359 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
360 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_ACP);
361 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
362 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
363 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
365
366 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
367 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_UTF8);
368 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
369 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
370 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
372
373 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
374 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
375 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
376 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
377 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
379
380 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
381 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
382 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
383 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
384 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
386
387 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
389 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
390 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_ACP\n");
391 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
393
394 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
396 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
397 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
398 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
400
401 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
402 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_ACP);
403 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_ACP\n");
404 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
405
406 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
407 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_UTF8);
408 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
409 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
410
411 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
413 hres = ITextDocument_Open(txtDoc, &testfile, tomText, CP_ACP);
414todo_wine {
415 ok(hres == S_OK, "got 0x%08x\n", hres);
416 ok(is_existing_file(filename) == TRUE, "a file should be created default\n");
417}
418 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
420
421 /* test of share mode */
423 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
424 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyRead, CP_ACP);
426 ok(hres == S_OK, "got 0x%08x\n", hres);
427 SetLastError(0xdeadbeef);
430 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
432 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
434
436 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
437 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite, CP_ACP);
439 ok(hres == S_OK, "got 0x%08x\n", hres);
440 SetLastError(0xdeadbeef);
443 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
445 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
447
449 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
450 SetLastError(0xdeadbeef);
451 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite|tomShareDenyRead, CP_ACP);
453 ok(hres == S_OK, "got 0x%08x\n", hres);
456 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
458 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
460
461 /* tests to check the content */
464 WriteFile(hFile, chACP, sizeof(chACP)-sizeof(CHAR), &dw, NULL);
466 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
467 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP);
469 ok(hres == S_OK, "got 0x%08x\n", hres);
470 result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
471 todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result);
472 result = strcmp(bufACP, chACP);
473 todo_wine ok(result == 0, "ITextDocument_Open: Test ASCII set wrong text: Result: %s\n", bufACP);
474 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
476
479 WriteFile(hFile, chUTF8, sizeof(chUTF8)-sizeof(CHAR), &dw, NULL);
481 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
482 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8);
484 ok(hres == S_OK, "got 0x%08x\n", hres);
485 result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
486 todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result);
487 result = strcmp(bufACP, &chUTF8[3]);
488 todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-8 set wrong text: Result: %s\n", bufACP);
489 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
491
494 WriteFile(hFile, chUTF16, sizeof(chUTF16)-sizeof(WCHAR), &dw, NULL);
496 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
497 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200);
499 ok(hres == S_OK, "got 0x%08x\n", hres);
500 result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode);
501 todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result);
502 result = lstrcmpW(bufUnicode, &chUTF16[1]);
503 todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-16 set wrong text: Result: %s\n", wine_dbgstr_w(bufUnicode));
504 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
506
507 VariantClear(&testfile);
508}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
@ VT_BSTR
Definition: compat.h:2303
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static BOOL touch_file(LPCWSTR filename)
Definition: richole.c:65
static BOOL is_existing_file(LPCWSTR filename)
Definition: richole.c:78
#define MAX_BUF_LEN
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define CP_UTF8
Definition: nls.h:20
@ tomRTF
Definition: tom.idl:178
@ tomPasteFile
Definition: tom.idl:172
@ tomText
Definition: tom.idl:179
@ tomOpenExisting
Definition: tom.idl:175
@ tomCreateAlways
Definition: tom.idl:174
@ tomReadOnly
Definition: tom.idl:169
@ tomShareDenyWrite
Definition: tom.idl:171
@ tomTruncateExisting
Definition: tom.idl:177
@ tomShareDenyRead
Definition: tom.idl:170
@ tomOpenAlways
Definition: tom.idl:176
@ tomCreateNew
Definition: tom.idl:173
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define WM_GETTEXT
Definition: winuser.h:1621
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ test_ITextDocument_Range()

static void test_ITextDocument_Range ( void  )
static

Definition at line 695 of file richole.c.

696{
697 static const CHAR test_text1[] = "TestSomeText";
698 HWND w;
699 IRichEditOle *reOle = NULL;
700 ITextDocument *txtDoc = NULL;
701 ITextRange *txtRge, *range2;
703 LONG value;
704
705 create_interfaces(&w, &reOle, &txtDoc, NULL);
706 hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
707 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
708 EXPECT_REF(txtRge, 1);
709
710 hres = ITextDocument_Range(txtDoc, 0, 0, &range2);
711 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
712 ok(range2 != txtRge, "A new pointer should be returned\n");
713 ITextRange_Release(range2);
714
715 hres = ITextDocument_Range(txtDoc, 0, 0, NULL);
716 ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%x.\n", hres);
717
718 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
719
720 hres = ITextDocument_Range(txtDoc, 8, 30, &range2);
721 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
722 hres = ITextRange_GetStart(range2, &value);
723 ok(hres == S_OK, "got 0x%08x\n", hres);
724 ok(value == 8, "got %d\n", value);
725
726 hres = ITextRange_GetEnd(range2, &value);
727 ok(hres == S_OK, "got 0x%08x\n", hres);
728 ok(value == 13, "got %d\n", value);
729 ITextRange_Release(range2);
730
731 release_interfaces(&w, &reOle, &txtDoc, NULL);
732 hres = ITextRange_CanEdit(txtRge, NULL);
733 ok(hres == CO_E_RELEASED, "ITextRange after ITextDocument destroyed\n");
734 ITextRange_Release(txtRge);
735}

Referenced by START_TEST().

◆ test_ITextFont()

static void test_ITextFont ( void  )
static

Definition at line 2294 of file richole.c.

2295{
2296 static const WCHAR arialW[] = {'A','r','i','a','l',0};
2297 static const CHAR test_text1[] = "TestSomeText";
2298 ITextFont *font, *font2, *font3;
2299 FLOAT size, position, kerning;
2300 IRichEditOle *reOle = NULL;
2301 ITextDocument *doc = NULL;
2304 LONG value;
2305 HRESULT hr;
2306 HWND hwnd;
2307 BOOL ret;
2308 BSTR str;
2309
2310 create_interfaces(&hwnd, &reOle, &doc, NULL);
2311 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2312
2313 hr = ITextDocument_Range(doc, 0, 10, &range);
2314 ok(hr == S_OK, "got 0x%08x\n", hr);
2315
2316 hr = ITextRange_GetFont(range, &font);
2317 ok(hr == S_OK, "got 0x%08x\n", hr);
2318
2319 hr = ITextFont_Reset(font, tomUseTwips);
2320 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2321
2322 hr = ITextFont_Reset(font, tomUsePoints);
2323 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2324
2325 hr = ITextFont_GetName(font, NULL);
2326 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2327
2328 /* default font size unit is point */
2329 size = 0.0;
2330 hr = ITextFont_GetSize(font, &size);
2331 ok(hr == S_OK, "got 0x%08x\n", hr);
2332
2333 /* set to some non-zero values */
2334 hr = ITextFont_SetPosition(font, 20.0);
2335 ok(hr == S_OK, "got 0x%08x\n", hr);
2336
2337 hr = ITextFont_SetKerning(font, 10.0);
2338 ok(hr == S_OK, "got 0x%08x\n", hr);
2339
2340 position = 0.0;
2341 hr = ITextFont_GetPosition(font, &position);
2342 ok(hr == S_OK, "got 0x%08x\n", hr);
2343
2344 kerning = 0.0;
2345 hr = ITextFont_GetKerning(font, &kerning);
2346 ok(hr == S_OK, "got 0x%08x\n", hr);
2347
2348 memset(&cf, 0, sizeof(cf));
2349 cf.cbSize = sizeof(cf);
2351
2352 /* CHARFORMAT members are in twips */
2353 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2355 ok(ret, "got %d\n", ret);
2356 ok(size == twips_to_points(cf.yHeight), "got yHeight %d, size %.2f\n", cf.yHeight, size);
2357 ok(position == twips_to_points(cf.yOffset), "got yOffset %d, position %.2f\n", cf.yOffset, position);
2358 ok(kerning == twips_to_points(cf.wKerning), "got wKerning %d, kerning %.2f\n", cf.wKerning, kerning);
2359
2360 hr = ITextFont_Reset(font, tomUseTwips);
2361 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2362
2363 hr = ITextFont_Reset(font, tomUsePoints);
2364 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2365
2366 hr = ITextFont_GetDuplicate(font, &font2);
2367 ok(hr == S_OK, "got 0x%08x\n", hr);
2368
2369 hr = ITextFont_Reset(font2, tomUseTwips);
2370 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2371
2372 hr = ITextFont_Reset(font2, tomUsePoints);
2373 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2374
2375 ITextFont_Release(font2);
2376
2377 /* default font name */
2378 str = NULL;
2379 hr = ITextFont_GetName(font, &str);
2380 ok(hr == S_OK, "got 0x%08x\n", hr);
2381 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2383
2384 /* change font name for an inner subrange */
2385 memset(&cf, 0, sizeof(cf));
2386 cf.cbSize = sizeof(cf);
2387 cf.dwMask = CFM_FACE;
2388 strcpy(cf.szFaceName, "Arial");
2389
2390 SendMessageA(hwnd, EM_SETSEL, 3, 4);
2392 ok(ret, "got %d\n", ret);
2393
2394 /* still original name */
2395 str = NULL;
2396 hr = ITextFont_GetName(font, &str);
2397 ok(hr == S_OK, "got 0x%08x\n", hr);
2398 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2400
2401 SendMessageA(hwnd, EM_SETSEL, 1, 2);
2403 ok(ret, "got %d\n", ret);
2404
2405 str = NULL;
2406 hr = ITextFont_GetName(font, &str);
2407 ok(hr == S_OK, "got 0x%08x\n", hr);
2408 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2410
2411 /* name is returned for first position within a range */
2412 SendMessageA(hwnd, EM_SETSEL, 0, 1);
2414 ok(ret, "got %d\n", ret);
2415
2416 str = NULL;
2417 hr = ITextFont_GetName(font, &str);
2418 ok(hr == S_OK, "got 0x%08x\n", hr);
2419 ok(!lstrcmpW(str, arialW), "got %s\n", wine_dbgstr_w(str));
2421
2422 /* GetDuplicate() */
2423 hr = ITextFont_GetDuplicate(font, NULL);
2424 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2425
2426 EXPECT_REF(range, 2);
2427 font2 = NULL;
2428 hr = ITextFont_GetDuplicate(font, &font2);
2429 ok(hr == S_OK, "got 0x%08x\n", hr);
2430 EXPECT_REF(range, 2);
2431
2432 /* set whole range to italic */
2433 cf.cbSize = sizeof(CHARFORMAT2A);
2434 cf.dwMask = CFM_ITALIC;
2435 cf.dwEffects = CFE_ITALIC;
2436
2437 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2439 ok(ret, "got %d\n", ret);
2440
2441 value = tomFalse;
2442 hr = ITextFont_GetItalic(font, &value);
2443 ok(hr == S_OK, "got 0x%08x\n", hr);
2444 ok(value == tomTrue, "got %d\n", value);
2445
2446 /* duplicate retains original value */
2447 value = tomTrue;
2448 hr = ITextFont_GetItalic(font2, &value);
2449 ok(hr == S_OK, "got 0x%08x\n", hr);
2450 ok(value == tomFalse, "got %d\n", value);
2451
2452 /* get a duplicate from a cloned font */
2453 hr = ITextFont_GetDuplicate(font2, &font3);
2454 ok(hr == S_OK, "got 0x%08x\n", hr);
2455 ITextFont_Release(font3);
2456
2457 ITextRange_Release(range);
2458 release_interfaces(&hwnd, &reOle, &doc, NULL);
2459
2460 hr = ITextFont_GetDuplicate(font, NULL);
2461 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2462
2465
2466 /* get a duplicate of detached font */
2467 hr = ITextFont_GetDuplicate(font2, &font3);
2468 ok(hr == S_OK, "got 0x%08x\n", hr);
2469 ITextFont_Release(font3);
2470
2471 /* reset detached font to undefined */
2473 hr = ITextFont_GetBold(font2, &value);
2474 ok(hr == S_OK, "got 0x%08x\n", hr);
2475 ok(value != tomUndefined, "got %d\n", value);
2476
2477 /* reset to undefined for detached font */
2478 hr = ITextFont_Reset(font2, tomUndefined);
2479 ok(hr == S_OK, "got 0x%08x\n", hr);
2481
2482 /* font is detached, default means global TOM defaults */
2483 hr = ITextFont_Reset(font2, tomDefault);
2484 ok(hr == S_OK, "got 0x%08x\n", hr);
2486
2487 hr = ITextFont_GetDuplicate(font2, &font3);
2488 ok(hr == S_OK, "got 0x%08x\n", hr);
2490
2491 hr = ITextFont_Reset(font2, tomApplyNow);
2492 ok(hr == S_OK, "got 0x%08x\n", hr);
2494
2495 hr = ITextFont_Reset(font2, tomApplyLater);
2496 ok(hr == S_OK, "got 0x%08x\n", hr);
2498
2499 hr = ITextFont_Reset(font2, tomTrackParms);
2500 ok(hr == S_OK, "got 0x%08x\n", hr);
2502
2503 hr = ITextFont_SetItalic(font2, tomUndefined);
2504 ok(hr == S_OK, "got 0x%08x\n", hr);
2505
2506 hr = ITextFont_GetItalic(font2, &value);
2507 ok(hr == S_OK, "got 0x%08x\n", hr);
2508 ok(value == tomFalse, "got %d\n", value);
2509
2510 hr = ITextFont_Reset(font2, tomCacheParms);
2511 ok(hr == S_OK, "got 0x%08x\n", hr);
2513
2514 ITextFont_Release(font3);
2515 ITextFont_Release(font2);
2516
2517 font2 = (void*)0xdeadbeef;
2518 hr = ITextFont_GetDuplicate(font, &font2);
2519 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2520 ok(font2 == NULL, "got %p\n", font2);
2521
2522 hr = ITextFont_Reset(font, tomDefault);
2523 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2524
2525 ITextFont_Release(font);
2526
2527 /* Reset() */
2528 create_interfaces(&hwnd, &reOle, &doc, NULL);
2529 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2530
2531 hr = ITextDocument_Range(doc, 0, 10, &range);
2532 ok(hr == S_OK, "got 0x%08x\n", hr);
2533
2534 hr = ITextRange_GetFont(range, &font);
2535 ok(hr == S_OK, "got 0x%08x\n", hr);
2536
2538 hr = ITextFont_GetBold(font, &value);
2539 ok(hr == S_OK, "got 0x%08x\n", hr);
2540 ok(value != tomUndefined, "got %d\n", value);
2541
2542 /* reset to undefined for attached font */
2543 hr = ITextFont_Reset(font, tomUndefined);
2544 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2545
2547 hr = ITextFont_GetBold(font, &value);
2548 ok(hr == S_OK, "got 0x%08x\n", hr);
2549 ok(value != tomUndefined, "got %d\n", value);
2550
2551 /* tomCacheParms/tomTrackParms */
2552 hr = ITextFont_Reset(font, tomCacheParms);
2553 ok(hr == S_OK, "got 0x%08x\n", hr);
2554
2555 hr = ITextFont_GetItalic(font, &value);
2556 ok(hr == S_OK, "got 0x%08x\n", hr);
2557 ok(value == tomFalse, "got %d\n", value);
2558
2559 memset(&cf, 0, sizeof(cf));
2560 cf.cbSize = sizeof(CHARFORMAT2A);
2561 cf.dwMask = CFM_ITALIC;
2562
2563 cf.dwEffects = CFE_ITALIC;
2564 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2566 ok(ret, "got %d\n", ret);
2567
2568 /* still cached value */
2569 hr = ITextFont_GetItalic(font, &value);
2570 ok(hr == S_OK, "got 0x%08x\n", hr);
2571 ok(value == tomFalse, "got %d\n", value);
2572
2573 hr = ITextFont_Reset(font, tomTrackParms);
2574 ok(hr == S_OK, "got 0x%08x\n", hr);
2575
2576 hr = ITextFont_GetItalic(font, &value);
2577 ok(hr == S_OK, "got 0x%08x\n", hr);
2578 ok(value == tomTrue, "got %d\n", value);
2579
2580 /* switch back to cache - value retained */
2581 hr = ITextFont_Reset(font, tomCacheParms);
2582 ok(hr == S_OK, "got 0x%08x\n", hr);
2583
2584 hr = ITextFont_GetItalic(font, &value);
2585 ok(hr == S_OK, "got 0x%08x\n", hr);
2586 ok(value == tomTrue, "got %d\n", value);
2587
2588 /* tomApplyLater */
2589 hr = ITextFont_Reset(font, tomApplyLater);
2590 ok(hr == S_OK, "got 0x%08x\n", hr);
2591
2592 hr = ITextFont_SetItalic(font, tomFalse);
2593 ok(hr == S_OK, "got 0x%08x\n", hr);
2594
2595 hr = ITextFont_GetItalic(font, &value);
2596 ok(hr == S_OK, "got 0x%08x\n", hr);
2597 ok(value == tomFalse, "got %d\n", value);
2598
2599 cf.dwEffects = 0;
2600 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2602 ok(ret, "got %d\n", ret);
2603 ok((cf.dwEffects & CFE_ITALIC) == CFE_ITALIC, "got 0x%08x\n", cf.dwEffects);
2604
2605 hr = ITextFont_Reset(font, tomApplyNow);
2606 ok(hr == S_OK, "got 0x%08x\n", hr);
2607
2608 cf.dwEffects = 0;
2609 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2611 ok(ret, "got %d\n", ret);
2612 ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2613
2614 hr = ITextFont_SetItalic(font, tomUndefined);
2615 ok(hr == S_OK, "got 0x%08x\n", hr);
2616
2617 hr = ITextFont_GetItalic(font, &value);
2618 ok(hr == S_OK, "got 0x%08x\n", hr);
2619 ok(value == tomFalse, "got %d\n", value);
2620
2621 hr = ITextFont_SetItalic(font, tomAutoColor);
2622 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2623
2624 cf.dwEffects = 0;
2625 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2627 ok(ret, "got %d\n", ret);
2628 ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2629
2630 ITextRange_Release(range);
2631 ITextFont_Release(font);
2632 release_interfaces(&hwnd, &reOle, &doc, NULL);
2633}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static FLOAT twips_to_points(LONG value)
Definition: richole.c:427
static void test_detached_font_getters(ITextFont *font, BOOL duplicate)
Definition: richole.c:1970
static void test_textfont_undefined(ITextFont *font)
Definition: richole.c:2167
static void test_textfont_global_defaults(ITextFont *font)
Definition: richole.c:2038
static const WCHAR sysW[]
Definition: richole.c:40
#define CFM_OFFSET
Definition: richedit.h:359
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define CFM_KERNING
Definition: richedit.h:352
#define CFM_FACE
Definition: richedit.h:360
#define memset(x, y, z)
Definition: compat.h:39
@ tomUseTwips
Definition: tom.idl:46
@ tomAutoColor
Definition: tom.idl:32
@ tomApplyNow
Definition: tom.idl:38
@ tomUsePoints
Definition: tom.idl:45
@ tomDefault
Definition: tom.idl:33
@ tomApplyLater
Definition: tom.idl:39
@ tomCacheParms
Definition: tom.idl:41
@ tomTrackParms
Definition: tom.idl:40
FT_UInt FT_UInt FT_Vector * kerning
Definition: ttdriver.c:204
float FLOAT
Definition: typedefs.h:69

Referenced by START_TEST().

◆ test_ITextRange_Collapse()

static void test_ITextRange_Collapse ( void  )
static

Definition at line 1402 of file richole.c.

1403{
1404 HWND w;
1405 IRichEditOle *reOle = NULL;
1406 ITextDocument *txtDoc = NULL;
1407 ITextRange *txtRge = NULL;
1408 HRESULT hres;
1409 LONG first, lim, start, end;
1410 static const CHAR test_text1[] = "TestSomeText";
1411
1412 create_interfaces(&w, &reOle, &txtDoc, NULL);
1413 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1414
1415 first = 4; lim = 8;
1416 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1417 ok(hres == S_OK, "got 0x%08x\n", hres);
1418 hres = ITextRange_Collapse(txtRge, tomTrue);
1419 ok(hres == S_OK, "ITextRange_Collapse\n");
1420 hres = ITextRange_GetStart(txtRge, &start);
1421 ok(hres == S_OK, "got 0x%08x\n", hres);
1422 ok(start == 4, "got wrong start value: %d\n", start);
1423 hres = ITextRange_GetEnd(txtRge, &end);
1424 ok(hres == S_OK, "got 0x%08x\n", hres);
1425 ok(end == 4, "got wrong end value: %d\n", end);
1426 ITextRange_Release(txtRge);
1427
1428 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1429 ok(hres == S_OK, "got 0x%08x\n", hres);
1430 hres = ITextRange_Collapse(txtRge, tomStart);
1431 ok(hres == S_OK, "ITextRange_Collapse\n");
1432 hres = ITextRange_GetStart(txtRge, &start);
1433 ok(hres == S_OK, "got 0x%08x\n", hres);
1434 ok(start == 4, "got wrong start value: %d\n", start);
1435 hres = ITextRange_GetEnd(txtRge, &end);
1436 ok(hres == S_OK, "got 0x%08x\n", hres);
1437 ok(end == 4, "got wrong end value: %d\n", end);
1438 ITextRange_Release(txtRge);
1439
1440 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1441 ok(hres == S_OK, "got 0x%08x\n", hres);
1442 hres = ITextRange_Collapse(txtRge, tomFalse);
1443 ok(hres == S_OK, "ITextRange_Collapse\n");
1444 hres = ITextRange_GetStart(txtRge, &start);
1445 ok(hres == S_OK, "got 0x%08x\n", hres);
1446 ok(start == 8, "got wrong start value: %d\n", start);
1447 hres = ITextRange_GetEnd(txtRge, &end);
1448 ok(hres == S_OK, "got 0x%08x\n", hres);
1449 ok(end == 8, "got wrong end value: %d\n", end);
1450 ITextRange_Release(txtRge);
1451
1452 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1453 ok(hres == S_OK, "got 0x%08x\n", hres);
1454 hres = ITextRange_Collapse(txtRge, tomEnd);
1455 ok(hres == S_OK, "ITextRange_Collapse\n");
1456 hres = ITextRange_GetStart(txtRge, &start);
1457 ok(hres == S_OK, "got 0x%08x\n", hres);
1458 ok(start == 8, "got wrong start value: %d\n", start);
1459 hres = ITextRange_GetEnd(txtRge, &end);
1460 ok(hres == S_OK, "got 0x%08x\n", hres);
1461 ok(end == 8, "got wrong end value: %d\n", end);
1462 ITextRange_Release(txtRge);
1463
1464 /* tomStart is the default */
1465 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1466 ok(hres == S_OK, "got 0x%08x\n", hres);
1467 hres = ITextRange_Collapse(txtRge, 256);
1468 ok(hres == S_OK, "ITextRange_Collapse\n");
1469 hres = ITextRange_GetStart(txtRge, &start);
1470 ok(hres == S_OK, "got 0x%08x\n", hres);
1471 ok(start == 4, "got wrong start value: %d\n", start);
1472 hres = ITextRange_GetEnd(txtRge, &end);
1473 ok(hres == S_OK, "got 0x%08x\n", hres);
1474 ok(end == 4, "got wrong end value: %d\n", end);
1475 ITextRange_Release(txtRge);
1476
1477 first = 6; lim = 6;
1478 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1479 ok(hres == S_OK, "got 0x%08x\n", hres);
1480 hres = ITextRange_Collapse(txtRge, tomEnd);
1481 ok(hres == S_FALSE, "ITextRange_Collapse\n");
1482 hres = ITextRange_GetStart(txtRge, &start);
1483 ok(hres == S_OK, "got 0x%08x\n", hres);
1484 ok(start == 6, "got wrong start value: %d\n", start);
1485 hres = ITextRange_GetEnd(txtRge, &end);
1486 ok(hres == S_OK, "got 0x%08x\n", hres);
1487 ok(end == 6, "got wrong end value: %d\n", end);
1488 ITextRange_Release(txtRge);
1489
1490 first = 8; lim = 8;
1491 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1492 ok(hres == S_OK, "got 0x%08x\n", hres);
1493 hres = ITextRange_Collapse(txtRge, tomStart);
1494 ok(hres == S_FALSE, "ITextRange_Collapse\n");
1495 hres = ITextRange_GetStart(txtRge, &start);
1496 ok(hres == S_OK, "got 0x%08x\n", hres);
1497 ok(start == 8, "got wrong start value: %d\n", start);
1498 hres = ITextRange_GetEnd(txtRge, &end);
1499 ok(hres == S_OK, "got 0x%08x\n", hres);
1500 ok(end == 8, "got wrong end value: %d\n", end);
1501
1502 release_interfaces(&w, &reOle, &txtDoc, NULL);
1503
1504 hres = ITextRange_Collapse(txtRge, tomStart);
1505 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1506
1507 hres = ITextRange_Collapse(txtRge, tomUndefined);
1508 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1509
1510 ITextRange_Release(txtRge);
1511}
@ tomEnd
Definition: tom.idl:66
@ tomStart
Definition: tom.idl:67

Referenced by START_TEST().

◆ test_ITextRange_GetChar()

static void test_ITextRange_GetChar ( void  )
static

Definition at line 737 of file richole.c.

738{
739 HWND w;
740 IRichEditOle *reOle = NULL;
741 ITextDocument *txtDoc = NULL;
742 ITextRange *txtRge = NULL;
744 LONG pch;
745 int first, lim;
746 static const CHAR test_text1[] = "TestSomeText";
747
748 first = 0, lim = 4;
749 create_interfaces(&w, &reOle, &txtDoc, NULL);
750 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
751 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
752 ok(hres == S_OK, "got 0x%08x\n", hres);
753 pch = 0xdeadbeef;
754 hres = ITextRange_GetChar(txtRge, &pch);
755 ok(hres == S_OK, "ITextRange_GetChar\n");
756 ok(pch == 'T', "got wrong char: %c\n", pch);
757 ITextRange_Release(txtRge);
758 release_interfaces(&w, &reOle, &txtDoc, NULL);
759
760 first = 0; lim = 0;
761 create_interfaces(&w, &reOle, &txtDoc, NULL);
762 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
763 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
764 ok(hres == S_OK, "got 0x%08x\n", hres);
765 pch = 0xdeadbeef;
766 hres = ITextRange_GetChar(txtRge, &pch);
767 ok(hres == S_OK, "ITextRange_GetChar\n");
768 ok(pch == 'T', "got wrong char: %c\n", pch);
769 ITextRange_Release(txtRge);
770 release_interfaces(&w, &reOle, &txtDoc, NULL);
771
772 first = 12; lim = 12;
773 create_interfaces(&w, &reOle, &txtDoc, NULL);
774 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
775 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
776 ok(hres == S_OK, "got 0x%08x\n", hres);
777 pch = 0xdeadbeef;
778 hres = ITextRange_GetChar(txtRge, &pch);
779 ok(hres == S_OK, "ITextRange_GetChar\n");
780 ok(pch == '\r', "got wrong char: %c\n", pch);
781 ITextRange_Release(txtRge);
782 release_interfaces(&w, &reOle, &txtDoc, NULL);
783
784 first = 13; lim = 13;
785 create_interfaces(&w, &reOle, &txtDoc, NULL);
786 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
787 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
788 ok(hres == S_OK, "got 0x%08x\n", hres);
789 pch = 0xdeadbeef;
790 hres = ITextRange_GetChar(txtRge, &pch);
791 ok(hres == S_OK, "ITextRange_GetChar\n");
792 ok(pch == '\r', "got wrong char: %c\n", pch);
793 ITextRange_Release(txtRge);
794 release_interfaces(&w, &reOle, &txtDoc, NULL);
795
796 create_interfaces(&w, &reOle, &txtDoc, NULL);
797 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
798 first = 12; lim = 12;
799 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
800 ok(hres == S_OK, "got 0x%08x\n", hres);
801 hres = ITextRange_GetChar(txtRge, NULL);
802 ok(hres == E_INVALIDARG, "ITextRange_GetChar\n");
803
804 release_interfaces(&w, &reOle, &txtDoc, NULL);
805
806 hres = ITextRange_GetChar(txtRge, NULL);
807 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
808
809 hres = ITextRange_GetChar(txtRge, &pch);
810 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
811
812 ITextRange_Release(txtRge);
813}
#define pch(ap)
Definition: match.c:418

Referenced by START_TEST().

◆ test_ITextRange_GetDuplicate()

static void test_ITextRange_GetDuplicate ( void  )
static

Definition at line 1359 of file richole.c.

1360{
1361 HWND w;
1362 IRichEditOle *reOle = NULL;
1363 ITextDocument *txtDoc = NULL;
1364 ITextRange *txtRge = NULL;
1365 ITextRange *txtRgeDup = NULL;
1366 HRESULT hres;
1367 LONG first, lim, start, end;
1368 static const CHAR test_text1[] = "TestSomeText";
1369
1370 create_interfaces(&w, &reOle, &txtDoc, NULL);
1371 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1372 first = 0; lim = 4;
1373 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1374 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
1375
1376 hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
1377 ok(hres == S_OK, "ITextRange_GetDuplicate\n");
1378 ok(txtRgeDup != txtRge, "A new pointer should be returned\n");
1379 hres = ITextRange_GetStart(txtRgeDup, &start);
1380 ok(hres == S_OK, "got 0x%08x\n", hres);
1381 ok(start == first, "got wrong value: %d\n", start);
1382 hres = ITextRange_GetEnd(txtRgeDup, &end);
1383 ok(hres == S_OK, "got 0x%08x\n", hres);
1384 ok(end == lim, "got wrong value: %d\n", end);
1385
1386 ITextRange_Release(txtRgeDup);
1387
1388 hres = ITextRange_GetDuplicate(txtRge, NULL);
1389 ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n");
1390
1391 release_interfaces(&w, &reOle, &txtDoc, NULL);
1392
1393 hres = ITextRange_GetDuplicate(txtRge, NULL);
1394 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1395
1396 hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
1397 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1398
1399 ITextRange_Release(txtRge);
1400}

Referenced by START_TEST().

◆ test_ITextRange_GetFont()

static void test_ITextRange_GetFont ( void  )
static

Definition at line 3942 of file richole.c.

3943{
3944 HWND w;
3945 IRichEditOle *reOle = NULL;
3946 ITextDocument *txtDoc = NULL;
3947 ITextRange *txtRge = NULL;
3948 ITextFont *txtFont = NULL, *txtFont1 = NULL;
3949 HRESULT hres;
3950 int first, lim;
3951 int refcount;
3952 static const CHAR test_text1[] = "TestSomeText";
3953 LONG value;
3954
3955 create_interfaces(&w, &reOle, &txtDoc, NULL);
3956 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
3957
3958 first = 4, lim = 4;
3959 ITextDocument_Range(txtDoc, first, lim, &txtRge);
3960 refcount = get_refcount((IUnknown *)txtRge);
3961 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
3962
3963 hres = ITextRange_GetFont(txtRge, &txtFont);
3964 ok(hres == S_OK, "ITextRange_GetFont\n");
3965 refcount = get_refcount((IUnknown *)txtFont);
3966 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
3967 refcount = get_refcount((IUnknown *)txtRge);
3968 ok(refcount == 2, "got wrong ref count: %d\n", refcount);
3969
3970 hres = ITextRange_GetFont(txtRge, &txtFont1);
3971 ok(hres == S_OK, "ITextRange_GetFont\n");
3972 ok(txtFont1 != txtFont, "A new pointer should be return\n");
3973 refcount = get_refcount((IUnknown *)txtFont1);
3974 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
3975 ITextFont_Release(txtFont1);
3976 refcount = get_refcount((IUnknown *)txtRge);
3977 ok(refcount == 2, "got wrong ref count: %d\n", refcount);
3978
3979 ITextRange_Release(txtRge);
3980 release_interfaces(&w, &reOle, &txtDoc, NULL);
3981
3982 hres = ITextFont_GetOutline(txtFont, &value);
3983 ok(hres == CO_E_RELEASED, "ITextFont after ITextDocument destroyed\n");
3984
3985 ITextFont_Release(txtFont);
3986}

Referenced by START_TEST().

◆ test_ITextRange_GetPara()

static void test_ITextRange_GetPara ( void  )
static

Definition at line 4033 of file richole.c.

4034{
4035 HWND w;
4036 IRichEditOle *reOle = NULL;
4037 ITextDocument *txtDoc = NULL;
4038 ITextRange *txtRge = NULL;
4039 ITextPara *txtPara = NULL, *txtPara1 = NULL;
4040 HRESULT hres;
4041 int first, lim;
4042 int refcount;
4043 static const CHAR test_text1[] = "TestSomeText";
4044 LONG value;
4045
4046 create_interfaces(&w, &reOle, &txtDoc, NULL);
4047 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
4048
4049 first = 4, lim = 4;
4050 ITextDocument_Range(txtDoc, first, lim, &txtRge);
4051 refcount = get_refcount((IUnknown *)txtRge);
4052 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
4053
4054 hres = ITextRange_GetPara(txtRge, &txtPara);
4055 ok(hres == S_OK, "ITextRange_GetPara\n");
4056 refcount = get_refcount((IUnknown *)txtPara);
4057 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
4058 refcount = get_refcount((IUnknown *)txtRge);
4059 ok(refcount == 2, "got wrong ref count: %d\n", refcount);
4060
4061 hres = ITextRange_GetPara(txtRge, &txtPara1);
4062 ok(hres == S_OK, "ITextRange_GetPara\n");
4063 ok(txtPara1 != txtPara, "A new pointer should be return\n");
4064 refcount = get_refcount((IUnknown *)txtPara1);
4065 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
4066 ITextPara_Release(txtPara1);
4067 refcount = get_refcount((IUnknown *)txtRge);
4068 ok(refcount == 2, "got wrong ref count: %d\n", refcount);
4069
4070 ITextRange_Release(txtRge);
4071 release_interfaces(&w, &reOle, &txtDoc, NULL);
4072
4073 hres = ITextPara_GetStyle(txtPara, &value);
4074 ok(hres == CO_E_RELEASED, "ITextPara after ITextDocument destroyed\n");
4075
4076 ITextPara_Release(txtPara);
4077}

Referenced by START_TEST().

◆ test_ITextRange_GetStart_GetEnd()

static void test_ITextRange_GetStart_GetEnd ( void  )
static

Definition at line 934 of file richole.c.

935{
936 HWND w;
937 IRichEditOle *reOle = NULL;
938 ITextDocument *txtDoc = NULL;
939 ITextRange *txtRge = NULL;
941 int first, lim, start, end;
942 static const CHAR test_text1[] = "TestSomeText";
943
944 create_interfaces(&w, &reOle, &txtDoc, NULL);
945 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
946
947 first = 1; lim = 6;
948 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
949 ok(hres == S_OK, "got 0x%08x\n", hres);
950 start = 0xdeadbeef;
951 hres = ITextRange_GetStart(txtRge, &start);
952 ok(hres == S_OK, "ITextRange_GetStart\n");
953 ok(start == 1, "got wrong start value: %d\n", start);
954 end = 0xdeadbeef;
955 hres = ITextRange_GetEnd(txtRge, &end);
956 ok(hres == S_OK, "ITextRange_GetEnd\n");
957 ok(end == 6, "got wrong end value: %d\n", end);
958 ITextRange_Release(txtRge);
959
960 first = 6; lim = 1;
961 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
962 ok(hres == S_OK, "got 0x%08x\n", hres);
963 start = 0xdeadbeef;
964 hres = ITextRange_GetStart(txtRge, &start);
965 ok(hres == S_OK, "ITextRange_GetStart\n");
966 ok(start == 1, "got wrong start value: %d\n", start);
967 end = 0xdeadbeef;
968 hres = ITextRange_GetEnd(txtRge, &end);
969 ok(hres == S_OK, "ITextRange_GetEnd\n");
970 ok(end == 6, "got wrong end value: %d\n", end);
971 ITextRange_Release(txtRge);
972
973 first = -1; lim = 13;
974 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
975 ok(hres == S_OK, "got 0x%08x\n", hres);
976 start = 0xdeadbeef;
977 hres = ITextRange_GetStart(txtRge, &start);
978 ok(hres == S_OK, "ITextRange_GetStart\n");
979 ok(start == 0, "got wrong start value: %d\n", start);
980 end = 0xdeadbeef;
981 hres = ITextRange_GetEnd(txtRge, &end);
982 ok(hres == S_OK, "ITextRange_GetEnd\n");
983 ok(end == 13, "got wrong end value: %d\n", end);
984 ITextRange_Release(txtRge);
985
986 first = 13; lim = 13;
987 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
988 ok(hres == S_OK, "got 0x%08x\n", hres);
989 start = 0xdeadbeef;
990 hres = ITextRange_GetStart(txtRge, &start);
991 ok(hres == S_OK, "ITextRange_GetStart\n");
992 ok(start == 12, "got wrong start value: %d\n", start);
993 end = 0xdeadbeef;
994 hres = ITextRange_GetEnd(txtRge, &end);
995 ok(hres == S_OK, "ITextRange_GetEnd\n");
996 ok(end == 12, "got wrong end value: %d\n", end);
997
998 /* SetStart */
999 hres = ITextRange_SetStart(txtRge, 0);
1000 ok(hres == S_OK, "got 0x%08x\n", hres);
1001
1002 /* same value */
1003 hres = ITextRange_SetStart(txtRge, 0);
1004 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1005
1006 hres = ITextRange_SetStart(txtRge, 1);
1007 ok(hres == S_OK, "got 0x%08x\n", hres);
1008
1009 /* negative resets to 0, return value is S_FALSE when
1010 position wasn't changed */
1011 hres = ITextRange_SetStart(txtRge, -1);
1012 ok(hres == S_OK, "got 0x%08x\n", hres);
1013
1014 hres = ITextRange_SetStart(txtRge, -1);
1015 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1016
1017 hres = ITextRange_SetStart(txtRge, 0);
1018 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1019
1020 start = -1;
1021 hres = ITextRange_GetStart(txtRge, &start);
1022 ok(hres == S_OK, "got 0x%08x\n", hres);
1023 ok(start == 0, "got %d\n", start);
1024
1025 /* greater than initial end, but less than total char count */
1026 hres = ITextRange_SetStart(txtRge, 1);
1027 ok(hres == S_OK, "got 0x%08x\n", hres);
1028
1029 hres = ITextRange_SetEnd(txtRge, 3);
1030 ok(hres == S_OK, "got 0x%08x\n", hres);
1031
1032 hres = ITextRange_SetStart(txtRge, 10);
1033 ok(hres == S_OK, "got 0x%08x\n", hres);
1034
1035 start = 0;
1036 hres = ITextRange_GetStart(txtRge, &start);
1037 ok(hres == S_OK, "got 0x%08x\n", hres);
1038 ok(start == 10, "got %d\n", start);
1039
1040 end = 0;
1041 hres = ITextRange_GetEnd(txtRge, &end);
1042 ok(hres == S_OK, "got 0x%08x\n", hres);
1043 ok(end == 10, "got %d\n", end);
1044
1045 /* more that total text length */
1046 hres = ITextRange_SetStart(txtRge, 50);
1047 ok(hres == S_OK, "got 0x%08x\n", hres);
1048
1049 start = 0;
1050 hres = ITextRange_GetStart(txtRge, &start);
1051 ok(hres == S_OK, "got 0x%08x\n", hres);
1052 ok(start == 12, "got %d\n", start);
1053
1054 end = 0;
1055 hres = ITextRange_GetEnd(txtRge, &end);
1056 ok(