riched20: Return 0x0 size for NULL objects.

This commit is contained in:
Nikolay Sivov 2015-06-02 17:26:15 +03:00 committed by Alexandre Julliard
parent 25d9fc3ecc
commit 2a2446abdb
2 changed files with 47 additions and 0 deletions

View File

@ -1420,8 +1420,12 @@ static HRESULT WINAPI
IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
{
IRichEditOleImpl *This = impl_from_IRichEditOle(me);
TRACE("(%p,%p)\n", This, reo);
if (!reo)
return E_INVALIDARG;
if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
ME_InsertOLEFromCursor(This->editor, reo, 0);
@ -5037,6 +5041,12 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
return;
}
if (!run->ole_obj->poleobj)
{
pSize->cx = pSize->cy = 0;
return;
}
if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
{
FIXME("Query Interface IID_IDataObject failed!\n");

View File

@ -3072,6 +3072,42 @@ static void test_SetFont(void)
ITextSelection_Release(selection);
}
static void test_InsertObject(void)
{
IRichEditOle *reole = NULL;
ITextDocument *doc = NULL;
IOleClientSite *clientsite;
REOBJECT reo;
HRESULT hr;
HWND hwnd;
create_interfaces(&hwnd, &reole, &doc, NULL);
hr = IRichEditOle_InsertObject(reole, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IRichEditOle_GetClientSite(reole, &clientsite);
ok(hr == S_OK, "got 0x%08x\n", hr);
reo.cbStruct = sizeof(reo);
reo.cp = 0;
memset(&reo.clsid, 0, sizeof(reo.clsid));
reo.poleobj = NULL;
reo.pstg = NULL;
reo.polesite = clientsite;
reo.sizel.cx = 10;
reo.sizel.cy = 10;
reo.dvaspect = DVASPECT_CONTENT;
reo.dwFlags = 0;
reo.dwUser = 0;
hr = IRichEditOle_InsertObject(reole, &reo);
ok(hr == S_OK, "got 0x%08x\n", hr);
IOleClientSite_Release(clientsite);
release_interfaces(&hwnd, &reole, &doc, NULL);
}
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@ -3104,4 +3140,5 @@ START_TEST(richole)
test_Select();
test_GetStoryType();
test_SetFont();
test_InsertObject();
}