From 8172d69e8f422d31bdeb5d82ca0c9c3f806b7ef6 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Tue, 8 Jul 2008 13:38:58 -0400 Subject: [PATCH] richedit: Set the default paragraph format consistently. I created a function to set the default paragraph format to ensure consistency when this is done. This initial paragraph format is also now more consistent with native richedit controls. The dwMask value always appears to have the same value when retrieved from the native richedit controls, so all the mask values are now initialized when the PARAFORMAT2 structure is created. --- dlls/riched20/editor.c | 5 ++++- dlls/riched20/editor.h | 1 + dlls/riched20/list.c | 3 +-- dlls/riched20/para.c | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 4665845ce23..35e4be1f828 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1040,13 +1040,16 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ME_InternalDeleteText(editor, from, to-from); } else { + ME_DisplayItem *para_item; style = editor->pBuffer->pDefaultStyle; ME_AddRefStyle(style); SendMessageA(editor->hWnd, EM_SETSEL, 0, 0); ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor)); from = to = 0; ME_ClearTempStyle(editor); - /* FIXME restore default paragraph formatting ! */ + + para_item = ME_GetParagraph(editor->pCursors[0].pRun); + ME_SetDefaultParaFormat(para_item->member.para.pFmt); } diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 76f61a2babd..786191a3a63 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -231,6 +231,7 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt); void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last); void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last); void ME_MarkAllForWrapping(ME_TextEditor *editor); +void ME_SetDefaultParaFormat(PARAFORMAT2 *pFmt); /* paint.c */ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate); diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c index f5c5f42fd8d..60c49e3aa37 100644 --- a/dlls/riched20/list.c +++ b/dlls/riched20/list.c @@ -151,8 +151,7 @@ ME_DisplayItem *ME_MakeDI(ME_DIType type) { item->prev = item->next = NULL; if (type == diParagraph || type == diUndoSplitParagraph) { item->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2); - item->member.para.pFmt->cbSize = sizeof(PARAFORMAT2); - item->member.para.pFmt->dwMask = 0; + ME_SetDefaultParaFormat(item->member.para.pFmt); item->member.para.nFlags = MEPF_REWRAP; } diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index c0f1857ca45..e2ba25870f4 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -28,7 +28,6 @@ static const WCHAR wszParagraphSign[] = {0xB6, 0}; void ME_MakeFirstParagraph(ME_TextEditor *editor) { ME_Context c; - PARAFORMAT2 fmt; CHARFORMAT2W cf; LOGFONTW lf; HFONT hf; @@ -62,13 +61,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor) cf.bPitchAndFamily = lf.lfPitchAndFamily; cf.bCharSet = lf.lfCharSet; - ZeroMemory(&fmt, sizeof(fmt)); - fmt.cbSize = sizeof(fmt); - fmt.dwMask = PFM_ALIGNMENT | PFM_OFFSET | PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_TABSTOPS; - fmt.wAlignment = PFA_LEFT; - - *para->member.para.pFmt = fmt; - style = ME_MakeStyle(&cf); text->pDefaultStyle = style; @@ -520,3 +512,13 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) para = para->member.para.next_para; } while(1); } + +void ME_SetDefaultParaFormat(PARAFORMAT2 *pFmt) +{ + ZeroMemory(pFmt, sizeof(PARAFORMAT2)); + pFmt->cbSize = sizeof(PARAFORMAT2); + pFmt->dwMask = PFM_ALL2; + pFmt->wAlignment = PFA_LEFT; + pFmt->sStyle = -1; + pFmt->bOutlineLevel = TRUE; +} -- 2.11.4.GIT