[Libreoffice-commits] core.git: sd/qa sd/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jan 25 18:24:44 UTC 2021
sd/qa/unit/export-tests-ooxml1.cxx | 6 ++
sd/source/filter/eppt/pptx-animations.cxx | 72 ++++++++++++++++++++++++++----
2 files changed, 70 insertions(+), 8 deletions(-)
New commits:
commit cf5fa358a6bf6e7c0aae2dca1e8fa3334d95ebdb
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jan 25 17:34:28 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jan 25 19:23:59 2021 +0100
PPTX export: fix missing audio anim node for slide narrations
Once the audio node is there, it'll be possible to specify various
custom properties on it in follow-up commits.
Change-Id: I8c00de27de483687eaf76d1661baf59c52711246
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109920
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index e87c04a06cbb..392aa4a8b32e 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1347,6 +1347,12 @@ void SdOOXMLExportTest1::testNarrationMimeType()
// i.e. '<p:cmd type="call">' was written instead of '<p:cmd type="call" cmd="playFrom(0.0)">'.
assertXPath(pSlideDoc, "//p:cmd", "cmd", "playFrom(0.0)");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 0
+ // i.e. <p:childTnLst> had no <p:audio> children, the whole audio animation node was lost.
+ assertXPath(pSlideDoc, "//p:childTnLst/p:audio/p:cMediaNode", 1);
+
xDocShRef->DoClose();
}
diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx
index 533f4804df81..e45ed5783c30 100644
--- a/sd/source/filter/eppt/pptx-animations.cxx
+++ b/sd/source/filter/eppt/pptx-animations.cxx
@@ -54,6 +54,7 @@
#include <com/sun/star/presentation/TextAnimationType.hpp>
#include <com/sun/star/text/XSimpleText.hpp>
#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <oox/export/utils.hxx>
#include <oox/ppt/pptfilterhelpers.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
@@ -652,6 +653,12 @@ public:
PPTXAnimationExport(PowerPointExport& rExport, const FSHelperPtr& pFS);
void WriteAnimations(const Reference<XDrawPage>& rXDrawPage);
};
+
+/// Returns if rURL has an extension which is an audio format.
+bool IsAudioURL(const OUString& rURL)
+{
+ return rURL.endsWithIgnoreAsciiCase(".wav") || rURL.endsWithIgnoreAsciiCase(".m4a");
+}
}
namespace oox::core
@@ -1193,14 +1200,40 @@ void PPTXAnimationExport::WriteAnimationNodeAudio()
Reference<XAudio> xAudio(getCurrentNode(), UNO_QUERY);
OUString sUrl;
+ uno::Reference<drawing::XShape> xShape;
OUString sRelId;
OUString sName;
- if (!(xAudio.is() && (xAudio->getSource() >>= sUrl) && !sUrl.isEmpty()
- && sUrl.endsWithIgnoreAsciiCase(".wav")))
+ if (!xAudio.is())
+ {
return;
+ }
+
+ bool bValid = false;
+ if ((xAudio->getSource() >>= sUrl) && !sUrl.isEmpty() && IsAudioURL(sUrl))
+ {
+ bValid = true;
+ }
- mrPowerPointExport.embedEffectAudio(mpFS, sUrl, sRelId, sName);
+ if (!bValid)
+ {
+ if (xAudio->getSource() >>= xShape)
+ {
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ if (xShapeProps->getPropertyValue("MediaURL") >>= sUrl)
+ {
+ bValid = IsAudioURL(sUrl);
+ }
+ }
+ }
+
+ if (!bValid)
+ return;
+
+ if (!xShape.is())
+ {
+ mrPowerPointExport.embedEffectAudio(mpFS, sUrl, sRelId, sName);
+ }
mpFS->startElementNS(XML_p, XML_audio);
mpFS->startElementNS(XML_p, XML_cMediaNode);
@@ -1211,9 +1244,17 @@ void PPTXAnimationExport::WriteAnimationNodeAudio()
mpFS->endElementNS(XML_p, XML_cTn);
mpFS->startElementNS(XML_p, XML_tgtEl);
- mpFS->singleElementNS(XML_p, XML_sndTgt, FSNS(XML_r, XML_embed),
- sax_fastparser::UseIf(sRelId, !sRelId.isEmpty()), XML_name,
- sax_fastparser::UseIf(sName, !sUrl.isEmpty()));
+ if (xShape.is())
+ {
+ sal_Int32 nShapeID = mrPowerPointExport.GetShapeID(xShape);
+ mpFS->singleElementNS(XML_p, XML_spTgt, XML_spid, OString::number(nShapeID));
+ }
+ else
+ {
+ mpFS->singleElementNS(XML_p, XML_sndTgt, FSNS(XML_r, XML_embed),
+ sax_fastparser::UseIf(sRelId, !sRelId.isEmpty()), XML_name,
+ sax_fastparser::UseIf(sName, !sUrl.isEmpty()));
+ }
mpFS->endElementNS(XML_p, XML_tgtEl);
mpFS->endElementNS(XML_p, XML_cMediaNode);
@@ -1377,8 +1418,23 @@ void NodeContext::initValid(bool bHasValidChild, bool bIsIterateChild)
{
Reference<XAudio> xAudio(mxNode, UNO_QUERY);
OUString sURL;
- mbValid
- = xAudio.is() && (xAudio->getSource() >>= sURL) && sURL.endsWithIgnoreAsciiCase(".wav");
+ uno::Reference<drawing::XShape> xShape;
+ mbValid = false;
+ if (xAudio.is())
+ {
+ if (xAudio->getSource() >>= sURL)
+ {
+ mbValid = IsAudioURL(sURL);
+ }
+ else if (xAudio->getSource() >>= xShape)
+ {
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ if (xShapeProps->getPropertyValue("MediaURL") >>= sURL)
+ {
+ mbValid = IsAudioURL(sURL);
+ }
+ }
+ }
}
else
{
More information about the Libreoffice-commits
mailing list