riched20: Use cell ptrs in the rtf parsing code.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
670dadf719
commit
431ee50875
|
@ -987,8 +987,9 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
|
|||
/* else fall through since v4.1 treats rtfNestRow and rtfRow the same */
|
||||
case rtfRow:
|
||||
{
|
||||
ME_DisplayItem *cell, *run;
|
||||
ME_DisplayItem *run;
|
||||
ME_Paragraph *para;
|
||||
ME_Cell *cell;
|
||||
int i;
|
||||
|
||||
if (!tableDef)
|
||||
|
@ -1004,44 +1005,44 @@ void ME_RTFSpecialCharHook(RTF_Info *info)
|
|||
info->nestingLevel++;
|
||||
}
|
||||
para = tableDef->row_start;
|
||||
cell = ME_FindItemFwd( para_get_di( para ), diCell );
|
||||
assert(cell && !cell->member.cell.prev_cell);
|
||||
cell = table_row_first_cell( para );
|
||||
assert( cell && !cell_prev( cell ) );
|
||||
if (tableDef->numCellsDefined < 1)
|
||||
{
|
||||
/* 2000 twips appears to be the cell size that native richedit uses
|
||||
* when no cell sizes are specified. */
|
||||
const int defaultCellSize = 2000;
|
||||
int nRightBoundary = defaultCellSize;
|
||||
cell->member.cell.nRightBoundary = nRightBoundary;
|
||||
while (cell->member.cell.next_cell) {
|
||||
cell = cell->member.cell.next_cell;
|
||||
nRightBoundary += defaultCellSize;
|
||||
cell->member.cell.nRightBoundary = nRightBoundary;
|
||||
const int default_size = 2000;
|
||||
int right_boundary = default_size;
|
||||
cell->nRightBoundary = right_boundary;
|
||||
while (cell_next( cell ))
|
||||
{
|
||||
cell = cell_next( cell );
|
||||
right_boundary += default_size;
|
||||
cell->nRightBoundary = right_boundary;
|
||||
}
|
||||
para = table_insert_cell( info->editor, info->editor->pCursors );
|
||||
cell = para->pCell;
|
||||
cell->member.cell.nRightBoundary = nRightBoundary;
|
||||
cell = para_cell( para );
|
||||
cell->nRightBoundary = right_boundary;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < tableDef->numCellsDefined; i++)
|
||||
{
|
||||
RTFCell *cellDef = &tableDef->cells[i];
|
||||
cell->member.cell.nRightBoundary = cellDef->rightBoundary;
|
||||
ME_ApplyBorderProperties(info, &cell->member.cell.border,
|
||||
cellDef->border);
|
||||
cell = cell->member.cell.next_cell;
|
||||
cell->nRightBoundary = cellDef->rightBoundary;
|
||||
ME_ApplyBorderProperties( info, &cell->border, cellDef->border );
|
||||
cell = cell_next( cell );
|
||||
if (!cell)
|
||||
{
|
||||
para = table_insert_cell( info->editor, info->editor->pCursors );
|
||||
cell = para->pCell;
|
||||
cell = para_cell( para );
|
||||
}
|
||||
}
|
||||
/* Cell for table row delimiter is empty */
|
||||
cell->member.cell.nRightBoundary = tableDef->cells[i-1].rightBoundary;
|
||||
cell->nRightBoundary = tableDef->cells[i - 1].rightBoundary;
|
||||
}
|
||||
|
||||
run = ME_FindItemFwd(cell, diRun);
|
||||
run = ME_FindItemFwd( cell_get_di( cell) , diRun );
|
||||
if (info->editor->pCursors[0].pRun != run ||
|
||||
info->editor->pCursors[0].nOffset)
|
||||
{
|
||||
|
|
|
@ -204,6 +204,7 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPE
|
|||
void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
|
||||
int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
ME_Cell *para_cell( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
void para_destroy( ME_TextEditor *editor, ME_Paragraph *item ) DECLSPEC_HIDDEN;
|
||||
ME_Run *para_end_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
ME_Run *para_first_run( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
|
@ -279,6 +280,8 @@ ME_Paragraph *editor_first_para( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
|||
|
||||
/* table.c */
|
||||
BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN;
|
||||
ME_Cell *cell_next( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
||||
ME_Cell *cell_prev( ME_Cell *cell ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_insert_cell( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_insert_row_end( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||
|
@ -286,6 +289,7 @@ ME_Paragraph *table_insert_row_start( ME_TextEditor *editor, ME_Cursor *cursor )
|
|||
ME_Paragraph *table_insert_row_start_at_para( ME_TextEditor *editor, ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_outer_para( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_row_end( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
ME_Cell *table_row_first_cell( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
ME_Paragraph *table_row_start( ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
void ME_CheckTablesForCorruption(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nChars) DECLSPEC_HIDDEN;
|
||||
|
@ -293,6 +297,11 @@ void ME_TabPressedInTable(ME_TextEditor *editor, BOOL bSelectedRow) DECLSPEC_HID
|
|||
void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef) DECLSPEC_HIDDEN;
|
||||
static inline ME_DisplayItem *cell_get_di(ME_Cell *cell)
|
||||
{
|
||||
return (ME_DisplayItem *)((ptrdiff_t)cell - offsetof(ME_DisplayItem, member));
|
||||
}
|
||||
|
||||
|
||||
/* txthost.c */
|
||||
ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -124,6 +124,12 @@ BOOL para_in_table( ME_Paragraph *para )
|
|||
return para->fmt.wEffects & PFE_TABLE;
|
||||
}
|
||||
|
||||
ME_Cell *para_cell( ME_Paragraph *para )
|
||||
{
|
||||
if (!para->pCell) return NULL;
|
||||
return ¶->pCell->member.cell;
|
||||
}
|
||||
|
||||
void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
||||
{
|
||||
static const WCHAR cr_lf[] = {'\r','\n',0};
|
||||
|
|
|
@ -172,6 +172,26 @@ ME_Paragraph* table_outer_para( ME_Paragraph *para )
|
|||
return para;
|
||||
}
|
||||
|
||||
ME_Cell *table_row_first_cell( ME_Paragraph *para )
|
||||
{
|
||||
if (!para_in_table( para )) return NULL;
|
||||
|
||||
para = para_next( table_row_start( para ) );
|
||||
return para_cell( para );
|
||||
}
|
||||
|
||||
ME_Cell *cell_next( ME_Cell *cell )
|
||||
{
|
||||
if (!cell->next_cell) return NULL;
|
||||
return &cell->next_cell->member.cell;
|
||||
}
|
||||
|
||||
ME_Cell *cell_prev( ME_Cell *cell )
|
||||
{
|
||||
if (!cell->prev_cell) return NULL;
|
||||
return &cell->prev_cell->member.cell;
|
||||
}
|
||||
|
||||
/* Make a bunch of assertions to make sure tables haven't been corrupted.
|
||||
*
|
||||
* These invariants may not hold true in the middle of streaming in rich text
|
||||
|
|
Loading…
Reference in New Issue