summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-18 07:38:32 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-18 07:47:20 +0200
commitcbe79789a0fc9b80b2fd14a5abfe0973a2cb69dc (patch)
tree11b1f41d7a05a6787513b0ef2efb3f2ce9085465 /writerfilter
parentRemove include stdio (part2) (diff)
downloadcore-cbe79789a0fc9b80b2fd14a5abfe0973a2cb69dc.tar.gz
core-cbe79789a0fc9b80b2fd14a5abfe0973a2cb69dc.zip
tdf#86814 RTF import: fix sometimes lost bold style
The problem was that commit 76c0d0abc89cd8948706083c2660b71a2dad670c (RTF import: adapt getProperties() to createStyleProperties(), 2014-09-07) only made the character style sprms/attributes a flat list, but not the paragraph style ones. Fixing that inconsistency avoids the tokenizer adding unwanted default sprms, which cause the bold sprms go away in the bugdoc. Change-Id: I86bd1b26af18cd968375c9b39be9c8e71d51271f
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx57
1 files changed, 33 insertions, 24 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 625818cd88f7..b351bef227b9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -415,6 +415,32 @@ void RTFDocumentImpl::setNeedSect(bool bNeedSect)
}
}
+/// Copy rProps to rStyleAttributes and rStyleSprms, but in case of nested sprms, copy their children as toplevel sprms/attributes.
+static void lcl_copyFlatten(RTFReferenceProperties& rProps, RTFSprms& rStyleAttributes, RTFSprms& rStyleSprms)
+{
+ for (RTFSprms::Iterator_t it = rProps.getSprms().begin(); it != rProps.getSprms().end(); ++it)
+ {
+ // createStyleProperties() puts properties to rPr, but here we need a flat list.
+ if (it->first == NS_ooxml::LN_CT_Style_rPr)
+ {
+ // rPr can have both attributes and SPRMs, copy over both types.
+ RTFSprms& rRPrSprms = it->second->getSprms();
+ for (RTFSprms::Iterator_t itRPrSprm = rRPrSprms.begin(); itRPrSprm != rRPrSprms.end(); ++itRPrSprm)
+ rStyleSprms.set(itRPrSprm->first, itRPrSprm->second);
+
+ RTFSprms& rRPrAttributes = it->second->getAttributes();
+ for (RTFSprms::Iterator_t itRPrAttribute = rRPrAttributes.begin(); itRPrAttribute != rRPrAttributes.end(); ++itRPrAttribute)
+ rStyleAttributes.set(itRPrAttribute->first, itRPrAttribute->second);
+ }
+ else
+ rStyleSprms.set(it->first, it->second);
+ }
+
+ RTFSprms& rAttributes = rProps.getAttributes();
+ for (RTFSprms::Iterator_t itAttr = rAttributes.begin(); itAttr != rAttributes.end(); ++itAttr)
+ rStyleAttributes.set(itAttr->first, itAttr->second);
+}
+
writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RTFSprms& rAttributes, RTFSprms& rSprms)
{
int nStyle = 0;
@@ -429,34 +455,17 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT
// let's merge paragraph and character style properties here.
int nCharStyle = m_aStates.top().nCurrentCharacterStyleIndex;
RTFReferenceTable::Entries_t::iterator itChar = m_aStyleTableEntries.find(nCharStyle);
- RTFSprms aStyleSprms = rProps.getSprms();
- RTFSprms aStyleAttributes = rProps.getAttributes();
+ RTFSprms aStyleSprms;
+ RTFSprms aStyleAttributes;
+
+ // Ensure the paragraph style is a flat list.
+ lcl_copyFlatten(rProps, aStyleAttributes, aStyleSprms);
+
if (itChar != m_aStyleTableEntries.end())
{
// Found active character style, then update aStyleSprms/Attributes.
RTFReferenceProperties& rCharProps = *static_cast<RTFReferenceProperties*>(itChar->second.get());
- RTFSprms& rCharStyleSprms = rCharProps.getSprms();
- for (RTFSprms::Iterator_t itSprm = rCharStyleSprms.begin(); itSprm != rCharStyleSprms.end(); ++itSprm)
- {
- // createStyleProperties() puts properties to rPr, but here we need a flat list.
- if (itSprm->first == NS_ooxml::LN_CT_Style_rPr)
- {
- // rPr can have both attributes and SPRM's, copy over both types.
- RTFSprms& rRPrSprms = itSprm->second->getSprms();
- for (RTFSprms::Iterator_t itRPrSprm = rRPrSprms.begin(); itRPrSprm != rRPrSprms.end(); ++itRPrSprm)
- aStyleSprms.set(itRPrSprm->first, itRPrSprm->second);
-
- RTFSprms& rRPrAttributes = itSprm->second->getAttributes();
- for (RTFSprms::Iterator_t itRPrAttribute = rRPrAttributes.begin(); itRPrAttribute != rRPrAttributes.end(); ++itRPrAttribute)
- aStyleAttributes.set(itRPrAttribute->first, itRPrAttribute->second);
- }
- else
- aStyleSprms.set(itSprm->first, itSprm->second);
- }
-
- RTFSprms& rCharStyleAttributes = rCharProps.getAttributes();
- for (RTFSprms::Iterator_t itAttr = rCharStyleAttributes.begin(); itAttr != rCharStyleAttributes.end(); ++itAttr)
- aStyleAttributes.set(itAttr->first, itAttr->second);
+ lcl_copyFlatten(rCharProps, aStyleAttributes, aStyleSprms);
}
// Get rid of direct formatting what is already in the style.