summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2022-04-06 16:18:29 +0200
committerAndras Timar <andras.timar@collabora.com>2022-04-27 13:20:02 +0200
commit272a1403164cdd236e33af8e72fbecae23907d91 (patch)
tree8c85faeff22adc2c9a27c9896ab6eec12e5ba3bf
parent124de76ff63dfd0393ff3fa038ad0bc594ad3ff8 (diff)
tdf#53970 PPTX: fix import of linked media files
Linked media files were imported as images in documents created with Impress after PPTX export. Change-Id: If4920c2e40f45fff73eca4a5fa987d524177597e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132635 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 9564747d2fd5d2c859a359dd7fa6242c6859c0d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133410 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--oox/source/drawingml/fillproperties.cxx6
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx32
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx19
3 files changed, 45 insertions, 12 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 2b682bcd1b99..e3830618522b 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -954,11 +954,11 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
rPropMap.setProperty(PROP_AdjustContrast, nContrast);
// Media content
- assert(m_xMediaStream.is() != m_sMediaPackageURL.isEmpty());
- if (m_xMediaStream.is() && !m_sMediaPackageURL.isEmpty())
+ if (!m_sMediaPackageURL.isEmpty())
{
- rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL);
+ if (m_xMediaStream.is())
+ rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
}
}
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index 3ed00edfd28c..d90980a87824 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -84,10 +84,12 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
case XML_wavAudioFile:
{
OUString const path(getEmbeddedWAVAudioFile(getRelations(), rAttribs));
- mpShapePtr->getGraphicProperties().m_xMediaStream =
- lcl_GetMediaStream(path, getFilter());
- mpShapePtr->getGraphicProperties().m_sMediaPackageURL =
- lcl_GetMediaReference(path);
+ Reference<XInputStream> xMediaStream = lcl_GetMediaStream(path, getFilter());
+ if (xMediaStream.is())
+ {
+ mpShapePtr->getGraphicProperties().m_xMediaStream = xMediaStream;
+ mpShapePtr->getGraphicProperties().m_sMediaPackageURL = lcl_GetMediaReference(path);
+ }
}
break;
case XML_audioFile:
@@ -95,10 +97,24 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
{
OUString rPath = getRelations().getFragmentPathFromRelId(
rAttribs.getString(R_TOKEN(link)).get() );
- mpShapePtr->getGraphicProperties().m_xMediaStream =
- lcl_GetMediaStream(rPath, getFilter());
- mpShapePtr->getGraphicProperties().m_sMediaPackageURL =
- lcl_GetMediaReference(rPath);
+ if (!rPath.isEmpty())
+ {
+ Reference<XInputStream> xMediaStream = lcl_GetMediaStream(rPath, getFilter());
+ if (xMediaStream.is()) // embedded media file
+ {
+ mpShapePtr->getGraphicProperties().m_xMediaStream = xMediaStream;
+ mpShapePtr->getGraphicProperties().m_sMediaPackageURL
+ = lcl_GetMediaReference(rPath);
+ }
+ }
+ else
+ {
+ rPath = getRelations().getExternalTargetFromRelId(
+ rAttribs.getString(R_TOKEN(link)).get());
+ if (!rPath.isEmpty()) // linked media file
+ mpShapePtr->getGraphicProperties().m_sMediaPackageURL
+ = getFilter().getAbsoluteUrl(rPath);
+ }
}
break;
}
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index dc6498ec614d..0b244bc76233 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1832,11 +1832,28 @@ void SdOOXMLExportTest2::testTdf53970()
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf53970_linked.odp"), ODP);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
- xDocShRef->DoClose();
xmlDocUniquePtr pXmlRels = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
CPPUNIT_ASSERT(pXmlRels);
assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@TargetMode='External']", 2);
+
+ uno::Reference<beans::XPropertySet> xShape(getShape(0, getPage(0, xDocShRef)));
+ CPPUNIT_ASSERT(xShape.is());
+ OUString sVideoURL;
+
+ // Without fix in place, the media shape was imported as an image after export.
+ try
+ {
+ CPPUNIT_ASSERT_MESSAGE("MediaURL property is not set",
+ xShape->getPropertyValue("MediaURL") >>= sVideoURL);
+ }
+ catch (const beans::UnknownPropertyException&)
+ {
+ CPPUNIT_FAIL("Error: MediaURL is unknown property");
+ }
+ CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty());
+
+ xDocShRef->DoClose();
}
}