From abb8d98f80b09450db754db704a0d98eb5427b41 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Mar 2024 20:20:59 +0300 Subject: =?UTF-8?q?fixes=20#4261=20(NewStory=20=D1=81=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=BE=D0=B9=20=D0=BA=D0=BE=D0=BF=D0=B8=D1=80=D1=83?= =?UTF-8?q?=D0=B5=D1=82=20RTF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/templates.cpp | 60 +++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index f55cc5234c..1a6b579b4e 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -50,10 +50,17 @@ static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p) } else if (*p == '[') { p++; - if (*p == 'c' && p[2] == ']') { - buf.AppendFormat("\\cf%c ", p[1]); - p += 2; - continue; + if (*p == 'c') { + if (p[2] == ']') { + buf.AppendFormat("\\cf%c ", p[1]); + p += 2; + continue; + } + if (p[3] == ']') { + buf.AppendFormat("\\cf%d ", _wtoi(p + 1)); + p += 3; + continue; + } } char *pEnd = ""; @@ -124,7 +131,28 @@ CMStringA ItemData::formatRtf(const wchar_t *pwszStr) CMStringA NewstoryListData::GatherSelectedRtf() { CMStringA buf; - buf.Append("{\\rtf1\\ansi\\deff0"); + buf.Append("{\\rtf1\\ansi\\deff0{\\fonttbl "); + for (int i=0; i < FONT_COUNT; i++) + buf.AppendFormat("{\\f%d\\fnil\\fcharset0 %s;}", i, g_fontTable[i].lf.lfFaceName); + + buf.AppendFormat("}{\\colortbl \\red%u\\green%u\\blue%u;\\red%u\\green%u\\blue%u;", 0, 0, 0, 0, 0, 0); + + for (auto cl : g_plugin.clCustom) { + COLORREF cr = (cl == -1) ? 0 : cl; + buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); + } + + for (int i = 0; i < COLOR_COUNT; i++) { + COLORREF cr = g_colorTable[i].cl; + buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); + } + + for (int i = 0; i < FONT_COUNT; i++) { + COLORREF cr = g_fontTable[i].cl; + buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); + } + + buf.Append("}"); int eventCount = totalCount; for (int i = 0; i < eventCount; i++) { @@ -132,25 +160,15 @@ CMStringA NewstoryListData::GatherSelectedRtf() if (!p->m_bSelected) continue; - buf.Append("{"); int fontID, colorID; p->getFontColor(fontID, colorID); - auto &F = g_fontTable[fontID]; - buf.AppendFormat("{\\fonttbl{\\f0\\fnil\\fcharset0 %s;}}", F.lf.lfFaceName); - - COLORREF cr = F.cl; - buf.AppendFormat("{\\colortbl \\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - cr = g_colorTable[(p->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl; - buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - - for (auto cl : g_plugin.clCustom) { - cr = (cl == -1) ? 0 : cl; - buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - } - buf.AppendFormat("}\\uc1\\pard \\cf0\\f0\\b0\\i0\\fs%d ", GetFontHeight(F.lf)); - AppendUnicodeToBuffer(buf, p->formatString()); - buf.Append("} \\par"); + buf.AppendFormat("{\\uc1\\pard \\cb%d\\cf%d\\f%d\\b0\\i0\\fs%d ", COLOR_BACK + 7, colorID+COLOR_COUNT+7, fontID, GetFontHeight(g_fontTable[fontID].lf)); + CMStringW wszText(p->formatString()); + wszText.Replace(L"[c0]", CMStringW(FORMAT, L"[c%d]", colorID + COLOR_COUNT + 7)); + wszText.Replace(L"[c1]", CMStringW(FORMAT, L"[c%d]", 7 + ((p->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK))); + AppendUnicodeToBuffer(buf, wszText); + buf.Append("}\\par"); } buf.Append("}"); -- cgit v1.2.3