[Libreoffice-commits] core.git: avmedia/source include/avmedia slideshow/source

Caolán McNamara caolanm at redhat.com
Fri Oct 4 12:21:32 PDT 2013


 avmedia/source/viewer/mediawindow.cxx             |   15 ++++++--
 include/avmedia/mediawindow.hxx                   |    4 ++
 slideshow/source/engine/shapes/viewmediashape.cxx |   41 +++++++++++++++++++---
 3 files changed, 53 insertions(+), 7 deletions(-)

New commits:
commit 507c1c9905ce02c376be4e57a937cde8d01d2c26
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 4 14:48:11 2013 +0100

    Resolves: rhbz#1012379 draw audio-placeholder in presentation mode
    
    Change-Id: Ied61f9b4947e1a6eda04c442d95037cc1c7ef460

diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
index 02e5b63..183a955 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -433,7 +433,7 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
 
             if( !aPrefSize.Width && !aPrefSize.Height )
             {
-                const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) );
+                const BitmapEx aBmpEx( getAudioLogo() );
                 apGraphic.reset( new Graphic( aBmpEx ) );
             }
         }
@@ -441,7 +441,7 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
 
     if( !xRet.is() && !apGraphic.get() && bAllowToCreateReplacementGraphic )
     {
-        const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) );
+        const BitmapEx aBmpEx( getEmptyLogo() );
         apGraphic.reset( new Graphic( aBmpEx ) );
     }
 
@@ -451,6 +451,17 @@ uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL
     return xRet;
 }
 
+BitmapEx MediaWindow::getAudioLogo()
+{
+    return BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_AUDIOLOGO));
+}
+
+BitmapEx MediaWindow::getEmptyLogo()
+{
+    return BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_EMPTYLOGO));
+}
+
+
 } // namespace avemdia
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx
index a5cb5dc..dcf4f36 100644
--- a/include/avmedia/mediawindow.hxx
+++ b/include/avmedia/mediawindow.hxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/media/XPlayer.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
+#include <vcl/bitmapex.hxx>
 #include <avmedia/avmediadllapi.h>
 
 #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0
@@ -107,6 +108,9 @@ namespace avmedia
                                                                                                   bool bAllowToCreateReplacementGraphic = false,
                                                                                                   double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME );
 
+        static BitmapEx getAudioLogo();
+        static BitmapEx getEmptyLogo();
+
     private:
 
                     // default: disabled copy/assignment
diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx
index 2da034a..b788a0f 100644
--- a/slideshow/source/engine/shapes/viewmediashape.cxx
+++ b/slideshow/source/engine/shapes/viewmediashape.cxx
@@ -28,10 +28,12 @@
 #include <comphelper/anytostring.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 
-#include <vcl/window.hxx>
+#include <vcl/canvastools.hxx>
 #include <vcl/syschild.hxx>
+#include <vcl/window.hxx>
 
 #include <basegfx/tools/canvastools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <basegfx/numeric/ftools.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/point/b2dpoint.hxx>
@@ -184,10 +186,32 @@ namespace slideshow
 
             if( !mpMediaWindow.get() && !mxPlayerWindow.is() )
             {
-                // fill the shape background with black
-                fillRect( pCanvas,
-                          rBounds,
-                          0x000000FFU );
+                // draw placeholder for no-video (no window) case
+                // no window and player == audio icon
+                // no window and no player == broken icon
+                BitmapEx aAudioLogo(mxPlayer.is() ?
+                    avmedia::MediaWindow::getAudioLogo() : avmedia::MediaWindow::getEmptyLogo() );
+
+                uno::Reference< rendering::XBitmap > xBitmap(vcl::unotools::xBitmapFromBitmapEx(
+                    pCanvas->getUNOCanvas()->getDevice(), aAudioLogo));
+
+                rendering::ViewState aViewState;
+                aViewState.AffineTransform = pCanvas->getViewState().AffineTransform;
+
+                rendering::RenderState aRenderState;
+                ::canvas::tools::initRenderState( aRenderState );
+
+                const ::Size aBmpSize( aAudioLogo.GetSizePixel() );
+
+                const ::basegfx::B2DVector aScale( rBounds.getWidth() / aBmpSize.Width(),
+                                                   rBounds.getHeight() / aBmpSize.Height() );
+                const basegfx::B2DHomMatrix aTranslation(basegfx::tools::createScaleTranslateB2DHomMatrix(
+                    aScale, rBounds.getMinimum()));
+                ::canvas::tools::setRenderStateTransform( aRenderState, aTranslation );
+
+                pCanvas->getUNOCanvas()->drawBitmap( xBitmap,
+                                                     aViewState,
+                                                     aRenderState );
             }
 
             return true;
@@ -463,6 +487,13 @@ namespace slideshow
                                     mxPlayerWindow->setEnable( true );
                                 }
                             }
+
+                            if( !mxPlayerWindow.is() )
+                            {
+                                //if there was no playerwindow, then clear the mpMediaWindow too
+                                //so that we can draw a placeholder instead in that space
+                                mpMediaWindow.reset();
+                            }
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list