summaryrefslogtreecommitdiff
path: root/plugins/NewStory
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/NewStory')
-rw-r--r--plugins/NewStory/src/history_array.cpp10
-rw-r--r--plugins/NewStory/src/templates.cpp24
-rw-r--r--plugins/NewStory/src/templates.h14
3 files changed, 36 insertions, 12 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index efd3fe9267..72d2b2e4ea 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -372,10 +372,12 @@ void ItemData::load(bool bFullLoad)
void ItemData::setText()
{
- if (m_bRtf)
- data = MTextCreateEx(htuLog, (void*)TplFormatRtf(getTemplate(), hContact, this).c_str(), MTEXT_FLG_RTF);
- else
- data = MTextCreateW(htuLog, Proto_GetBaseAccountName(hContact), TplFormatString(getTemplate(), hContact, this));
+ if (m_bRtf) {
+ NSRtfProvider prov(this);
+ data = MTextCreateEx(htuLog, &prov, 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 cab175563a..7010ff1e85 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -121,27 +121,37 @@ static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p)
buf.AppendChar('}');
}
-CMStringA TplFormatRtf(int tpl, MCONTACT hContact, ItemData *item)
+CMStringA NSRtfProvider::CreateRtfHeader()
{
- 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];
+ auto &F = g_fontTable[(m_pItem->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;
+ cr = g_colorTable[(m_pItem->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl;
buf.AppendFormat("\\red%u\\green%u\\blue%u;}", GetRValue(cr), GetGValue(cr), GetBValue(cr));
+ return buf;
+}
+
+CMStringA NSRtfProvider::CreateRtfBody()
+{
+ auto &F = g_fontTable[(m_pItem->dbe.flags & DBEF_SENT) ? FONT_OUTMSG : FONT_INMSG];
+ CMStringW wszText = TplFormatString(m_pItem->getTemplate(), m_pItem->hContact, m_pItem);
- buf.AppendFormat("\\par\\ltrpar \\f0\\cf0\\b0\\i0\\fs%d ", -F.lf.lfHeight);
+ CMStringA buf;
+ // buf.AppendFormat("\\f0\\cf0\\b0\\i0\\fs%d ", -F.lf.lfHeight);
AppendUnicodeToBuffer(buf, wszText);
- buf.AppendChar('}');
return buf;
}
+CMStringA NSRtfProvider::CreateRtfFooter()
+{
+ return "}";
+}
+
///////////////////////////////////////////////////////////////////////////////
// Template formatting for copying text
diff --git a/plugins/NewStory/src/templates.h b/plugins/NewStory/src/templates.h
index 932f9dc437..1ad2deed48 100644
--- a/plugins/NewStory/src/templates.h
+++ b/plugins/NewStory/src/templates.h
@@ -71,9 +71,21 @@ extern TemplateInfo templates[TPL_COUNT];
void LoadTemplates();
void SaveTemplates();
-CMStringA TplFormatRtf(int tpl, MCONTACT hContact, ItemData *args);
CMStringW TplFormatString(int tpl, MCONTACT hContact, ItemData *item);
CMStringW TplFormatStringEx(int tpl, wchar_t *sztpl, ItemData *args);
+class NSRtfProvider : public MRtfProvider
+{
+ ItemData *m_pItem;
+
+public:
+ NSRtfProvider(ItemData *pItem) :
+ m_pItem(pItem)
+ {}
+
+ CMStringA CreateRtfHeader() override;
+ CMStringA CreateRtfBody() override;
+ CMStringA CreateRtfFooter() override;
+};
#endif // __templates_h__ \ No newline at end of file