riched20: Use run ptrs in SetCharFormat().
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bfac43798b
commit
1797d2124a
|
@ -76,8 +76,6 @@ ME_DisplayItem *ME_MakeDI(ME_DIType type) DECLSPEC_HIDDEN;
|
||||||
void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
||||||
void ME_DumpDocument(ME_TextBuffer *buffer) DECLSPEC_HIDDEN;
|
void ME_DumpDocument(ME_TextBuffer *buffer) DECLSPEC_HIDDEN;
|
||||||
void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
||||||
ME_Run *run_prev( ME_Run *run ) DECLSPEC_HIDDEN;
|
|
||||||
ME_Run *run_next( ME_Run *run ) DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
/* string.c */
|
/* string.c */
|
||||||
ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN;
|
ME_String *ME_MakeStringN(LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN;
|
||||||
|
@ -132,6 +130,9 @@ int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visua
|
||||||
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN;
|
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN;
|
||||||
BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN;
|
BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN;
|
||||||
void run_join( ME_TextEditor *editor, ME_Run *run ) DECLSPEC_HIDDEN;
|
void run_join( ME_TextEditor *editor, ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
|
ME_Run *run_next( ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
|
ME_Run *run_next_all_paras( ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
|
ME_Run *run_prev( ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||||
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN;
|
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN;
|
||||||
SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
|
SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
|
||||||
|
|
|
@ -47,6 +47,16 @@ ME_Run *run_prev( ME_Run *run )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ME_Run *run_next_all_paras( ME_Run *run )
|
||||||
|
{
|
||||||
|
ME_DisplayItem *item = run_get_di( run ), *dummy = para_get_di( run->para );
|
||||||
|
|
||||||
|
if (ME_NextRun( &dummy, &item, TRUE ))
|
||||||
|
return &item->member.run;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ME_CanJoinRuns
|
* ME_CanJoinRuns
|
||||||
*
|
*
|
||||||
|
@ -745,22 +755,22 @@ void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
|
||||||
*
|
*
|
||||||
* If no text is selected, then nothing is done.
|
* If no text is selected, then nothing is done.
|
||||||
*/
|
*/
|
||||||
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt)
|
void ME_SetCharFormat( ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *fmt )
|
||||||
{
|
{
|
||||||
ME_DisplayItem *run, *start_run = start->pRun, *end_run = NULL;
|
ME_Run *run, *start_run = &start->pRun->member.run, *end_run = NULL;
|
||||||
|
|
||||||
if (end && start->pRun == end->pRun && start->nOffset == end->nOffset)
|
if (end && start->pRun == end->pRun && start->nOffset == end->nOffset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (start->nOffset == start->pRun->member.run.len)
|
if (start->nOffset == start->pRun->member.run.len)
|
||||||
start_run = ME_FindItemFwd( start->pRun, diRun );
|
start_run = run_next_all_paras( &start->pRun->member.run );
|
||||||
else if (start->nOffset)
|
else if (start->nOffset)
|
||||||
{
|
{
|
||||||
/* run_split() may or may not update the cursors, depending on whether they
|
/* 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. */
|
* are selection cursors, but we need to make sure they are valid. */
|
||||||
int split_offset = start->nOffset;
|
int split_offset = start->nOffset;
|
||||||
ME_Run *split_run = run_split( editor, start );
|
ME_Run *split_run = run_split( editor, start );
|
||||||
start_run = start->pRun;
|
start_run = &start->pRun->member.run;
|
||||||
if (end && &end->pRun->member.run == split_run)
|
if (end && &end->pRun->member.run == split_run)
|
||||||
{
|
{
|
||||||
end->pRun = start->pRun;
|
end->pRun = start->pRun;
|
||||||
|
@ -771,26 +781,26 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
|
||||||
if (end)
|
if (end)
|
||||||
{
|
{
|
||||||
if (end->nOffset == end->pRun->member.run.len)
|
if (end->nOffset == end->pRun->member.run.len)
|
||||||
end_run = ME_FindItemFwd( end->pRun, diRun );
|
end_run = run_next_all_paras( &end->pRun->member.run );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (end->nOffset) run_split( editor, end );
|
if (end->nOffset) run_split( editor, end );
|
||||||
end_run = end->pRun;
|
end_run = &end->pRun->member.run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (run = start_run; run != end_run; run = ME_FindItemFwd( run, diRun ))
|
for (run = start_run; run != end_run; run = run_next_all_paras( run ))
|
||||||
{
|
{
|
||||||
ME_Style *new_style = ME_ApplyStyle(editor, run->member.run.style, pFmt);
|
ME_Style *new_style = ME_ApplyStyle( editor, run->style, fmt );
|
||||||
ME_Paragraph *para = run->member.run.para;
|
ME_Paragraph *para = run->para;
|
||||||
|
|
||||||
add_undo_set_char_fmt( editor, run->member.run.para->nCharOfs + run->member.run.nCharOfs,
|
add_undo_set_char_fmt( editor, para->nCharOfs + run->nCharOfs,
|
||||||
run->member.run.len, &run->member.run.style->fmt );
|
run->len, &run->style->fmt );
|
||||||
ME_ReleaseStyle(run->member.run.style);
|
ME_ReleaseStyle( run->style );
|
||||||
run->member.run.style = new_style;
|
run->style = new_style;
|
||||||
|
|
||||||
/* The para numbering style depends on the eop style */
|
/* The para numbering style depends on the eop style */
|
||||||
if ((run->member.run.nFlags & MERF_ENDPARA) && para->para_num.style)
|
if ((run->nFlags & MERF_ENDPARA) && para->para_num.style)
|
||||||
{
|
{
|
||||||
ME_ReleaseStyle(para->para_num.style);
|
ME_ReleaseStyle(para->para_num.style);
|
||||||
para->para_num.style = NULL;
|
para->para_num.style = NULL;
|
||||||
|
|
Loading…
Reference in New Issue