summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-23 07:49:49 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-10-01 09:23:43 +0000
commitc33af041298fc4897ee1215efda488654955ebf7 (patch)
treeb857deff2a7b60be020081b6650d776b8195dc3d
parent7abfe85709bba387c1ce224e5ec8cfebc8a00130 (diff)
tdf#92124 DOCX import: don't add a dummy Suffix for an empty LabelFollowedBy
(cherry picked from commit 3e27df1035677c7cca5200858d5d8e8283bf7aa9) Conflicts: sw/qa/extras/ooxmlimport/ooxmlimport.cxx writerfilter/source/dmapper/NumberingManager.cxx Change-Id: I0c4366ad0a2f81a198860869f670767343a392be Reviewed-on: https://gerrit.libreoffice.org/19032 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf92124.docxbin0 -> 7042 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx13
3 files changed, 24 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf92124.docx b/sw/qa/extras/ooxmlimport/data/tdf92124.docx
new file mode 100644
index 000000000000..2999311930eb
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf92124.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index c36cc1761d61..b00b53254e68 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2783,6 +2783,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf92454, "tdf92454.docx")
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, xParagraph->getPropertyState("ParaFirstLineIndent"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf92124, "tdf92124.docx")
+{
+ // Get the second paragraph's numbering style's 1st level's suffix.
+ uno::Reference<text::XTextRange> xParagraph = getParagraph(2);
+ auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules");
+ uno::Sequence<beans::PropertyValue> aLevel;
+ xLevels->getByIndex(0) >>= aLevel; // 1st level
+ OUString aSuffix = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "Suffix"; })->Value.get<OUString>();
+ // Make sure it's empty as the source document contains <w:suff w:val="nothing"/>.
+ CPPUNIT_ASSERT(aSuffix.isEmpty());
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index b19b8618b2f7..e9b8a46c14c4 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -632,7 +632,18 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
if (aMap.find("NumberingType") != aMap.end())
{
sal_Int16 nNumberFormat = aMap["NumberingType"].get<sal_Int16>();
- if (nNumberFormat == style::NumberingType::NUMBER_NONE)
+
+ // No need for a zero width space without a real LabelFollowedBy.
+ bool bLabelFollowedBy = true;
+ auto it = std::find_if(aLvlProps.begin(), aLvlProps.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "LabelFollowedBy"; });
+ if (it != aLvlProps.end())
+ {
+ sal_Int16 nValue;
+ if (it->Value >>= nValue)
+ bLabelFollowedBy = nValue != SvxNumberFormat::NOTHING;
+ }
+
+ if (bLabelFollowedBy && nNumberFormat == style::NumberingType::NUMBER_NONE)
rSuffix = OUString(static_cast<sal_Unicode>(0x200B));
}
}