sd/qa/unit/data/pptx/LostPlaceholder.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx       |   35 ++++++++++++++++++++++++++++++-
 sd/source/filter/eppt/pptx-epptooxml.cxx |   17 +++++++++++----
 3 files changed, 47 insertions(+), 5 deletions(-)

New commits:
commit 6dc0e26f9b88fc8490315ac97d23630f014ee4a9
Author:     Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu>
AuthorDate: Tue Apr 20 13:02:44 2021 +0200
Commit:     Balazs Varga <varga.bala...@nisz.hu>
CommitDate: Thu Oct 21 09:39:59 2021 +0200

    tdf#111903 tdf#137152 PPTX export: fix placeholders
    
    Empty placeholders were exported as white empty
    custom shapes, losing their visibility and usability.
    
    Note: export of properties hasn't been implemented, yet.
    
    Change-Id: Ie8bd6a611f5fb43bcaa55f6b2f5b07daf731b163
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114331
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123856
    Tested-by: Balazs Varga <varga.bala...@nisz.hu>
    Reviewed-by: Balazs Varga <varga.bala...@nisz.hu>

diff --git a/sd/qa/unit/data/pptx/LostPlaceholder.odp 
b/sd/qa/unit/data/pptx/LostPlaceholder.odp
new file mode 100644
index 000000000000..80ead189f260
Binary files /dev/null and b/sd/qa/unit/data/pptx/LostPlaceholder.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index d0837001ceca..a6b0c428aff1 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -62,6 +62,7 @@ public:
     void testN828390_4();
     void testN828390_5();
     void testFdo71961();
+    void testLostPlaceholders();
     void testN828390();
     void testBnc880763();
     void testBnc862510_5();
@@ -114,6 +115,7 @@ public:
     CPPUNIT_TEST(testN828390_4);
     CPPUNIT_TEST(testN828390_5);
     CPPUNIT_TEST(testFdo71961);
+    CPPUNIT_TEST(testLostPlaceholders);
     CPPUNIT_TEST(testN828390);
     CPPUNIT_TEST(testBnc880763);
     CPPUNIT_TEST(testBnc862510_5);
@@ -361,6 +363,37 @@ void SdOOXMLExportTest1::testN828390_5()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testLostPlaceholders()
+{
+    ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/LostPlaceholder.odp"),
 ODP);
+    CPPUNIT_ASSERT(xDocShRef.is());
+
+    xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
+    CPPUNIT_ASSERT(xDocShRef.is());
+
+    auto pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT(pDoc);
+    auto pPage = pDoc->GetPage(1);
+    CPPUNIT_ASSERT(pPage);
+    auto pObj = pPage->GetObj(1);
+    CPPUNIT_ASSERT(pObj);
+    uno::Reference<drawing::XShape> xShp (pObj->getUnoShape(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xShp);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ShapeType!", 
OUString(u"com.sun.star.presentation.OutlinerShape"), xShp->getShapeType());
+    uno::Reference<beans::XPropertySet> xShpProps(xShp, uno::UNO_QUERY);
+    // Without the fix in place there will be the following error:
+    // Expected: com.sun.star.presentation.OutlinerShape
+    // Actual: com.sun.star.drawing.CustomShape
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("It must be a placeholder!", true, 
xShpProps->getPropertyValue("IsPresentationObject").get<bool>());
+    // Without the fix in place this will the following:
+    // Expected: true
+    // Actual: false
+
+    xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest1::testFdo71961()
 {
     ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP);
@@ -370,7 +403,7 @@ void SdOOXMLExportTest1::testFdo71961()
 
     // Export to .pptx changes all text frames to custom shape objects, which 
obey TextWordWrap property
     // (which is false for text frames otherwise and is ignored). Check that 
frames that should wrap still do.
-    SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( 
pPage->GetObj( 1 ));
+    auto  pTxtObj = pPage->GetObj( 1 );
     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
     CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), 
pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
     CPPUNIT_ASSERT_EQUAL( true, 
pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index c734bf10f0f5..2579d5627148 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1438,13 +1438,22 @@ ShapeExport& 
PowerPointShapeExport::WritePageShape(const Reference< XShape >& xS
 bool PowerPointShapeExport::WritePlaceholder(const Reference< XShape >& 
xShape, PlaceholderType ePlaceholder, bool bMaster)
 {
     SAL_INFO("sd.eppt", "WritePlaceholder " << bMaster << " " << 
ShapeExport::NonEmptyText(xShape));
-    if (bMaster && ShapeExport::NonEmptyText(xShape))
+    if (!xShape)
+        return false;
+    try
     {
-        WritePlaceholderShape(xShape, ePlaceholder);
+        Reference<XPropertySet> xShapeProps(xShape, UNO_QUERY);
+        if (xShapeProps->getPropertyValue("IsPresentationObject").get<bool>())
+        {
+            WritePlaceholderShape(xShape, ePlaceholder);
 
-        return true;
+            return true;
+        }
+    }
+    catch (Exception&)
+    {
+        return false;
     }
-
     return false;
 }
 

Reply via email to