Module: wine Branch: master Commit: 872a2ad0312c14fd5b1d40609f36f374204b6158 URL: http://source.winehq.org/git/wine.git/?a=commit;h=872a2ad0312c14fd5b1d40609f...
Author: Huw Davies huw@codeweavers.com Date: Tue Feb 5 13:19:39 2013 +0000
riched20: Pass a character ptr and length to SplitParagraph.
---
dlls/riched20/caret.c | 13 ++++++------- dlls/riched20/editor.h | 2 +- dlls/riched20/para.c | 10 ++++++---- dlls/riched20/table.c | 13 +++++-------- dlls/riched20/undo.c | 4 +--- 5 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 4c7ee8a..1457778 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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); diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index de1a7bc..2dbd7e0 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -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; diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 7960972..ccb025a 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -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; diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c index 06287fb..d5fbfcb 100644 --- a/dlls/riched20/table.c +++ b/dlls/riched20/table.c @@ -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; }
diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c index bfac1ed..07926ed 100644 --- a/dlls/riched20/undo.c +++ b/dlls/riched20/undo.c @@ -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;