Kaydet (Commit) dffc87dd authored tarafından Siqi LIU's avatar Siqi LIU

pointer display on the screen

Change-Id: I43c91bdf6c364da282d354e5a07f871a9247f2d6
üst a5468d2a
...@@ -16,14 +16,23 @@ ...@@ -16,14 +16,23 @@
#include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/RuntimeException.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/anytostring.hxx>
#include "cppuhelper/exc_hlp.hxx"
#include <osl/file.hxx> #include <osl/file.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/presentation/SlideShow.hpp>
using namespace sd; using namespace sd;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::osl; using namespace ::osl;
using namespace std; 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 ) Receiver::Receiver( Transmitter *aTransmitter )
{ {
...@@ -61,6 +70,7 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand ) ...@@ -61,6 +70,7 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
{ {
uno::Reference<presentation::XSlideShowController> xSlideShowController; uno::Reference<presentation::XSlideShowController> xSlideShowController;
uno::Reference<presentation::XPresentation2> xPresentation; uno::Reference<presentation::XPresentation2> xPresentation;
uno::Reference<presentation::XSlideShow> xSlideShow;
try { try {
uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() ); uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
...@@ -70,6 +80,8 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand ) ...@@ -70,6 +80,8 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
// Throws an exception if now slideshow running // Throws an exception if now slideshow running
xSlideShowController = uno::Reference<presentation::XSlideShowController>( xSlideShowController = uno::Reference<presentation::XSlideShowController>(
xPresentation->getController(), uno::UNO_QUERY_THROW ); xPresentation->getController(), uno::UNO_QUERY_THROW );
xSlideShow = uno::Reference<presentation::XSlideShow>(
xSlideShowController->getSlideShow(), uno::UNO_QUERY_THROW );
} }
catch (uno::RuntimeException &) catch (uno::RuntimeException &)
{ {
...@@ -120,12 +132,43 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand ) ...@@ -120,12 +132,43 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
} }
else if (aCommand[0].equals( "pointer_started" )) 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" ); SAL_INFO( "sdremote", "Pointer started, we display the pointer on screen" );
} }
else if (aCommand[0].equals( "pointer_dismissed" )) 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" ); SAL_INFO( "sdremote", "Pointer dismissed, we hide the pointer on screen" );
} }
else if (aCommand[0].equals( "pointer_coordination" )) else if (aCommand[0].equals( "pointer_coordination" ))
...@@ -135,8 +178,23 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand ) ...@@ -135,8 +178,23 @@ void Receiver::executeCommand( const std::vector<OString> &aCommand )
SAL_INFO( "sdremote", "Pointer at ("<<x<<","<<y<<")" ); SAL_INFO( "sdremote", "Pointer at ("<<x<<","<<y<<")" );
const ::com::sun::star::geometry::RealPoint2D pos(x,y); const ::com::sun::star::geometry::RealPoint2D pos(x,y);
// Same problem here... std::cerr << "Pointer at ("<<pos.X<<","<<pos.Y<<")" << std::endl;
// xSlideShowController->setPointerPosition(pos);
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" ) ) else if ( aCommand[0].equals( "presentation_resume" ) )
{ {
......
...@@ -142,6 +142,7 @@ $(eval $(call gb_Library_add_exception_objects,slideshow,\ ...@@ -142,6 +142,7 @@ $(eval $(call gb_Library_add_exception_objects,slideshow,\
slideshow/source/engine/unoviewcontainer \ slideshow/source/engine/unoviewcontainer \
slideshow/source/engine/usereventqueue \ slideshow/source/engine/usereventqueue \
slideshow/source/engine/waitsymbol \ slideshow/source/engine/waitsymbol \
slideshow/source/engine/pointersymbol \
slideshow/source/engine/wakeupevent \ slideshow/source/engine/wakeupevent \
)) ))
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2dvector.hxx>
#include <com/sun/star/rendering/XCanvas.hpp> #include <com/sun/star/rendering/XCanvas.hpp>
#include "com/sun/star/uno/Reference.hxx"
#include "pointersymbol.hxx" #include "pointersymbol.hxx"
#include "eventmultiplexer.hxx" #include "eventmultiplexer.hxx"
...@@ -51,8 +52,8 @@ PointerSymbolSharedPtr PointerSymbol::create( const uno::Reference<rendering::XB ...@@ -51,8 +52,8 @@ PointerSymbolSharedPtr PointerSymbol::create( const uno::Reference<rendering::XB
{ {
PointerSymbolSharedPtr pRet( PointerSymbolSharedPtr pRet(
new PointerSymbol( xBitmap, new PointerSymbol( xBitmap,
rScreenUpdater, rScreenUpdater,
rViewContainer )); rViewContainer ));
rEventMultiplexer.addViewHandler( pRet ); rEventMultiplexer.addViewHandler( pRet );
...@@ -100,8 +101,20 @@ void PointerSymbol::setVisible( const bool bVisible ) ...@@ -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( 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(), const uno::Reference<rendering::XBitmap> xBitmap( rView->getCanvas()->getUNOCanvas(),
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
...@@ -195,7 +208,7 @@ void PointerSymbol::viewsChanged() ...@@ -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 // reposition sprites on all views
ViewsVecT::const_iterator aIter( maViews.begin() ); ViewsVecT::const_iterator aIter( maViews.begin() );
...@@ -210,6 +223,6 @@ void PointerSymbol::viewsChanged(const ::com::sun::star::geometry::RealPoint2D& ...@@ -210,6 +223,6 @@ void PointerSymbol::viewsChanged(const ::com::sun::star::geometry::RealPoint2D&
} }
} // namespace internal } // namespace internal
} // namespace presentation } // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <com/sun/star/rendering/XBitmap.hpp> #include <com/sun/star/rendering/XBitmap.hpp>
#include <cppcanvas/customsprite.hxx> #include <cppcanvas/customsprite.hxx>
#include "com/sun/star/uno/Reference.hxx"
#include "vieweventhandler.hxx" #include "vieweventhandler.hxx"
#include "screenupdater.hxx" #include "screenupdater.hxx"
#include "eventmultiplexer.hxx" #include "eventmultiplexer.hxx"
...@@ -24,6 +26,8 @@ ...@@ -24,6 +26,8 @@
#include <boost/utility.hpp> // for noncopyable #include <boost/utility.hpp> // for noncopyable
#include <vector> #include <vector>
using namespace com::sun::star;
namespace slideshow { namespace slideshow {
namespace internal { namespace internal {
...@@ -49,7 +53,8 @@ public: ...@@ -49,7 +53,8 @@ public:
void hide() { setVisible(false); } void hide() { setVisible(false); }
/** Use this method to update the pointer's position /** 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: private:
PointerSymbol( const ::com::sun::star::uno::Reference< PointerSymbol( const ::com::sun::star::uno::Reference<
...@@ -63,9 +68,9 @@ private: ...@@ -63,9 +68,9 @@ private:
virtual void viewChanged( const UnoViewSharedPtr& rView ); virtual void viewChanged( const UnoViewSharedPtr& rView );
virtual void viewsChanged(); 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> template <typename func_type>
void for_each_sprite( func_type const & func ) const void for_each_sprite( func_type const & func ) const
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
#include "waitsymbol.hxx" #include "waitsymbol.hxx"
#include "effectrewinder.hxx" #include "effectrewinder.hxx"
#include "framerate.hxx" #include "framerate.hxx"
#include "pointersymbol.hxx"
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
...@@ -459,6 +460,8 @@ private: ...@@ -459,6 +460,8 @@ private:
boost::shared_ptr<RehearseTimingsActivity> mpRehearseTimingsActivity; boost::shared_ptr<RehearseTimingsActivity> mpRehearseTimingsActivity;
boost::shared_ptr<WaitSymbol> mpWaitSymbol; boost::shared_ptr<WaitSymbol> mpWaitSymbol;
boost::shared_ptr<PointerSymbol> mpPointerSymbol;
/// the current slide transition sound object: /// the current slide transition sound object:
SoundPlayerSharedPtr mpCurrentSlideTransitionSound; SoundPlayerSharedPtr mpCurrentSlideTransitionSound;
...@@ -579,6 +582,7 @@ SlideShowImpl::SlideShowImpl( ...@@ -579,6 +582,7 @@ SlideShowImpl::SlideShowImpl(
mpListener(), mpListener(),
mpRehearseTimingsActivity(), mpRehearseTimingsActivity(),
mpWaitSymbol(), mpWaitSymbol(),
mpPointerSymbol(),
mpCurrentSlideTransitionSound(), mpCurrentSlideTransitionSound(),
mxComponentContext( xContext ), mxComponentContext( xContext ),
mxOptionalTransitionFactory(), mxOptionalTransitionFactory(),
...@@ -653,6 +657,7 @@ void SlideShowImpl::disposing() ...@@ -653,6 +657,7 @@ void SlideShowImpl::disposing()
} }
mpWaitSymbol.reset(); mpWaitSymbol.reset();
mpPointerSymbol.reset();
if( mpRehearseTimingsActivity ) if( mpRehearseTimingsActivity )
{ {
...@@ -1777,6 +1782,37 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) ...@@ -1777,6 +1782,37 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty )
return true; 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( if (rProperty.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("NoSlideTransitions") )) RTL_CONSTASCII_STRINGPARAM("NoSlideTransitions") ))
{ {
......
...@@ -195,6 +195,6 @@ void WaitSymbol::viewsChanged() ...@@ -195,6 +195,6 @@ void WaitSymbol::viewsChanged()
} }
} // namespace internal } // namespace internal
} // namespace presentation } // namespace slideshow
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment