[Libreoffice-commits] core.git: 32 commits - desktop/Library_sofficeapp.mk desktop/source include/basebmp include/LibreOfficeKit include/vcl libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source Repository.mk sc/inc sc/source sw/inc sw/source vcl/headless vcl/inc vcl/source
Andrzej Hunt
andrzej.hunt at collabora.com
Wed Jun 25 05:05:59 PDT 2014
Repository.mk | 2
desktop/Library_sofficeapp.mk | 4
desktop/source/lib/init.cxx | 199 +++++++++++++++++---
include/LibreOfficeKit/LibreOfficeKit.h | 46 ++++
include/LibreOfficeKit/LibreOfficeKit.hxx | 37 +++
include/LibreOfficeKit/LibreOfficeKitGtk.h | 65 ++++++
include/basebmp/rgbmaskpixelformats.hxx | 10 +
include/vcl/ITiledRenderable.hxx | 48 ++++
include/vcl/salbtype.hxx | 29 +-
include/vcl/virdev.hxx | 16 +
libreofficekit/Executable_gtktiledviewer.mk | 49 ++++
libreofficekit/Library_libreofficekitgtk.mk | 31 +++
libreofficekit/Module_libreofficekit.mk | 11 +
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 127 ++++++++++++
libreofficekit/source/gtk/lokdocview.c | 162 ++++++++++++++++
sc/inc/docuno.hxx | 13 +
sc/source/ui/inc/gridwin.hxx | 5
sc/source/ui/unoobj/docuno.cxx | 23 ++
sc/source/ui/view/gridwin4.cxx | 14 +
sw/inc/unotxdoc.hxx | 14 +
sw/source/core/view/viewsh.cxx | 10 -
sw/source/uibase/uno/unotxdoc.cxx | 18 +
vcl/headless/svpbmp.cxx | 40 +---
vcl/headless/svpinst.cxx | 45 ++++
vcl/headless/svpvd.cxx | 50 ++---
vcl/inc/headless/svpinst.hxx | 12 +
vcl/inc/headless/svpvd.hxx | 7
vcl/inc/salvd.hxx | 8
vcl/source/gdi/bmpacc2.cxx | 8
vcl/source/gdi/virdev.cxx | 24 +-
30 files changed, 1010 insertions(+), 117 deletions(-)
New commits:
commit 2c658ae4fb9d24b6c63dce20af1c244d25862357
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 24 21:13:42 2014 +0100
LOK DocView: clean up document on exit.
Otherwise lock files etc. aren't cleaned up, which isn't particularly
nice should when then opening the file in normal LibreOffice.
Change-Id: I822b6fb582473674371a4c1d403d5a05adb7ea6b
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 99f2b15..bf86679 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -17,6 +17,15 @@
static void lok_docview_class_init( LOKDocViewClass* pClass );
static void lok_docview_init( LOKDocView* pDocView );
+// We specifically need to destroy the document when closing in order to ensure
+// that lock files etc. are cleaned up.
+void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
+{
+ (void) pData;
+ pDocView->pDocument->pClass->destroy( pDocView->pDocument );
+ pDocView->pDocument = 0;
+}
+
SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
{
static guint lok_docview_type = 0;
@@ -70,6 +79,9 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView->pDocument = 0;
pDocView->fZoom = 1;
+
+ gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
+ GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
}
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
commit 4171e2fdb29c728a4a74764b73ba5cbf53feebda
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 23 15:13:40 2014 +0100
Add zoom controls to gtktiledviewer.
Change-Id: I33ae83a97be254a3d3716bd9ae05f089845fd536
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 3549903..bc4ad09 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -21,6 +21,52 @@ static int help()
return 1;
}
+static GtkWidget* pDocView;
+
+const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 };
+
+void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
+{
+ const char *sName = gtk_tool_button_get_stock_id( GTK_TOOL_BUTTON(pButton) );
+
+ float fZoom = 0;
+ const float fCurrentZoom = lok_docview_get_zoom( LOK_DOCVIEW(pDocView) );
+ if ( strcmp(sName, "gtk-zoom-in") == 0)
+ {
+ for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
+ {
+ if ( fCurrentZoom < fZooms[i] )
+ {
+ fZoom = fZooms[i];
+ break;
+ }
+ }
+ }
+ else if ( strcmp(sName, "gtk-zoom-100") == 0)
+ {
+ fZoom = 1;
+ }
+ else if ( strcmp(sName, "gtk-zoom-fit") == 0)
+ {
+ // TODO -- will need access to lokdocview internals?
+ }
+ else if ( strcmp(sName, "gtk-zoom-out") == 0)
+ {
+ for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ )
+ {
+ if ( fCurrentZoom > fZooms[i] )
+ {
+ fZoom = fZooms[i];
+ }
+ }
+ }
+
+ if ( fZoom != 0 )
+ {
+ lok_docview_set_zoom( LOK_DOCVIEW(pDocView), fZoom );
+ }
+}
+
int main( int argc, char* argv[] )
{
if( argc < 2 ||
@@ -42,14 +88,38 @@ int main( int argc, char* argv[] )
gtk_window_set_default_size(GTK_WINDOW(pWindow), 800, 600);
g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
+ GtkWidget* pVBox = gtk_vbox_new( FALSE, 0 );
+ gtk_container_add( GTK_CONTAINER(pWindow), pVBox );
- GtkWidget* pDocView = lok_docview_new( pOffice );
- gtk_container_add( GTK_CONTAINER(pWindow), pDocView );
+ // Toolbar
+ GtkWidget* pToolbar = gtk_toolbar_new();
+ gtk_toolbar_set_style( GTK_TOOLBAR(pToolbar), GTK_TOOLBAR_ICONS );
- lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
+ GtkToolItem* pZoomIn = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_IN );
+ gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomIn, 0);
+ g_signal_connect( G_OBJECT(pZoomIn), "clicked", G_CALLBACK(changeZoom), NULL );
+
+ GtkToolItem* pZoom1 = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_100 );
+ gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoom1, -1);
+ g_signal_connect( G_OBJECT(pZoom1), "clicked", G_CALLBACK(changeZoom), NULL );
- gtk_widget_show( pDocView );
- gtk_widget_show( pWindow );
+ GtkToolItem* pZoomFit = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_FIT );
+ gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomFit, -1);
+ g_signal_connect( G_OBJECT(pZoomFit), "clicked", G_CALLBACK(changeZoom), NULL );
+
+ GtkToolItem* pZoomOut = gtk_tool_button_new_from_stock( GTK_STOCK_ZOOM_OUT );
+ gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomOut, -1);
+ g_signal_connect( G_OBJECT(pZoomOut), "clicked", G_CALLBACK(changeZoom), NULL );
+
+ gtk_box_pack_start( GTK_BOX(pVBox), pToolbar, FALSE, FALSE, 0 ); // Adds to top.
+
+ // Docview
+ pDocView = lok_docview_new( pOffice );
+ gtk_container_add( GTK_CONTAINER(pVBox), pDocView );
+
+ gtk_widget_show_all( pWindow );
+
+ lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
gtk_main();
commit 6024ddbfac8e62db50dd5352d610c87d279627de
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 23 15:13:25 2014 +0100
LOK Docview: add set_zoom
Change-Id: I902f3a134b4a7dcc721eff3f67376014a4276885
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 2435fc2..f160925 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -37,6 +37,8 @@ struct _LOKDocView
GtkWidget* pCanvas;
GdkPixbuf* pPixBuf;
+ float fZoom;
+
LibreOfficeKit* pOffice;
LibreOfficeKitDocument* pDocument;
};
@@ -52,6 +54,9 @@ guint lok_docview_get_type (void);
GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
gboolean lok_docview_open_document (LOKDocView* pDocView,
char* pPath);
+void lok_docview_set_zoom (LOKDocView* pDocView,
+ float fZoom);
+float lok_docview_get_zoom (LOKDocView* pDocView);
#ifdef __cplusplus
}
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 4a16db0..99f2b15 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -68,6 +68,8 @@ static void lok_docview_init( LOKDocView* pDocView )
// TODO: figure out a clever view of getting paths set up.
pDocView->pOffice = 0;
pDocView->pDocument = 0;
+
+ pDocView->fZoom = 1;
}
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
@@ -77,16 +79,10 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
return GTK_WIDGET( pDocView );
}
-SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+void renderDocument( LOKDocView* pDocView )
{
- if ( pDocView->pDocument )
- {
- pDocView->pDocument->pClass->destroy( pDocView->pDocument );
- pDocView->pDocument = 0;
- }
+ g_assert( pDocView->pDocument );
- pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
- pPath );
if ( pDocView->pPixBuf )
{
g_object_unref( G_OBJECT( pDocView->pPixBuf ) );
@@ -96,15 +92,17 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
pDocView->pDocument->pClass->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight );
// Draw the whole document at once (for now)
- int nRenderWidth = nWidth / 10;
- int nRenderHeight = nHeight / 10;
+
+ // TODO: we really should scale by screen DPI here -- 10 seems to be a vaguely
+ // correct factor for my screen at least.
+ int nRenderWidth = nWidth * pDocView->fZoom / 10;
+ int nRenderHeight = nHeight * pDocView->fZoom / 10;
pDocView->pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
TRUE, 8,
nRenderWidth, nRenderHeight);
- // TODO: move the rendering into it's own function etc.
unsigned char* pBuffer = gdk_pixbuf_get_pixels( pDocView->pPixBuf );
int nRowStride;
pDocView->pDocument->pClass->paintTile( pDocView->pDocument,
@@ -119,8 +117,34 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
(void) nRowStride;
gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas ), pDocView->pPixBuf );
+}
+
+SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+{
+ if ( pDocView->pDocument )
+ {
+ pDocView->pDocument->pClass->destroy( pDocView->pDocument );
+ pDocView->pDocument = 0;
+ }
+
+ pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
+ pPath );
+
+ renderDocument( pDocView );
return FALSE;
}
+SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom )
+{
+ pDocView->fZoom = fZoom;
+ renderDocument( pDocView );
+ // TODO: maybe remember and reset positiong?
+}
+
+SAL_DLLPUBLIC_EXPORT float lok_docview_get_zoom ( LOKDocView* pDocView )
+{
+ return pDocView->fZoom;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3545b78755672321e3017fd25dec756827459fb6
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:51:15 2014 +0100
Use full sofficerc for LOK.
Otherwise we get segfaults in cppu::idefaultConstructElements when exiting,
in addition to complaints of:
ignoring GError "Operation not supported" for <***RECURSION DETECTED***/log.txt>
Change-Id: If2f56873f50ba957288d1e5591db967d248ee7a4
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c3792ad..7e112f4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -520,16 +520,7 @@ static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
static void initialize_uno(const OUString &aAppURL)
{
- rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
-
- rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
- "xcsxcu:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
- "res:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
-// "bundledext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
-// "sharedext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
-// "userext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
-// "user:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
- );
+ rtl::Bootstrap::setIniFilename( aAppURL + "/sofficerc" );
xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf(stderr, "Uno initialized %d\n", xContext.is());
commit 5da5882df48b4ef9cb9807798102453249cd1aef
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 13:50:49 2014 +0100
Add tiled rendering outline to Calc.
(No real implementation yet.)
Change-Id: I67b84b554dbb29db449d8c190ef816645a8bff07
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 9e2f53c..27575fe 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -54,6 +54,7 @@
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <svl/itemprop.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include "drwlayer.hxx"
class ScDocShell;
@@ -69,6 +70,7 @@ class ScPrintUIOptions;
class ScSheetSaveData;
class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
+ public ::vcl::ITiledRenderable,
public com::sun::star::sheet::XSpreadsheetDocument,
public com::sun::star::document::XActionLockable,
public com::sun::star::sheet::XCalculatable,
@@ -350,6 +352,17 @@ public:
virtual com::sun::star::uno::Sequence< com::sun::star::sheet::opencl::OpenCLPlatform >
SAL_CALL getOpenCLPlatforms()
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+
+ // ITiledRenderable
+ virtual void paintTile( VirtualDevice& rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
+ virtual Size getDocumentSize() SAL_OVERRIDE;
};
class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index df03b88..17b02f8 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -321,6 +321,11 @@ public:
virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
+ void PaintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight );
+
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
void FakeButtonUp();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 16d50ed..57a80b5 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -96,6 +96,7 @@
#include "platforminfo.hxx"
#include "interpre.hxx"
#include "formulagroup.hxx"
+#include "gridwin.hxx"
#include <columnspanset.hxx>
using namespace com::sun::star;
@@ -446,6 +447,28 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange )
pDocShell->PostPaint( rRange, PAINT_GRID );
}
+void ScModelObj::paintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ // There seems to be no clear way of getting the grid window for this
+ // particular document, hence we need to hope we get the right window.
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+ pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight );
+}
+
+Size ScModelObj::getDocumentSize()
+{
+ // TODO: not sure what we want to do here, maybe just return the size for a certain
+ // default minimum number of cells, e.g. 100x100 and more if more cells have
+ // content?
+ return Size();
+}
+
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
throw(uno::RuntimeException, std::exception)
{
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 24a6fb5..fa697ee5 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -870,6 +870,20 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
rDoc.ClearFormulaContext();
}
+void ScGridWindow::PaintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ (void) rDevice;
+ (void) nOutputWidth;
+ (void) nOutputHeight;
+ (void) nTilePosX;
+ (void) nTilePosY;
+ (void) nTileWidth;
+ (void) nTileHeight;
+}
+
void ScGridWindow::CheckNeedsRepaint()
{
// called at the end of painting, and from timer after background text width calculation
commit cd96b0498d9147422ecb25a38aa2b04a480cdfa9
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:32:44 2014 +0100
Use ITiledRenderable for LIBLOK.
Means that no changes should be required here once calc/impress/draw
support tiled rendering.
Change-Id: I0987d94303f39ba37e29b9ae7b2276e82dc0ccbf
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 671ff12..8a592cc 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -14,7 +14,6 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/source/deployment/inc \
- -I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/vcl/inc \
))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 605f109..c3792ad 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -42,17 +42,11 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx>
#include <osl/module.hxx>
-// Dirty hack -- we go directly into sw -- ideally we need some sort of
-// layer to get the writer shell for tiled rendering
-#include <doc.hxx>
-#include <docsh.hxx>
-#include <unotxdoc.hxx>
-#include <viewsh.hxx>
-
#include <salinst.hxx>
// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
@@ -445,38 +439,32 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
Application::AcquireSolarMutex(1);
- switch (doc_getDocumentType(pThis))
{
- case LOK_DOCTYPE_TEXT:
- {
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
-
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
- }
- break;
- default:
- break;
+ *pRowStride = pBmpDev->getScanlineStride();
}
Application::ReleaseSolarMutex();
}
@@ -487,20 +475,16 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (pDoc)
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- Size aDocumentSize = pViewShell->GetDocSize();
+ Size aDocumentSize = pDoc->getDocumentSize();
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
else
{
- pWidth = 0;
- pHeight = 0;
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
}
}
commit f35b010a95ad877988bb5eaa4f689644b00f702c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:31:42 2014 +0100
Add ITiledRenderable.
We want to have a simple interface that allows access to tiled
rendering without digging into the internals of writer
(and in the future calc/impress/draw).
Change-Id: Ia9c278a48c919333186e5361ff25bb1ab603b846
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
new file mode 100644
index 0000000..fecfd6c
--- /dev/null
+++ b/include/vcl/ITiledRenderable.hxx
@@ -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 INCLUDED_VCL_ITILEDRENDERABLE_HXX
+#define INCLUDED_VCL_ITILEDRENDERABLE_HXX
+
+#include <tools/gen.hxx>
+#include <vcl/virdev.hxx>
+
+namespace vcl
+{
+
+class VCL_DLLPUBLIC ITiledRenderable
+{
+public:
+ virtual ~ITiledRenderable() {};
+
+ /**
+ * Paint a tile to a given VirtualDevice.
+ *
+ * Output parameters are measured in pixels, tile parameters are in
+ * twips.
+ */
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) = 0;
+
+ /**
+ * Get the document size in twips.
+ */
+ virtual Size getDocumentSize() = 0;
+
+};
+
+} // namespace vcl
+
+#endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e43ea2b..a48a8f3 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -67,6 +67,7 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase4.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unobaseclass.hxx>
#include <viewopt.hxx>
@@ -161,7 +162,8 @@ SwXTextDocumentBaseClass;
class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
public SvxFmMSFactory,
- public SfxBaseModel
+ public SfxBaseModel,
+ public ::vcl::ITiledRenderable
{
private:
class Impl;
@@ -428,6 +430,16 @@ public:
// ::com::sun::star::util::XCloneable
virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ // ITiledRenderable
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
+ virtual Size getDocumentSize() SAL_OVERRIDE;
+
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
SwXDocumentPropertyHelper * GetPropertyHelper ();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 1ce5469..b61eb77 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3119,6 +3119,24 @@ uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::
return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
}
+void SwXTextDocument::paintTile( VirtualDevice &rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+}
+
+Size SwXTextDocument::getDocumentSize()
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ return pViewShell->GetDocSize();
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);
commit 837631c6cfa189280f9e723481f2251de56a1d92
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 15:00:42 2014 +0100
LIBLOK: implement getDocumentType, make doctypes unique.
Change-Id: I6cf810af55284cb6ddd9e0bfd879fd19508d127a
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4959195..605f109 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -307,31 +307,23 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
try
{
- uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
- uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
-
- MediaDescriptor aMediaDescriptor(aSequence);
- OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
- OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+ const ExtensionMap* pMap;
- if (aDocumentService.isEmpty())
+ switch (doc_getDocumentType(pThis))
{
- gImpl->maLastExceptionMsg = "unknown document type";
- return false;
- }
-
- const ExtensionMap* pMap;
- if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ case LOK_DOCTYPE_SPREADSHEET:
pMap = (const ExtensionMap*) aCalcExtensionMap;
- else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ break;
+ case LOK_DOCTYPE_PRESENTATION:
pMap = (const ExtensionMap*) aImpressExtensionMap;
- else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ break;
+ case LOK_DOCTYPE_DRAWING:
pMap = (const ExtensionMap*) aDrawExtensionMap;
- else if (aDocumentService == "com.sun.star.text.TextDocument")
+ break;
+ case LOK_DOCTYPE_TEXT:
pMap = (const ExtensionMap*) aWriterExtensionMap;
- else
- {
- gImpl->maLastExceptionMsg = "unknown document mapping";
+ break;
+ case LOK_DOCTYPE_OTHER:
return false;
}
@@ -386,8 +378,49 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* pThis)
{
- (void) pThis;
- return WRITER;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ try
+ {
+ uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
+
+ MediaDescriptor aMediaDescriptor(aSequence);
+ OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
+ OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+
+ if (aDocumentService.isEmpty())
+ {
+ gImpl->maLastExceptionMsg = "unknown document type";
+ return LOK_DOCTYPE_OTHER;
+ }
+
+ if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ {
+ return LOK_DOCTYPE_SPREADSHEET;
+ }
+ else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ {
+ return LOK_DOCTYPE_PRESENTATION;
+ }
+ else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ {
+ return LOK_DOCTYPE_DRAWING;
+ }
+ else if (aDocumentService == "com.sun.star.text.TextDocument")
+ {
+ return LOK_DOCTYPE_TEXT;
+ }
+ else
+ {
+ gImpl->maLastExceptionMsg = "unknown document mapping";
+ }
+ }
+ catch (const uno::Exception& exception)
+ {
+ gImpl->maLastExceptionMsg = "exception: " + exception.Message;
+ }
+ return LOK_DOCTYPE_OTHER;
}
static int doc_getNumberOfParts (LibreOfficeKitDocument* pThis)
@@ -412,30 +445,38 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
Application::AcquireSolarMutex(1);
+ switch (doc_getDocumentType(pThis))
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ case LOK_DOCTYPE_TEXT:
+ {
+ SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
+ SwDocShell* pDocShell = pTxtDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
+ *pRowStride = pBmpDev->getScanlineStride();
+ }
+ break;
+ default:
+ break;
}
Application::ReleaseSolarMutex();
}
@@ -446,7 +487,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (true) // TODO: test that we have a writer document here (vs calc/impress/etc.)
+ if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
SwDocShell* pDocShell = pTxtDoc->GetDocShell();
@@ -456,6 +497,11 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
+ else
+ {
+ pWidth = 0;
+ pHeight = 0;
+ }
}
static char* lo_getError (LibreOfficeKit *pThis)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index db9aff2..77a8d0f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -33,10 +33,11 @@ typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass;
#ifdef LOK_USE_UNSTABLE_API
typedef enum
{
- WRITER,
- SPREADSHEET,
- PRESENTATION,
- OTHER
+ LOK_DOCTYPE_TEXT,
+ LOK_DOCTYPE_SPREADSHEET,
+ LOK_DOCTYPE_PRESENTATION,
+ LOK_DOCTYPE_DRAWING,
+ LOK_DOCTYPE_OTHER
}
LibreOfficeKitDocumentType;
#endif // LOK_USE_UNSTABLE_API
commit eaa21b726db220c7883453f197aac81a6d35b201
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:21:38 2014 +0100
Prevent GTK assertions due to scrolled window not being initialised.
Seems to be a gtk bug which we need to work around. The assertions
don't actually seem to cause any harm (they just print a bunch of
"Gtk-CRITICAL **: IA__gtk_range_get_adjustment: assertion `GTK_IS_RANGE (range)' failed"
but probably best to avoid them.
Change-Id: I5d1bb20bd5c0569c6d023a6148123208a15b9de2
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 4302040..4a16db0 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -47,6 +47,12 @@ static void lok_docview_class_init( LOKDocViewClass* pClass )
static void lok_docview_init( LOKDocView* pDocView )
{
+ // Gtk ScrolledWindow is apparently not fully initialised yet, we specifically
+ // have to set the [hv]adjustment to prevent GTK assertions from firing, see
+ // https://bugzilla.gnome.org/show_bug.cgi?id=438114 for more info.
+ gtk_scrolled_window_set_hadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
+ gtk_scrolled_window_set_vadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
+
pDocView->pEventBox = gtk_event_box_new();
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
pDocView->pEventBox );
commit 0cea87d60cfdc2bbc7c6b5d5ee9918e283fc7b2c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:20:15 2014 +0100
Move gtktiledviewer into libreofficekit.
desktop is no longer the right place for it now that
libreofficekit has its own directory.
Change-Id: I207f1d642e7e35c460ff85bb57aa142cb98023c8
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index 04b71f7..cfaf0d9 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -29,14 +29,6 @@ $(eval $(call gb_Module_add_l10n_targets,desktop,\
UIConfig_deployment \
))
-ifeq ($(OS),LINUX)
-ifneq ($(ENABLE_GTK),)
-$(eval $(call gb_Module_add_targets,desktop,\
- Executable_gtktiledviewer \
-))
-endif
-endif
-
ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,desktop,\
Executable_soffice_bin \
diff --git a/desktop/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
similarity index 95%
rename from desktop/Executable_gtktiledviewer.mk
rename to libreofficekit/Executable_gtktiledviewer.mk
index a0bf8ea..0ce9222 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -43,7 +43,7 @@ $(eval $(call gb_Executable_add_libs,gtktiledviewer,\
endif
$(eval $(call gb_Executable_add_exception_objects,gtktiledviewer,\
- desktop/qa/gtktiledviewer/gtktiledviewer \
+ libreofficekit/qa/gtktiledviewer/gtktiledviewer \
))
# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 0412a33..55136a4 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -10,10 +10,18 @@
$(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
+
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
Library_libreofficekitgtk \
))
-endif
+
+ifneq ($(ENABLE_GTK),)
+$(eval $(call gb_Module_add_targets,libreofficekit,\
+ Executable_gtktiledviewer \
+))
+endif # ($(ENABLE_GTK),)
+
+endif # ($(OS),LINUX)
# vim: set ts=4 sw=4 et:
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
similarity index 90%
rename from desktop/qa/gtktiledviewer/gtktiledviewer.cxx
rename to libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2c80a8d..3549903 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -34,13 +34,6 @@ int main( int argc, char* argv[] )
}
LibreOfficeKit* pOffice = lok_init( argv[1] );
- if( !pOffice )
- {
- fprintf( stderr, "Failed to initialize\n" );
- return -1;
- }
-
- ::lok::Document* pDocument = pOffice->documentLoad( argv[2] );
gtk_init( &argc, &argv );
commit ff6a38b76df80d0f907f2f92cb851dea43c91d81
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 10:43:07 2014 +0100
Tiled Rendering: ensure rendered area is visible.
MakeVisible only scrolls the view, so parts of the tile to be rendered
might be outside the SwView's visible area, and therefore not painted.
This however makes the background window (shown for the tilederendering
app) unuseable (but that window is invisible for all practical uses
of tiled rendering, and hence probably not a problem).
Change-Id: I6c3c2846906163b362f7cff6d8c7ba308a58a7ad
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index ea111dd..cc80298 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1784,8 +1784,14 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
Imp()->GetDrawView()->AddWindowToPaintView(&rDevice);
}
- // scroll the requested area into view if necessary
- MakeVisible(SwRect(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+ // Make the requested area visible -- we can't use MakeVisible as that will
+ // only scroll the contents, but won't zoom/resize if needed.
+ // Without this, items/text that are outside the visible area (in the SwView)
+ // won't be painted when rendering tiles (at least when using either the
+ // tiledrendering app, or the gtktiledviewer) -- although ultimately we
+ // probably want to fix things so that the SwView's area doesn't affect
+ // tiled rendering?
+ mpDoc->GetDocShell()->SetVisArea(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
// draw - works in logic coordinates
Paint(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
commit 17f223c195867df8356a9e8c86981d88ce3b4b05
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 25 09:19:02 2014 +0100
Implement data area size retrieval.
The scaling is wrong, but seems to work in principle
(i.e. we get roughly 1.5x the correct size).
Conflicts:
sc/source/ui/view/gridwin4.cxx
Change-Id: I6db1986e6cb1e5f3889ec3a462d999a9eab57331
diff --git a/desktop/Executable_gtktiledviewer.mk b/desktop/Executable_gtktiledviewer.mk
index 6295f5e..a0bf8ea 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/desktop/Executable_gtktiledviewer.mk
@@ -18,6 +18,10 @@ $(eval $(call gb_Executable_use_externals,gtktiledviewer,\
gtk \
))
+$(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
+ libreofficekitgtk \
+))
+
$(eval $(call gb_Executable_use_static_libraries,gtktiledviewer,\
libreofficekit \
))
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index f5690b4..2c80a8d 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -13,10 +13,7 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#define LOK_USE_UNSTABLE_API
-#include <LibreOfficeKit/LibreOfficeKit.hxx>
-
-using namespace ::lok;
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
static int help()
{
@@ -24,56 +21,6 @@ static int help()
return 1;
}
-static GtkWidget* ourCanvas;
-static GdkPixbuf* ourPixBuf = 0;
-
-bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
-{
- fprintf(stderr, "attempting to draw tile");
-
- Document* pDocument = static_cast< Document* >( pData );
-
- long nWidth, nHeight;
- pDocument->getDocumentSize( &nWidth, &nHeight );
-
- // Draw the whole document at once (for now)
- int nRenderWidth = nWidth / 10;
- int nRenderHeight = nHeight / 10;
- int nRowStride;
-
- if ( ourPixBuf &&
- (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
- gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
- {
- g_object_unref( G_OBJECT( ourPixBuf ) );
- ourPixBuf = 0;
-
- }
- if (!ourPixBuf)
- {
- ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight);
- }
-
- unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
-
- pDocument->paintTile( pBuffer,
- nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
- // TODO: double check that the rowstride really matches what we expected,
- // although presumably we'd already be crashing by now if things were
- // wrong.
- (void) nRowStride;
-
- gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
-
- return true;
-
-}
-
int main( int argc, char* argv[] )
{
if( argc < 2 ||
@@ -86,7 +33,7 @@ int main( int argc, char* argv[] )
return 1;
}
- ::lok::Office *pOffice = ::lok::lok_cpp_init( argv[1] );
+ LibreOfficeKit* pOffice = lok_init( argv[1] );
if( !pOffice )
{
fprintf( stderr, "Failed to initialize\n" );
@@ -103,25 +50,14 @@ int main( int argc, char* argv[] )
g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
- GtkWidget* pScroller = gtk_scrolled_window_new( 0, 0 );
- gtk_container_add( GTK_CONTAINER(pWindow), pScroller );
-
- GtkWidget* pEventBox = gtk_event_box_new();
- gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pScroller), pEventBox );
+ GtkWidget* pDocView = lok_docview_new( pOffice );
+ gtk_container_add( GTK_CONTAINER(pWindow), pDocView );
- GtkWidget* pCanvas = gtk_image_new();
- ourCanvas = pCanvas;
- gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
+ lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
- g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument);
-
- gtk_widget_show( pCanvas );
- gtk_widget_show( pEventBox );
- gtk_widget_show( pScroller );
+ gtk_widget_show( pDocView );
gtk_widget_show( pWindow );
- drawCallback( pCanvas, 0, pDocument );
-
gtk_main();
return 0;
commit d465dfb209948a795e393bfc4a05485e893f24d0
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 17:38:10 2014 +0100
Implement LibreOfficeKit gtk+ viewer widget.
Very basic, but works.
Change-Id: I0c521e833b53e13065e0be48e6fa767e44b29787
diff --git a/Repository.mk b/Repository.mk
index 8210aba..1c4298b 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -524,6 +524,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
i18nlangtag \
i18nutil \
index_data \
+ $(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), libreofficekitgtk) \
localedata_en \
localedata_es \
localedata_euro \
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
new file mode 100644
index 0000000..2435fc2
--- /dev/null
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -0,0 +1,60 @@
+/* -*- 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 INCLUDED_DESKTOP_INC_LIBREOFFICEKITGTK_H
+#define INCLUDED_DESKTOP_INC_LIBREOFFICEKITGTK_H
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define LOK_DOCVIEW(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
+#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
+#define IS_LOK_DOCVIEW(obj) GTK_CHECK_TYPE (obj, lok_docview_get_type())
+
+
+typedef struct _LOKDocView LOKDocView;
+typedef struct _LOKDocViewClass LOKDocViewClass;
+
+struct _LOKDocView
+{
+ GtkScrolledWindow scrollWindow;
+
+ GtkWidget* pEventBox;
+ GtkWidget* pCanvas;
+ GdkPixbuf* pPixBuf;
+
+ LibreOfficeKit* pOffice;
+ LibreOfficeKitDocument* pDocument;
+};
+
+struct _LOKDocViewClass
+{
+ GtkScrolledWindowClass parent_class;
+
+ void (*lok_docview) (LOKDocView* pDocView);
+};
+
+guint lok_docview_get_type (void);
+GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
+gboolean lok_docview_open_document (LOKDocView* pDocView,
+ char* pPath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
new file mode 100644
index 0000000..be485cd
--- /dev/null
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -0,0 +1,31 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,libreofficekitgtk))
+
+
+$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
+ gtk \
+))
+
+$(eval $(call gb_Library_use_static_libraries,libreofficekitgtk,\
+ libreofficekit \
+))
+
+$(eval $(call gb_Library_add_cobjects,libreofficekitgtk,\
+ libreofficekit/source/gtk/lokdocview \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Library_add_libs,libreofficekitgtk,\
+ -ldl \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 1d65d45..0412a33 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
+ Library_libreofficekitgtk \
))
endif
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
new file mode 100644
index 0000000..4302040
--- /dev/null
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -0,0 +1,120 @@
+/* -*- 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 <sal/types.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
+
+static void lok_docview_class_init( LOKDocViewClass* pClass );
+static void lok_docview_init( LOKDocView* pDocView );
+
+SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
+{
+ static guint lok_docview_type = 0;
+
+ if (!lok_docview_type)
+ {
+ GtkTypeInfo lok_docview_info =
+ {
+ "LokDocView",
+ sizeof( LOKDocView ),
+ sizeof( LOKDocViewClass ),
+ (GtkClassInitFunc) lok_docview_class_init,
+ (GtkObjectInitFunc) lok_docview_init,
+ NULL,
+ NULL,
+ (GtkClassInitFunc) NULL
+ };
+
+ lok_docview_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_info );
+ }
+ return lok_docview_type;
+}
+
+static void lok_docview_class_init( LOKDocViewClass* pClass )
+{
+ pClass->lok_docview = NULL;
+}
+
+static void lok_docview_init( LOKDocView* pDocView )
+{
+ pDocView->pEventBox = gtk_event_box_new();
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
+ pDocView->pEventBox );
+
+ pDocView->pCanvas = gtk_image_new();
+ gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pCanvas );
+
+ gtk_widget_show( pDocView->pCanvas );
+ gtk_widget_show( pDocView->pEventBox );
+
+ pDocView->pPixBuf = 0;
+
+ // TODO: figure out a clever view of getting paths set up.
+ pDocView->pOffice = 0;
+ pDocView->pDocument = 0;
+}
+
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
+{
+ LOKDocView* pDocView = gtk_type_new( lok_docview_get_type() );
+ pDocView->pOffice = pOffice;
+ return GTK_WIDGET( pDocView );
+}
+
+SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+{
+ if ( pDocView->pDocument )
+ {
+ pDocView->pDocument->pClass->destroy( pDocView->pDocument );
+ pDocView->pDocument = 0;
+ }
+
+ pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
+ pPath );
+ if ( pDocView->pPixBuf )
+ {
+ g_object_unref( G_OBJECT( pDocView->pPixBuf ) );
+ }
+
+ long nWidth, nHeight;
+ pDocView->pDocument->pClass->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight );
+
+ // Draw the whole document at once (for now)
+ int nRenderWidth = nWidth / 10;
+ int nRenderHeight = nHeight / 10;
+
+ pDocView->pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ nRenderWidth, nRenderHeight);
+
+
+ // TODO: move the rendering into it's own function etc.
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( pDocView->pPixBuf );
+ int nRowStride;
+ pDocView->pDocument->pClass->paintTile( pDocView->pDocument,
+ pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // TODO: double check that the rowstride really matches what we expected,
+ // although presumably we'd already be crashing by now if things were
+ // wrong.
+ (void) nRowStride;
+
+ gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas ), pDocView->pPixBuf );
+
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e6b881521c5220a2504811ecfaed1c5cc33910d6
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 15:14:58 2014 +0100
Remove outdated includes.
These were needed for the X11 "context" rendering which is no longer used.
Change-Id: Ib60c8fff9dad06b1f8f489eed66c3b3c3597e1ee
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 1f238a9..f5690b4 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -11,15 +11,8 @@
#include <string.h>
#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <X11/extensions/Xrender.h>
-
-// Only for the SystemGraphicsData struct, and hopefully we can find some better
-// replacement for that at some point.
-#include <vcl/sysdata.hxx>
-
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.hxx>
commit 539552484dcba8fc97d26a04ef903b4139ba9a2f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:54:49 2014 +0100
Kill gtktiledviewer's alpha channel hack.
basebmp and vcl now set the alpha channel appropriately, so no need
to do so in the viewer now.
However it would perhaps make more sense to just use RGB instead
of RGBA, seeing as the alpha channel is permanently set to be opaque.
Change-Id: I86ad758c6a8bee21b265730727a76605e5850c0c
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 2ffa599..1f238a9 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -75,11 +75,6 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
// wrong.
(void) nRowStride;
- for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
- {
- pBuffer[i] = 0xFF;
- }
-
gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
return true;
commit cd1f3480a6ebff075f243bde5891a3e8f3c9533c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:39:56 2014 +0100
Fill the alpha channel by default for vcl 32-bit bitmaps too.
Otherwise the alpha channel for bitmaps created directly is empty,
indicating a transparent bitmap (although we don't actually handle
transparency). This complements hardcoding of the alpha channel
in basebmp. VCL bitmaps can be copied bit-for-bit directly into
a basebmp bitmap, hence it's important to make sure we fill the
alpha channel in vcl too.
Conflicts:
include/vcl/salbtype.hxx
Change-Id: Icb2fa417db6625a6ffa6bd82eb5773ff75be5a3c
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index ccdbfbe..92258c5 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -84,13 +84,14 @@ d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift
-#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS ) \
+#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_ALPHA ) \
( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \
( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \
( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \
( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \
( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \
- ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) )
+ ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) | \
+ d_ALPHA )
// - BitmapColor -
@@ -215,12 +216,16 @@ class VCL_DLLPUBLIC ColorMask
sal_uLong mnROr;
sal_uLong mnGOr;
sal_uLong mnBOr;
+ sal_uLong mnAlphaChannel;
SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const;
public:
- inline ColorMask( sal_uLong nRedMask = 0UL, sal_uLong nGreenMask = 0UL, sal_uLong nBlueMask = 0UL );
+ inline ColorMask( sal_uLong nRedMask = 0UL,
+ sal_uLong nGreenMask = 0UL,
+ sal_uLong nBlueMask = 0UL,
+ sal_uLong nAlphaChannel = 0UL );
inline ~ColorMask() {}
inline sal_uLong GetRedMask() const;
@@ -698,7 +703,10 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const
-inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask ) :
+inline ColorMask::ColorMask( sal_uLong nRedMask,
+ sal_uLong nGreenMask,
+ sal_uLong nBlueMask,
+ sal_uLong nAlphaChannel ) :
mnRMask( nRedMask ),
mnGMask( nGreenMask ),
mnBMask( nBlueMask ),
@@ -707,7 +715,8 @@ inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong
mnBOrShift( 0L ),
mnROr( 0L ),
mnGOr( 0L ),
- mnBOr( 0L )
+ mnBOr( 0L ),
+ mnAlphaChannel( nAlphaChannel )
{
mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L );
mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L );
@@ -774,7 +783,7 @@ inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
}
@@ -790,7 +799,7 @@ inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
pPixel[ 1 ] = (sal_uInt8) nVal;
@@ -809,7 +818,7 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal;
pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
@@ -828,7 +837,7 @@ inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
}
@@ -857,7 +866,7 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8&
inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL );
}
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 0a81fdc..3920aea 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -188,36 +188,36 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#endif
break;
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index bf1d540..12b0c1d 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -179,7 +179,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetRed();
@@ -198,7 +198,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetBlue();
@@ -220,7 +220,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetRed();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
@@ -239,7 +239,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetBlue();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
commit e756452c40b39fc0fc7ea15b446b88c6c8736c90
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 10 17:15:49 2014 +0100
Add base value to set alpha channel for 32 bit colourspaces.
Currently the alpha channel is completely ignored by basebmp.
However this results in completely "transparent" output, meaning
the client has to manually overwrite the alpha channel -- instead
we now set it automatically when writing colourdata.
Unfortunately this doesn't quite work -- it seems that drawing
a non-opaque bitmap/image on top of the existing bitmap can
erase the alpha channel information (i.e. these areas will
once again be transparent -- for example document borders seem
to have a transition effect overlayed onto them): presumably
there is some method that bypasses our RGBMaskSetter (probably
some form of direct manipulation of raw values?).
manipulation in basebmp
Change-Id: Ia4be6a748cc30191a4422121f9ec347d9198b225
diff --git a/include/basebmp/rgbmaskpixelformats.hxx b/include/basebmp/rgbmaskpixelformats.hxx
index d1d9b84..696f35a 100644
--- a/include/basebmp/rgbmaskpixelformats.hxx
+++ b/include/basebmp/rgbmaskpixelformats.hxx
@@ -148,6 +148,7 @@ template< typename PixelType,
template< typename PixelType,
typename ColorType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -174,6 +175,7 @@ template< typename PixelType,
const typename base_type::unsigned_pixel_type blue (c.getBlue());
typename base_type::unsigned_pixel_type res(
+ BaseValue |
(shiftLeft(red,
base_type::red_shift-8*
(signed)sizeof(typename base_type::component_type)+
@@ -194,6 +196,7 @@ template< typename PixelType,
template< typename PixelType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -209,6 +212,7 @@ template< typename PixelType,
SwapBytes> getter_type;
typedef RGBMaskSetter<pixel_type,
Color,
+ BaseValue,
RedMask,
GreenMask,
BlueMask,
@@ -256,6 +260,7 @@ template< typename PixelType,
// 16bpp MSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -266,6 +271,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_MSB::getter_type,
// 16bpp LSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -286,6 +292,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_LSB::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -297,6 +304,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_BGRX32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -308,6 +316,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XRGB32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
@@ -317,6 +326,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XBGR32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
commit 2eff3574d519d7bf5c668b8f5cd5d516b3f02d8f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 18:30:00 2014 +0100
Get rid of outdated comments.
We can now set the colourspace as desired, and we return the rowstride too.
Change-Id: Idf1e55a67b9e9ab58e82d7ed0be2813b682ec2ff
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e44e552..4959195 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -403,29 +403,12 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
-// to just be RGB, 8 bits per sample, and vertically mirrored compared
-// to what gtk expects.
-// The BitmapDevice actually supports various formats, as detailed in
-// basebmp/scanlineformat.hxx -- for svp SVP_DEFAULT_BITMAP_FORMAT is seemingly used
-// (see creation in svpvd.cxx) -- which is simply FORMAT_TWENTYFOUR_BIT_TC_MASK
-// for now -- we could probably adjust this as necessary to get whatever
-// format is presumably most useful, or maybe even allow that as a parameter.
-//
-// It's actually possible to set the depth in the creation of a VirtualDevice,
-// however that only allows 0, 1 or 8 -- and we can't select the full range of formats
-// as above, so we'd need to add a way of setting the format entirely from scratch
-// should that be deemed necessary.
-//
-// We probably also want to use getScanlineStride() -- I'm guessing that
-// this is where we are actually just returning a sub-portion of a larger buffer
-// which /shouldn't/ apply in our case, but better to be safe here.
void doc_paintTile (LibreOfficeKitDocument* pThis,
unsigned char* pBuffer,
- const int nCanvasWidth, const int nCanvasHeight,
- int* pRowStride,
- const int nTilePosX, const int nTilePosY,
- const int nTileWidth, const int nTileHeight)
+ const int nCanvasWidth, const int nCanvasHeight,
+ int* pRowStride,
+ const int nTilePosX, const int nTilePosY,
+ const int nTileWidth, const int nTileHeight)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
commit 24dfd0a0d65bf72c2c083c28c4d6c6a8b9ebe3cf
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:42:17 2014 +0100
Upgrade gtktiledviewer to use its own buffer.
Change-Id: I3f567ff19ee0d5b0d54aeef9b163b78567d72946
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 51d9414..2ffa599 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -32,6 +32,7 @@ static int help()
}
static GtkWidget* ourCanvas;
+static GdkPixbuf* ourPixBuf = 0;
bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
{
@@ -46,25 +47,41 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
int nRenderWidth = nWidth / 10;
int nRenderHeight = nHeight / 10;
int nRowStride;
- unsigned char* pBuffer = pDocument->paintTile( nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
+
+ if ( ourPixBuf &&
+ (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
+ gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
+ {
+ g_object_unref( G_OBJECT( ourPixBuf ) );
+ ourPixBuf = 0;
+
+ }
+ if (!ourPixBuf)
+ {
+ ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ true, 8,
+ nRenderWidth, nRenderHeight);
+ }
+
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
+
+ pDocument->paintTile( pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // TODO: double check that the rowstride really matches what we expected,
+ // although presumably we'd already be crashing by now if things were
+ // wrong.
+ (void) nRowStride;
for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
{
pBuffer[i] = 0xFF;
}
- GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight,
- nRowStride,
- 0, 0 );
- pBixBuf = gdk_pixbuf_flip( pBixBuf, false );
- gtk_image_set_from_pixbuf( GTK_IMAGE(ourCanvas), pBixBuf );
+ gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
- // TODO: we need to keep track of and cleanup these buffers etc.
return true;
}
@@ -108,7 +125,6 @@ int main( int argc, char* argv[] )
ourCanvas = pCanvas;
gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
-
g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument);
gtk_widget_show( pCanvas );
commit 67d7bad694928e8a5d7416de21c612822e14dadc
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 16:24:33 2014 +0100
Use external buffer for LibLO tiled rendering.
Means we can get rid of hackily storing a reference to the last
buffer we created.
Change-Id: I8092a7d87bc391301f75651a59b37fbd73ac64fd
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8f3bda4..e44e552 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -79,6 +79,17 @@ typedef struct
const char *filterName;
} ExtensionMap;
+// We need a shared_array for passing into the BitmapDevice (via
+// VirtualDevice.SetOutputSizePixelScaleOffsetAndBuffer which goes via the
+// SvpVirtualDevice, ending up in the basebmp BitmapDevice. However as we're
+// given the array externally we can't delete it, and hence need to override
+// shared_array's default of deleting its pointer.
+template<typename T>
+struct NoDelete
+{
+ void operator()(T* /* p */) {}
+};
+
static const ExtensionMap aWriterExtensionMap[] =
{
{ "doc", "MS Word 97" },
@@ -175,12 +186,13 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const ch
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
-static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
+void doc_paintTile(LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
@@ -391,14 +403,6 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Temporary hack -- we need to keep the buffer alive while we paint it
-// in the gtk tiled viewer -- we can't pass out the shared_array through
-// the C interface, so maybe we want some sort of wrapper where we can return
-// a handle which we then associate with a given shared_array within LibLO
-// (where the client then has to tell us when they are finished with using
-// the buffer).
-boost::shared_array< sal_uInt8 > ourBuffer;
-
// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
// to just be RGB, 8 bits per sample, and vertically mirrored compared
// to what gtk expects.
@@ -416,7 +420,8 @@ boost::shared_array< sal_uInt8 > ourBuffer;
// We probably also want to use getScanlineStride() -- I'm guessing that
// this is where we are actually just returning a sub-portion of a larger buffer
// which /shouldn't/ apply in our case, but better to be safe here.
-static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
+void doc_paintTile (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
@@ -424,8 +429,6 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- unsigned char* pRet = 0;
-
Application::AcquireSolarMutex(1);
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
@@ -438,6 +441,10 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -446,16 +453,11 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
*pRowStride = pBmpDev->getScanlineStride();
- ourBuffer = pBmpDev->getBuffer();
-
- pRet = ourBuffer.get();
}
Application::ReleaseSolarMutex();
-
- return pRet;
}
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index f63f3a7..db9aff2 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -90,7 +90,8 @@ struct _LibreOfficeKitDocumentClass
// for its internal buffer, i.e. the rowstride for the buffer may be larger
// than the desired width, hence we need to be able to return the
// rowstride too.
- unsigned char* (*paintTile) (LibreOfficeKitDocument* pThis,
+ void (*paintTile) (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index ee310fe..427ea83 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -59,7 +59,9 @@ public:
mpDoc->pClass->setPart(mpDoc, nPart);
}
- inline unsigned char* paintTile(const int nCanvasWidth,
+ inline void paintTile(
+ unsigned char* pBuffer,
+ const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
const int nTilePosX,
@@ -67,7 +69,7 @@ public:
const int nTileWidth,
const int nTileHeight)
{
- return mpDoc->pClass->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
+ return mpDoc->pClass->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
commit 56fea375b915bb96012b36012634523b9806040a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:40:47 2014 +0100
Allow passing in external buffers to svp's VirtualDevice.
We also want to be able to set whether or not the buffers
should be painted to top down, so add that parameter
as necessary (default seems to be false, however e.g. gtk
requires this to be true, i.e. needed for tiled rendering).
Change-Id: Id98882e4c7f62508ae5a976c0d8df743460a4ab2
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 74a6174..8c36f52 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -43,8 +43,12 @@ private:
sal_uInt8 meRefDevMode;
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL );
- SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
- SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
+ SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
+ SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
// Copy assignment is forbidden and not implemented.
VirtualDevice (const VirtualDevice &);
@@ -119,7 +123,11 @@ public:
virtual void EnableRTL( bool bEnable = true ) SAL_OVERRIDE;
bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
- bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer );
+ bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
+ const Fraction& rScale,
+ const Point& rNewOffset,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown = false );
bool SetOutputSize( const Size& rNewSize, bool bErase = true )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index d85cd8c..dc280db 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -52,10 +52,12 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{
- return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
+ return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray(), false );
}
-bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
+bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 )
@@ -73,13 +75,13 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const ba
std::vector< basebmp::Color > aDevPal(2);
aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
- m_aDevice = createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
}
else
{
m_aDevice = pBuffer ?
- createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, false, nFormat );
+ createBitmapDevice( aDevSize, bTopDown, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, bTopDown, nFormat );
}
// update device in existing graphics
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index e4d37fc..f6a9cc5 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -45,7 +45,10 @@ public:
virtual void ReleaseGraphics( SalGraphics* pGraphics ) SAL_OVERRIDE;
virtual bool SetSize( long nNewDX, long nNewDY ) SAL_OVERRIDE;
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer ) SAL_OVERRIDE;
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown
+ ) SAL_OVERRIDE;
virtual void GetSize( long& rWidth, long& rHeight ) SAL_OVERRIDE;
basebmp::BitmapDeviceSharedPtr getBitmapDevice() { return m_aDevice; }
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index 842429f..0cac639 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -40,9 +40,13 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY ) = 0;
// Set new size using a buffer at the given address
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray & /* pBuffer */ )
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray & /* pBuffer */,
+ const bool /* bTopDown */
+ )
{
- // Only the headless virtual device has an implementation that uses pBuffer.
+ // Only the headless virtual device has an implementation that uses
+ // pBuffer (and bTopDown).
return SetSize( nNewDX, nNewDY );
}
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 6378785..54cd376 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -267,7 +267,9 @@ VirtualDevice::~VirtualDevice()
pSVData->maGDIData.mpLastVirDev = mpPrev;
}
-bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
SAL_INFO( "vcl.gdi",
"VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", "
@@ -296,7 +298,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
if ( bErase )
{
if ( pBuffer )
- bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer );
+ bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer, bTopDown );
else
bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
@@ -381,9 +383,11 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
Pop();
}
-bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
- if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
+ if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer, bTopDown) )
{
if( mnAlphaDepth != -1 )
{
@@ -397,7 +401,9 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, c
if( !mpAlphaVDev )
{
mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
- mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, basebmp::RawMemorySharedArray() );
+ mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
+ basebmp::RawMemorySharedArray(),
+ bTopDown );
}
// TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
@@ -430,10 +436,12 @@ void VirtualDevice::EnableRTL( bool bEnable )
bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase )
{
- return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray() );
+ return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), false );
}
-bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
+ const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
+ const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown )
{
if (pBuffer) {
MapMode mm = GetMapMode();
@@ -442,7 +450,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize
mm.SetScaleY( rScale );
SetMapMode( mm );
}
- return ImplSetOutputSizePixel( rNewSize, true, pBuffer);
+ return ImplSetOutputSizePixel( rNewSize, true, pBuffer, bTopDown );
}
void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
commit 01bd2bd371051e9dcab0cd15db43a607d5f12b63
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 20:02:05 2014 +0100
Upgrade gtktiledviewer to RGBA.
The Alpha channel seems to be set incorrectly by LO, hence
we need to manually set it here for now.
Change-Id: I1f9091b8b6f88c1dba6653dfb7bf51f9fe14b3fc
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index f689ab1..51d9414 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -51,9 +51,13 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
0, 0, // origin
nWidth, nHeight );
+ for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
+ {
+ pBuffer[i] = 0xFF;
+ }
GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- false, 8,
+ true, 8,
nRenderWidth, nRenderHeight,
nRowStride,
0, 0 );
commit 04d5b861f8aa3d2d6027b4e4a580a20ae82ee54a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 20:00:58 2014 +0100
Upgrade LibLO tiled rendering to RGBA.
This is the expected format for gtk+ pixbufs which is currently
the primary target. We could potentially allow the user to choose
the format via LibLO -- but we want to eventually allow passing
in a buffer (rather than passing out an LO owned buffer) anyway, so
should add that then.
Change-Id: I8427925a94366917fa82fb8ea28e7dbb3fa1840d
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 06527bb..671ff12 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
ucbhelper \
utl \
vcl \
+ vclplug_svp \
$(gb_UWINAPI) \
))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 252d79b..8f3bda4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -53,7 +53,10 @@
#include <unotxdoc.hxx>
#include <viewsh.hxx>
-// And let's also grab the SvpSalVirtualDevice
+#include <salinst.hxx>
+
+// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
+#include <headless/svpinst.hxx>
#include <headless/svpvd.hxx>
#include <basebmp/bitmapdevice.hxx>
@@ -430,7 +433,11 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
SwDoc* pDoc = pDocShell->GetDoc();
SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- VirtualDevice aDevice(0, (sal_uInt16)0);
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+
+ VirtualDevice aDevice(0, (sal_uInt16)32);
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
commit e82d491263edf18fadf7c403f60e2895887fe971
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 19:59:03 2014 +0100
svp: deduplicate bitcount->colourspace mapping and allow overriding.
Although svp defaults to BGR, we might want to use alternative
formats (e.g. for tiled rendering to bitmap buffers which are
to be used in e.g. gtk), it is probably safest to keep the current
defaults but allow the user to change to whatever format they may
require. (This currently only makes sense for the 32-bit
RGBA/ARGB/etc. formats. However the 23 bit formats could potentially
be expanded to allow a similar RGB/BGR choice.)
Change-Id: I70bd3d6e7d297faef163b910f576655efee4cb3f
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 3e08e90..0a81fdc 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -20,6 +20,7 @@
#ifndef IOS
#include "headless/svpbmp.hxx"
+#include "headless/svpinst.hxx"
#include <basegfx/vector/b2ivector.hxx>
#include <basegfx/range/b2ibox.hxx>
@@ -40,25 +41,12 @@ bool SvpSalBitmap::Create( const Size& rSize,
sal_uInt16 nBitCount,
const BitmapPalette& rPalette )
{
- basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
SAL_INFO( "vcl.headless", "SvpSalBitmap::Create(" << rSize.Width() << "," << rSize.Height() << "," << nBitCount << ")" );
- switch( nBitCount )
- {
- case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL; break;
- case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
- case 8: nFormat = FORMAT_EIGHT_BIT_PAL; break;
-#ifdef OSL_BIGENDIAN
- case 16: nFormat = FORMAT_SIXTEEN_BIT_MSB_TC_MASK; break;
-#else
- case 16: nFormat = FORMAT_SIXTEEN_BIT_LSB_TC_MASK; break;
-#endif
- case 24: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
-#ifdef ANDROID
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break;
-#else
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break;
-#endif
- }
+
+ SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
+ assert( pInst );
+ basebmp::Format nFormat = pInst->getFormatForBitCount( nBitCount );
+
B2IVector aSize( rSize.Width(), rSize.Height() );
if( aSize.getX() == 0 )
aSize.setX( 1 );
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 2ce2a01..3fa2226 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -45,6 +45,8 @@
// FIXME: remove when we re-work the svp mainloop
#include <unx/salunxtime.h>
+using namespace basebmp;
+
bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
{
for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
@@ -405,4 +407,47 @@ void SvpSalTimer::Start( sal_uLong nMS )
m_pInstance->StartTimer( nMS );
}
+void SvpSalInstance::setBitCountFormatMapping( sal_uInt16 nBitCount,
+ Format aFormat )
+{
+ m_aBitCountFormatMap[nBitCount] = aFormat;
+}
+
+Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount )
+{
+ BitCountFormatMap::iterator aIt;
+ if ( (aIt = m_aBitCountFormatMap.find( nBitCount )) != m_aBitCountFormatMap.end() )
+ {
+ return aIt->second;
+ }
+
+ switch( nBitCount )
+ {
+ case 1:
+ return FORMAT_ONE_BIT_MSB_PAL;
+ case 4:
+ return FORMAT_FOUR_BIT_MSB_PAL;
+ case 8:
+ return FORMAT_EIGHT_BIT_PAL;
+ case 16:
+#ifdef OSL_BIGENDIAN
+ return FORMAT_SIXTEEN_BIT_MSB_TC_MASK;
+#else
+ return FORMAT_SIXTEEN_BIT_LSB_TC_MASK;
+#endif
+ case 24:
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
+ case 32:
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA;
+ case 0:
+#ifdef ANDROID
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA;
+#else
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
+#endif
+ default:
+ return SVP_DEFAULT_BITMAP_FORMAT;
+ }
+
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list