Commit 00fa9a95 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Use paragraph and run ptrs in the cursor structure.

parent 12dd2d5d
......@@ -348,7 +348,7 @@ static HGLOBAL get_unicode_text(ME_TextEditor *editor, const ME_Cursor *start, i
int nEnd = ME_GetCursorOfs(start) + nChars;
/* count paragraphs in range */
para = &start->pPara->member.para;
para = start->para;
while ((para = para_next( para )) && para->nCharOfs <= nEnd)
pars++;
......
......@@ -274,8 +274,8 @@ typedef struct tagME_TextBuffer
typedef struct tagME_Cursor
{
ME_DisplayItem *pPara;
ME_DisplayItem *pRun;
ME_Paragraph *para;
ME_Run *run;
int nOffset;
} ME_Cursor;
......
......@@ -437,7 +437,7 @@ static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) {
static void draw_run( ME_Context *c, int x, int y, ME_Cursor *cursor )
{
ME_Row *row;
ME_Run *run = &cursor->pRun->member.run;
ME_Run *run = cursor->run;
int runofs = run_char_ofs( run, cursor->nOffset );
int nSelFrom, nSelTo;
......@@ -999,8 +999,8 @@ static void draw_paragraph( ME_Context *c, ME_Paragraph *para )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( para );
cursor.run = run;
cursor.para = para;
cursor.nOffset = 0;
draw_run( c, c->pt.x + run->pt.x, c->pt.y + para->pt.y + run->pt.y + baseline, &cursor );
}
......@@ -1271,9 +1271,9 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor )
{
ME_Run *run = &cursor->pRun->member.run;
ME_Run *run = cursor->run;
ME_Row *row = row_from_cursor( cursor );
ME_Paragraph *para = &cursor->pPara->member.para;
ME_Paragraph *para = cursor->para;
int x, y, yheight;
......
......@@ -581,10 +581,10 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
/* Update selection cursors to point to the correct paragraph. */
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pPara == para_get_di( old_para ) &&
run->nCharOfs <= editor->pCursors[i].pRun->member.run.nCharOfs)
if (editor->pCursors[i].para == old_para &&
run->nCharOfs <= editor->pCursors[i].run->nCharOfs)
{
editor->pCursors[i].pPara = para_get_di( new_para );
editor->pCursors[i].para = new_para;
}
}
......@@ -708,10 +708,10 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
/* null char format operation to store the original char format for the ENDPARA run */
ME_InitCharFormat2W(&fmt);
startCur.pPara = para_get_di( para );
startCur.pRun = run_get_di( end_run );
endCur.pPara = para_get_di( next );
endCur.pRun = run_get_di( next_first_run );
startCur.para = para;
startCur.run = end_run;
endCur.para = next;
endCur.run = next_first_run;
startCur.nOffset = endCur.nOffset = 0;
ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
......@@ -757,13 +757,13 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
* paragraph run, and point to the correct paragraph. */
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( end_run ))
if (editor->pCursors[i].run == end_run)
{
editor->pCursors[i].pRun = run_get_di( next_first_run );
editor->pCursors[i].run = next_first_run;
editor->pCursors[i].nOffset = 0;
}
else if (editor->pCursors[i].pPara == para_get_di( next ))
editor->pCursors[i].pPara = para_get_di( para );
else if (editor->pCursors[i].para == next)
editor->pCursors[i].para = para;
}
for (tmp_run = next_first_run; tmp_run; tmp_run = run_next( tmp_run ))
......@@ -869,8 +869,8 @@ void editor_get_selection_paras( ME_TextEditor *editor, ME_Paragraph **para, ME_
{
ME_Cursor *pEndCursor = &editor->pCursors[1];
*para = &editor->pCursors[0].pPara->member.para;
*para_end = &editor->pCursors[1].pPara->member.para;
*para = editor->pCursors[0].para;
*para_end = editor->pCursors[1].para;
if (*para == *para_end)
return;
......@@ -885,7 +885,7 @@ void editor_get_selection_paras( ME_TextEditor *editor, ME_Paragraph **para, ME_
/* The paragraph at the end of a non-empty selection isn't included
* if the selection ends at the start of the paragraph. */
if (!pEndCursor->pRun->member.run.nCharOfs && !pEndCursor->nOffset)
if (!pEndCursor->run->nCharOfs && !pEndCursor->nOffset)
*para_end = para_prev( *para_end );
}
......
......@@ -1390,20 +1390,20 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
TRACE("character offset: %d\n", lpreobject->cp);
cursor_from_char_ofs( This->editor, lpreobject->cp, &cursor );
if (!cursor.pRun->member.run.reobj)
if (!cursor.run->reobj)
return E_INVALIDARG;
else
reobj = cursor.pRun->member.run.reobj;
reobj = cursor.run->reobj;
}
else if (iob == REO_IOB_SELECTION)
{
ME_Cursor *from, *to;
ME_GetSelection(This->editor, &from, &to);
if (!from->pRun->member.run.reobj)
if (!from->run->reobj)
return E_INVALIDARG;
else
reobj = from->pRun->member.run.reobj;
reobj = from->run->reobj;
}
else
{
......@@ -1659,7 +1659,7 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str)
if (!*str)
return E_OUTOFMEMORY;
bEOP = (end.pRun->next->type == diTextEnd && This->end > ME_GetTextLength(editor));
bEOP = (!para_next( para_next( end.para )) && This->end > ME_GetTextLength(editor));
ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP);
return S_OK;
}
......@@ -1714,7 +1714,7 @@ static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch
{
WCHAR wch[2];
ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, !para_next( para_next( cursor->para ) ));
*pch = wch[0];
return S_OK;
......@@ -4745,7 +4745,7 @@ static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
if (!*pbstr)
return E_OUTOFMEMORY;
bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
bEOP = (!para_next( para_next( end->para ) ) && endOfs > ME_GetTextLength(This->reOle->editor));
ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
TRACE("%s\n", wine_dbgstr_w(*pbstr));
......
......@@ -57,7 +57,7 @@ ME_Row *row_from_cursor( ME_Cursor *cursor )
{
ME_DisplayItem *item;
item = ME_FindItemBack( cursor->pRun, diStartRow );
item = ME_FindItemBack( run_get_di( cursor->run ), diStartRow );
return &item->member.row;
}
......@@ -66,8 +66,8 @@ void row_first_cursor( ME_Row *row, ME_Cursor *cursor )
ME_DisplayItem *item;
item = ME_FindItemFwd( row_get_di( row ), diRun );
cursor->pRun = item;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &item->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
}
......@@ -77,9 +77,9 @@ void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop )
item = ME_FindItemFwd( row_get_di( row ), diStartRowOrParagraphOrEnd );
run = ME_FindItemBack( item, diRun );
cursor->pRun = run;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->pRun->member.run.len : 0;
cursor->run = &run->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->run->len : 0;
}
ME_Row *row_from_row_number( ME_TextEditor *editor, int row_num )
......
......@@ -29,15 +29,15 @@ WINE_DECLARE_DEBUG_CHANNEL(richedit_lists);
BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para )
{
ME_DisplayItem *p = cursor->pRun->next;
ME_DisplayItem *p = run_get_di( cursor->run )->next;
while (p->type != diTextEnd)
{
if (p->type == diParagraph && !all_para) return FALSE;
else if (p->type == diRun)
{
cursor->pRun = p;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &p->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
return TRUE;
}
......@@ -48,15 +48,15 @@ BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para )
BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para )
{
ME_DisplayItem *p = cursor->pRun->prev;
ME_DisplayItem *p = run_get_di( cursor->run )->prev;
while (p->type != diTextStart)
{
if (p->type == diParagraph && !all_para) return FALSE;
else if (p->type == diRun)
{
cursor->pRun = p;
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
cursor->run = &p->member.run;
cursor->para = cursor->run->para;
cursor->nOffset = 0;
return TRUE;
}
......@@ -69,12 +69,12 @@ ME_Run *run_next( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_next_run( &cursor, FALSE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -83,12 +83,12 @@ ME_Run *run_prev( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_prev_run( &cursor, FALSE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -97,12 +97,12 @@ ME_Run *run_next_all_paras( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_next_run( &cursor, TRUE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -111,12 +111,12 @@ ME_Run *run_prev_all_paras( ME_Run *run )
{
ME_Cursor cursor;
cursor.pRun = run_get_di( run );
cursor.pPara = para_get_di( run->para );
cursor.run = run;
cursor.para = run->para;
cursor.nOffset = 0;
if (cursor_prev_run( &cursor, TRUE ))
return &cursor.pRun->member.run;
return cursor.run;
return NULL;
}
......@@ -282,8 +282,8 @@ void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *curso
char_ofs -= run->nCharOfs;
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( run );
cursor->para = para;
cursor->run = run;
cursor->nOffset = char_ofs;
}
......@@ -304,9 +304,9 @@ void run_join( ME_TextEditor *editor, ME_Run *run )
/* Update all cursors so that they don't contain the soon deleted run */
for (i = 0; i < editor->nCursors; i++)
{
if (&editor->pCursors[i].pRun->member.run == next)
if (editor->pCursors[i].run == next)
{
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].run = run;
editor->pCursors[i].nOffset += run->len;
}
}
......@@ -326,7 +326,7 @@ void run_join( ME_TextEditor *editor, ME_Run *run )
*/
ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
{
ME_Run *run = &cursor->pRun->member.run, *new_run;
ME_Run *run = cursor->run, *new_run;
int i;
int nOffset = cursor->nOffset;
......@@ -337,7 +337,7 @@ ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
new_run->len = run->len - nOffset;
new_run->para = run->para;
run->len = nOffset;
cursor->pRun = run_get_di( new_run );
cursor->run = new_run;
cursor->nOffset = 0;
ME_InsertBefore( run_get_di( run )->next, run_get_di( new_run ) );
......@@ -346,10 +346,10 @@ ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor )
ME_UpdateRunFlags( editor, new_run );
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( run ) &&
if (editor->pCursors[i].run == run &&
editor->pCursors[i].nOffset >= nOffset)
{
editor->pCursors[i].pRun = run_get_di( new_run );
editor->pCursors[i].run = new_run;
editor->pCursors[i].nOffset -= nOffset;
}
}
......@@ -397,19 +397,19 @@ ME_Run *run_create( ME_Style *s, int flags )
ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
const WCHAR *str, int len, int flags )
{
ME_Run *insert_before = &cursor->pRun->member.run, *run, *prev;
ME_Run *insert_before = cursor->run, *run, *prev;
if (cursor->nOffset)
{
if (cursor->nOffset == insert_before->len)
{
insert_before = run_next_all_paras( insert_before );
if (!insert_before) insert_before = &cursor->pRun->member.run; /* Always insert before the final eop run */
if (!insert_before) insert_before = cursor->run; /* Always insert before the final eop run */
}
else
{
run_split( editor, cursor );
insert_before = &cursor->pRun->member.run;
insert_before = cursor->run;
}
}
......@@ -433,10 +433,10 @@ ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
for (i = 0; i < editor->nCursors; i++)
{
if (editor->pCursors[i].pRun == run_get_di( prev ) &&
if (editor->pCursors[i].run == prev &&
editor->pCursors[i].nOffset == prev->len)
{
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].run = run;
editor->pCursors[i].nOffset = len;
}
}
......@@ -795,35 +795,35 @@ void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
*/
void ME_SetCharFormat( ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *fmt )
{
ME_Run *run, *start_run = &start->pRun->member.run, *end_run = NULL;
ME_Run *run, *start_run = start->run, *end_run = NULL;
if (end && start->pRun == end->pRun && start->nOffset == end->nOffset)
if (end && start->run == end->run && start->nOffset == end->nOffset)
return;
if (start->nOffset == start->pRun->member.run.len)
start_run = run_next_all_paras( &start->pRun->member.run );
if (start->nOffset == start->run->len)
start_run = run_next_all_paras( start->run );
else if (start->nOffset)
{
/* run_split() may or may not update the cursors, depending on whether they
* are selection cursors, but we need to make sure they are valid. */
int split_offset = start->nOffset;
ME_Run *split_run = run_split( editor, start );
start_run = &start->pRun->member.run;
if (end && &end->pRun->member.run == split_run)
start_run = start->run;
if (end && end->run == split_run)
{
end->pRun = start->pRun;
end->run = start->run;
end->nOffset -= split_offset;
}
}
if (end)
{
if (end->nOffset == end->pRun->member.run.len)
end_run = run_next_all_paras( &end->pRun->member.run );
if (end->nOffset == end->run->len)
end_run = run_next_all_paras( end->run );
else
{
if (end->nOffset) run_split( editor, end );
end_run = &end->pRun->member.run;
end_run = end->run;
}
}
......@@ -893,16 +893,16 @@ void ME_GetCharFormat( ME_TextEditor *editor, const ME_Cursor *from,
ME_Run *run, *run_end, *prev_run;
CHARFORMAT2W tmp;
run = &from->pRun->member.run;
run = from->run;
/* special case - if selection is empty, take previous char's formatting */
if (from->pRun == to->pRun && from->nOffset == to->nOffset)
if (from->run == to->run && from->nOffset == to->nOffset)
{
if (!from->nOffset && (prev_run = run_prev( run ))) run = prev_run;
run_copy_char_fmt( run, fmt );
return;
}
run_end = &to->pRun->member.run;
run_end = to->run;
if (!to->nOffset) run_end = run_prev_all_paras( run_end );
run_copy_char_fmt( run, fmt );
......
......@@ -482,14 +482,14 @@ ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor )
if (ME_IsSelection( editor ))
{
ME_GetSelection( editor, &from, &to );
style = from->pRun->member.run.style;
style = from->run->style;
}
else if (editor->pBuffer->pCharStyle)
style = editor->pBuffer->pCharStyle;
else if (!cursor->nOffset && (prev = run_prev( &cursor->pRun->member.run )))
else if (!cursor->nOffset && (prev = run_prev( cursor->run )))
style = prev->style;
else
style = cursor->pRun->member.run.style;
style = cursor->run->style;
ME_AddRefStyle( style );
return style;
......
......@@ -64,10 +64,10 @@ static ME_Paragraph* table_insert_end_para( ME_TextEditor *editor, ME_Cursor *cu
if (cursor->nOffset) run_split( editor, cursor );
para = para_split( editor, &cursor->pRun->member.run, style, eol_str, eol_len, para_flags );
para = para_split( editor, cursor->run, style, eol_str, eol_len, para_flags );
ME_ReleaseStyle( style );
cursor->pPara = para_get_di( para );
cursor->pRun = run_get_di( para_first_run( para ) );
cursor->para = para;
cursor->run = para_first_run( para );
return para;
}
......@@ -84,13 +84,13 @@ ME_Paragraph* table_insert_row_start_at_para( ME_TextEditor *editor, ME_Paragrap
ME_Paragraph *prev_para, *end_para, *start_row;
ME_Cursor cursor;
cursor.pPara = para_get_di( para );
cursor.pRun = run_get_di( para_first_run( para ) );
cursor.para = para;
cursor.run = para_first_run( para );
cursor.nOffset = 0;
start_row = table_insert_row_start( editor, &cursor );
end_para = para_next( &editor->pCursors[0].pPara->member.para );
end_para = para_next( editor->pCursors[0].para );
prev_para = para_next( start_row );
para = para_next( prev_para );
......@@ -220,20 +220,20 @@ void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *n
{
int start_ofs = ME_GetCursorOfs( c );
ME_Cursor c2 = *c;
ME_Paragraph *this_para = &c->pPara->member.para, *end_para;
ME_Paragraph *this_para = c->para, *end_para;
ME_MoveCursorChars( editor, &c2, *num_chars, FALSE );
end_para = &c2.pPara->member.para;
if (c2.pRun->member.run.nFlags & MERF_ENDPARA)
end_para = c2.para;
if (c2.run->nFlags & MERF_ENDPARA)
{
/* End offset might be in the middle of the end paragraph run.
* If this is the case, then we need to use the next paragraph as the last
* paragraphs.
*/
int remaining = start_ofs + *num_chars - c2.pRun->member.run.nCharOfs - end_para->nCharOfs;
int remaining = start_ofs + *num_chars - c2.run->nCharOfs - end_para->nCharOfs;
if (remaining)
{
assert( remaining < c2.pRun->member.run.len );
assert( remaining < c2.run->len );
end_para = para_next( end_para );
}
}
......@@ -293,11 +293,11 @@ void table_protect_partial_deletion( ME_TextEditor *editor, ME_Cursor *c, int *n
if ((this_para->nCharOfs != start_ofs || this_para == end_para) && para_in_table( this_para ))
{
run = &c->pRun->member.run;
run = c->run;
/* Find the next tab or end paragraph to use as a delete boundary */
while (!(run->nFlags & (MERF_TAB | MERF_ENDPARA)))
run = run_next( run );
chars_to_boundary = run->nCharOfs - c->pRun->member.run.nCharOfs - c->nOffset;
chars_to_boundary = run->nCharOfs - c->run->nCharOfs - c->nOffset;
*num_chars = min( *num_chars, chars_to_boundary );
}
else if (para_in_table( end_para ))
......@@ -341,8 +341,8 @@ ME_Paragraph* table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row )
prev_table_end = table_row_end( table_row );
para = para_next( prev_table_end );
run = para_first_run( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = para;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
new_row_start = table_insert_row_start( editor, editor->pCursors );
......@@ -368,12 +368,12 @@ ME_Paragraph* table_append_row( ME_TextEditor *editor, ME_Paragraph *table_row )
{
run = para_end_run( table_row );
assert( para_in_table( table_row ) );
editor->pCursors[0].pPara = para_get_di( table_row );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = table_row;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_InsertTextFromCursor( editor, 0, &endl, 1, run->style );
run = &editor->pCursors[0].pRun->member.run;
run = editor->pCursors[0].run;
for (i = 0; i < table_row->fmt.cTabCount; i++)
ME_InsertTextFromCursor( editor, 0, &tab, 1, run->style );
......@@ -410,8 +410,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
para = table_append_row( editor, table_row_start( para ) );
/* Put cursor at the start of the new table row */
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_WrapMarkedParagraphs(editor);
......@@ -419,11 +419,11 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
}
}
/* Select cell */
editor->pCursors[1].pPara = para_get_di( cell_first_para( cell ) );
editor->pCursors[1].pRun = run_get_di( para_first_run( &editor->pCursors[1].pPara->member.para ) );
editor->pCursors[1].para = cell_first_para( cell );
editor->pCursors[1].run = para_first_run( editor->pCursors[1].para );
editor->pCursors[1].nOffset = 0;
editor->pCursors[0].pPara = para_get_di( cell_end_para( cell ) );
editor->pCursors[0].pRun = run_get_di( para_end_run( &editor->pCursors[0].pPara->member.para ) );
editor->pCursors[0].para = cell_end_para( cell );
editor->pCursors[0].run = para_end_run( editor->pCursors[0].para );
editor->pCursors[0].nOffset = 0;
}
else /* v1.0 - 3.0 */
......@@ -443,8 +443,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
if (para_in_table( para ))
{
run = para_first_run( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( run );
editor->pCursors[0].para = para;
editor->pCursors[0].run = run;
editor->pCursors[0].nOffset = 0;
i = 1;
}
......@@ -453,8 +453,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
/* Insert table row */
para = table_append_row( editor, para_prev( para ) );
/* Put cursor at the start of the new table row */
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
ME_WrapMarkedParagraphs(editor);
......@@ -464,8 +464,8 @@ static void table_select_next_cell_or_append( ME_TextEditor *editor, ME_Run *run
else run = run_next( run );
}
if (i == 0) run = run_next_all_paras( run );
editor->pCursors[i].pRun = run_get_di( run );
editor->pCursors[i].pPara = para_get_di( run->para );
editor->pCursors[i].run = run;
editor->pCursors[i].para = run->para;
editor->pCursors[i].nOffset = 0;
}
}
......@@ -494,32 +494,32 @@ void table_handle_tab( ME_TextEditor *editor, BOOL selected_row )
}
if (!editor->bEmulateVersion10) /* v4.1 */
{
if (!para_in_table( &toCursor.pPara->member.para ))
if (!para_in_table( toCursor.para ))
{
editor->pCursors[0] = toCursor;
editor->pCursors[1] = toCursor;
}
else table_select_next_cell_or_append( editor, &toCursor.pRun->member.run );
else table_select_next_cell_or_append( editor, toCursor.run );
}
else /* v1.0 - 3.0 */
{
if (!para_in_table( &fromCursor.pPara->member.para) )
if (!para_in_table( fromCursor.para ))
{
editor->pCursors[0] = fromCursor;
editor->pCursors[1] = fromCursor;
/* FIXME: For some reason the caret is shown at the start of the
* previous paragraph in v1.0 to v3.0 */
}
else if ((selected_row || !para_in_table( &toCursor.pPara->member.para )))
table_select_next_cell_or_append( editor, &fromCursor.pRun->member.run );
else if ((selected_row || !para_in_table( toCursor.para )))
table_select_next_cell_or_append( editor, fromCursor.run );
else
{
ME_Run *run = run_prev( &toCursor.pRun->member.run );
ME_Run *run = run_prev( toCursor.run );
if (ME_IsSelection(editor) && !toCursor.nOffset && run && run->nFlags & MERF_TAB)
table_select_next_cell_or_append( editor, run );
else
table_select_next_cell_or_append( editor, &toCursor.pRun->member.run );
table_select_next_cell_or_append( editor, toCursor.run );
}
}
ME_InvalidateSelection(editor);
......@@ -532,15 +532,15 @@ void table_handle_tab( ME_TextEditor *editor, BOOL selected_row )
* without a selection. */
void table_move_from_row_start( ME_TextEditor *editor )
{
ME_Paragraph *para = &editor->pCursors[0].pPara->member.para;
ME_Paragraph *para = editor->pCursors[0].para;
if (para == &editor->pCursors[1].pPara->member.para && para->nFlags & MEPF_ROWSTART)
if (para == editor->pCursors[1].para && para->nFlags & MEPF_ROWSTART)
{
/* The cursors should not be at the hidden start row paragraph without
* a selection, so the cursor is moved into the first cell. */
para = para_next( para );
editor->pCursors[0].pPara = para_get_di( para );
editor->pCursors[0].pRun = run_get_di( para_first_run( para ) );
editor->pCursors[0].para = para;
editor->pCursors[0].run = para_first_run( para );
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
}
......
......@@ -336,10 +336,10 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
{
ME_Cursor tmp;
cursor_from_char_ofs( editor, undo->u.set_para_fmt.pos, &tmp );
add_undo_set_para_fmt( editor, &tmp.pPara->member.para );
tmp.pPara->member.para.fmt = undo->u.set_para_fmt.fmt;
tmp.pPara->member.para.border = undo->u.set_para_fmt.border;
para_mark_rewrap( editor, &tmp.pPara->member.para );
add_undo_set_para_fmt( editor, tmp.para );
tmp.para->fmt = undo->u.set_para_fmt.fmt;
tmp.para->border = undo->u.set_para_fmt.border;
para_mark_rewrap( editor, tmp.para );
break;
}
case undo_set_char_fmt:
......@@ -371,7 +371,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
{
ME_Cursor tmp;
cursor_from_char_ofs( editor, undo->u.join_paras.pos, &tmp );
para_join( editor, &tmp.pPara->member.para, TRUE );
para_join( editor, tmp.para, TRUE );
break;
}
case undo_split_para:
......@@ -383,7 +383,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
cursor_from_char_ofs( editor, undo->u.split_para.pos, &tmp );
if (tmp.nOffset) run_split( editor, &tmp );
this_para = &tmp.pPara->member.para;
this_para = tmp.para;
bFixRowStart = this_para->nFlags & MEPF_ROWSTART;
if (bFixRowStart)
{
......@@ -391,7 +391,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
* is correct. */
this_para->nFlags &= ~MEPF_ROWSTART;
}
new_para = para_split( editor, &tmp.pRun->member.run, tmp.pRun->member.run.style,
new_para = para_split( editor, tmp.run, tmp.run->style,
undo->u.split_para.eol_str->szData, undo->u.split_para.eol_str->nLen, paraFlags );
if (bFixRowStart)
new_para->nFlags |= MEPF_ROWSTART;
......
......@@ -131,7 +131,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
{
ME_TextEditor *editor = wc->context->editor;
ME_Run *run2;
ME_Cursor cursor = {para_get_di( wc->para ), run_get_di( run ), nVChar};
ME_Cursor cursor = { wc->para, run, nVChar };
assert( run->nCharOfs != -1 );
ME_CheckCharOffsets(editor);
......@@ -141,7 +141,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
run_split( editor, &cursor );
run2 = &cursor.pRun->member.run;
run2 = cursor.run;
run2->script_analysis = run->script_analysis;
shape_run( wc->context, run );
......@@ -157,7 +157,7 @@ static ME_Run *split_run_extents( ME_WrapContext *wc, ME_Run *run, int nVChar )
debugstr_run( run ), run->pt.x, run->pt.y,
debugstr_run( run2 ), run2->pt.x, run2->pt.y);
return &cursor.pRun->member.run;
return cursor.run;
}
/******************************************************************************
......@@ -777,7 +777,7 @@ static HRESULT itemize_para( ME_Context *c, ME_Paragraph *para )
if (run->nCharOfs + run->len > items[cur_item+1].iCharPos)
{
ME_Cursor cursor = {para_get_di( para ), run_get_di( run ), items[cur_item+1].iCharPos - run->nCharOfs};
ME_Cursor cursor = { para, run, items[cur_item + 1].iCharPos - run->nCharOfs };
run_split( c->editor, &cursor );
}
}
......
......@@ -1003,7 +1003,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
return FALSE;
if (!stream_out_font_and_colour_tbls( pStream, &cursor.pRun->member.run, &endCur.pRun->member.run ))
if (!stream_out_font_and_colour_tbls( pStream, cursor.run, endCur.run ))
return FALSE;
/* TODO: stylesheet table */
......@@ -1021,29 +1021,29 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
do
{
if (&cursor.pPara->member.para != prev_para)
if (cursor.para != prev_para)
{
prev_para = &cursor.pPara->member.para;
if (!stream_out_para_props( editor, pStream, &cursor.pPara->member.para ))
prev_para = cursor.para;
if (!stream_out_para_props( editor, pStream, cursor.para ))
return FALSE;
}
if (cursor.pRun == endCur.pRun && !endCur.nOffset)
if (cursor.run == endCur.run && !endCur.nOffset)
break;
TRACE("flags %xh\n", cursor.pRun->member.run.nFlags);
TRACE("flags %xh\n", cursor.run->nFlags);
/* TODO: emit embedded objects */
if (cursor.pPara->member.para.nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
if (cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
continue;
if (cursor.pRun->member.run.nFlags & MERF_GRAPHICS)
if (cursor.run->nFlags & MERF_GRAPHICS)
{
if (!stream_out_graphics(editor, pStream, &cursor.pRun->member.run))
if (!stream_out_graphics( editor, pStream, cursor.run ))
return FALSE;
}
else if (cursor.pRun->member.run.nFlags & MERF_TAB)
else if (cursor.run->nFlags & MERF_TAB)
{
if (editor->bEmulateVersion10 && /* v1.0 - 3.0 */
para_in_table( &cursor.pPara->member.para ))
para_in_table( cursor.para ))
{
if (!ME_StreamOutPrint(pStream, "\\cell "))
return FALSE;
......@@ -1054,7 +1054,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
return FALSE;
}
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDCELL)
else if (cursor.run->nFlags & MERF_ENDCELL)
{
if (pStream->nNestingLevel > 1)
{
......@@ -1068,13 +1068,13 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
}
nChars--;
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
else if (cursor.run->nFlags & MERF_ENDPARA)
{
if (!ME_StreamOutRTFCharProps(pStream, &cursor.pRun->member.run.style->fmt))
if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
return FALSE;
if (para_in_table( &cursor.pPara->member.para) &&
!(cursor.pPara->member.para.nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)))
if (para_in_table( cursor.para ) &&
!(cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)))
{
if (!ME_StreamOutPrint(pStream, "\\row\r\n"))
return FALSE;
......@@ -1085,9 +1085,9 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
return FALSE;
}
/* Skip as many characters as required by current line break */
nChars = max(0, nChars - cursor.pRun->member.run.len);
nChars = max(0, nChars - cursor.run->len);
}
else if (cursor.pRun->member.run.nFlags & MERF_ENDROW)
else if (cursor.run->nFlags & MERF_ENDROW)
{
if (!ME_StreamOutPrint(pStream, "\\line\r\n"))
return FALSE;
......@@ -1097,17 +1097,17 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
{
int nEnd;
TRACE("style %p\n", cursor.pRun->member.run.style);
if (!ME_StreamOutRTFCharProps(pStream, &cursor.pRun->member.run.style->fmt))
TRACE("style %p\n", cursor.run->style);
if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
return FALSE;
nEnd = (cursor.pRun == endCur.pRun) ? endCur.nOffset : cursor.pRun->member.run.len;
if (!ME_StreamOutRTFText(pStream, get_text( &cursor.pRun->member.run, cursor.nOffset ),
nEnd = (cursor.run == endCur.run) ? endCur.nOffset : cursor.run->len;
if (!ME_StreamOutRTFText(pStream, get_text( cursor.run, cursor.nOffset ),
nEnd - cursor.nOffset))
return FALSE;
cursor.nOffset = 0;
}
} while (cursor.pRun != endCur.pRun && cursor_next_run( &cursor, TRUE ));
} while (cursor.run != endCur.run && cursor_next_run( &cursor, TRUE ));
if (!ME_StreamOutMove(pStream, "}\0", 2))
return FALSE;
......@@ -1125,7 +1125,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
int nBufLen = 0;
BOOL success = TRUE;
if (!cursor.pRun)
if (!cursor.run)
return FALSE;
if (dwFormat & SF_USECODEPAGE)
......@@ -1133,10 +1133,11 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
/* TODO: Handle SF_TEXTIZED */
while (success && nChars && cursor.pRun) {
nLen = min(nChars, cursor.pRun->member.run.len - cursor.nOffset);
while (success && nChars && cursor.run)
{
nLen = min(nChars, cursor.run->len - cursor.nOffset);
if (!editor->bEmulateVersion10 && cursor.pRun->member.run.nFlags & MERF_ENDPARA)
if (!editor->bEmulateVersion10 && cursor.run->nFlags & MERF_ENDPARA)
{
static const WCHAR szEOL[] = { '\r', '\n' };
......@@ -1147,18 +1148,18 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
success = ME_StreamOutMove(pStream, "\r\n", 2);
} else {
if (dwFormat & SF_UNICODE)
success = ME_StreamOutMove(pStream, (const char *)(get_text( &cursor.pRun->member.run, cursor.nOffset )),
success = ME_StreamOutMove(pStream, (const char *)(get_text( cursor.run, cursor.nOffset )),
sizeof(WCHAR) * nLen);
else {
int nSize;
nSize = WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
nSize = WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
nLen, NULL, 0, NULL, NULL);
if (nSize > nBufLen) {
buffer = heap_realloc(buffer, nSize);
nBufLen = nSize;
}
WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ),
WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
nLen, buffer, nSize, NULL, NULL);
success = ME_StreamOutMove(pStream, buffer, nSize);
}
......@@ -1166,8 +1167,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
nChars -= nLen;
cursor.nOffset = 0;
cursor.pRun = run_next_all_paras( &cursor.pRun->member.run ) ?
run_get_di( run_next_all_paras( &cursor.pRun->member.run ) ) : NULL;
cursor.run = run_next_all_paras( cursor.run );
}
heap_free(buffer);
......
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