summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-26 09:13:05 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-26 11:11:33 +0200
commit56a695fddb915bcba13b088b5b2b4e0841d4acbc (patch)
treea6550018aaceaf9e5265f1633cbcd69c46267b49 /writerfilter
parent4bd1449aa036b88629f22e9516f7f67f6414fbfb (diff)
tdf#112211 RTF import: fix unwanted direct formatting for left indents
Commit f528f9499bd91b700c549575e88fa102cfffede9 (tdf#106953 RTF import: fix missing paragraph left margin, 2017-05-16) fixed a problem around inheriting indents from numbering styles vs paragraph styles, but it turns out that document was rather special and in general the old behavior was correct. So fix that bug in a different way again, this time without less side-effects. The trick is that in case the level numbers group in a list definition ends with \u59 (instead of an ASCII ';'), then that group is considered to be invalid by Word. RTF import already was aware of this, but it wasn't known that when this invalid state is reached, that also means that the indents of the list level definitions should be ignored. So in general not putting direct formatting on a paragraph is a good thing: that way in case the paragraph style and the number style both has indent infos, then the numbering style wins, and that is what we want -- but in case \u59 appears in the list definition, then the indentation from the numbering style should be ignored. So fix up the tokenizer to import the indentation from list levels in general, ignore it for invalid list levels, and then we can remove the direct formatting from the paragraphs, which fixes this bug and keeps the old one fixed as well. This required fixing up two poor testcases, which tested paragraph properties, but in fact are interested in the real source of indentation, which is now the numbering style. Visually both bugdocs are unchanged. Change-Id: I6390aa870659a8ad02ba5512d84dea34dba29e9f
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx10
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx1
3 files changed, 12 insertions, 5 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index bebaee85107e..70d6cbf46f2f 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1373,8 +1373,16 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_FI:
- putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
+ {
+ if (m_aStates.top().eDestination == Destination::LISTLEVEL)
+ {
+ if (m_aStates.top().bLevelNumbersValid)
+ putNestedAttribute(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
+ }
+ else
+ putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
break;
+ }
case RTF_LI:
{
putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_left, pIntValue);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 575562fb2eca..4c6f03ad06c8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2976,9 +2976,9 @@ RTFError RTFDocumentImpl::popState()
if (!m_aStates.empty())
{
m_aStates.top().aTableSprms = aState.aTableSprms;
- if (aState.eDestination == Destination::LEVELNUMBERS)
- // Both current and parent state is levelnumbers: mark parent
- // as invalid as well if necessary.
+ if (m_aStates.top().eDestination == Destination::LEVELNUMBERS || m_aStates.top().eDestination == Destination::LISTLEVEL)
+ // Parent state is level number or list level, current state is
+ // level numbers: mark parent as invalid as well if necessary.
m_aStates.top().bLevelNumbersValid = aState.bLevelNumbersValid;
}
break;
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 34293344240b..d3faf3a145fd 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -164,7 +164,6 @@ static bool isSPRMDeduplicateBlacklist(Id nId)
// Erasing these just because they equal to the style one is
// problematic, as then the used value won't be from the style, but
// possibly from the numbering.
- case NS_ooxml::LN_CT_Ind_left:
case NS_ooxml::LN_CT_Ind_right:
case NS_ooxml::LN_CT_Ind_firstLine:
case NS_ooxml::LN_CT_Ind_hanging: