riched20: Use cell ptrs in the paragraph splitting and joining functions.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b692fb5e08
commit
b7084cd7e3
|
@ -289,6 +289,7 @@ ME_Paragraph *editor_end_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
||||||
ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* table.c */
|
/* table.c */
|
||||||
|
ME_Cell *cell_create( void ) DECLSPEC_HIDDEN;
|
||||||
ME_Paragraph *cell_end_para( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
ME_Paragraph *cell_end_para( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
||||||
ME_Paragraph *cell_first_para( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
ME_Paragraph *cell_first_para( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
||||||
ME_Cell *cell_next( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
ME_Cell *cell_next( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -243,7 +243,7 @@ static void table_update_flags( ME_Paragraph *para )
|
||||||
{
|
{
|
||||||
para->fmt.dwMask |= PFM_TABLE | PFM_TABLEROWDELIMITER;
|
para->fmt.dwMask |= PFM_TABLE | PFM_TABLEROWDELIMITER;
|
||||||
|
|
||||||
if (para->pCell) para->nFlags |= MEPF_CELL;
|
if (para_cell( para )) para->nFlags |= MEPF_CELL;
|
||||||
else para->nFlags &= ~MEPF_CELL;
|
else para->nFlags &= ~MEPF_CELL;
|
||||||
|
|
||||||
if (para->nFlags & MEPF_ROWEND) para->fmt.wEffects |= PFE_TABLEROWDELIMITER;
|
if (para->nFlags & MEPF_ROWEND) para->fmt.wEffects |= PFE_TABLEROWDELIMITER;
|
||||||
|
@ -623,29 +623,28 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
|
||||||
{
|
{
|
||||||
if (paraFlags & (MEPF_ROWSTART | MEPF_CELL))
|
if (paraFlags & (MEPF_ROWSTART | MEPF_CELL))
|
||||||
{
|
{
|
||||||
ME_DisplayItem *cell = ME_MakeDI(diCell);
|
ME_Cell *cell = cell_create();
|
||||||
ME_InsertBefore( para_get_di( new_para ), cell );
|
ME_InsertBefore( para_get_di( new_para ), cell_get_di( cell ) );
|
||||||
new_para->pCell = cell;
|
new_para->pCell = cell_get_di( cell );
|
||||||
cell->member.cell.next_cell = NULL;
|
cell->next_cell = NULL;
|
||||||
if (paraFlags & MEPF_ROWSTART)
|
if (paraFlags & MEPF_ROWSTART)
|
||||||
{
|
{
|
||||||
old_para->nFlags |= MEPF_ROWSTART;
|
old_para->nFlags |= MEPF_ROWSTART;
|
||||||
cell->member.cell.prev_cell = NULL;
|
cell->prev_cell = NULL;
|
||||||
cell->member.cell.parent_cell = old_para->pCell;
|
cell->parent_cell = old_para->pCell;
|
||||||
if (old_para->pCell)
|
if (para_cell( old_para ))
|
||||||
cell->member.cell.nNestingLevel = old_para->pCell->member.cell.nNestingLevel + 1;
|
cell->nNestingLevel = para_cell( old_para )->nNestingLevel + 1;
|
||||||
else
|
else
|
||||||
cell->member.cell.nNestingLevel = 1;
|
cell->nNestingLevel = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cell->member.cell.prev_cell = old_para->pCell;
|
cell->prev_cell = old_para->pCell;
|
||||||
assert(cell->member.cell.prev_cell);
|
cell_prev( cell )->next_cell = cell_get_di( cell );
|
||||||
cell->member.cell.prev_cell->member.cell.next_cell = cell;
|
|
||||||
assert( old_para->nFlags & MEPF_CELL );
|
assert( old_para->nFlags & MEPF_CELL );
|
||||||
assert( !(old_para->nFlags & MEPF_ROWSTART) );
|
assert( !(old_para->nFlags & MEPF_ROWSTART) );
|
||||||
cell->member.cell.nNestingLevel = cell->member.cell.prev_cell->member.cell.nNestingLevel;
|
cell->nNestingLevel = cell_prev( cell )->nNestingLevel;
|
||||||
cell->member.cell.parent_cell = cell->member.cell.prev_cell->member.cell.parent_cell;
|
cell->parent_cell = cell_prev( cell )->parent_cell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (paraFlags & MEPF_ROWEND)
|
else if (paraFlags & MEPF_ROWEND)
|
||||||
|
@ -653,11 +652,11 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
|
||||||
old_para->nFlags |= MEPF_ROWEND;
|
old_para->nFlags |= MEPF_ROWEND;
|
||||||
old_para->pCell = old_para->pCell->member.cell.parent_cell;
|
old_para->pCell = old_para->pCell->member.cell.parent_cell;
|
||||||
new_para->pCell = old_para->pCell;
|
new_para->pCell = old_para->pCell;
|
||||||
assert( old_para->prev_para->member.para.nFlags & MEPF_CELL );
|
assert( para_prev( old_para )->nFlags & MEPF_CELL );
|
||||||
assert( !(old_para->prev_para->member.para.nFlags & MEPF_ROWSTART) );
|
assert( !(para_prev( old_para )->nFlags & MEPF_ROWSTART) );
|
||||||
if (new_para->pCell != new_para->next_para->member.para.pCell
|
if (new_para->pCell != para_next( new_para )->pCell
|
||||||
&& new_para->next_para->member.para.pCell
|
&& para_next( new_para )->pCell
|
||||||
&& !new_para->next_para->member.para.pCell->member.cell.prev_cell)
|
&& !para_next( new_para )->pCell->member.cell.prev_cell)
|
||||||
{
|
{
|
||||||
/* Row starts just after the row that was ended. */
|
/* Row starts just after the row that was ended. */
|
||||||
new_para->nFlags |= MEPF_ROWSTART;
|
new_para->nFlags |= MEPF_ROWSTART;
|
||||||
|
@ -686,9 +685,10 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
|
||||||
specified in use_first_fmt */
|
specified in use_first_fmt */
|
||||||
ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt )
|
ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt )
|
||||||
{
|
{
|
||||||
ME_DisplayItem *tmp, *pCell = NULL;
|
ME_DisplayItem *tmp;
|
||||||
ME_Paragraph *next = para_next( para );
|
ME_Paragraph *next = para_next( para );
|
||||||
ME_Run *end_run, *next_first_run, *tmp_run;
|
ME_Run *end_run, *next_first_run, *tmp_run;
|
||||||
|
ME_Cell *cell = NULL;
|
||||||
int i, shift;
|
int i, shift;
|
||||||
int end_len;
|
int end_len;
|
||||||
CHARFORMAT2W fmt;
|
CHARFORMAT2W fmt;
|
||||||
|
@ -729,22 +729,22 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
||||||
{
|
{
|
||||||
if (tmp->type == diCell)
|
if (tmp->type == diCell)
|
||||||
{
|
{
|
||||||
pCell = tmp;
|
cell = &tmp->member.cell;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_undo_split_para( editor, next, eol_str, pCell ? &pCell->member.cell : NULL );
|
add_undo_split_para( editor, next, eol_str, cell );
|
||||||
|
|
||||||
if (pCell)
|
if (cell)
|
||||||
{
|
{
|
||||||
ME_Remove( pCell );
|
ME_Remove( cell_get_di( cell ) );
|
||||||
if (pCell->member.cell.prev_cell)
|
if (cell_prev( cell ))
|
||||||
pCell->member.cell.prev_cell->member.cell.next_cell = pCell->member.cell.next_cell;
|
cell_prev( cell )->next_cell = cell_next( cell ) ? cell_get_di( cell_next( cell ) ) : NULL;
|
||||||
if (pCell->member.cell.next_cell)
|
if (cell_next( cell ))
|
||||||
pCell->member.cell.next_cell->member.cell.prev_cell = pCell->member.cell.prev_cell;
|
cell_next( cell )->prev_cell = cell_prev( cell ) ? cell_get_di( cell_prev( cell ) ) : NULL;
|
||||||
ME_DestroyDisplayItem( pCell );
|
ME_DestroyDisplayItem( cell_get_di( cell ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_first_fmt)
|
if (!use_first_fmt)
|
||||||
|
|
|
@ -185,6 +185,12 @@ ME_Cell *table_row_end_cell( ME_Paragraph *para )
|
||||||
return cell_next( para_cell( para ) );
|
return cell_next( para_cell( para ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ME_Cell *cell_create( void )
|
||||||
|
{
|
||||||
|
ME_DisplayItem *item = ME_MakeDI( diCell );
|
||||||
|
return &item->member.cell;
|
||||||
|
}
|
||||||
|
|
||||||
ME_Cell *cell_next( ME_Cell *cell )
|
ME_Cell *cell_next( ME_Cell *cell )
|
||||||
{
|
{
|
||||||
if (!cell->next_cell) return NULL;
|
if (!cell->next_cell) return NULL;
|
||||||
|
|
Loading…
Reference in New Issue