summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtfsprm.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/rtftok/rtfsprm.cxx')
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx62
1 files changed, 40 insertions, 22 deletions
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index f768785a5cba..d63eaef70694 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -137,21 +137,36 @@ void RTFSprms::eraseLast(Id nKeyword)
}
}
-static RTFValue::Pointer_t getDefaultSPRM(Id const id)
+static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType)
{
- switch (id)
+ if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character)
{
- case NS_ooxml::LN_CT_Spacing_before:
- case NS_ooxml::LN_CT_Spacing_after:
- case NS_ooxml::LN_EG_RPrBase_b:
- case NS_ooxml::LN_CT_Ind_left:
- case NS_ooxml::LN_CT_Ind_right:
- case NS_ooxml::LN_CT_Ind_firstLine:
- return std::make_shared<RTFValue>(0);
+ switch (id)
+ {
+ case NS_ooxml::LN_EG_RPrBase_b:
+ return std::make_shared<RTFValue>(0);
+ default:
+ break;
+ }
+ }
- default:
- return RTFValue::Pointer_t();
+ if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_paragraph)
+ {
+ switch (id)
+ {
+ case NS_ooxml::LN_CT_Spacing_before:
+ case NS_ooxml::LN_CT_Spacing_after:
+ case NS_ooxml::LN_CT_Ind_left:
+ case NS_ooxml::LN_CT_Ind_right:
+ case NS_ooxml::LN_CT_Ind_firstLine:
+ return std::make_shared<RTFValue>(0);
+
+ default:
+ break;
+ }
}
+
+ return RTFValue::Pointer_t();
}
/// Is it problematic to deduplicate this SPRM?
@@ -199,7 +214,8 @@ static bool isSPRMChildrenExpected(Id nId)
}
/// Does the clone / deduplication of a single sprm.
-static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t> const& rSprm, RTFSprms& ret)
+static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t> const& rSprm, RTFSprms& ret,
+ Id nStyleType)
{
RTFValue::Pointer_t const pValue(ret.find(rSprm.first));
if (pValue)
@@ -211,9 +227,10 @@ static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t> const& rS
}
else if (!rSprm.second->getSprms().empty() || !rSprm.second->getAttributes().empty())
{
- RTFSprms const sprms(pValue->getSprms().cloneAndDeduplicate(rSprm.second->getSprms()));
- RTFSprms const attributes(
- pValue->getAttributes().cloneAndDeduplicate(rSprm.second->getAttributes()));
+ RTFSprms const sprms(
+ pValue->getSprms().cloneAndDeduplicate(rSprm.second->getSprms(), nStyleType));
+ RTFSprms const attributes(pValue->getAttributes().cloneAndDeduplicate(
+ rSprm.second->getAttributes(), nStyleType));
// Don't copy the sprm in case we expect it to have children but it doesn't have some.
if (!isSPRMChildrenExpected(rSprm.first) || !sprms.empty() || !attributes.empty())
ret.set(rSprm.first,
@@ -223,16 +240,17 @@ static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t> const& rS
else
{
// not found - try to override style with default
- RTFValue::Pointer_t const pDefault(getDefaultSPRM(rSprm.first));
+ RTFValue::Pointer_t const pDefault(getDefaultSPRM(rSprm.first, nStyleType));
if (pDefault)
{
ret.set(rSprm.first, pDefault);
}
else if (!rSprm.second->getSprms().empty() || !rSprm.second->getAttributes().empty())
{
- RTFSprms const sprms(RTFSprms().cloneAndDeduplicate(rSprm.second->getSprms()));
+ RTFSprms const sprms(
+ RTFSprms().cloneAndDeduplicate(rSprm.second->getSprms(), nStyleType));
RTFSprms const attributes(
- RTFSprms().cloneAndDeduplicate(rSprm.second->getAttributes()));
+ RTFSprms().cloneAndDeduplicate(rSprm.second->getAttributes(), nStyleType));
if (!sprms.empty() || !attributes.empty())
{
ret.set(rSprm.first, std::make_shared<RTFValue>(attributes, sprms));
@@ -314,14 +332,14 @@ void RTFSprms::duplicateList(const RTFValue::Pointer_t& pAbstract)
= getNestedAttribute(*this, NS_ooxml::LN_CT_PPrBase_ind, rListLevelPair.first);
if (!pParagraphValue)
putNestedAttribute(*this, NS_ooxml::LN_CT_PPrBase_ind, rListLevelPair.first,
- getDefaultSPRM(rListLevelPair.first));
+ getDefaultSPRM(rListLevelPair.first, 0));
break;
}
}
}
-RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference) const
+RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference, Id nStyleType) const
{
RTFSprms ret(*this);
ret.ensureCopyBeforeWrite();
@@ -337,10 +355,10 @@ RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference) const
if (rSprm.first == NS_ooxml::LN_CT_Style_pPr)
{
for (auto& i : rSprm.second->getSprms())
- cloneAndDeduplicateSprm(i, ret);
+ cloneAndDeduplicateSprm(i, ret, nStyleType);
}
else
- cloneAndDeduplicateSprm(rSprm, ret);
+ cloneAndDeduplicateSprm(rSprm, ret, nStyleType);
}
return ret;
}