summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtfdocumentimpl.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-09-09 18:40:20 +0300
committerJustin Luth <justin_luth@sil.org>2020-09-11 10:13:12 +0200
commit46187510e383d62ee7bae8f8332322d7c3b0c61e (patch)
tree3fdfb55854f15b1b988e5effab6fde493619384d /writerfilter/source/rtftok/rtfdocumentimpl.cxx
parente83201a5fcfa7470cdad76c93c497e71b1caa7f4 (diff)
tdf#136587 rtf writerfilter: don't deduplicate yourself
The default style was not being imported because it was based on itself, and therefore deduplicated itself away, or something like that. Probably this is the only scenario that truly would end up deduplicating itself, but I made it generic just in case. Why not? Change-Id: I621092bf2e067933b5d23d27689a5d3a7f8cf2bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102328 Tested-by: Jenkins Tested-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index cf757dd58737..7edeccdcb4e7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2093,6 +2093,7 @@ RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable()
for (auto const& it : m_aStyleTableEntries)
{
auto pStyle = it.second;
+ ret[it.first] = pStyle;
// ugly downcasts here, but can't easily replace the members with
// RTFReferenceProperties because dmapper wants SvRef<Properties> anyway
RTFValue::Pointer_t const pBasedOn(
@@ -2101,6 +2102,10 @@ RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable()
if (pBasedOn)
{
int const nBasedOn(pBasedOn->getInt());
+ // don't deduplicate yourself - especially a potential problem for the default style.
+ if (it.first == nBasedOn)
+ continue;
+
auto const itParent(m_aStyleTableEntries.find(nBasedOn)); // definition as read!
if (itParent != m_aStyleTableEntries.end())
{
@@ -2120,14 +2125,13 @@ RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable()
static_cast<RTFReferenceProperties&>(*itParent->second).getAttributes(),
nStyleType));
- pStyle = new RTFReferenceProperties(attributes, sprms);
+ ret[it.first] = new RTFReferenceProperties(attributes, sprms);
}
else
{
SAL_WARN("writerfilter.rtf", "parent style not found: " << nBasedOn);
}
}
- ret[it.first] = pStyle;
}
assert(ret.size() == m_aStyleTableEntries.size());
return ret;