[Libreoffice-commits] core.git: sd/qa sd/source

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Fri May 28 10:27:27 UTC 2021


 sd/qa/unit/data/pptx/tdf125071.pptx      |binary
 sd/qa/unit/export-tests-ooxml1.cxx       |   15 +++++++
 sd/source/filter/eppt/epptooxml.hxx      |    4 +
 sd/source/filter/eppt/pptx-epptooxml.cxx |   66 +++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)

New commits:
commit a4b66458a7b8da2f5580014813e5dabe3fa670b6
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Wed May 26 10:22:30 2021 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri May 28 12:26:10 2021 +0200

    tdf#125071 PPTX: fix missing custom slide show export
    
    Follow-up to commit ecf48b2d4f3e54dbb2c1e295120d73e7b7a11338
    "tdf#131390 PPTX: fix custom slide show is not imported".
    
    Change-Id: I2a85e2ea08f6a70cd5f26cfb99a0ff1add2c296a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116177
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sd/qa/unit/data/pptx/tdf125071.pptx b/sd/qa/unit/data/pptx/tdf125071.pptx
new file mode 100644
index 000000000000..42b65ab1f1b2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125071.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index c2d07f5ca092..9395e6eabeab 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 testTdf125071();
     void testTdf54037();
     void testFdo90607();
     void testTdf127237();
@@ -117,6 +118,7 @@ public:
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+    CPPUNIT_TEST(testTdf125071);
     CPPUNIT_TEST(testTdf54037);
     CPPUNIT_TEST(testFdo90607);
     CPPUNIT_TEST(testTdf127237);
@@ -223,6 +225,19 @@ void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal)
 
 }
 
+void SdOOXMLExportTest1::testTdf125071()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf125071.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    xDocShRef->DoClose();
+
+    xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/presentation.xml");
+
+    assertXPath(pXmlDoc, "/p:presentation/p:custShowLst/p:custShow[1]", "name", "Custom1");
+    assertXPath(pXmlDoc, "/p:presentation/p:custShowLst/p:custShow[2]", "name", "Custom2");
+}
+
 void SdOOXMLExportTest1::testTdf54037()
 {
     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf54037.pptx"), PPTX );
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index bedd492ca2b7..43beea7ca032 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -110,6 +110,8 @@ private:
     // Write docProps/core.xml and docprops/custom.xml and docprops/app.xml
     void writeDocumentProperties();
 
+    void WriteCustomSlideShow();
+
     void AddLayoutIdAndRelation( const ::sax_fastparser::FSHelperPtr& pFS, sal_Int32 nLayoutFileId );
 
     virtual OUString SAL_CALL getImplementationName() override;
@@ -134,6 +136,8 @@ private:
 
     sal_uInt32 mnDiagramId;
 
+    std::vector<OUString> maRelId;
+
     bool mbCreateNotes;
 
     ::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap;
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index cee8f7760e4a..089e3bbdffa5 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -47,6 +47,9 @@
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XNamed.hpp>
 
 #include <oox/export/utils.hxx>
 
@@ -436,6 +439,8 @@ bool PowerPointExport::exportDocument()
                                      XML_cx, OString::number(PPTtoEMU(maNotesPageSize.Width)),
                                      XML_cy, OString::number(PPTtoEMU(maNotesPageSize.Height)));
 
+    WriteCustomSlideShow();
+
     WriteAuthors();
 
     WriteVBA();
@@ -449,6 +454,7 @@ bool PowerPointExport::exportDocument()
 
     maShapeMap.clear();
     maAuthors.clear();
+    maRelId.clear();
 
     return true;
 }
@@ -458,6 +464,64 @@ bool PowerPointExport::exportDocument()
     return new ::oox::ole::VbaProject(getComponentContext(), getModel(), u"Impress");
 }
 
+void PowerPointExport::WriteCustomSlideShow()
+{
+    Reference<XCustomPresentationSupplier> aXCPSup(mXModel, css::uno::UNO_QUERY);
+    if (aXCPSup.is() && aXCPSup->getCustomPresentations()->hasElements())
+    {
+        mPresentationFS->startElementNS(XML_p, XML_custShowLst);
+
+        Reference<XDrawPagesSupplier> xDPS(getModel(), uno::UNO_QUERY_THROW);
+        Reference<XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
+        Reference<XNameContainer> aXNameCont(aXCPSup->getCustomPresentations());
+        const Sequence<OUString> aNameSeq(aXNameCont->getElementNames());
+
+        OUString sRelId;
+        sal_uInt32 nCustomShowIndex = 0;
+        sal_Int32 nSlideCount = xDrawPages->getCount();
+
+        for (OUString const& customShowName : aNameSeq)
+        {
+            mPresentationFS->startElementNS(XML_p, XML_custShow, XML_name, customShowName, XML_id,
+                                            OUString::number(nCustomShowIndex++));
+
+            mAny = aXNameCont->getByName(customShowName);
+            Reference<XIndexContainer> aXIContainer;
+            if (mAny >>= aXIContainer)
+            {
+                mPresentationFS->startElementNS(XML_p, XML_sldLst);
+
+                sal_Int32 nCustomShowSlideCount = aXIContainer->getCount();
+                for (sal_Int32 i = 0; i < nCustomShowSlideCount; ++i)
+                {
+                    Reference<XDrawPage> aXCustomShowDrawPage;
+                    aXIContainer->getByIndex(i) >>= aXCustomShowDrawPage;
+                    Reference<XNamed> aXName(aXCustomShowDrawPage, UNO_QUERY_THROW);
+                    OUString sCustomShowSlideName = aXName->getName();
+
+                    for (sal_Int32 j = 0; j < nSlideCount; ++j)
+                    {
+                        Reference<XDrawPage> xDrawPage;
+                        xDrawPages->getByIndex(j) >>= xDrawPage;
+                        Reference<XNamed> xNamed(xDrawPage, UNO_QUERY_THROW);
+                        OUString sSlideName = xNamed->getName();
+
+                        if (sCustomShowSlideName == sSlideName)
+                        {
+                            sRelId = maRelId[j];
+                            break;
+                        }
+                    }
+                    mPresentationFS->singleElementNS(XML_p, XML_sld, FSNS(XML_r, XML_id), sRelId);
+                }
+                mPresentationFS->endElementNS(XML_p, XML_sldLst);
+            }
+            mPresentationFS->endElementNS(XML_p, XML_custShow);
+        }
+        mPresentationFS->endElementNS(XML_p, XML_custShowLst);
+    }
+}
+
 void PowerPointExport::ImplWriteBackground(const FSHelperPtr& pFS, const Reference< XPropertySet >& rXPropSet)
 {
     FillStyle aFillStyle(FillStyle_NONE);
@@ -1088,6 +1152,8 @@ void PowerPointExport::ImplWriteSlide(sal_uInt32 nPageNum, sal_uInt32 nMasterNum
                                      XML_id, OString::number(GetNewSlideId()),
                                      FSNS(XML_r, XML_id), sRelId);
 
+    maRelId.push_back(sRelId);
+
     if (nPageNum == mnPages - 1)
         mPresentationFS->endElementNS(XML_p, XML_sldIdLst);
 


More information about the Libreoffice-commits mailing list