[PATCH 3/4] riched20: Implement IRichEditOle::GetObject.
Huw Davies
huw at codeweavers.com
Thu Apr 12 03:52:18 CDT 2018
On Thu, Apr 12, 2018 at 11:31:46AM +0800, Jactry Zeng wrote:
> Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
> ---
> dlls/riched20/caret.c | 2 +-
> dlls/riched20/editor.h | 2 +-
> dlls/riched20/richole.c | 57
> +++++++++++++++++++++++++++++++++++++++++++------
> 3 files changed, 53 insertions(+), 8 deletions(-)
>
>
> diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
> index 1e654a0a80..aec6859fb0 100644
> --- a/dlls/riched20/caret.c
> +++ b/dlls/riched20/caret.c
> @@ -476,7 +476,7 @@ static ME_ReObjItem* create_reobj_item(const REOBJECT* reo)
> ME_ReObjItem *reo_item = heap_alloc(sizeof(ME_ReObjItem));
>
> reo_item->reobj = heap_alloc(sizeof(*reo));
> - ME_CopyReObject(reo_item->reobj, reo);
> + ME_CopyReObject(reo_item->reobj, reo, REO_IOB_USE_CP);
This doesn't make sense. You probably want REO_GETOBJ_ALL_INTERFACES.
> return reo_item;
> }
>
> diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
> index 0db532640b..d05aa87f29 100644
> --- a/dlls/riched20/editor.h
> +++ b/dlls/riched20/editor.h
> @@ -231,7 +231,7 @@ int ME_GetParaBorderWidth(const ME_Context *c, int flags) DECLSPEC_HIDDEN;
> LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj) DECLSPEC_HIDDEN;
> void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPEC_HIDDEN;
> void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN;
> -void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src) DECLSPEC_HIDDEN;
> +void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src, DWORD flags) DECLSPEC_HIDDEN;
> void ME_DeleteReObject(REOBJECT* reo) DECLSPEC_HIDDEN;
> void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
>
> diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
> index 8f00962ce2..a28d475c8e 100644
> --- a/dlls/riched20/richole.c
> +++ b/dlls/riched20/richole.c
> @@ -1371,8 +1371,38 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
> REOBJECT *lpreobject, DWORD dwFlags)
> {
> IRichEditOleImpl *This = impl_from_IRichEditOle(me);
> - FIXME("stub %p\n",This);
> - return E_NOTIMPL;
> + ME_ReObjItem *reo_item = NULL;
> + LONG count = 0;
> +
> + TRACE("(%p)->(%x, %p, %x)\n", This, iob, lpreobject, dwFlags);
> +
> + if (!lpreobject || !lpreobject->cbStruct)
> + return E_INVALIDARG;
> +
> + if (iob == REO_IOB_USE_CP)
> + {
> + ME_Cursor cursor;
> +
> + TRACE("character offset: %d\n", lpreobject->cp);
> + ME_CursorFromCharOfs(This->editor, lpreobject->cp, &cursor);
> + if(!cursor.pRun->member.run.reo_item)
> + return E_INVALIDARG;
> + else
> + reo_item = cursor.pRun->member.run.reo_item;
> + }
> + else
> + {
> + if (iob > IRichEditOle_GetObjectCount(me))
> + return E_INVALIDARG;
> + LIST_FOR_EACH_ENTRY(reo_item, &This->editor->reobj_list, ME_ReObjItem, entry)
> + {
> + if (count == iob)
> + break;
> + count++;
> + }
> + }
> + ME_CopyReObject(lpreobject, reo_item->reobj, dwFlags);
> + return S_OK;
> }
>
> static LONG WINAPI
> @@ -5455,13 +5485,28 @@ void ME_DeleteReObject(REOBJECT* reo)
> heap_free(reo);
> }
>
> -void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
> +void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src, DWORD flags)
> {
> *dst = *src;
> + dst->poleobj = NULL;
> + dst->pstg = NULL;
> + dst->polesite = NULL;
>
> - if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
> - if (dst->pstg) IStorage_AddRef(dst->pstg);
> - if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
> + if ((flags & REO_GETOBJ_POLEOBJ) && src->poleobj)
> + {
> + dst->poleobj = src->poleobj;
> + IOleObject_AddRef(dst->poleobj);
> + }
> + if ((flags & REO_GETOBJ_PSTG) && src->pstg)
> + {
> + dst->pstg = src->pstg;
> + IStorage_AddRef(dst->pstg);
> + }
> + if ((flags & REO_GETOBJ_POLESITE) && src->polesite)
> + {
> + dst->polesite = src->polesite;
> + IOleClientSite_AddRef(dst->polesite);
> + }
> }
>
> void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
>
>
More information about the wine-devel
mailing list