riched20: Retrieve the default paragraph alignment from the text host.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-08-21 12:31:45 +01:00 committed by Alexandre Julliard
parent 4cb7578d0b
commit 5cc8c9fe83
6 changed files with 30 additions and 13 deletions

View file

@ -2884,7 +2884,7 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
return TRUE;
}
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD csStyle)
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
{
ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor);
int i;
@ -2898,11 +2898,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD
ed->reOle = NULL;
ed->bEmulateVersion10 = bEmulateVersion10;
ed->styleFlags = 0;
ed->alignStyle = PFA_LEFT;
if (csStyle & ES_RIGHT)
ed->alignStyle = PFA_RIGHT;
if (csStyle & ES_CENTER)
ed->alignStyle = PFA_CENTER;
ITextHost_TxGetPropertyBits(texthost,
(TXTBIT_RICHTEXT|TXTBIT_MULTILINE|
TXTBIT_READONLY|TXTBIT_USEPASSWORD|
@ -4799,7 +4794,7 @@ static BOOL create_windowed_editor(HWND hwnd, CREATESTRUCTW *create, BOOL emulat
if (!host) return FALSE;
editor = ME_MakeEditor( host, emulate_10, create->style );
editor = ME_MakeEditor( host, emulate_10 );
if (!editor)
{
ITextHost_Release( host );

View file

@ -255,7 +255,7 @@ void ME_DeleteReObject(REOBJECT* reo) DECLSPEC_HIDDEN;
void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
/* editor.c */
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD csStyle) DECLSPEC_HIDDEN;
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN;
void ME_DestroyEditor(ME_TextEditor *editor) DECLSPEC_HIDDEN;
LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
LPARAM lParam, BOOL unicode, HRESULT* phresult) DECLSPEC_HIDDEN;

View file

@ -382,7 +382,6 @@ typedef struct tagME_TextEditor
ME_TextBuffer *pBuffer;
ME_Cursor *pCursors;
DWORD styleFlags;
DWORD alignStyle;
DWORD exStyleFlags;
int nCursors;
SIZE sizeWindow;

View file

@ -863,10 +863,22 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
{
const PARAFORMAT2 *host_fmt;
HRESULT hr;
ZeroMemory(pFmt, sizeof(PARAFORMAT2));
pFmt->cbSize = sizeof(PARAFORMAT2);
pFmt->dwMask = PFM_ALL2;
pFmt->wAlignment = editor->alignStyle;
pFmt->wAlignment = PFA_LEFT;
pFmt->sStyle = -1;
pFmt->bOutlineLevel = TRUE;
hr = ITextHost_TxGetParaFormat( editor->texthost, (const PARAFORMAT **)&host_fmt );
if (SUCCEEDED(hr))
{
/* Just use the alignment for now */
if (host_fmt->dwMask & PFM_ALIGNMENT)
pFmt->wAlignment = host_fmt->wAlignment;
ITextHost_OnTxParaFormatChange( editor->texthost, (PARAFORMAT *)pFmt );
}
}

View file

@ -38,6 +38,7 @@ typedef struct ITextHostImpl {
LONG ref;
HWND hWnd;
BOOL bEmulateVersion10;
PARAFORMAT2 para_fmt;
} ITextHostImpl;
static const ITextHostVtbl textHostVtbl;
@ -53,6 +54,14 @@ ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion1
texthost->ref = 1;
texthost->hWnd = hwnd;
texthost->bEmulateVersion10 = bEmulateVersion10;
memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
texthost->para_fmt.dwMask = PFM_ALIGNMENT;
texthost->para_fmt.wAlignment = PFA_LEFT;
if (cs->style & ES_RIGHT)
texthost->para_fmt.wAlignment = PFA_RIGHT;
if (cs->style & ES_CENTER)
texthost->para_fmt.wAlignment = PFA_CENTER;
return &texthost->ITextHost_iface;
}
@ -260,9 +269,11 @@ DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface,
}
DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface,
const PARAFORMAT **ppPF)
const PARAFORMAT **fmt)
{
return E_NOTIMPL;
ITextHostImpl *This = impl_from_ITextHost(iface);
*fmt = (const PARAFORMAT *)&This->para_fmt;
return S_OK;
}
DECLSPEC_HIDDEN COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface,

View file

@ -413,7 +413,7 @@ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, I
ITextImpl->pMyHost = pITextHost;
ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl;
ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE, ES_LEFT);
ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
ITextImpl->editor->exStyleFlags = 0;
SetRectEmpty(&ITextImpl->editor->rcFormat);