summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-04-20 13:02:44 +0200
committerLászló Németh <nemeth@numbertext.org>2021-04-29 10:48:27 +0200
commitb6b02e0b4c9d739836e1f61a886ea45b01e6696e (patch)
tree5a50d8696222361f7903a45f595dcdaab37c1917
parent80d7bedee20eb191b1f5a6b2767630eb823d63b2 (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sd/qa/unit/data/pptx/LostPlaceholder.odpbin0 -> 13206 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx35
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx17
3 files changed, 47 insertions, 5 deletions
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
--- /dev/null
+++ b/sd/qa/unit/data/pptx/LostPlaceholder.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index fded47a1c2c9..0be65e22ee13 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -69,6 +69,7 @@ public:
void testN828390_4();
void testN828390_5();
void testFdo71961();
+ void testLostPlaceholders();
void testN828390();
void testBnc880763();
void testBnc862510_5();
@@ -122,6 +123,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);
@@ -370,6 +372,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(u"/sd/qa/unit/data/fdo71961.odp"), ODP);
@@ -379,7 +412,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 d87f51a07712..fa1a55ac6b5f 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1439,13 +1439,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;
}