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

Alexandre Julliard julliard at winehq.org
Wed Aug 23 19:54:07 CDT 2017


Module: wine
Branch: master
Commit: 5cc8c9fe83d6d6deb95f2ec743f6c629480e2a96
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5cc8c9fe83d6d6deb95f2ec743f6c629480e2a96

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Aug 21 12:31:45 2017 +0100

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

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.c  |  9 ++-------
 dlls/riched20/editor.h  |  2 +-
 dlls/riched20/editstr.h |  1 -
 dlls/riched20/para.c    | 14 +++++++++++++-
 dlls/riched20/txthost.c | 15 +++++++++++++--
 dlls/riched20/txtsrv.c  |  2 +-
 6 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index f5b9e4c..3cd80be 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -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 );
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 237036c..53c41a9 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -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;
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index eafe2b7..2bf680e 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -382,7 +382,6 @@ typedef struct tagME_TextEditor
   ME_TextBuffer *pBuffer;
   ME_Cursor *pCursors;
   DWORD styleFlags;
-  DWORD alignStyle;
   DWORD exStyleFlags;
   int nCursors;
   SIZE sizeWindow;
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 6c023f2..f2a70e5 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -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 );
+    }
 }
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index ccd554d..b479bde 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -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,
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 307b484..2a2149e 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -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);
 




More information about the wine-cvs mailing list