oox/source/core/xmlfilterbase.cxx | 10 ++++------ sw/qa/extras/ooxmlexport/data/tdf143175.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 13 +++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-)
New commits: commit 965639aec1407c25bed1716a1f2c3ee19923ec1a Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Sat Jul 3 21:00:20 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Jul 4 09:10:32 2021 +0200 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.gran...@collabora.co.uk> diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 307949ae4076..b2184e7a97d8 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 000000000000..bcfbd2db763b Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf143175.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index fb21f41284b4..24c4ecbce63d 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); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits