summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiqi LIU <me@siqi.fr>2013-08-04 13:10:55 +0200
committerSiqi LIU <me@siqi.fr>2013-08-04 14:18:10 +0200
commitdffc87dd13daf9a2f2f629cd50558995aadc4d19 (patch)
tree959406db44ffaed1f86bb935504968573cc1ba16
parenta5468d2a372fd1aba80b4a708c4751fdccf0157a (diff)
pointer display on the screen
Change-Id: I43c91bdf6c364da282d354e5a07f871a9247f2d6
-rw-r--r--sd/source/ui/remotecontrol/Receiver.cxx66
-rw-r--r--slideshow/Library_slideshow.mk1
-rw-r--r--slideshow/source/engine/pointersymbol.cxx23
-rw-r--r--slideshow/source/engine/pointersymbol.hxx11
-rw-r--r--slideshow/source/engine/slideshowimpl.cxx36
-rw-r--r--slideshow/source/engine/waitsymbol.cxx2
6 files changed, 126 insertions, 13 deletions
diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx
index 5ea11e400415..f7a3f8c344e4 100644
--- a/sd/source/ui/remotecontrol/Receiver.cxx
+++ b/sd/source/ui/remotecontrol/Receiver.cxx
@@ -16,14 +16,23 @@
#include <com/sun/star/uno/RuntimeException.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/anytostring.hxx>
+#include "cppuhelper/exc_hlp.hxx"
#include <osl/file.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/presentation/SlideShow.hpp>
using namespace sd;
using namespace ::com::sun::star;
using namespace ::osl;
using namespace std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::presentation;
+using namespace ::com::sun::star::beans;
Receiver::Receiver( Transmitter *aTransmitter )
{
@@ -61,6 +70,7 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
{
uno::Reference<presentation::XSlideShowController> xSlideShowController;
uno::Reference<presentation::XPresentation2> xPresentation;
+ uno::Reference<presentation::XSlideShow> xSlideShow;
try {
uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
@@ -70,6 +80,8 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
// Throws an exception if now slideshow running
xSlideShowController = uno::Reference<presentation::XSlideShowController>(
xPresentation->getController(), uno::UNO_QUERY_THROW );
+ xSlideShow = uno::Reference<presentation::XSlideShow>(
+ xSlideShowController->getSlideShow(), uno::UNO_QUERY_THROW );
}
catch (uno::RuntimeException &)
{
@@ -120,12 +132,43 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
}
else if (aCommand[0].equals( "pointer_started" ))
{
- // xSlideShowController->setPointerMode(true);
+ std::cerr << "pointer_started" << std::endl;
+ SolarMutexGuard aSolarGuard;
+ if (xSlideShow.is()) try
+ {
+ std::cerr << "pointer_started in the is" << std::endl;
+ xSlideShow->setProperty(
+ beans::PropertyValue( "PointerVisible" ,
+ -1,
+ makeAny( true ),
+ beans::PropertyState_DIRECT_VALUE ) );
+ }
+ catch ( Exception& )
+ {
+ SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerMode(), "
+ "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
+ }
SAL_INFO( "sdremote", "Pointer started, we display the pointer on screen" );
}
else if (aCommand[0].equals( "pointer_dismissed" ))
{
- // xSlideShowController->setPointerMode(false);
+ std::cerr << "pointer_dismissed" << std::endl;
+ SolarMutexGuard aSolarGuard;
+ if (xSlideShow.is()) try
+ {
+ std::cerr << "pointer_dismissed in the is" << std::endl;
+ xSlideShow->setProperty(
+ beans::PropertyValue( "PointerVisible" ,
+ -1,
+ makeAny( false ),
+ beans::PropertyState_DIRECT_VALUE ) );
+ }
+ catch ( Exception& )
+ {
+ SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerMode(), "
+ "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
+ }
+
SAL_INFO( "sdremote", "Pointer dismissed, we hide the pointer on screen" );
}
else if (aCommand[0].equals( "pointer_coordination" ))
@@ -135,8 +178,23 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
SAL_INFO( "sdremote", "Pointer at ("<<x<<","<<y<<")" );
const ::com::sun::star::geometry::RealPoint2D pos(x,y);
- // Same problem here...
- // xSlideShowController->setPointerPosition(pos);
+ std::cerr << "Pointer at ("<<pos.X<<","<<pos.Y<<")" << std::endl;
+
+ SolarMutexGuard aSolarGuard;
+ if (xSlideShow.is()) try
+ {
+ std::cerr << "pointer_coordination in the is" << std::endl;
+ xSlideShow->setProperty(
+ beans::PropertyValue( "PointerPosition" ,
+ -1,
+ makeAny( pos ),
+ beans::PropertyState_DIRECT_VALUE ) );
+ }
+ catch ( Exception& )
+ {
+ SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerPosition(), "
+ "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
+ }
}
else if ( aCommand[0].equals( "presentation_resume" ) )
{
diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk
index 3e792554693f..e8485efb26a2 100644
--- a/slideshow/Library_slideshow.mk
+++ b/slideshow/Library_slideshow.mk
@@ -142,6 +142,7 @@ $(eval $(call gb_Library_add_exception_objects,slideshow,\
slideshow/source/engine/unoviewcontainer \
slideshow/source/engine/usereventqueue \
slideshow/source/engine/waitsymbol \
+ slideshow/source/engine/pointersymbol \
slideshow/source/engine/wakeupevent \
))
diff --git a/slideshow/source/engine/pointersymbol.cxx b/slideshow/source/engine/pointersymbol.cxx
index 48ad0e5d1693..8629ea74f413 100644
--- a/slideshow/source/engine/pointersymbol.cxx
+++ b/slideshow/source/engine/pointersymbol.cxx
@@ -28,6 +28,7 @@
#include <basegfx/vector/b2dvector.hxx>
#include <com/sun/star/rendering/XCanvas.hpp>
+#include "com/sun/star/uno/Reference.hxx"
#include "pointersymbol.hxx"
#include "eventmultiplexer.hxx"
@@ -51,8 +52,8 @@ PointerSymbolSharedPtr PointerSymbol::create( const uno::Reference<rendering::XB
{
PointerSymbolSharedPtr pRet(
new PointerSymbol( xBitmap,
- rScreenUpdater,
- rViewContainer ));
+ rScreenUpdater,
+ rViewContainer ));
rEventMultiplexer.addViewHandler( pRet );
@@ -100,8 +101,20 @@ void PointerSymbol::setVisible( const bool bVisible )
}
}
+basegfx::B2DPoint PointerSymbol::calcSpritePos( UnoViewSharedPtr const & rView ) const
+{
+ const uno::Reference<rendering::XBitmap> xBitmap( rView->getCanvas()->getUNOCanvas(),
+ uno::UNO_QUERY_THROW );
+ const geometry::IntegerSize2D realSize( xBitmap->getSize() );
+ return basegfx::B2DPoint(
+ // pos.X pos.Y are given in 0..1, beginning from the upper left corner of the currentSlide.
+ std::min<sal_Int32>( 0, LEFT_BORDER_SPACE ),
+ std::max<sal_Int32>( 0, realSize.Height * 1 - mxBitmap->getSize().Height
+ - LOWER_BORDER_SPACE ) );
+}
+
basegfx::B2DPoint PointerSymbol::calcSpritePos(
- UnoViewSharedPtr const & rView, const ::com::sun::star::geometry::RealPoint2D& pos) const
+ UnoViewSharedPtr const & rView, const ::com::sun::star::geometry::RealPoint2D pos) const
{
const uno::Reference<rendering::XBitmap> xBitmap( rView->getCanvas()->getUNOCanvas(),
uno::UNO_QUERY_THROW );
@@ -195,7 +208,7 @@ void PointerSymbol::viewsChanged()
}
}
-void PointerSymbol::viewsChanged(const ::com::sun::star::geometry::RealPoint2D& pos)
+void PointerSymbol::viewsChanged(const ::com::sun::star::geometry::RealPoint2D pos)
{
// reposition sprites on all views
ViewsVecT::const_iterator aIter( maViews.begin() );
@@ -210,6 +223,6 @@ void PointerSymbol::viewsChanged(const ::com::sun::star::geometry::RealPoint2D&
}
} // namespace internal
-} // namespace presentation
+} // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/source/engine/pointersymbol.hxx b/slideshow/source/engine/pointersymbol.hxx
index 9dc2818d2dd9..77309e712c0a 100644
--- a/slideshow/source/engine/pointersymbol.hxx
+++ b/slideshow/source/engine/pointersymbol.hxx
@@ -14,6 +14,8 @@
#include <com/sun/star/rendering/XBitmap.hpp>
#include <cppcanvas/customsprite.hxx>
+#include "com/sun/star/uno/Reference.hxx"
+
#include "vieweventhandler.hxx"
#include "screenupdater.hxx"
#include "eventmultiplexer.hxx"
@@ -24,6 +26,8 @@
#include <boost/utility.hpp> // for noncopyable
#include <vector>
+using namespace com::sun::star;
+
namespace slideshow {
namespace internal {
@@ -49,7 +53,8 @@ public:
void hide() { setVisible(false); }
/** Use this method to update the pointer's position
*/
- virtual void viewsChanged(const ::com::sun::star::geometry::RealPoint2D& pos);
+ void setVisible( const bool bVisible );
+ virtual void viewsChanged(const ::com::sun::star::geometry::RealPoint2D pos);
private:
PointerSymbol( const ::com::sun::star::uno::Reference<
@@ -63,9 +68,9 @@ private:
virtual void viewChanged( const UnoViewSharedPtr& rView );
virtual void viewsChanged();
- void setVisible( const bool bVisible );
- basegfx::B2DPoint calcSpritePos( UnoViewSharedPtr const & rView, const ::com::sun::star::geometry::RealPoint2D& pos = ::com::sun::star::geometry::RealPoint2D(0, 0) ) const;
+ ::basegfx::B2DPoint calcSpritePos( UnoViewSharedPtr const & rView, const ::com::sun::star::geometry::RealPoint2D pos ) const;
+ ::basegfx::B2DPoint calcSpritePos( UnoViewSharedPtr const & rView ) const;
template <typename func_type>
void for_each_sprite( func_type const & func ) const
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx
index f9e8ed8b58e0..db207a892adb 100644
--- a/slideshow/source/engine/slideshowimpl.cxx
+++ b/slideshow/source/engine/slideshowimpl.cxx
@@ -95,6 +95,7 @@
#include "waitsymbol.hxx"
#include "effectrewinder.hxx"
#include "framerate.hxx"
+#include "pointersymbol.hxx"
#include <boost/noncopyable.hpp>
#include <boost/bind.hpp>
@@ -459,6 +460,8 @@ private:
boost::shared_ptr<RehearseTimingsActivity> mpRehearseTimingsActivity;
boost::shared_ptr<WaitSymbol> mpWaitSymbol;
+ boost::shared_ptr<PointerSymbol> mpPointerSymbol;
+
/// the current slide transition sound object:
SoundPlayerSharedPtr mpCurrentSlideTransitionSound;
@@ -579,6 +582,7 @@ SlideShowImpl::SlideShowImpl(
mpListener(),
mpRehearseTimingsActivity(),
mpWaitSymbol(),
+ mpPointerSymbol(),
mpCurrentSlideTransitionSound(),
mxComponentContext( xContext ),
mxOptionalTransitionFactory(),
@@ -653,6 +657,7 @@ void SlideShowImpl::disposing()
}
mpWaitSymbol.reset();
+ mpPointerSymbol.reset();
if( mpRehearseTimingsActivity )
{
@@ -1777,6 +1782,37 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty )
return true;
}
+ if ( rProperty.Name == "PointerSymbolBitmap" )
+ {
+ uno::Reference<rendering::XBitmap> xBitmap;
+ if (! (rProperty.Value >>= xBitmap))
+ return false;
+
+ mpPointerSymbol = PointerSymbol::create( xBitmap,
+ maScreenUpdater,
+ maEventMultiplexer,
+ maViewContainer );
+
+ return true;
+ }
+
+ if ( rProperty.Name == "PointerVisible" )
+ {
+ bool visible;
+ rProperty.Value >>= visible;
+ mpPointerSymbol->setVisible(visible);
+ }
+
+ if ( rProperty.Name == "PointerPosition")
+ {
+ ::com::sun::star::geometry::RealPoint2D pos;
+ if (! (rProperty.Value >>= pos))
+ return false;
+
+ std::cerr<<"Received pos at :(" << pos.X << ","<<pos.Y << ")" << std::endl;
+ mpPointerSymbol->viewsChanged(pos);
+ }
+
if (rProperty.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("NoSlideTransitions") ))
{
diff --git a/slideshow/source/engine/waitsymbol.cxx b/slideshow/source/engine/waitsymbol.cxx
index 01ce9dbf0def..6c56ac795749 100644
--- a/slideshow/source/engine/waitsymbol.cxx
+++ b/slideshow/source/engine/waitsymbol.cxx
@@ -195,6 +195,6 @@ void WaitSymbol::viewsChanged()
}
} // namespace internal
-} // namespace presentation
+} // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */