Kaydet (Commit) 92f23297 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Work in progress: Add "touch" module for Android and iOS stuff

Change-Id: I10652743194d44d8465ddf8079f6b4458e6710f9
üst 71dbf5bf
...@@ -130,6 +130,7 @@ test\ ...@@ -130,6 +130,7 @@ test\
testtools\ testtools\
toolkit\ toolkit\
tools\ tools\
touch\
translations\ translations\
twain\ twain\
ucb\ ucb\
......
...@@ -110,6 +110,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\ ...@@ -110,6 +110,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\
test \ test \
toolkit \ toolkit \
tools \ tools \
touch \
twain \ twain \
ucb \ ucb \
unixODBC \ unixODBC \
......
...@@ -385,6 +385,14 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \ ...@@ -385,6 +385,14 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
xsltfilter \ xsltfilter \
)) ))
ifneq (,$(filter ANDROID IOS,$(OS)))
$(eval $(call gb_Helper_register_libraries,OOOLIBS, \
libotouch \
))
endif
ifeq ($(filter MACOSX WNT,$(OS)),) ifeq ($(filter MACOSX WNT,$(OS)),)
$(eval $(call gb_Helper_register_libraries,OOOLIBS, \ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
......
...@@ -133,6 +133,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\ ...@@ -133,6 +133,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
testtools \ testtools \
toolkit \ toolkit \
tools \ tools \
touch \
$(if $(filter TRANSLATIONS,$(BUILD_TYPE)),\ $(if $(filter TRANSLATIONS,$(BUILD_TYPE)),\
translations \ translations \
) \ ) \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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/.
$(eval $(call gb_CustomTarget_CustomTarget,touch/touch_javamaker))
touch_javamaker_DIR := $(call gb_CustomTarget_get_workdir,touch)
$(call gb_CustomTarget_get_target,touch/touch_javamaker) : $(touch_javamaker_DIR)/done
$(touch_javamaker_DIR)/done : $(call gb_UnoApiTarget_get_target,touch) \
$(call gb_Executable_get_target_for_build,javamaker) | $(touch_javamaker_DIR)/.dir
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),JVM,1)
$(call gb_Helper_abbreviate_dirs, \
$(call gb_Helper_execute,javamaker -BUCR -nD -O$(touch_javamaker_DIR)/class -X$(OUTDIR)/bin/types.rdb $<) && touch $@)
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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/.
$(eval $(call gb_InternalUnoApi_InternalUnoApi,touch))
$(eval $(call gb_InternalUnoApi_use_api,touch,\
udkapi \
))
$(eval $(call gb_InternalUnoApi_define_api_dependencies,touch, \
offapi,\
udkapi \
))
$(eval $(call gb_InternalUnoApi_set_include,touch,\
-I$(SRCDIR)/touch/idl \
-I$(OUTDIR)/idl \
$$(INCLUDE) \
))
$(eval $(call gb_InternalUnoApi_add_idlfiles,touch,touch/idl/org/libreoffice/touch,\
Document \
DocumentRenderCallback \
XDocument \
XDocumentRenderCallback \
))
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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/.
$(eval $(call gb_Library_Library,libotouch))
$(eval $(call gb_Library_set_include,libotouch,\
-I$(SRCDIR)/libotouch/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Library_use_internal_comprehensive_api,libotouch,\
udkapi \
offapi \
touch \
))
$(eval $(call gb_Library_use_libraries,libotouch,\
$(gb_STDLIBS) \
))
$(eval $(call gb_Library_add_exception_objects,libotouch,\
touch/source/uno/Document \
touch/source/generic/libotouch \
))
ifeq ($(OS),IOS)
$(eval $(call gb_Library_add_objcxx_objects,libotouch,\
touch/source/ios/ios \
))
endif
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
include $(module_directory)/../solenv/gbuild/partial_build.mk
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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/.
$(eval $(call gb_Module_Module,touch))
ifneq (,$(filter IOS ANDROID,$(OS)))
$(eval $(call gb_Module_add_targets,touch,\
CustomTarget_touch_javamaker \
InternalUnoApi_touch \
Library_libotouch \
Package_inc \
))
endif
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Copyright 2012 LibreOffice contributors.
#
# 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/.
$(eval $(call gb_Package_Package,touch_inc,$(SRCDIR)/touch/inc))
$(eval $(call gb_Package_add_file,touch_inc,inc/touch/libotouch.hxx,touch/libotouch.hxx))
# vim: set noet sw=4 ts=4:
Library that provides API used by LO-based apps on touch devices
This is all very much a work in progress and the design can change radically
at any moment. The name "touch" for this module and the library name
"libotouch" are not fixed and might change if somebody comes up with niftier
names.
This module will contain an UNO API to be called either from Java (for
Android), or directly (iOS). (Or, on iOS, possibly through some thin
Objective-C layer to hide the UNO.)
The API will provide a mechanism to render "tiles" of a document at some
requested zoom level. Initially for viewer style apps, but the work should
ideally be open-ended to potentially be a base for editing apps, too.
For starters, concentrating on text ("Writer") documents as they are
easiest. With spreadsheets come the added complexity of the cell grid being
potentially unbounded and no clear "page" area. With presentations come the
animation complications, and possibly LO-based viewer apps for presentations
will be done in a totally different fashion.
// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// Copyright 2012 LibreOffice contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License 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 org_libreoffice_touch_Document_idl
#define org_libreoffice_touch_Document_idl
#include <org/libreoffice/touch/XDocument.idl>
module org { module libreoffice { module touch {
service Document:
XDocument {
create( [in] string uri );
};
}; }; };
#endif
// vim:set shiftwidth=4 softtabstop=4 expandtab:
// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// Copyright 2012 LibreOffice contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License 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 org_libreoffice_touch_DocumentRenderCallback_idl
#define org_libreoffice_touch_DocumentRenderCallback_idl
#include <org/libreoffice/touch/XDocumentRenderCallback.idl>
module org { module libreoffice { module touch {
service DocumentRenderCallback: XDocumentRenderCallback
{
create();
};
}; }; };
#endif
// vim:set shiftwidth=4 softtabstop=4 expandtab:
// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// Copyright 2012 LibreOffice contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License 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 org_libreoffice_touch_XDocument_idl
#define org_libreoffice_touch_XDocument_idl
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/lang/IllegalArgumentException.idl>
module org { module libreoffice { module touch {
// Note that this is work in progress
// Error handling? Presumably for true errors expected to be uncommon, or
// invalid usage, the methods should throw exceptions.
// Multithreaded use of this is undefined (the intent obviously is that this
// API is called in another thread than the "main" UI thread, but calling this
// stuff on the same object simultaneously in multiple threads is undefined).
// Represents one (Writer, for now) document
interface XDocumentRenderCallback;
interface XDocument: com::sun::star::uno::XInterface
{
[attribute, readonly] long numberOfPages;
// Renders a (part of a) page into a square bitmap, for Android in the
// android.graphics.Bitmap.Config.ARGB_8888 format. Despite the name, the
// order of bytes is R,G,B,A. Is this reliable, or coincidental depending
// on Android version and/or hardware? TBD. Will the same format be useful
// also for iOS? TBD.
// buffer must have an exact number of bytes for a square number of
// pixels, At the UNO level buffer is represented as the address of its
// bytes, i.e. on Android it must be a "direct" ByteBuffer for that to be
// meaningful.
// listener gets a "reasonable" number of callbacks during the rendering
// if it takes "significantly" long, and can inerrupt the rendering.
// zoomLevel is 0 for whole page, 1 for tiled into four, etc.
// x and y are in [0..2^zoomLevel]
// Should we have this method copy the rendered buffer into a Bitmap
// instead and return that? A Bitmap is presumably what the caller wants
// anyway?
// Or should we just go OpenGL ES and render into a texture?
void render( [in] hyper buffer,
[in] long bufferSize,
[in] XDocumentRenderCallback listener,
[in] long pageNo,
[in] long zoomLevel,
[in] long x,
[in] long y)
raises( com::sun::star::lang::IllegalArgumentException );
};
}; }; };
#endif
// vim:set shiftwidth=4 softtabstop=4 expandtab:
// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// Copyright 2012 LibreOffice contributors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License 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 org_libreoffice_touch_XDocumentRenderCallback_idl
#define org_libreoffice_touch_XDocumentRenderCallback_idl
#include <com/sun/star/uno/XInterface.idl>
module org { module libreoffice { module touch {
interface XDocument;
interface XDocumentRenderCallback: com::sun::star::uno::XInterface
{
// Return false from any of the callbacks if the render result isn't
// wanted after all and the rendering should stop
// pageWidth and pageHeight are in [1..squareSide] where squareSide is
// the side of the render target square implied by the size of the
// buffer passed to render().
// This always called at the start of rendering one page
boolean start( [in] long pageWidth,
[in] long pageHeight );
// Called with unspecified frequency during the rendering, possibly
// even not at all, but the intent is to call this with "reasonable"
// frquency if the rendering takes a "long" time. Maybe around ten
// times a second?
// There is no guarantee in which order the bitmap is being rendered
// fraction is in [0..1] and is an approximation of unknown exactness
// If the rendering code doesn't even bother guessing, it can pass
// zero all the time. The fraction in subsequent calls never
// decreases.
boolean progress( [in] float fraction );
// There is no callback when the rendering finishes; render() just
// returns.
};
}; }; };
#endif
// vim:set shiftwidth=4 softtabstop=4 expandtab:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* 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 _TOUCH_LIBOTOUCH_HXX
#define _TOUCH_LIBOTOUCH_HXX
#endif // _TOUCH_LIBOTOUCH_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* 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/.
*/
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* 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/.
*/
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* 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/.
*/
// NOTE: Work in progress, most likely makes little sense
#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/awt/XToolkit.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/view/XRenderable.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/basemutex.hxx>
#include <org/libreoffice/touch/Document.hpp>
using namespace ::com::sun::star;
using ::rtl::OUString;
using ::osl::MutexGuard;
namespace org { namespace libreoffice { namespace touch
{
class DocumentImpl:
public XDocument
{
private:
OUString m_sURI;
uno::Reference< uno::XComponentContext > m_rContext;
uno::Reference< lang::XComponent > m_xComponent;
uno::Reference< frame::XController > m_xController;
uno::Reference< view::XRenderable > m_xRenderable;
beans::PropertyValues m_aRenderProps;
typedef ::cppu::WeakImplHelper1< frame::XController > MyXController_Base;
class MyXController:
public MyXController_Base,
public ::cppu::BaseMutex
{
private:
uno::Reference< frame::XFrame > m_xFrame;
uno::Reference< frame::XModel > m_xModel;
public:
virtual void SAL_CALL
attachFrame( const uno::Reference< frame::XFrame >& xFrame )
throw( uno::RuntimeException )
{
m_xFrame = xFrame;
}
virtual sal_Bool SAL_CALL
attachModel( const uno::Reference< frame::XModel >& xModel )
throw( uno::RuntimeException )
{
m_xModel = xModel;
return sal_True;
}
virtual sal_Bool SAL_CALL
suspend( sal_Bool /* bSuspend */ )
throw( uno::RuntimeException )
{
return sal_False;
}
virtual uno::Any SAL_CALL getViewData()
throw( uno::RuntimeException )
{
return uno::Any();
}
virtual void SAL_CALL restoreViewData( const uno::Any& /* data */ )
throw ( uno::RuntimeException )
{
}
virtual uno::Reference< frame::XModel > SAL_CALL
getModel()
throw ( uno::RuntimeException )
{
return m_xModel;
}
virtual uno::Reference< frame::XFrame > SAL_CALL
getFrame()
throw ( uno::RuntimeException )
{
return m_xFrame;
}
virtual void SAL_CALL
dispose()
throw ( uno::RuntimeException )
{
}
virtual void SAL_CALL
addEventListener( const uno::Reference< lang::XEventListener >& /* xListener */ )
throw ( uno::RuntimeException )
{
}
virtual void SAL_CALL
removeEventListener( const uno::Reference< lang::XEventListener >& /* xListener */ )
throw ( uno::RuntimeException )
{
}
};
protected:
DocumentImpl( const uno::Reference< uno::XComponentContext > context ):
m_rContext( context )
{
}
virtual ~DocumentImpl()
{
}
// XInitialization
virtual void SAL_CALL
initialize( const uno::Sequence< uno::Any >& arguments )
throw ( uno::Exception, uno::RuntimeException )
{
if ( arguments.getLength() != 1 )
throw lang::IllegalArgumentException( OUString(), static_cast<uno::Reference< uno::XInterface> >(this), 1 );
uno::Sequence< beans::NamedValue > settings;
if ( arguments[0] >>= m_sURI )
{
// create( [in] string uri );
uno::Reference< frame::XDesktop > desktop( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.frame.Desktop", m_rContext ), uno::UNO_QUERY_THROW );
uno::Reference< frame::XComponentLoader > componentLoader( desktop, uno::UNO_QUERY_THROW );
(void) componentLoader;
beans::PropertyValues loadProps(3);
loadProps[0].Name = "Hidden";
loadProps[0].Value <<= sal_Bool(true);
loadProps[1].Name = "ReadOnly";
loadProps[1].Value <<= sal_Bool(true);
loadProps[2].Name = "Preview";
loadProps[2].Value <<= sal_Bool(true);
m_xComponent = componentLoader->loadComponentFromURL( m_sURI, "_blank", 0, loadProps );
uno::Reference< awt::XToolkit > toolkit( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.Toolkit", m_rContext ), uno::UNO_QUERY_THROW );
uno::Reference< awt::XDevice > device( toolkit->createScreenCompatibleDevice( 1024, 1024 ) );
m_xRenderable = uno::Reference< view::XRenderable >(m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.view.Renderable", m_rContext ), uno::UNO_QUERY_THROW );
m_xController = new MyXController();
m_aRenderProps.realloc( 3 );
m_aRenderProps[0].Name = "IsPrinter";
m_aRenderProps[0].Value <<= sal_Bool(true);
m_aRenderProps[1].Name = "RenderDevice";
m_aRenderProps[1].Value <<= device;
m_aRenderProps[2].Name = "View";
m_aRenderProps[2].Value <<= m_xController;
}
}
// XDocument
virtual sal_Int32 SAL_CALL
getNumberOfPages()
throw ( uno::RuntimeException )
{
uno::Any selection;
selection <<= m_xComponent;
return m_xRenderable->getRendererCount( selection, m_aRenderProps );
}
virtual void SAL_CALL
render( sal_Int64 buffer,
sal_Int32 bufferSize,
const uno::Reference< XDocumentRenderCallback >& listener,
sal_Int32 pageNo,
sal_Int32 zoomLevel,
sal_Int32 x,
sal_Int32 y )
throw ( lang::IllegalArgumentException, uno::RuntimeException)
{
(void) buffer;
(void) bufferSize;
(void) listener;
(void) pageNo;
(void) zoomLevel;
(void) x;
(void) y ;
}
};
} } } // namespace org::libreoffice::touch
/* 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