riched20: Factor out device context acquisition from ME_MakeFirstParagraph.

This lets ME_MakeEditor() reuse the device context throughout the editor
initialization process.
This commit is contained in:
Jinoh Kang 2023-07-13 20:47:52 +09:00 committed by Alexandre Julliard
parent 94d61d1b28
commit 03036f42e1
3 changed files with 7 additions and 5 deletions

View file

@ -2931,6 +2931,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
int i; int i;
LONG selbarwidth; LONG selbarwidth;
HRESULT hr; HRESULT hr;
HDC hdc;
ed->sizeWindow.cx = ed->sizeWindow.cy = 0; ed->sizeWindow.cx = ed->sizeWindow.cy = 0;
if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK) if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK)
@ -2957,7 +2958,10 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->nZoomNumerator = ed->nZoomDenominator = 0; ed->nZoomNumerator = ed->nZoomDenominator = 0;
ed->nAvailWidth = 0; /* wrap to client area */ ed->nAvailWidth = 0; /* wrap to client area */
list_init( &ed->style_list ); list_init( &ed->style_list );
ME_MakeFirstParagraph(ed);
hdc = ITextHost_TxGetDC( ed->texthost );
ME_MakeFirstParagraph( ed, hdc );
ITextHost_TxReleaseDC( ed->texthost, hdc );
/* The four cursors are for: /* The four cursors are for:
* 0 - The position where the caret is shown * 0 - The position where the caret is shown
* 1 - The anchored end of the selection (for normal selection) * 1 - The anchored end of the selection (for normal selection)

View file

@ -209,7 +209,7 @@ void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt );
void editor_mark_rewrap_all( ME_TextEditor *editor ); void editor_mark_rewrap_all( ME_TextEditor *editor );
void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt); void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt);
BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ); BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt );
void ME_MakeFirstParagraph(ME_TextEditor *editor); void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc);
void ME_DumpParaStyle(ME_Paragraph *s); void ME_DumpParaStyle(ME_Paragraph *s);
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]); void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]);
int get_total_width(ME_TextEditor *editor); int get_total_width(ME_TextEditor *editor);

View file

@ -148,7 +148,7 @@ ME_Row *para_end_row( ME_Paragraph *para )
return &item->member.row; return &item->member.row;
} }
void ME_MakeFirstParagraph(ME_TextEditor *editor) void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc)
{ {
ME_Context c; ME_Context c;
CHARFORMAT2W cf; CHARFORMAT2W cf;
@ -160,7 +160,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
ME_Run *run; ME_Run *run;
ME_Style *style; ME_Style *style;
int eol_len; int eol_len;
HDC hdc = ITextHost_TxGetDC( editor->texthost );
ME_InitContext( &c, editor, hdc ); ME_InitContext( &c, editor, hdc );
@ -223,7 +222,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
para_mark_add( editor, para ); para_mark_add( editor, para );
ME_DestroyContext(&c); ME_DestroyContext(&c);
wrap_marked_paras_dc( editor, hdc, FALSE ); wrap_marked_paras_dc( editor, hdc, FALSE );
ITextHost_TxReleaseDC( editor->texthost, hdc );
} }
static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end ) static void para_mark_rewrap_paras( ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end )