summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorAndrzej J. R. Hunt <andrzej@ahunt.org>2012-07-20 17:50:10 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:22:59 +0100
commit6794e94bfd321f66298b11bd2b753c9433d5d5eb (patch)
tree7d0e7e7a94f4a3e02d42de4cf5fa31fb0493fa5f /sd/source
parent0aa7aa85a4cb0b0608afea6c69f61ed8426c8185 (diff)
Implemented Thumbnail activity.
Change-Id: I I6de8651f3ed36798ca1cc69765c448b821a819a2
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/ui/remotecontrol/ImagePreparer.cxx154
-rw-r--r--sd/source/ui/remotecontrol/ImagePreparer.hxx51
-rw-r--r--sd/source/ui/remotecontrol/Listener.cxx8
-rw-r--r--sd/source/ui/remotecontrol/Listener.hxx4
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx3
5 files changed, 218 insertions, 2 deletions
diff --git a/sd/source/ui/remotecontrol/ImagePreparer.cxx b/sd/source/ui/remotecontrol/ImagePreparer.cxx
new file mode 100644
index 000000000000..a42be1f5c135
--- /dev/null
+++ b/sd/source/ui/remotecontrol/ImagePreparer.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "ImagePreparer.hxx"
+
+#include <comphelper/processfactory.hxx>
+#include <osl/file.hxx>
+#include <xmlsec/base64.h>
+#include <rtl/ustrbuf.hxx>
+#include <sax/tools/converter.hxx>
+#include <rtl/strbuf.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+
+using namespace sd;
+using namespace rtl;
+using namespace osl;
+using namespace ::com::sun::star;
+
+ImagePreparer::ImagePreparer(
+ const uno::Reference<presentation::XSlideShowController>& rxController,
+ Transmitter *aTransmitter, rtl::Reference<ImagePreparer>& rRef )
+ : Thread( "ImagePreparer Thread" ),
+ xController( rxController ),
+ pTransmitter( aTransmitter ),
+ mRef( rRef )
+{
+}
+
+ImagePreparer::~ImagePreparer()
+{
+}
+
+void ImagePreparer::execute()
+{
+ fprintf( stderr, "ImagePreparer running\n" );
+ sal_uInt32 aSlides = xController->getSlideCount();
+ for ( sal_uInt32 i = 0; i < aSlides; i++ )
+ {
+ if ( !xController->isRunning() ) // stopped/disposed of.
+ {
+ break;
+ }
+ sendPreview( i );
+ }
+ fprintf( stderr, "ImagePreparer done\n" );
+ mRef.clear();
+}
+
+void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
+{
+ sal_uInt64 aSize;
+ uno::Sequence<sal_Int8> aImageData = preparePreview( aSlideNumber, 160, 120,
+ aSize );
+ if ( !xController->isRunning() )
+ return;
+
+ OUStringBuffer aStrBuffer;
+ ::sax::Converter::encodeBase64( aStrBuffer, aImageData );
+
+ OString aEncodedShortString = OUStringToOString(
+ aStrBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+
+ // Start the writing
+ OStringBuffer aBuffer;
+
+ aBuffer.append( "slide_preview\n" );
+
+ aBuffer.append( OString::valueOf( sal_Int32( aSlideNumber ) ).getStr() );
+ aBuffer.append( "\n" );
+
+ aBuffer.append( aEncodedShortString.getStr() );
+ aBuffer.append( "\n\n" );
+ pTransmitter->addMessage( aBuffer.makeStringAndClear(),
+ Transmitter::Priority::LOW );
+
+}
+
+uno::Sequence<sal_Int8> ImagePreparer::preparePreview(
+ sal_uInt32 aSlideNumber, sal_uInt32 aWidth, sal_uInt32 aHeight,
+ sal_uInt64 &rSize )
+{
+ 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 );
+
+ if ( !xController->isRunning() )
+ return uno::Sequence<sal_Int8>();
+ uno::Reference< lang::XComponent > xSourceDoc(
+ xController->getSlideByIndex( aSlideNumber ),
+ uno::UNO_QUERY_THROW );
+
+ xExporter->setSourceDocument( xSourceDoc );
+
+ uno::Sequence< beans::PropertyValue > aFilterData(3);
+
+ aFilterData[0].Name = "PixelWidth";
+ aFilterData[0].Value <<= aWidth;
+
+ aFilterData[1].Name = "PixelHeight";
+ aFilterData[1].Value <<= aHeight;
+
+ aFilterData[2].Name = "ColorMode";
+ aFilterData[2].Value <<= sal_Int32(0); // 0: Color, 1: B&W
+
+ 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: */ \ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/ImagePreparer.hxx b/sd/source/ui/remotecontrol/ImagePreparer.hxx
new file mode 100644
index 000000000000..7f193bb91fec
--- /dev/null
+++ b/sd/source/ui/remotecontrol/ImagePreparer.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX
+#define _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX
+
+#include <salhelper/thread.hxx>
+#include <rtl/ref.hxx>
+
+#include <com/sun/star/presentation/XSlideShowController.hpp>
+
+#include "Transmitter.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace sd
+{
+
+class ImagePreparer:
+ public salhelper::Thread
+{
+public:
+ ImagePreparer( const
+ css::uno::Reference<css::presentation::XSlideShowController>&
+ rxController, sd::Transmitter *aTransmitter,
+ rtl::Reference<ImagePreparer>& rRef );
+ ~ImagePreparer();
+
+private:
+ css::uno::Reference<css::presentation::XSlideShowController> xController;
+ Transmitter *pTransmitter;
+ rtl::Reference<ImagePreparer>& mRef;
+
+ // Thread method
+ void execute();
+
+ void sendPreview( sal_uInt32 aSlideNumber );
+ css::uno::Sequence<sal_Int8> preparePreview( sal_uInt32 aSlideNumber,
+ sal_uInt32 aWidth, sal_uInt32 aHeight, sal_uInt64 &rSize );
+};
+
+}
+
+
+#endif // _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx
index 1f55710fe41d..361990530cf5 100644
--- a/sd/source/ui/remotecontrol/Listener.cxx
+++ b/sd/source/ui/remotecontrol/Listener.cxx
@@ -48,6 +48,14 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon
aController->addSlideShowListener( this );
fprintf( stderr, "Registered listener.\n" );
+ sal_Int32 aSlides = aController->getSlideCount();
+ OStringBuffer aBuffer;
+ aBuffer.append( "slideshow_started\n" )
+ .append( OString::valueOf( aSlides ) ).append( "\n\n" );
+
+ pTransmitter->addMessage( aBuffer.makeStringAndClear(),
+ Transmitter::Priority::HIGH );
+
mPreparer.set( new ImagePreparer( aController, pTransmitter, mPreparer ) );
mPreparer->launch();
}
diff --git a/sd/source/ui/remotecontrol/Listener.hxx b/sd/source/ui/remotecontrol/Listener.hxx
index 92a0b93ff7ea..1fc411d08c64 100644
--- a/sd/source/ui/remotecontrol/Listener.hxx
+++ b/sd/source/ui/remotecontrol/Listener.hxx
@@ -26,6 +26,10 @@
namespace css = ::com::sun::star;
namespace sd {
+/**
+ * Slide show listener. This class can also be used for anything else that is
+ * specific to the lifetime of one slideshow while a client is connected.
+ */
class Listener
: protected ::cppu::BaseMutex,
public ::cppu::WeakComponentImplHelper1< css::presentation::XSlideShowListener >
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 0329e27ffb1f..700e561d24c8 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -94,8 +94,7 @@ void Server::listenThread()
}
// TODO: deal with transmision errors gracefully.
fprintf( stderr, "done with transmitting\n" );
- mListener->disposing();
- mListener = NULL;
+ presentationStopped();
delete pTransmitter;
pTransmitter = NULL;