diff options
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 5 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 37 |
2 files changed, 16 insertions, 26 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 7cfafa7b16..238bd3b36d 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -288,6 +288,9 @@ void ItemData::load(bool bFullLoad) db_event_markRead(hContact, hEvent); Clist_RemoveEvent(-1, hEvent); } + + // uncomment this to use RTF engine + // m_bRtf = true; __fallthrough; case EVENTTYPE_STATUSCHANGE: @@ -352,7 +355,7 @@ void ItemData::load(bool bFullLoad) void ItemData::setText() { if (m_bRtf) - data = MTextCreateEx(htuLog, this->wtext, MTEXT_FLG_WCHAR | MTEXT_FLG_RTF); + data = MTextCreateEx(htuLog, (void*)TplFormatRtf(getTemplate(), hContact, this).c_str(), MTEXT_FLG_RTF); else data = MTextCreateW(htuLog, Proto_GetBaseAccountName(hContact), TplFormatString(getTemplate(), hContact, this)); savedHeight = -1; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 28bf16757a..3dfc7f2188 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -40,8 +40,10 @@ CMStringW TplFormatStringEx(int tpl, wchar_t *sztpl, ItemData *item) /////////////////////////////////////////////////////////////////////////////// // Template formatting for the control -static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p, TemplateVars *vars) +static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p) { + buf.Append("{\\uc1 "); + for (; *p; p++) { if (*p == '\r' && p[1] == '\n') { buf.Append("\\p "); @@ -91,12 +93,6 @@ static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p, TemplateVars } else buf.AppendChar('['); } - else if (*p == '%' && vars) { - wchar_t *var = vars->GetVar((p[1] & 0xff)); - if (var) - AppendUnicodeToBuffer(buf, var, 0); - p++; - } else if (*p < 128) { buf.AppendChar((char)*p); } @@ -104,36 +100,27 @@ static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p, TemplateVars buf.AppendFormat("\\u%d ?", *p); } } + buf.AppendChar('}'); } CMStringA TplFormatRtf(int tpl, MCONTACT hContact, ItemData *item) { - if (tpl < 0 || tpl >= TPL_COUNT) - return CMStringA(""); - - auto &T = templates[tpl]; - - TemplateVars vars; - - for (auto &it : T.vf) - if (it) - it(&vars, hContact, item); + CMStringW wszText = TplFormatString(tpl, hContact, item); CMStringA buf; buf.Append("{\\rtf1\\ansi\\deff0"); + auto &F = g_fontTable[(item->dbe.flags & DBEF_SENT) ? FONT_OUTMSG : FONT_INMSG]; + buf.AppendFormat("{\\fonttbl{\\f0\\fnil\\fcharset1 %s;}}", F.lf.lfFaceName); + COLORREF cr = GetSysColor(COLOR_WINDOWTEXT); buf.AppendFormat("{\\colortbl \\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr)); cr = g_colorTable[(item->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl; - buf.AppendFormat("\\colortbl \\red%u\\green%u\\blue%u;}", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - - wchar_t tmp[2] = { 0, 0 }; + buf.AppendFormat("\\red%u\\green%u\\blue%u;}", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - buf.Append("\\par "); - - buf.Append("{\\uc1 "); - AppendUnicodeToBuffer(buf, (T.value != nullptr) ? T.value : T.defvalue, &vars); - buf.Append("}}"); + buf.AppendFormat("\\par\\ltrpar \\f0\\cf0\\b0\\i0\\fs%d ", -F.lf.lfHeight); + AppendUnicodeToBuffer(buf, wszText); + buf.AppendChar('}'); return buf; } |