Commit 872a2ad0 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Pass a character ptr and length to SplitParagraph.

parent 6af92365
......@@ -558,13 +558,12 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
WCHAR space = ' ';
ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, style, 0);
} else {
ME_String *eol_str;
const WCHAR cr = '\r', *eol_str = str;
if (!editor->bEmulateVersion10) {
WCHAR cr = '\r';
eol_str = ME_MakeStringN(&cr, 1);
} else {
eol_str = ME_MakeStringN(str, eol_len);
if (!editor->bEmulateVersion10)
{
eol_str = &cr;
eol_len = 1;
}
p = &editor->pCursors[nCursor];
......@@ -572,7 +571,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
ME_SplitRunSimple(editor, p);
tmp_style = ME_GetInsertStyle(editor, nCursor);
/* ME_SplitParagraph increases style refcount */
tp = ME_SplitParagraph(editor, p->pRun, p->pRun->member.run.style, eol_str, 0);
tp = ME_SplitParagraph(editor, p->pRun, p->pRun->member.run.style, eol_str, eol_len, 0);
p->pRun = ME_FindItemFwd(tp, diRun);
p->pPara = tp;
end_run = ME_FindItemBack(tp, diRun);
......
......@@ -202,7 +202,7 @@ void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run) DECLSPEC_HIDDEN;
void ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end) DECLSPEC_HIDDEN;
void ME_MakeFirstParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style, ME_String *eol_str, int paraFlags) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
BOOL keepFirstParaFormat) DECLSPEC_HIDDEN;
void ME_DumpParaStyle(ME_Paragraph *s) DECLSPEC_HIDDEN;
......
......@@ -192,7 +192,7 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const
/* split paragraph at the beginning of the run */
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
ME_Style *style, ME_String *eol_str,
ME_Style *style, const WCHAR *eol_str, int eol_len,
int paraFlags)
{
ME_DisplayItem *next_para = NULL;
......@@ -202,6 +202,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
int ofs, i;
ME_DisplayItem *pp;
int run_flags = MERF_ENDPARA;
ME_String *str;
if (!editor->bEmulateVersion10) { /* v4.1 */
/* At most 1 of MEPF_CELL, MEPF_ROWSTART, or MEPF_ROWEND should be set. */
......@@ -218,7 +219,8 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
run_para = ME_GetParagraph(run);
assert(run_para->member.para.pFmt->cbSize == sizeof(PARAFORMAT2));
end_run = ME_MakeRun(style, eol_str, run_flags);
str = ME_MakeStringN( eol_str, eol_len );
end_run = ME_MakeRun(style, str, run_flags);
ofs = end_run->member.run.nCharOfs = run->member.run.nCharOfs;
end_run->member.run.para = run->member.run.para;
......@@ -244,7 +246,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
pp = ME_FindItemFwd(pp, diRunOrParagraphOrEnd);
}
new_para->member.para.nCharOfs = run_para->member.para.nCharOfs + ofs;
new_para->member.para.nCharOfs += eol_str->nLen;
new_para->member.para.nCharOfs += eol_len;
new_para->member.para.nFlags = MEPF_REWRAP;
/* FIXME initialize format style and call ME_SetParaFormat blah blah */
......@@ -311,7 +313,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
new_para->member.para.prev_para->member.para.nFlags |= MEPF_REWRAP;
/* we've added the end run, so we need to modify nCharOfs in the next paragraphs */
ME_PropagateCharOffset(next_para, eol_str->nLen);
ME_PropagateCharOffset(next_para, eol_len);
editor->nParagraphs++;
return new_para;
......
......@@ -58,7 +58,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit_lists);
static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
int nCursor,
ME_String *eol_str,
const WCHAR *eol_str, int eol_len,
int paraFlags)
{
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
......@@ -67,7 +67,7 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
if (cursor->nOffset)
ME_SplitRunSimple(editor, cursor);
tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, paraFlags);
tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, eol_len, paraFlags);
ME_ReleaseStyle(pStyle);
cursor->pPara = tp;
cursor->pRun = ME_FindItemFwd(tp, diRun);
......@@ -78,8 +78,7 @@ ME_DisplayItem* ME_InsertTableRowStartFromCursor(ME_TextEditor *editor)
{
ME_DisplayItem *para;
WCHAR cr_lf[] = {'\r', '\n', 0};
ME_String *eol_str = ME_MakeStringN(cr_lf, 2);
para = ME_InsertEndParaFromCursor(editor, 0, eol_str, MEPF_ROWSTART);
para = ME_InsertEndParaFromCursor(editor, 0, cr_lf, 2, MEPF_ROWSTART);
return para->member.para.prev_para;
}
......@@ -122,8 +121,7 @@ ME_DisplayItem* ME_InsertTableCellFromCursor(ME_TextEditor *editor)
{
ME_DisplayItem *para;
WCHAR tab = '\t';
ME_String *eol_str = ME_MakeStringN(&tab, 1);
para = ME_InsertEndParaFromCursor(editor, 0, eol_str, MEPF_CELL);
para = ME_InsertEndParaFromCursor(editor, 0, &tab, 1, MEPF_CELL);
return para;
}
......@@ -131,8 +129,7 @@ ME_DisplayItem* ME_InsertTableRowEndFromCursor(ME_TextEditor *editor)
{
ME_DisplayItem *para;
WCHAR cr_lf[] = {'\r', '\n', 0};
ME_String *eol_str = ME_MakeStringN(cr_lf, 2);
para = ME_InsertEndParaFromCursor(editor, 0, eol_str, MEPF_ROWEND);
para = ME_InsertEndParaFromCursor(editor, 0, cr_lf, 2, MEPF_ROWEND);
return para->member.para.prev_para;
}
......
......@@ -394,9 +394,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
this_para->member.para.nFlags &= ~MEPF_ROWSTART;
}
new_para = ME_SplitParagraph(editor, tmp.pRun, tmp.pRun->member.run.style,
undo->u.split_para.eol_str, paraFlags);
/* ME_SplitParagraph owns eol_str */
undo->u.split_para.eol_str = NULL;
undo->u.split_para.eol_str->szData, undo->u.split_para.eol_str->nLen, paraFlags);
if (bFixRowStart)
new_para->member.para.nFlags |= MEPF_ROWSTART;
*new_para->member.para.pFmt = undo->u.split_para.fmt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment