[Libreoffice-commits] .: oox/source

Muthu Subramanian sumuthu at kemper.freedesktop.org
Mon Apr 2 04:53:00 PDT 2012


 oox/source/drawingml/fillproperties.cxx      |    4 ++--
 oox/source/drawingml/graphicshapecontext.cxx |   21 ++++++++++++++++++++-
 oox/source/drawingml/shape.cxx               |   15 +++++++++++++--
 oox/source/token/properties.txt              |    3 +++
 4 files changed, 38 insertions(+), 5 deletions(-)

New commits:
commit 8866e1986d354f0eb7eb26d78e6b6a22c6fda632
Author: Muthu Subramanian <sumuthu at suse.com>
Date:   Mon Apr 2 17:33:32 2012 +0530

    n747499: PPTX embedded media playback.
    
    Currently plays the embedded audio files.
    The image for the audio file seems to be
    rendered bad, currently.

diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 07df75d..4a94c01 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -440,9 +440,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
     if( nContrast != 0 )
         rPropMap[ PROP_AdjustContrast ] <<= nContrast;
 
-    // TODO: Audio content, yet to be implemented
+    // Media content
     if( !maAudio.msEmbed.isEmpty() )
-        rPropMap[ PROP_Sound ] <<= maAudio.msEmbed;
+        rPropMap[ PROP_MediaURL ] <<= maAudio.msEmbed;
 }
 
 // ============================================================================
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index f01854c..2230a3b 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -26,6 +26,7 @@
  *
  ************************************************************************/
 
+#include <com/sun/star/io/XTempFile.hpp>
 #include "oox/drawingml/graphicshapecontext.hxx"
 #include <osl/diagnose.h>
 
@@ -42,6 +43,9 @@
 #include "oox/vml/vmlshapecontainer.hxx"
 #include "oox/drawingml/fillproperties.hxx"
 #include "oox/drawingml/transform2dcontext.hxx"
+#include "oox/helper/binaryinputstream.hxx"
+#include "oox/helper/binaryoutputstream.hxx"
+#include <comphelper/processfactory.hxx>
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
@@ -77,7 +81,22 @@ Reference< XFastContextHandler > GraphicShapeContext::createFastChildContext( sa
         xRet.set( new BlipFillContext( *this, xAttribs, mpShapePtr->getGraphicProperties().maBlipProps ) );
         break;
     case XML_wavAudioFile:
-        getEmbeddedWAVAudioFile( getRelations(), xAttribs, mpShapePtr->getGraphicProperties().maAudio );
+        {
+            getEmbeddedWAVAudioFile( getRelations(), xAttribs, mpShapePtr->getGraphicProperties().maAudio );
+            if( !mpShapePtr->getGraphicProperties().maAudio.msEmbed.isEmpty() )
+            {
+                Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
+                Reference< XInputStream > xInStrm( getFilter().openInputStream( mpShapePtr->getGraphicProperties().maAudio.msEmbed ), UNO_SET_THROW );
+                Reference< XTempFile > xTempFile( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TempFile" ) ), UNO_QUERY_THROW );
+                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();
+            }
+        }
         break;
     }
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index d9f30f7..01ee819 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -330,11 +330,22 @@ Reference< XShape > Shape::createAndInsert(
         sal_Bool bClearText,
         basegfx::B2DHomMatrix& aParentTransformation )
 {
+    bool bIsEmbMedia = false;
     OSL_TRACE("Shape::createAndInsert id: %s", rtl::OUStringToOString(msId, RTL_TEXTENCODING_UTF8 ).getStr());
 
     awt::Rectangle aShapeRectHmm( maPosition.X / 360, maPosition.Y / 360, maSize.Width / 360, maSize.Height / 360 );
 
-    OUString aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
+    OUString aServiceName;
+    if( rServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicObjectShape") ) &&
+        mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->maAudio.msEmbed.isEmpty() )
+    {
+        aServiceName = finalizeServiceName( rFilterBase, OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.MediaShape" ) ), aShapeRectHmm );
+        bIsEmbMedia = true;
+    }
+    else
+    {
+        aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
+    }
     sal_Bool bIsCustomShape = aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShape" ) ) || aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ConnectorShape" ) );
 
     basegfx::B2DHomMatrix aTransformation;
@@ -518,7 +529,7 @@ Reference< XShape > Shape::createAndInsert(
         // applying properties
         aShapeProps.assignUsed( getShapeProperties() );
         aShapeProps.assignUsed( maDefaultShapeProperties );
-        if ( aServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) )
+        if ( bIsEmbMedia || aServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) )
             mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
         if ( mpTablePropertiesPtr.get() && aServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) )
             mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 97555c8..7ad1a4c 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -285,6 +285,7 @@ MarkPosition
 MaxFieldCount
 MaxTextLen
 MediaType
+MediaURL
 MinorTickmarks
 MirroredX
 MirroredY
@@ -345,6 +346,8 @@ PrintDownFirst
 PrintGrid
 PrintHeaders
 Printable
+PrivateStream
+PrivateTempFileURL
 ProgressValueMax
 ProgressValueMin
 Protected


More information about the Libreoffice-commits mailing list