tdf#112557: Subtitle placeholder shape leads to corrupted PPTX file

Reviewed-on: https://gerrit.libreoffice.org/42611
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 238cfa9efa21f08514703ea6cc181ce02d8feb12)

Change-Id: I26680ecdb5f0db4f27180c221de062341af0265c
Reviewed-on: https://gerrit.libreoffice.org/42650
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sd/qa/unit/data/odp/tdf112557.odp b/sd/qa/unit/data/odp/tdf112557.odp
new file mode 100755
index 0000000..5587e7f
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf112557.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 3300dc4..c7311ef 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -102,6 +102,7 @@ public:
    void testTdf59046();
    void testTdf105739();
    void testTdf112552();
    void testTdf112557();

    CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);

@@ -127,6 +128,7 @@ public:
    CPPUNIT_TEST(testTdf59046);
    CPPUNIT_TEST(testTdf105739);
    CPPUNIT_TEST(testTdf112552);
    CPPUNIT_TEST(testTdf112557);

    CPPUNIT_TEST_SUITE_END();

@@ -799,6 +801,18 @@ void SdOOXMLExportTest2::testTdf112552()
    xDocShRef->DoClose();
}

void SdOOXMLExportTest2::testTdf112557()
{
    // Subtitle shape should be skipped by export.
    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf112557.odp"), ODP);
    utl::TempFile tempFile;
    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);

    xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slideMasters/slideMaster1.xml");
    assertXPath(pXmlDocContent, "/p:sldMaster/p:cSld/p:spTree/p:sp", 2); // title and object
    xDocShRef->DoClose();
}

CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);

CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index cf5a37d..d5b9783 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -305,8 +305,11 @@ ShapeExport& PowerPointShapeExport::WriteUnknownShape( const Reference< XShape >
    }
    else if ( sShapeType == "com.sun.star.presentation.SubtitleShape" )
    {
        if( !WritePlaceholder( xShape, Subtitle, mbMaster ) )
            ShapeExport::WriteTextShape( xShape );
        if(mePageType != MASTER)
        {
            if( !WritePlaceholder( xShape, Subtitle, mbMaster ) )
                ShapeExport::WriteTextShape( xShape );
        }
    }

    return *this;
@@ -1714,7 +1717,7 @@ void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPr
    pFS->startElementNS( XML_p, XML_cSld, FSEND );

    ImplWriteBackground( pFS, aXBackgroundPropSet );
    WriteShapeTree( pFS, LAYOUT, true );
    WriteShapeTree( pFS, MASTER, true );

    pFS->endElementNS( XML_p, XML_cSld );

@@ -1871,7 +1874,7 @@ void PowerPointExport::WriteShapeTree( const FSHelperPtr& pFS, PageType ePageTyp

ShapeExport& PowerPointShapeExport::WritePageShape( const Reference< XShape >& xShape, PageType ePageType, bool bPresObj )
{
    if( ( ePageType == NOTICE && bPresObj ) || ePageType == LAYOUT )
    if( ( ePageType == NOTICE && bPresObj ) || ePageType == LAYOUT || ePageType == MASTER )
        return WritePlaceholderShape( xShape, SlideImage );

    return WriteTextShape( xShape );