summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-12 16:08:34 +0200
committerAndras Timar <andras.timar@collabora.com>2014-09-17 09:59:32 +0000
commit23a817342f264bde5b6d4cb6b00b298c7b930430 (patch)
tree51254ab17946ee55d4fd1cc545edcab47607889c /oox
parent4ecfac2e86492dda389d16ab4a9690445201f469 (diff)
bnc#591147: OOXML import: Import video file too.
Change-Id: Ie9b6c5ff866269e5d7a26d025cb1c0d884ff1134 (cherry picked from commit b7006f3c2f8f71f4d4721c6e5cdc122628c756f0) Reviewed-on: https://gerrit.libreoffice.org/11468 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx40
1 files changed, 27 insertions, 13 deletions
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index cd4e75d95a66..1813af42e2e5 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -47,6 +47,22 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::xml::sax;
using namespace ::oox::core;
+static OUString lcl_CopyToTempFile(const OUString& rStream, const oox::core::XmlFilterBase& rFilter)
+{
+ if (rStream.isEmpty())
+ return OUString();
+
+ Reference< XInputStream > xInStrm( rFilter.openInputStream(rStream), UNO_SET_THROW );
+ Reference< XTempFile > xTempFile( TempFile::create(rFilter.getComponentContext()) );
+ Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW );
+ oox::BinaryXOutputStream aOutStrm( xOutStrm, false );
+ oox::BinaryXInputStream aInStrm( xInStrm, false );
+ aInStrm.copyToStream( aOutStrm );
+
+ xTempFile->setRemoveFile( false );
+ return xTempFile->getUri();
+}
+
namespace oox {
namespace drawingml {
@@ -70,19 +86,17 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
case XML_wavAudioFile:
{
getEmbeddedWAVAudioFile( getRelations(), rAttribs.getFastAttributeList(), mpShapePtr->getGraphicProperties().maAudio );
- if( !mpShapePtr->getGraphicProperties().maAudio.msEmbed.isEmpty() )
- {
- Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
- Reference< XInputStream > xInStrm( getFilter().openInputStream( mpShapePtr->getGraphicProperties().maAudio.msEmbed ), UNO_SET_THROW );
- Reference< XTempFile > xTempFile( TempFile::create(xContext) );
- Reference< XOutputStream > xOutStrm( xTempFile->getOutputStream(), UNO_SET_THROW );
- BinaryXOutputStream aOutStrm( xOutStrm, false );
- BinaryXInputStream aInStrm( xInStrm, false );
- aInStrm.copyToStream( aOutStrm );
-
- xTempFile->setRemoveFile( false );
- mpShapePtr->getGraphicProperties().maAudio.msEmbed = xTempFile->getUri();
- }
+ mpShapePtr->getGraphicProperties().maAudio.msEmbed =
+ lcl_CopyToTempFile( mpShapePtr->getGraphicProperties().maAudio.msEmbed, getFilter() );
+ }
+ break;
+ case XML_audioFile:
+ case XML_videoFile:
+ {
+ OUString rPath = getRelations().getFragmentPathFromRelId(
+ rAttribs.getString(R_TOKEN(link)).get() );
+ mpShapePtr->getGraphicProperties().maAudio.msEmbed =
+ lcl_CopyToTempFile( rPath, getFilter() );
}
break;
}