tdf#47365 PPTX export: support loop attribute

Follow-up to commit ad2809b4b6dc4837b0c1cadd89a14a234d995fb2
"tdf#47365: import support for PPTX presentation's loop attribute".

Change-Id: I7f75acc2bbd6301384883691d5ef4069b1757a05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116560
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/include/oox/token/relationship.hxx b/include/oox/token/relationship.hxx
index 3f798b1..3c3a433 100644
--- a/include/oox/token/relationship.hxx
+++ b/include/oox/token/relationship.hxx
@@ -52,6 +52,7 @@ enum class Relationship
    OFFICEDOCUMENT,
    OLEOBJECT,
    PACKAGE,
    PRESPROPS,
    SETTINGS,
    SHAREDSTRINGS,
    SLIDE,
diff --git a/oox/source/token/relationship.inc b/oox/source/token/relationship.inc
index f549627..4a77267 100644
--- a/oox/source/token/relationship.inc
+++ b/oox/source/token/relationship.inc
@@ -32,6 +32,7 @@
{Relationship::OFFICEDOCUMENT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},
{Relationship::OLEOBJECT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"},
{Relationship::PACKAGE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"},
{Relationship::PRESPROPS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"},
{Relationship::SETTINGS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"},
{Relationship::SHAREDSTRINGS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"},
{Relationship::SLIDE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"},
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index d5c2d8d..a450e6d 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
class SdOOXMLExportTest1 : public SdModelTestBaseXML
{
public:
    void testTdf47365();
    void testTdf125071();
    void testTdf54037();
    void testFdo90607();
@@ -119,6 +120,7 @@ public:

    CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);

    CPPUNIT_TEST(testTdf47365);
    CPPUNIT_TEST(testTdf125071);
    CPPUNIT_TEST(testTdf54037);
    CPPUNIT_TEST(testFdo90607);
@@ -204,6 +206,20 @@ void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal, sal_uInt32 nId

}

void SdOOXMLExportTest1::testTdf47365()
{
    sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX );
    utl::TempFile tempFile;
    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
    xDocShRef->DoClose();

    xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/presProps.xml");

    assertXPath(pXmlDoc, "/p:presentationPr/p:showPr", "loop", "1");

    assertXPath(pXmlDoc, "/p:presentationPr/p:showPr", "showNarration", "1");
}

void SdOOXMLExportTest1::testTdf125071()
{
    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf125071.pptx"), PPTX);
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 43beea7c..93029f0 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -151,6 +151,8 @@ private:

    void WriteAuthors();

    void WritePresentationProps();

    /// If this is PPTM, output the VBA stream.
    void WriteVBA();
};
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index a1a6dd6..6a85023 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -50,6 +50,7 @@
#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>

#include <oox/export/utils.hxx>

@@ -71,6 +72,10 @@
                      FSNS(XML_xmlns, XML_p15), OUStringToOString(this->getNamespaceURL(OOX_NS(p15)), RTL_TEXTENCODING_UTF8).getStr(), \
                      FSNS(XML_xmlns, XML_mc),  OUStringToOString(this->getNamespaceURL(OOX_NS(mce)), RTL_TEXTENCODING_UTF8).getStr()

// presentationPr namespace
#define PPRNMSS       FSNS(XML_xmlns, XML_a),   OUStringToOString(this->getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(), \
                      FSNS(XML_xmlns, XML_r),   OUStringToOString(this->getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr(), \
                      FSNS(XML_xmlns, XML_p),   OUStringToOString(this->getNamespaceURL(OOX_NS(ppt)), RTL_TEXTENCODING_UTF8).getStr()

using namespace ::com::sun::star;
using namespace ::com::sun::star::animations;
@@ -441,6 +446,8 @@ bool PowerPointExport::exportDocument()

    WriteCustomSlideShow();

    WritePresentationProps();

    WriteAuthors();

    WriteVBA();
@@ -1052,6 +1059,31 @@ sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor, sal
    return maAuthors[ sAuthor ].nId;
}

void PowerPointExport::WritePresentationProps()
{
    Reference<XPresentationSupplier> xPresentationSupplier(mXModel, uno::UNO_QUERY);
    if (xPresentationSupplier.is())
    {
        Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
                                                          uno::UNO_QUERY);
        bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>();

        FSHelperPtr pFS = openFragmentStreamWithSerializer(
            "ppt/presProps.xml",
            "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml");

        addRelation(mPresentationFS->getOutputStream(),
                    oox::getRelationship(Relationship::PRESPROPS), u"presProps.xml");

        pFS->startElementNS(XML_p, XML_presentationPr, PPRNMSS);

        pFS->singleElementNS(XML_p, XML_showPr, XML_loop, sax_fastparser::UseIf("1", bEndlessVal),
                             XML_showNarration, sax_fastparser::UseIf("1", bEndlessVal));

        pFS->endElementNS(XML_p, XML_presentationPr);
    }
}

bool PowerPointExport::WriteComments(sal_uInt32 nPageNum)
{
    Reference< XAnnotationAccess > xAnnotationAccess(mXDrawPage, uno::UNO_QUERY);