From 016e03401feb9b9293577fbb220fd3d1934403d7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 2 Mar 2025 17:12:08 +0300 Subject: =?UTF-8?q?fixes=20#4888=20(NewStory:=20=D0=BD=D0=B5=D0=BA=D0=BE?= =?UTF-8?q?=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=B2=D1=8B=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=B3=D0=B0=D0=BC=D0=B8?= =?UTF-8?q?,=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B2=D1=8B=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=D1=8B=D0=B9=20=D1=82=D0=B5=D0=BA=D1=81=D1=82?= =?UTF-8?q?=20=D1=81=D0=BE=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D1=82=20=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D1=82=D1=83=D1=8E=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/src/chat_rtf.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/chat_rtf.cpp b/src/mir_app/src/chat_rtf.cpp index 12f20d93f4..7faf8c35e2 100644 --- a/src/mir_app/src/chat_rtf.cpp +++ b/src/mir_app/src/chat_rtf.cpp @@ -71,7 +71,7 @@ bool CSrmmBaseDialog::DoRtfToTags(CMStringW &pszText) const } else idx += 5; - bool bInsideUl = false, bStart = true; + bool bBold = false, bItalic = false, bStrike = false , bUnderline = false, bStart = true; CMStringW res; // iterate through all characters, if rtf control character found then take action @@ -137,27 +137,33 @@ bool CSrmmBaseDialog::DoRtfToTags(CMStringW &pszText) const } else if (!wcsncmp(p, L"\\b", 2)) { //bold // only allow bold if the font itself isn't a bold one, otherwise just strip it.. - if (lf.lfWeight != FW_BOLD && m_bSendFormat) - res.Append((p[2] != '0') ? L"[b]" : L"[/b]"); + if (lf.lfWeight != FW_BOLD && m_bSendFormat) { + bBold = (p[2] != '0'); + res.Append(bBold ? L"[b]" : L"[/b]"); + } } else if (!wcsncmp(p, L"\\i", 2)) { // italics - if (!lf.lfItalic && m_bSendFormat) - res.Append((p[2] != '0') ? L"[i]" : L"[/i]"); + if (!lf.lfItalic && m_bSendFormat) { + bItalic = p[2] != '0'; + res.Append(bItalic ? L"[i]" : L"[/i]"); + } } else if (!wcsncmp(p, L"\\strike", 7)) { // strike-out - if (!lf.lfStrikeOut && m_bSendFormat) - res.Append((p[7] != '0') ? L"[s]" : L"[/s]"); + if (!lf.lfStrikeOut && m_bSendFormat) { + bStrike = p[7] != '0'; + res.Append(bStrike ? L"[s]" : L"[/s]"); + } } else if (!wcsncmp(p, L"\\ul", 3)) { // underlined if (!lf.lfUnderline && m_bSendFormat) { if (p[3] == 0 || wcschr(tszRtfBreaks, p[3])) { res.Append(L"[u]"); - bInsideUl = true; + bUnderline = true; } else if (!wcsncmp(p + 3, L"none", 4)) { - if (bInsideUl) + if (bUnderline) res.Append(L"[/u]"); - bInsideUl = false; + bUnderline = false; } } } @@ -202,7 +208,13 @@ bool CSrmmBaseDialog::DoRtfToTags(CMStringW &pszText) const } } - if (bInsideUl) + if (bBold) + res.Append(L"[/b]"); + if (bItalic) + res.Append(L"[/i]"); + if (bStrike) + res.Append(L"[/s]"); + if (bUnderline) res.Append(L"[/u]"); pszText = res; -- cgit v1.2.3