android/sdremote/src/org/libreoffice/impressremote/TestClient.java | 2 sd/Library_sd.mk | 1 sd/source/ui/inc/Server.hxx | 2 sd/source/ui/remotecontrol/Listener.cxx | 16 - sd/source/ui/remotecontrol/Receiver.cxx | 97 ---------- sd/source/ui/remotecontrol/Receiver.hxx | 6 sd/source/ui/remotecontrol/Server.cxx | 76 ++++--- sd/source/ui/slideshow/slideshow.cxx | 4 8 files changed, 54 insertions(+), 150 deletions(-)
New commits: commit c88c56c30c1484e0100e36de9365e8a6c38a8caf Author: Andrzej J. R. Hunt <andr...@ahunt.org> Date: Thu Jul 19 18:43:18 2012 +0200 Moved preview image preparation/transfer into separate class. Enabled. Change-Id: I09b0c2d1521939af058526d1727d0c4d34ad0452 diff --git a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java index 1b0f749..4d716ad 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java +++ b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java @@ -158,8 +158,6 @@ public class TestClient extends Activity { mImageView.setImageBitmap(aBitmap); mCurrentPreviewImageMissing = false; } - mImageView.setImageBitmap(aBitmap); - // TODO: remove above line, use slide changed to show image. break; } diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 2b43a36..4847abf 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -320,6 +320,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/presenter/PresenterPreviewCache \ sd/source/ui/presenter/PresenterTextView \ sd/source/ui/presenter/SlideRenderer \ + sd/source/ui/remotecontrol/ImagePreparer \ sd/source/ui/remotecontrol/Server \ sd/source/ui/remotecontrol/Receiver \ sd/source/ui/remotecontrol/Listener \ diff --git a/sd/source/ui/inc/Server.hxx b/sd/source/ui/inc/Server.hxx index b0dcc1c..065b1cd 100644 --- a/sd/source/ui/inc/Server.hxx +++ b/sd/source/ui/inc/Server.hxx @@ -35,6 +35,7 @@ namespace sd class Transmitter; class Listener; + class ImagePreparer; class Server : public salhelper::Thread { @@ -53,6 +54,7 @@ namespace sd void execute(); static Transmitter *pTransmitter; static rtl::Reference<Listener> mListener; + static rtl::Reference<ImagePreparer> mPreparer; }; } diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index e51bb57..9607707 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -101,7 +101,7 @@ void SAL_CALL Listener::slideTransitionStarted (void) sal_Int32 aSlide = mController->getCurrentSlideIndex(); OStringBuffer aBuilder( "slide_updated\n" ); - aBuilder.append( OString::valueOf( aSlide + 1 ) ); // Slides are numbered from 0 + aBuilder.append( OString::valueOf( aSlide ) ); aBuilder.append( "\n\n" ); if ( pTransmitter ) diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx index 86a1a03..654664a 100644 --- a/sd/source/ui/remotecontrol/Receiver.cxx +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -12,10 +12,8 @@ #include <com/sun/star/presentation/XPresentationSupplier.hpp> #include <com/sun/star/presentation/XPresentation2.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> -#include <com/sun/star/document/XFilter.hpp> -#include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> + #include <comphelper/processfactory.hxx> #include <osl/file.hxx> @@ -110,99 +108,6 @@ void Receiver::parseCommand( std::vector<OString> aCommand ) xSlideShowController->resume(); } } - // FIXME: remove later, this is just to test functionality -// sendPreview( 0, xSlideShowController, mTransmitter ); - -} - -void sendPreview( sal_uInt32 aSlideNumber, - const uno::Reference<presentation::XSlideShowController>& xSlideShowController, Transmitter *aTransmitter ) -{ - - sal_uInt64 aSize; // Unused - uno::Sequence<sal_Int8> aImageData = preparePreview( aSlideNumber, xSlideShowController, 320, 240, aSize ); - rtl::OUStringBuffer aStrBuffer; - ::sax::Converter::encodeBase64( aStrBuffer, aImageData ); - - OString aEncodedShortString = rtl::OUStringToOString( - aStrBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); - - // Start the writing - rtl::OStringBuffer aBuffer; - - aBuffer.append( "slide_preview\n" ); - - rtl::OString aSlideNumberString( rtl::OString::valueOf( sal_Int32(2) ) ); // FIXME get number - aBuffer.append( aSlideNumberString.getStr() ); - aBuffer.append( "\n" ); - - aBuffer.append( aEncodedShortString.getStr() ); - aBuffer.append( "\n\n" ); - aTransmitter->addMessage( aBuffer.makeStringAndClear(), Transmitter::Priority::LOW ); - -} - -uno::Sequence<sal_Int8> -preparePreview(sal_uInt32 aSlideNumber, - const uno::Reference<presentation::XSlideShowController>& xSlideShowController, - sal_uInt32 aWidth, sal_uInt32 aHeight, sal_uInt64 &rSize ) -{ - (void)aWidth; (void)aHeight; // FIXME: remove me when I'm used - // Create temp file - OUString aFileURL; - FileBase::createTempFile( 0, 0, &aFileURL ); - - uno::Reference< lang::XMultiServiceFactory > xServiceManager( - ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - - uno::Reference< document::XFilter > xFilter( xServiceManager->createInstance( - "com.sun.star.drawing.GraphicExportFilter" ) , uno::UNO_QUERY_THROW ); - - uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY_THROW ); - - uno::Reference< lang::XComponent > xSourceDoc( - xSlideShowController->getSlideByIndex( aSlideNumber ) , uno::UNO_QUERY_THROW ); - - xExporter->setSourceDocument( xSourceDoc ); - - uno::Sequence< beans::PropertyValue > aFilterData(3); - aFilterData[0].Name = "PixelWidth"; - aFilterData[0].Value <<= sal_Int32(2000); - aFilterData[1].Name = "PixelHeight"; - aFilterData[1].Value <<= sal_Int32(2000); - - // Add quality if jpg "Quality" [1-100] - // FIXME: is setting color mode needed. - aFilterData[2].Name = "ColorMode"; - aFilterData[2].Value <<= sal_Int32(0); // Color - - uno::Sequence< beans::PropertyValue > aProps(3); - aProps[0].Name = "MediaType"; - aProps[0].Value <<= OUString( "image/png" ); - - aProps[1].Name = "URL"; - aProps[1].Value <<= aFileURL; - - aProps[2].Name = "FilterData"; - aProps[2].Value <<= aFilterData; - - xFilter->filter( aProps ); - - // FIXME: error handling. - - File aFile( aFileURL ); - aFile.open(0); - sal_uInt64 aRead; - rSize = 0; - aFile.getSize( rSize ); - uno::Sequence<sal_Int8> aContents( rSize ); - - aFile.read( aContents.getArray(), rSize, aRead ); - aFile.close(); - File::remove( aFileURL ); - return aContents; - } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/remotecontrol/Receiver.hxx b/sd/source/ui/remotecontrol/Receiver.hxx index 99245d8..5c73913 100644 --- a/sd/source/ui/remotecontrol/Receiver.hxx +++ b/sd/source/ui/remotecontrol/Receiver.hxx @@ -38,11 +38,5 @@ private: }; } - -css::uno::Sequence<sal_Int8> preparePreview(sal_uInt32 aSlideNumber, const css::uno::Reference<css::presentation::XSlideShowController>& xSlideShowController, sal_uInt32 aWidth, sal_uInt32 aHeight, sal_uInt64 &aSize ); - -void sendPreview(sal_uInt32 aSlideNumber, const css::uno::Reference< - css::presentation::XSlideShowController>& xSlideShowController, sd::Transmitter *aTransmitter ); - #endif // _SD_IMPRESSREMOTE_RECEIVER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index 361954d..ab6a212 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -13,10 +13,11 @@ #include <comphelper/processfactory.hxx> #include "sddll.hxx" -#include "Server.hxx" -#include "Receiver.hxx" -#include "Listener.hxx" +#include "ImagePreparer.hxx" +#include "Listener.hxx" +#include "Receiver.hxx" +#include "Server.hxx" using namespace std; using namespace sd; @@ -94,6 +95,11 @@ void Server::listenThread() // TODO: deal with transmision errors gracefully. mListener->disposing(); mListener = NULL; + + if ( mPreparer.is() ) + delete mPreparer.get(); + mPreparer = NULL; + delete pTransmitter; pTransmitter = NULL; fprintf( stderr, "Finished listening\n" ); @@ -134,6 +140,9 @@ void Server::presentationStarted( const css::uno::Reference< { mListener = rtl::Reference<Listener>( new Listener( spServer, pTransmitter ) ); mListener->init( rController ); + + mPreparer = rtl::Reference<ImagePreparer>( new ImagePreparer( rController, pTransmitter ) ); + mPreparer->launch(); } } @@ -142,6 +151,7 @@ void Server::presentationStarted( const css::uno::Reference< Server *sd::Server::spServer = NULL; Transmitter *sd::Server::pTransmitter = NULL; rtl::Reference<Listener> sd::Server::mListener = NULL; +rtl::Reference<ImagePreparer> sd::Server::mPreparer = NULL; void Server::setup() { commit e818599d1397c965b554f406bda58b52d302faca Author: Andrzej J. R. Hunt <andr...@ahunt.org> Date: Thu Jul 19 15:36:24 2012 +0200 Fixed Listener registration and destruction for all cases. Change-Id: I I I8be3c67889969d714514ca073c48ab26248a30e1 diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index ed6532c..e51bb57 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -36,12 +36,16 @@ Listener::~Listener() void Listener::init( const css::uno::Reference< css::presentation::XSlideShowController >& aController) { - if (aController.is() ) + if ( aController.is() ) { mController = css::uno::Reference< css::presentation::XSlideShowController >( aController ); aController->addSlideShowListener( this ); fprintf( stderr, "Registered listener.\n" ); } + else + { + fprintf( stderr, "Couldn't register listener -- aController isn't\n" ); + } } //----- XAnimationListener ---------------------------------------------------- @@ -93,6 +97,7 @@ void SAL_CALL Listener::hyperLinkClicked (const rtl::OUString &) void SAL_CALL Listener::slideTransitionStarted (void) throw (css::uno::RuntimeException) { + fprintf( stderr, "slideTransitionStarted\n" ); sal_Int32 aSlide = mController->getCurrentSlideIndex(); OStringBuffer aBuilder( "slide_updated\n" ); @@ -118,25 +123,20 @@ void SAL_CALL Listener::slideAnimationsEnded (void) void SAL_CALL Listener::disposing (void) { - fprintf( stderr, "In disposing\n" ); pTransmitter = NULL; - fprintf( stderr, "Nulled transmitter\n" ); if ( mController.is() ) { - fprintf( stderr, "mController was\n" ); mController->removeSlideShowListener( this ); mController = NULL; } mServer->informListenerDestroyed(); - fprintf( stderr, "finished disposing\n" ); } void SAL_CALL Listener::disposing ( const css::lang::EventObject& rEvent) throw (::com::sun::star::uno::RuntimeException) { - fprintf( stderr, "disposing\n"); (void) rEvent; - dispose(); + dispose(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index 919d471..361954d 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -35,12 +35,9 @@ Server::~Server() // Run as a thread void Server::listenThread() { - fprintf( stderr, "Server:: address of Transmitter before:%p\n", pTransmitter ); pTransmitter = new Transmitter( mStreamSocket ); pTransmitter->launch(); Receiver aReceiver( pTransmitter ); - fprintf( stderr, "Server:: address of Transmitter:%p\n", pTransmitter ); -// aTransmitter.addMessage( "Hello world\n\n", Transmitter::Priority::HIGH ); try { fprintf( stderr, "Trying to add a Listener in listenThread\n" ); uno::Reference< lang::XMultiServiceFactory > xServiceManager( @@ -60,50 +57,46 @@ void Server::listenThread() } catch ( com::sun::star::uno::RuntimeException &e ) { - fprintf( stderr, "Exception on add\n" ); } // TODO: decryption - while (true) + + sal_uInt64 aRet, aRead; + vector<char> aBuffer; + vector<OString> aCommand; + aRead = 0; + while ( true ) { - sal_uInt64 aRet, aRead; - vector<char> aBuffer; - vector<OString> aCommand; - aRead = 0; - while ( true ) + aBuffer.resize( aRead + 100 ); + aRet = mStreamSocket.recv( &aBuffer[aRead], 100 ); + if ( aRet == 0 ) { - aBuffer.resize( aRead + 100 ); - aRet = mStreamSocket.recv( &aBuffer[aRead], 100 ); - if ( aRet == 0 ) - { - break; // I.e. transmission finished. - } - aRead += aRet; - vector<char>::iterator aIt; - while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' )) - != aBuffer.end() ) - { - sal_uInt64 aLocation = aIt - aBuffer.begin(); - - aCommand.push_back( OString( &(*aBuffer.begin()), aLocation ) ); + break; // I.e. transmission finished. + } + aRead += aRet; + vector<char>::iterator aIt; + while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' )) + != aBuffer.end() ) + { + sal_uInt64 aLocation = aIt - aBuffer.begin(); - if ( aIt == aBuffer.begin() ) - { - aReceiver.parseCommand( aCommand ); - aCommand.clear(); - } - aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the newline - aRead -= (aLocation + 1); + aCommand.push_back( OString( &(*aBuffer.begin()), aLocation ) ); + if ( aIt == aBuffer.begin() ) + { + aReceiver.parseCommand( aCommand ); + aCommand.clear(); } + aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the newline + aRead -= (aLocation + 1); } - - // TODO: deal with transmision errors gracefully. } - mListener->dispose(); + // TODO: deal with transmision errors gracefully. + mListener->disposing(); mListener = NULL; delete pTransmitter; pTransmitter = NULL; + fprintf( stderr, "Finished listening\n" ); } @@ -141,7 +134,6 @@ void Server::presentationStarted( const css::uno::Reference< { mListener = rtl::Reference<Listener>( new Listener( spServer, pTransmitter ) ); mListener->init( rController ); - } } diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index a48de21..05bf461 100644 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -268,7 +268,7 @@ void SlideShow::CreateController( ViewShell* pViewSh, ::sd::View* pView, ::Wind // multiple slide show instances for one document. mxController = xController; mbIsInStartup = false; - Server::presentationStarted( getController() ); + } // -------------------------------------------------------------------- @@ -1073,6 +1073,8 @@ void SlideShow::activate( ViewShellBase& rBase ) if( mxController.is() ) mxController->activate(); + + Server::presentationStarted( mxController.get() ); } // --------------------------------------------------------- _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits