Image export, encoding and decoding. Protocol improvements.
Change-Id: Ibbc7ac02c5946a49c1cd777abc2853fe7e158009
This commit is contained in:
committed by
Michael Meeks
parent
a4e7636536
commit
9d7d8eb7a8
@@ -77,6 +77,7 @@ public class TestClient extends Activity {
|
||||
}
|
||||
|
||||
void doUnbindService() {
|
||||
mCommunicationService.disconnect();
|
||||
mCommunicationService.setActivityMessenger(null);
|
||||
if (mIsBound) {
|
||||
unbindService(mConnection);
|
||||
|
@@ -29,48 +29,70 @@ public abstract class Client {
|
||||
private Receiver mReceiver;
|
||||
|
||||
public void setReceiver(Receiver aReceiver) {
|
||||
aReceiver = mReceiver;
|
||||
mReceiver = aReceiver;
|
||||
}
|
||||
|
||||
protected void startListening() {
|
||||
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
listen();
|
||||
};
|
||||
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void listen() {
|
||||
ByteArrayBuffer aBuffer = new ByteArrayBuffer(10);
|
||||
byte aTemp;
|
||||
|
||||
try {
|
||||
while ((aTemp = (byte) mInputStream.read()) != 0x0d) {
|
||||
aBuffer.append(aTemp);
|
||||
while (true) {
|
||||
ByteArrayBuffer aBuffer = new ByteArrayBuffer(0);
|
||||
int aTemp;
|
||||
System.out.println("Now listening");
|
||||
try {
|
||||
while ((aTemp = mInputStream.read()) != 0x0a) {
|
||||
if (aTemp == -1) {
|
||||
System.out.println("EOF Reached!!!");
|
||||
}
|
||||
System.out.println("Char: " + aTemp);
|
||||
aBuffer.append((byte) aTemp);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
// TODO stream couldn't be opened.
|
||||
e1.printStackTrace();
|
||||
}
|
||||
System.out.println("Escaped the loop!");
|
||||
String aLengthString;
|
||||
try {
|
||||
aLengthString = new String(aBuffer.toByteArray(), CHARSET);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
throw new Error("Specified network encoding [" + CHARSET
|
||||
+ " not available.");
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
// TODO stream couldn't be opened.
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
String aLengthString;
|
||||
try {
|
||||
aLengthString = new String(aBuffer.toByteArray(), CHARSET);
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
throw new Error("Specified network encoding [" + CHARSET
|
||||
+ " not available.");
|
||||
int aLength = Integer.parseInt(aLengthString);
|
||||
System.out.println("Lenth = " + aLength);
|
||||
byte[] aCommand = new byte[aLength];
|
||||
try {
|
||||
int readIn = 0;
|
||||
while (readIn < aLength) {
|
||||
readIn += mInputStream.read(aCommand, 0, aLength - readIn);
|
||||
// System.out.println("Read in :" + readIn + " of : "
|
||||
// + aLength);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO close and notify that the connection has closed
|
||||
e.printStackTrace();
|
||||
}
|
||||
String aCommandString;
|
||||
try {
|
||||
aCommandString = new String(aCommand, CHARSET);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new Error("Specified network encoding [" + CHARSET
|
||||
+ " not available.");
|
||||
}
|
||||
mReceiver.parseCommand(aCommandString);
|
||||
}
|
||||
|
||||
int aLength = Integer.parseInt(aLengthString);
|
||||
|
||||
byte[] aCommand = new byte[aLength];
|
||||
try {
|
||||
mInputStream.read(aCommand, 0, aLength);
|
||||
} catch (IOException e) {
|
||||
// TODO close and notify that the connection has closed
|
||||
e.printStackTrace();
|
||||
}
|
||||
String aCommandString;
|
||||
try {
|
||||
aCommandString = new String(aCommand, CHARSET);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new Error("Specified network encoding [" + CHARSET
|
||||
+ " not available.");
|
||||
}
|
||||
mReceiver.parseCommand(aCommandString);
|
||||
|
||||
}
|
||||
|
||||
private void parseCommand(String aCommand) {
|
||||
|
@@ -4,6 +4,8 @@ import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import android.os.StrictMode;
|
||||
|
||||
/**
|
||||
* Standard Network client. Connects to a server using Sockets.
|
||||
*
|
||||
@@ -16,13 +18,16 @@ public class NetworkClient extends Client {
|
||||
private Socket mSocket;
|
||||
|
||||
public NetworkClient(String ipAddress) {
|
||||
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
|
||||
.permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
System.out.println("Attempting to open port.");
|
||||
try {
|
||||
mSocket = new Socket(ipAddress, PORT);
|
||||
System.out.println("We seem to have opened.");
|
||||
mInputStream = mSocket.getInputStream();
|
||||
mOutputStream = mSocket.getOutputStream();
|
||||
startListening();
|
||||
} catch (UnknownHostException e) {
|
||||
// TODO Tell the user we have a problem
|
||||
e.printStackTrace();
|
||||
@@ -36,7 +41,8 @@ public class NetworkClient extends Client {
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
try {
|
||||
mSocket.close();
|
||||
if (mSocket != null)
|
||||
mSocket.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@@ -30,6 +30,16 @@ public class Receiver {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// int aPrinted = 0;
|
||||
// while (aPrinted < aJSONCommandString.length()) {
|
||||
// if (aPrinted + 100 < aJSONCommandString.length())
|
||||
// System.out.println(aJSONCommandString.substring(aPrinted,
|
||||
// aPrinted + 100));
|
||||
// else
|
||||
// System.out.println(aJSONCommandString.substring(aPrinted));
|
||||
// aPrinted += 100;
|
||||
// }
|
||||
|
||||
JSONObject aJSONCommand = new JSONObject(aJSONCommandString);
|
||||
String aInstruction = aJSONCommand.getString("command");
|
||||
if (aInstruction.equals("slide_updated")) {
|
||||
@@ -47,7 +57,7 @@ public class Receiver {
|
||||
}
|
||||
} else if (aInstruction.equals("slide_preview")) {
|
||||
int aSlideNumber = aJSONCommand.getInt("slide_number");
|
||||
String aImageString = aJSONCommand.getString("image");
|
||||
String aImageString = aJSONCommand.getString("image_preview");
|
||||
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
|
||||
Message aMessage = Message.obtain(null,
|
||||
CommunicationService.MSG_SLIDE_PREVIEW);
|
||||
|
@@ -60,6 +60,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
|
||||
i18nisolang1 \
|
||||
msfilter \
|
||||
sal \
|
||||
sax \
|
||||
salhelper \
|
||||
sb \
|
||||
sfx \
|
||||
|
@@ -328,6 +328,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
|
||||
sd/source/ui/presenter/SlideRenderer \
|
||||
sd/source/ui/remotecontrol/Server \
|
||||
sd/source/ui/remotecontrol/Receiver \
|
||||
sd/source/ui/remotecontrol/Listener \
|
||||
sd/source/ui/slideshow/PaneHider \
|
||||
sd/source/ui/slideshow/SlideShowRestarter \
|
||||
sd/source/ui/slideshow/showwin \
|
||||
|
112
sd/source/ui/remotecontrol/Listener.cxx
Normal file
112
sd/source/ui/remotecontrol/Listener.cxx
Normal file
@@ -0,0 +1,112 @@
|
||||
/* -*- 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 <cstring>
|
||||
|
||||
#include "Listener.hxx"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
using namespace sd;
|
||||
using namespace ::com::sun::star::presentation;
|
||||
using rtl::OString;
|
||||
|
||||
|
||||
Listener::Listener( const css::uno::Reference<XSlideShowController>& rxSlideShowController,
|
||||
osl::StreamSocket aSocket )
|
||||
: ::cppu::WeakComponentImplHelper1< XSlideShowListener >( m_aMutex ),
|
||||
mxSlideShowController(rxSlideShowController),
|
||||
mStreamSocket( aSocket )
|
||||
{
|
||||
g_type_init();
|
||||
|
||||
|
||||
if( mxSlideShowController.is() )
|
||||
{
|
||||
// Listen for events from the slide show controller.
|
||||
mxSlideShowController->addSlideShowListener(static_cast<XSlideShowListener*>(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Listener::~Listener()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
//----- XSlideShowListener ----------------------------------------------------
|
||||
|
||||
void SAL_CALL Listener::paused (void)
|
||||
throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::resumed (void)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::slideEnded (sal_Bool bReverse)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
JsonBuilder *aBuilder = json_builder_new();
|
||||
|
||||
|
||||
json_builder_begin_object( aBuilder );
|
||||
json_builder_set_member_name( aBuilder, "slide_numer");
|
||||
json_builder_add_int_value( aBuilder, 2 );
|
||||
// FIXME: get the slide number
|
||||
json_builder_end_object( aBuilder );
|
||||
|
||||
JsonGenerator *aGen = json_generator_new();
|
||||
JsonNode *aRoot = json_builder_get_root( aBuilder );
|
||||
json_generator_set_root( aGen, aRoot );
|
||||
char *aCommand = json_generator_to_data( aGen, NULL);
|
||||
|
||||
json_node_free( aRoot );
|
||||
g_object_unref ( aGen );
|
||||
g_object_unref ( aBuilder );
|
||||
|
||||
sal_Int32 aLen = strlen( aCommand );
|
||||
|
||||
OString aLengthString = OString::valueOf( aLen );
|
||||
const char *aLengthChar = aLengthString.getStr();
|
||||
|
||||
sal_Int32 aLengthLength = aLengthString.getLength();
|
||||
|
||||
mStreamSocket.write( aLengthChar, aLengthLength );
|
||||
mStreamSocket.write( "\n", 1 );
|
||||
mStreamSocket.write( aCommand, aLen );
|
||||
// Transmit here.
|
||||
|
||||
g_free( aCommand );
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::hyperLinkClicked (const rtl::OUString &)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::slideTransitionStarted (void)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::slideTransitionEnded (void)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL Listener::slideAnimationsEnded (void)
|
||||
throw (css::uno::RuntimeException)
|
||||
{
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
48
sd/source/ui/remotecontrol/Listener.hxx
Normal file
48
sd/source/ui/remotecontrol/Listener.hxx
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- 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_LISTENER_HXX
|
||||
#define _SD_IMPRESSREMOTE_LISTENER_HXX
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <com/sun/star/presentation/XSlideShowListener.hpp>
|
||||
#include <com/sun/star/presentation/XSlideShowController.hpp>
|
||||
|
||||
#include <cppuhelper/compbase1.hxx>
|
||||
#include <cppuhelper/basemutex.hxx>
|
||||
#include <osl/socket.hxx>
|
||||
|
||||
namespace css = ::com::sun::star;
|
||||
//using namespace ::com::sun::star::presentation;
|
||||
|
||||
namespace sd {
|
||||
class Listener
|
||||
: protected ::cppu::BaseMutex,
|
||||
public ::cppu::WeakComponentImplHelper1< css::presentation::XSlideShowListener >
|
||||
{
|
||||
public:
|
||||
Listener( const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController,
|
||||
osl::StreamSocket aSocket );
|
||||
~Listener();
|
||||
|
||||
// XSlideShowListener
|
||||
virtual void SAL_CALL paused( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL resumed( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL slideTransitionStarted( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL slideAnimationsEnded( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL hyperLinkClicked( const ::rtl::OUString& hyperLink ) throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
private:
|
||||
css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
|
||||
osl::StreamSocket mStreamSocket;
|
||||
};
|
||||
}
|
||||
#endif // _SD_IMPRESSREMOTE_LISTENER_HXX
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,38 +1,34 @@
|
||||
/*************************************************************************
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2012 Andrzej J.R. Hunt
|
||||
*
|
||||
* LibreOffice - a multi-platform office productivity suite
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* LibreOffice is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* Libreoffice is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with LibreOffice. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
* 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 "Receiver.hxx"
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
#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>
|
||||
#include <xmlsec/base64.h>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <sax/tools/converter.hxx>
|
||||
using namespace sd;
|
||||
using namespace ::com::sun::star::presentation;
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::frame;
|
||||
using namespace ::com::sun::star::beans;
|
||||
using namespace ::com::sun::star::document;
|
||||
using rtl::OUString;
|
||||
using rtl::OString;
|
||||
using namespace ::osl;
|
||||
|
||||
Receiver::Receiver()
|
||||
{
|
||||
g_type_init ();
|
||||
@@ -65,7 +61,7 @@ void Receiver::executeCommand( JsonObject *aObject, Reference<XSlideShowControll
|
||||
|
||||
}
|
||||
|
||||
void Receiver::parseCommand( const char* aCommand, sal_Int32 size, XSlideShowController *aController )
|
||||
void Receiver::parseCommand( const char* aCommand, sal_Int32 size, osl::StreamSocket &aStreamSocket )
|
||||
{
|
||||
Reference<XSlideShowController> xSlideShowController;
|
||||
try {
|
||||
@@ -78,6 +74,7 @@ void Receiver::parseCommand( const char* aCommand, sal_Int32 size, XSlideShowCon
|
||||
Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
|
||||
// Throws an exception if now slideshow running
|
||||
xSlideShowController = Reference<XSlideShowController>( xPresentation->getController(), UNO_QUERY_THROW );
|
||||
sendPreview( 1, xSlideShowController, aStreamSocket );
|
||||
}
|
||||
catch ( com::sun::star::uno::RuntimeException &e )
|
||||
{
|
||||
@@ -107,18 +104,128 @@ void Receiver::parseCommand( const char* aCommand, sal_Int32 size, XSlideShowCon
|
||||
|
||||
}
|
||||
|
||||
// void preparePreview(sal_Int32 aSlideNumber, Reference<SlideShowController> aController)
|
||||
// {
|
||||
// uno::Reference< XDrawPage > aSlide( aController->getSlideByIndex( aSlideNumber ) );
|
||||
//
|
||||
// uno::Reference< lang::XMultiServiceFactory > xServiceManager(
|
||||
// ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
|
||||
//
|
||||
// uno::Reference< XGraphicExportFilter > xGraphicExportFilter( xServiceManager->createInstance(
|
||||
// "com.sun.star.drawing.GraphicExportFilter" ) , UNO_QUERY_THROW );
|
||||
//
|
||||
// xGraphicExportFilter->setSource( aSlide );
|
||||
|
||||
void sendPreview(sal_uInt32 aSlideNumber, Reference<XSlideShowController> xSlideShowController, osl::StreamSocket &mStreamSocket )
|
||||
{
|
||||
|
||||
sal_uInt64 aSize;
|
||||
|
||||
uno::Sequence<sal_Int8> aData = preparePreview( aSlideNumber, xSlideShowController, 320, 240, aSize );
|
||||
|
||||
rtl::OUStringBuffer aStrBuffer;
|
||||
// char* aDataEncoded = (char*) xmlSecBase64Encode( (xmlSecByte *) aData, aSize, 0 );
|
||||
::sax::Converter::encodeBase64( aStrBuffer, aData );
|
||||
|
||||
OUString aEncodedString = aStrBuffer.makeStringAndClear();
|
||||
OString aEncodedShortString = rtl::OUStringToOString( aEncodedString, RTL_TEXTENCODING_UTF8 );
|
||||
// aEncodedString.convertToString( &aEncodedShortString, RTL_TEXTENCODING_UTF8 , 0);
|
||||
|
||||
JsonBuilder *aBuilder = json_builder_new();
|
||||
|
||||
|
||||
json_builder_begin_object( aBuilder );
|
||||
|
||||
// }
|
||||
json_builder_set_member_name( aBuilder, "command" );
|
||||
json_builder_add_string_value( aBuilder, "slide_preview" );
|
||||
|
||||
json_builder_set_member_name( aBuilder, "slide_number" );
|
||||
json_builder_add_int_value( aBuilder, 2 );
|
||||
|
||||
json_builder_set_member_name( aBuilder, "image_preview" );
|
||||
json_builder_add_string_value( aBuilder, aEncodedShortString.getStr() );
|
||||
|
||||
// FIXME: get the slide number
|
||||
json_builder_end_object( aBuilder );
|
||||
|
||||
JsonGenerator *aGen = json_generator_new();
|
||||
JsonNode *aRoot = json_builder_get_root( aBuilder );
|
||||
json_generator_set_root( aGen, aRoot );
|
||||
char *aCommand = json_generator_to_data( aGen, NULL);
|
||||
|
||||
json_node_free( aRoot );
|
||||
g_object_unref ( aGen );
|
||||
g_object_unref ( aBuilder );
|
||||
|
||||
sal_Int32 aLen = strlen( aCommand );
|
||||
|
||||
OString aLengthString = OString::valueOf( aLen );
|
||||
const char *aLengthChar = aLengthString.getStr();
|
||||
|
||||
sal_Int32 aLengthLength = aLengthString.getLength();
|
||||
|
||||
fprintf( stderr, "%s\n", aCommand );
|
||||
|
||||
mStreamSocket.write( aLengthChar, aLengthLength );
|
||||
mStreamSocket.write( "\n", 1 );
|
||||
mStreamSocket.write( aCommand, aLen );
|
||||
// Transmit here.
|
||||
|
||||
g_free( aCommand );
|
||||
|
||||
}
|
||||
|
||||
Sequence<sal_Int8> preparePreview(sal_uInt32 aSlideNumber, Reference<XSlideShowController> xSlideShowController, sal_uInt32 aWidth, sal_uInt32 aHeight, sal_uInt64 &rSize )
|
||||
{
|
||||
|
||||
// Create temp file
|
||||
OUString aFileURL;
|
||||
FileBase::createTempFile( 0, 0, &aFileURL );
|
||||
|
||||
|
||||
uno::Reference< lang::XMultiServiceFactory > xServiceManager(
|
||||
::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
|
||||
|
||||
uno::Reference< XFilter > xFilter( xServiceManager->createInstance(
|
||||
"com.sun.star.drawing.GraphicExportFilter" ) , UNO_QUERY_THROW );
|
||||
|
||||
uno::Reference< XExporter > xExporter( xFilter, uno::UNO_QUERY_THROW );
|
||||
|
||||
|
||||
uno::Reference< lang::XComponent > xSourceDoc(
|
||||
xSlideShowController->getSlideByIndex( aSlideNumber ) , uno::UNO_QUERY_THROW );
|
||||
|
||||
xExporter->setSourceDocument( xSourceDoc );
|
||||
|
||||
Sequence< beans::PropertyValue > aFilterData(3);
|
||||
aFilterData[0].Name = "PixelWidth";
|
||||
aFilterData[0].Value <<= 2000;
|
||||
aFilterData[1].Name = "PixelHeight";
|
||||
aFilterData[1].Value <<= 2000;
|
||||
|
||||
// Add quality if jpg "Quality" [1-100]
|
||||
// FIXME: is setting color mode needed.
|
||||
aFilterData[2].Name = "ColorMode";
|
||||
aFilterData[2].Value <<= 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 );
|
||||
|
||||
fprintf( stderr, "%s\n", rtl::OUStringToOString( aFileURL , RTL_TEXTENCODING_UTF8 ).getStr() );
|
||||
|
||||
// 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: */
|
@@ -1,12 +1,20 @@
|
||||
|
||||
/* -*- 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_RECEIVER_HXX
|
||||
#define _SD_IMPRESSREMOTE_RECEIVER_HXX
|
||||
|
||||
#include <com/sun/star/presentation/XSlideShowListener.hpp>
|
||||
#include <com/sun/star/presentation/XSlideShowController.hpp>
|
||||
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
|
||||
#include <com/sun/star/presentation/XPresentation.hpp>
|
||||
#include <com/sun/star/presentation/XPresentation2.hpp>
|
||||
|
||||
#include <osl/socket.hxx>
|
||||
#include <stdlib.h>
|
||||
#include <glib-object.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
@@ -21,7 +29,8 @@ class Receiver
|
||||
public:
|
||||
Receiver();
|
||||
~Receiver();
|
||||
void parseCommand( const char* aCommand, sal_Int32 size, XSlideShowController *aController );
|
||||
void parseCommand( const char* aCommand, sal_Int32 size, osl::StreamSocket &aSocket );
|
||||
|
||||
|
||||
private:
|
||||
void executeCommand( JsonObject *aObject, Reference<XSlideShowController> aController );
|
||||
@@ -30,4 +39,9 @@ private:
|
||||
|
||||
}
|
||||
|
||||
Sequence<sal_Int8> preparePreview(sal_uInt32 aSlideNumber, Reference<XSlideShowController> xSlideShowController, sal_uInt32 aWidth, sal_uInt32 aHeight, sal_uInt64 &aSize );
|
||||
|
||||
void sendPreview(sal_uInt32 aSlideNumber, Reference<XSlideShowController> xSlideShowController, osl::StreamSocket &mStreamSocket );
|
||||
|
||||
#endif // _SD_IMPRESSREMOTE_RECEIVER_HXX
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,3 +1,11 @@
|
||||
/* -*- 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 "RemoteDialog.hxx"
|
||||
|
||||
|
||||
@@ -9,3 +17,4 @@ RemoteDialog::~RemoteDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,3 +1,11 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
// SERVER
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -18,3 +26,4 @@ namespace sd
|
||||
};
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,4 +1,11 @@
|
||||
|
||||
/* -*- 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 <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -18,7 +25,6 @@ using rtl::OString;
|
||||
Server::Server()
|
||||
: Thread( "ServerThread" ), mSocket(), mReceiver()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
@@ -60,7 +66,7 @@ void Server::listenThread()
|
||||
aTempStr = OString( aMessage ); //, (sal_Int32) aLen, CHARSET, 0u
|
||||
const sal_Char* aCommandChar = aTempStr.getStr();
|
||||
|
||||
mReceiver.parseCommand( aCommandChar, aTempStr.getLength(), NULL );
|
||||
mReceiver.parseCommand( aCommandChar, aTempStr.getLength(), mStreamSocket );
|
||||
delete [] aMessage;
|
||||
|
||||
// TODO: deal with transmision errors gracefully.
|
||||
@@ -82,6 +88,7 @@ void Server::execute()
|
||||
}
|
||||
while ( true )
|
||||
{
|
||||
fprintf( stderr, "Awaiting a connection.\n" );
|
||||
mSocket.acceptConnection( mStreamSocket );
|
||||
fprintf( stderr, "Accepted a connection!\n" );
|
||||
listenThread();
|
||||
@@ -89,6 +96,8 @@ void Server::execute()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Server *sd::Server::spServer = NULL;
|
||||
|
||||
void Server::setup()
|
||||
@@ -106,3 +115,4 @@ void SdDLL::RegisterRemotes()
|
||||
sd::Server::setup();
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -1,4 +1,11 @@
|
||||
|
||||
/* -*- 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_SERVER_HXX
|
||||
#define _SD_IMPRESSREMOTE_SERVER_HXX
|
||||
|
||||
@@ -8,10 +15,10 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <osl/socket.hxx>
|
||||
//#include <com/sun/star/presentation/AnimationEffect.hpp>
|
||||
#include <com/sun/star/presentation/XSlideShowListener.hpp>
|
||||
|
||||
#include <salhelper/thread.hxx>
|
||||
|
||||
@@ -34,7 +41,7 @@ namespace sd
|
||||
private:
|
||||
Server();
|
||||
~Server();
|
||||
static Server *spServer;
|
||||
static Server *spServer;
|
||||
osl::AcceptorSocket mSocket;
|
||||
osl::StreamSocket mStreamSocket;
|
||||
void listenThread();
|
||||
@@ -44,3 +51,4 @@ namespace sd
|
||||
}
|
||||
|
||||
#endif // _SD_IMPRESSREMOTE_SERVER_HXX
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Reference in New Issue
Block a user