riched20: Pass a run ptr to, and return a para ptr from, the para splitting function.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2020-10-16 12:08:09 +01:00 committed by Alexandre Julliard
parent d3fb8b29c1
commit f758d1effd
5 changed files with 43 additions and 41 deletions

View file

@ -619,7 +619,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
run = &cursor->pRun->member.run;
}
new_para = &ME_SplitParagraph( editor, run_get_di( run ), style, eol_str, eol_len, 0 )->member.para;
new_para = para_split( editor, run, style, eol_str, eol_len, 0 );
end_run = para_end_run( para_prev( new_para ) );
/* Move any cursors that were at the end of the previous run to the beginning of the new para */

View file

@ -198,7 +198,6 @@ 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, 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;
@ -207,16 +206,19 @@ BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) D
void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
void para_num_init( ME_Context *c, ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_num_clear( struct para_num *pn ) DECLSPEC_HIDDEN;
int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void para_mark_rewrap( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_mark_add( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_mark_remove( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_mark_rewrap( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Paragraph *para_next( ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_num_clear( struct para_num *pn ) DECLSPEC_HIDDEN;
void para_num_init( ME_Context *c, ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Paragraph *para_prev( ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
const WCHAR *eol_str, int eol_len, int paraFlags ) DECLSPEC_HIDDEN;
static inline ME_DisplayItem *para_get_di(ME_Paragraph *para)
{
return (ME_DisplayItem *)((ptrdiff_t)para - offsetof(ME_DisplayItem, member));

View file

@ -512,40 +512,40 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_Paragraph *para, const PA
}
/* split paragraph at the beginning of the run */
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
ME_Style *style, const WCHAR *eol_str, int eol_len,
int paraFlags)
ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
const WCHAR *eol_str, int eol_len, int paraFlags )
{
ME_Paragraph *new_para = para_create( editor ), *old_para, *next_para;
ME_Run *end_run, *next_run;
int ofs, i;
int run_flags = MERF_ENDPARA;
if (!editor->bEmulateVersion10) { /* v4.1 */
if (!editor->bEmulateVersion10) /* v4.1 */
{
/* At most 1 of MEPF_CELL, MEPF_ROWSTART, or MEPF_ROWEND should be set. */
assert(!(paraFlags & ~(MEPF_CELL|MEPF_ROWSTART|MEPF_ROWEND)));
assert(!(paraFlags & (paraFlags-1)));
assert( !(paraFlags & ~(MEPF_CELL | MEPF_ROWSTART | MEPF_ROWEND)) );
assert( !(paraFlags & (paraFlags-1)) );
if (paraFlags == MEPF_CELL)
run_flags |= MERF_ENDCELL;
run_flags |= MERF_ENDCELL;
else if (paraFlags == MEPF_ROWSTART)
run_flags |= MERF_TABLESTART|MERF_HIDDEN;
} else { /* v1.0 - v3.0 */
assert(!(paraFlags & (MEPF_CELL|MEPF_ROWSTART|MEPF_ROWEND)));
run_flags |= MERF_TABLESTART | MERF_HIDDEN;
}
assert(run->type == diRun);
old_para = &ME_GetParagraph( run )->member.para;
else /* v1.0 - v3.0 */
assert( !(paraFlags & (MEPF_CELL |MEPF_ROWSTART | MEPF_ROWEND)) );
old_para = run->para;
assert( old_para->fmt.cbSize == sizeof(PARAFORMAT2) );
/* Clear any cached para numbering following this paragraph */
if (old_para->fmt.wNumbering)
para_num_clear_list( editor, old_para, &old_para->fmt );
new_para->text = ME_VSplitString( old_para->text, run->member.run.nCharOfs );
new_para->text = ME_VSplitString( old_para->text, run->nCharOfs );
end_run = run_create( style, run_flags );
ofs = end_run->nCharOfs = run->member.run.nCharOfs;
ofs = end_run->nCharOfs = run->nCharOfs;
end_run->len = eol_len;
end_run->para = run->member.run.para;
end_run->para = run->para;
ME_AppendString( old_para->text, eol_str, eol_len );
next_para = &old_para->next_para->member.para;
@ -555,14 +555,14 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pPara == para_get_di( old_para ) &&
run->member.run.nCharOfs <= editor->pCursors[i].pRun->member.run.nCharOfs)
run->nCharOfs <= editor->pCursors[i].pRun->member.run.nCharOfs)
{
editor->pCursors[i].pPara = para_get_di( new_para );
}
}
/* the new paragraph will have a different starting offset, so update its runs */
for (next_run = &run->member.run; next_run; next_run = run_next( next_run ))
for (next_run = run; next_run; next_run = run_next( next_run ))
{
next_run->nCharOfs -= ofs;
next_run->para = new_para;
@ -584,7 +584,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
next_para->prev_para = para_get_di( new_para );
/* insert end run of the old paragraph, and new paragraph, into DI double linked list */
ME_InsertBefore( run, para_get_di( new_para ) );
ME_InsertBefore( run_get_di( run ), para_get_di( new_para ) );
ME_InsertBefore( para_get_di( new_para ), run_get_di( end_run ) );
/* Fix up the paras' eop_run ptrs */
@ -651,7 +651,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
ME_PropagateCharOffset( para_get_di( next_para ), eol_len );
editor->nParagraphs++;
return para_get_di( new_para );
return new_para;
}
/* join tp with tp->member.para.next_para, keeping tp's style; this

View file

@ -64,16 +64,16 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
int paraFlags)
{
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
ME_DisplayItem *tp;
ME_Paragraph *para;
ME_Cursor* cursor = &editor->pCursors[nCursor];
if (cursor->nOffset) run_split( editor, cursor );
tp = ME_SplitParagraph(editor, cursor->pRun, pStyle, eol_str, eol_len, paraFlags);
para = para_split( editor, &cursor->pRun->member.run, pStyle, eol_str, eol_len, paraFlags );
ME_ReleaseStyle(pStyle);
cursor->pPara = tp;
cursor->pRun = ME_FindItemFwd(tp, diRun);
return tp;
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( para_first_run( para ) );
return para_get_di( para );
}
ME_DisplayItem* ME_InsertTableRowStartFromCursor(ME_TextEditor *editor)

View file

@ -379,29 +379,29 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
case undo_split_para:
{
ME_Cursor tmp;
ME_DisplayItem *this_para, *new_para;
ME_Paragraph *this_para, *new_para;
BOOL bFixRowStart;
int paraFlags = undo->u.split_para.flags & (MEPF_ROWSTART|MEPF_CELL|MEPF_ROWEND);
cursor_from_char_ofs( editor, undo->u.split_para.pos, &tmp );
if (tmp.nOffset) run_split( editor, &tmp );
this_para = tmp.pPara;
bFixRowStart = this_para->member.para.nFlags & MEPF_ROWSTART;
this_para = &tmp.pPara->member.para;
bFixRowStart = this_para->nFlags & MEPF_ROWSTART;
if (bFixRowStart)
{
/* Re-insert the paragraph before the table, making sure the nFlag value
* is correct. */
this_para->member.para.nFlags &= ~MEPF_ROWSTART;
this_para->nFlags &= ~MEPF_ROWSTART;
}
new_para = ME_SplitParagraph(editor, tmp.pRun, tmp.pRun->member.run.style,
undo->u.split_para.eol_str->szData, undo->u.split_para.eol_str->nLen, paraFlags);
new_para = para_split( editor, &tmp.pRun->member.run, tmp.pRun->member.run.style,
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.fmt = undo->u.split_para.fmt;
new_para->member.para.border = undo->u.split_para.border;
new_para->nFlags |= MEPF_ROWSTART;
new_para->fmt = undo->u.split_para.fmt;
new_para->border = undo->u.split_para.border;
if (paraFlags)
{
ME_DisplayItem *pCell = new_para->member.para.pCell;
ME_DisplayItem *pCell = new_para->pCell;
pCell->member.cell.nRightBoundary = undo->u.split_para.cell_right_boundary;
pCell->member.cell.border = undo->u.split_para.cell_border;
}