static HRESULT CreateITextRange(IRichEditOle *reOle, LONG start, LONG end,
ITextRangeImpl *txtRge, ITextRange** ppRange)
{
IRichEditOleImpl *reOleImpl = impl_from_IRichEditOle(reOle);
txtRge->ITextRange_iface.lpVtbl = &trvt;
txtRge->ref = 1;
IRichEditOle_AddRef(reOle);
txtRge->reOle = reOleImpl;
txtRge->start = start;
txtRge->end = end;
list_add_head(&reOleImpl->rangelist, &txtRge->entry);
*ppRange = &txtRge->ITextRange_iface;
return S_OK;
}
I will prefer passing ITextRangeImpl into CreateITextRange instead of ITextRange interface.
So we don't need to impl_from_ITextRange again. Is it also ok?
btw, I didn't alloc txtRge (txtRge = heap_alloc(sizeof(ITextRangeImpl));) in CreateITextRange(),
because CreateITextRange() was just created for sharing code with ITextRange::GetDuplicate and GetDuplicate
will return E_FAIL for all any other error[0] when ITextDocument::Range returning E_OUTOFMEMORY.[1]
Thanks.