DataObjectImpl_EnumDAdvise
};
-static HGLOBAL get_unicode_text(ME_TextEditor *editor, const CHARRANGE *lpchrg)
+static HGLOBAL get_unicode_text(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
{
- int pars, len;
+ int pars = 0;
WCHAR *data;
HANDLE ret;
+ ME_DisplayItem *para;
+ int nEnd = ME_GetCursorOfs(start) + nChars;
- pars = ME_CountParagraphsBetween(editor, lpchrg->cpMin, lpchrg->cpMax);
- len = lpchrg->cpMax-lpchrg->cpMin;
- ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR)*(len+pars+1));
+ /* count paragraphs in range */
+ para = start->pPara;
+ while((para = para->member.para.next_para) &&
+ para->member.para.nCharOfs <= nEnd)
+ pars++;
+
+ ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * (nChars + pars + 1));
data = GlobalLock(ret);
- len = ME_GetTextW(editor, data, lpchrg->cpMin, len, TRUE);
- data[len] = 0;
+ ME_GetTextW(editor, data, nChars + pars, start, nChars, TRUE);
GlobalUnlock(ret);
return ret;
}
return 0;
}
-static HGLOBAL get_rtf_text(ME_TextEditor *editor, const CHARRANGE *lpchrg)
+static HGLOBAL get_rtf_text(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
{
EDITSTREAM es;
ME_GlobalDestStruct gds;
gds.nLength = 0;
es.dwCookie = (DWORD_PTR)&gds;
es.pfnCallback = ME_AppendToHGLOBAL;
- ME_StreamOutRange(editor, SF_RTF, lpchrg->cpMin, lpchrg->cpMax, &es);
+ ME_StreamOutRange(editor, SF_RTF, start, nChars, &es);
GlobalReAlloc(gds.hData, gds.nLength+1, 0);
return gds.hData;
}
-HRESULT ME_GetDataObject(ME_TextEditor *editor, const CHARRANGE *lpchrg, LPDATAOBJECT *lplpdataobj)
+HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start,
+ int nChars, LPDATAOBJECT *lplpdataobj)
{
DataObjectImpl *obj;
- TRACE("(%p,%d,%d)\n", editor, lpchrg->cpMin, lpchrg->cpMax);
+ TRACE("(%p,%d,%d)\n", editor, ME_GetCursorOfs(start), nChars);
obj = heap_alloc(sizeof(DataObjectImpl));
if(cfRTF == 0)
obj->lpVtbl = &VT_DataObjectImpl;
obj->ref = 1;
- obj->unicode = get_unicode_text(editor, lpchrg);
+ obj->unicode = get_unicode_text(editor, start, nChars);
obj->rtf = NULL;
obj->fmtetc_cnt = 1;
obj->fmtetc = GlobalAlloc(GMEM_ZEROINIT, obj->fmtetc_cnt*sizeof(FORMATETC));
InitFormatEtc(obj->fmtetc[0], CF_UNICODETEXT, TYMED_HGLOBAL);
if(editor->mode & TM_RICHTEXT) {
- obj->rtf = get_rtf_text(editor, lpchrg);
+ obj->rtf = get_rtf_text(editor, start, nChars);
InitFormatEtc(obj->fmtetc[1], cfRTF, TYMED_HGLOBAL);
}