tdf#143175 - Join elements including a delimiter using a standard iterator
Otherwise, the document's keywords will be duplicated since the first
keyword is written twice. Regression from I19eba57bc6058c317473d0746f06699a09ba2830.
Change-Id: I4c6f840b6e095ca9eaf5ffb53af07280b901e28d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118358
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 307949a..b2184e7 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
#include <comphelper/processfactory.hxx>
#include <oox/core/filterdetect.hxx>
#include <comphelper/stl_types.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/ofopxmlhelper.hxx>
@@ -598,12 +599,9 @@ writeElement( const FSHelperPtr& pDoc, sal_Int32 nXmlElement, const Sequence< OU
return;
OUStringBuffer sRep;
sRep.append( aItems[ 0 ] );
for( const OUString& rItem : aItems )
{
sRep.append( " " + rItem );
}
// tdf#143175 - join elements including a delimiter using a standard iterator
::comphelper::intersperse(aItems.begin(), aItems.end(),
::comphelper::OUStringBufferAppender(sRep), OUString(" "));
writeElement( pDoc, nXmlElement, sRep.makeStringAndClear() );
}
diff --git a/sw/qa/extras/ooxmlexport/data/tdf143175.docx b/sw/qa/extras/ooxmlexport/data/tdf143175.docx
new file mode 100644
index 0000000..bcfbd2d
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf143175.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index fb21f41..24c4ecb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -166,6 +166,19 @@ DECLARE_OOXMLEXPORT_TEST(testUTF8CustomProperties, "tdf127864.docx")
CPPUNIT_ASSERT_EQUAL(OUString(u"первый"), getProperty<OUString>(xPropertySet, u"первый"));
}
DECLARE_OOXMLEXPORT_TEST(testKeywords, "tdf143175.docx")
{
uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(
mxComponent, uno::UNO_QUERY);
uno::Reference<document::XDocumentProperties> xDocumentProperties
= xDocumentPropertiesSupplier->getDocumentProperties();
uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aKeywords.getLength());
CPPUNIT_ASSERT_EQUAL(OUString("One"), aKeywords[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Two"), aKeywords[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Three"), aKeywords[2]);
}
DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);