diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/mTextControl/src/FormattedTextDraw.cpp | 38 | ||||
-rw-r--r-- | libs/mTextControl/src/FormattedTextDraw.h | 2 | ||||
-rw-r--r-- | libs/mTextControl/src/services.cpp | 4 |
3 files changed, 9 insertions, 35 deletions
diff --git a/libs/mTextControl/src/FormattedTextDraw.cpp b/libs/mTextControl/src/FormattedTextDraw.cpp index fc1e84c0ea..e89ab6ad1d 100644 --- a/libs/mTextControl/src/FormattedTextDraw.cpp +++ b/libs/mTextControl/src/FormattedTextDraw.cpp @@ -151,46 +151,20 @@ HRESULT CFormattedTextDraw::putTextW(wchar_t *newVal) return S_OK; } -///////////////////////////////////////////////////////////////////////////////////////// - -#define STREAMSTAGE_HEADER 0 -#define STREAMSTAGE_EVENTS 1 -#define STREAMSTAGE_TAIL 2 -#define STREAMSTAGE_STOP 3 - -struct STREAMDATA -{ - const char *str; - int lSize, lCount; -}; - -static DWORD CALLBACK EditStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) -{ - auto *dat = (STREAMDATA *)dwCookie; - - if (dat->lSize - dat->lCount < cb) - *pcb = dat->lSize - dat->lCount; - else - *pcb = cb; - - memcpy(pbBuff, dat->str + dat->lCount, *pcb); - dat->lCount += *pcb; - return 0; // callback succeeded - no errors -} - -HRESULT CFormattedTextDraw::putRTFText(MRtfProvider *pProv) +HRESULT CFormattedTextDraw::putRTFText(char *newVal) { if (!m_spTextServices) return S_FALSE; - CMStringA buf = pProv->CreateRtfHeader() + pProv->CreateRtfBody() + pProv->CreateRtfFooter(); - - STREAMDATA streamData = { buf.c_str(), buf.GetLength(), 0 }; + STREAMDATATEXT streamData = {}; + streamData.isUnicode = false; + streamData.ansi = newVal; + streamData.cbSize = mir_strlen(newVal); EDITSTREAM editStream; editStream.dwCookie = (DWORD_PTR)&streamData; editStream.dwError = 0; - editStream.pfnCallback = EditStreamInCallback; + editStream.pfnCallback = EditStreamTextInCallback; LRESULT lResult = 0; m_spTextServices->TxSendMessage(EM_STREAMIN, SF_RTF, (LPARAM)&editStream, &lResult); diff --git a/libs/mTextControl/src/FormattedTextDraw.h b/libs/mTextControl/src/FormattedTextDraw.h index 3ec7a7412e..f9ff25f2b6 100644 --- a/libs/mTextControl/src/FormattedTextDraw.h +++ b/libs/mTextControl/src/FormattedTextDraw.h @@ -38,7 +38,7 @@ public: HRESULT get_NaturalSize(HDC hdcDraw, long *Width, long *pVal); HRESULT Draw(HDC hdcDraw, RECT *prc); - HRESULT putRTFText(MRtfProvider *pProv); + HRESULT putRTFText(char *newVal); HRESULT putTextA(char *newVal); HRESULT putTextW(wchar_t *newVal); diff --git a/libs/mTextControl/src/services.cpp b/libs/mTextControl/src/services.cpp index bd7eee6a50..1575b716dd 100644 --- a/libs/mTextControl/src/services.cpp +++ b/libs/mTextControl/src/services.cpp @@ -101,7 +101,7 @@ MTEXTCONTROL_DLL(TextObject *) MTextCreateW(HANDLE userHandle, const char *szPro ///////////////////////////////////////////////////////////////////////////////////////// // allocate text object (advanced) -MTEXTCONTROL_DLL(TextObject *) MTextCreateEx(HANDLE userHandle, void *text, uint32_t flags) +MTEXTCONTROL_DLL(TextObject *) MTextCreateEx(HANDLE userHandle, const void *text, uint32_t flags) { TextObject *result = new TextObject; result->options = TextUserGetOptions(userHandle); @@ -110,7 +110,7 @@ MTEXTCONTROL_DLL(TextObject *) MTextCreateEx(HANDLE userHandle, void *text, uint MText_InitFormatting0(result->ftd, result->options); if (flags & MTEXT_FLG_RTF) { - result->ftd->putRTFText((MRtfProvider *)text); + result->ftd->putRTFText((char *)text); } else { if (flags & MTEXT_FLG_WCHAR) |