diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-12 16:08:34 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-14 11:29:26 +0200 |
commit | b7006f3c2f8f71f4d4721c6e5cdc122628c756f0 (patch) | |
tree | e33b03acf2c8d6f3497e44a04bf93f635daeb9e2 /oox | |
parent | fce166376335b97bf26bcd895ae785070f393878 (diff) |
bnc#591147: OOXML import: Import video file too.
Change-Id: Ie9b6c5ff866269e5d7a26d025cb1c0d884ff1134
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/graphicshapecontext.cxx | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index e78a3e26d710..f23ee1f003f6 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -48,6 +48,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; } |