[Libreoffice-commits] core.git: Branch 'feature/gtkbmptiledviewer2' - 307 commits - accessibility/source basctl/uiconfig basegfx/source basic/source binaryurp/source bin/distro-install-file-lists bridges/Library_cpp_uno.mk canvas/source chart2/inc chart2/Library_chartcontroller.mk chart2/opengl chart2/Package_opengl.mk chart2/qa chart2/source chart2/uiconfig chart2/UIConfig_chart2.mk codemaker/source comphelper/source compilerplugins/clang config.guess config.sub configure.ac connectivity/inc connectivity/source cui/AllLangResTarget_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk dbaccess/source dbaccess/uiconfig desktop/Library_sofficeapp.mk desktop/source editeng/source embeddedobj/source extensions/source extensions/uiconfig external/icu external/lpsolve external/rhino extras/source filter/source filter/uiconfig forms/source formula/source fpicker/uiconfig framework/source helpcontent2 hwpfilter/source idlc/inc include/basebmp include/basic include/codemaker include/comphelper include/conne ctivity include/editeng include/formula include/LibreOfficeKit include/oox include/sal include/sfx2 include/svl include/svtools include/svx include/tools include/vcl include/xmloff instsetoo_native/inc_openoffice l10ntools/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source lotuswordpro/source Makefile.in odk/examples odk/Package_examples.mk offapi/com offapi/UnoApi_offapi.mk oox/inc oox/source postprocess/qa readlicense_oo/docs registry/source reportdesign/inc reportdesign/source Repository.mk rsc/source sc/inc scp2/source sc/qa scripting/source sc/source sc/uiconfig sc/workben sd/AllLangResTarget_sd.mk sdext/source sd/inc sd/qa sd/source sd/uiconfig sd/UIConfig_simpress.mk sd/workben sfx2/source sfx2/uiconfig shell/source smoketest/libtest.cxx soltools/cpp soltools/mkdepend starmath/inc starmath/source starmath/uiconfig stoc/source svl/CppunitTest_svl_qa_cppun it.mk svl/qa svl/source svtools/source svtools/uiconfig svx/source svx/uiconfig sw/CppunitTest_sw_tox.mk sw/CppunitTest_sw_uiwriter.mk sw/inc sw/qa sw/sdi sw/source sw/uiconfig toolkit/source tools/source ucb/source udkapi/com unodevtools/source unusedcode.easy uui/AllLangResTarget_uui.mk uui/source uui/uiconfig uui/UIConfig_uui.mk vcl/generic vcl/headless vcl/inc vcl/osx vcl/source vcl/uiconfig vcl/unx writerfilter/CustomTarget_source.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/source xmloff/source xmlscript/source xmlsecurity/uiconfig
Andrzej Hunt
andrzej.hunt at collabora.com
Wed Jun 25 02:52:21 PDT 2014
Rebased ref, commits from common ancestor:
commit 7ceb9484cf691770e5fb3d307b1c2365dd62ae2f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 24 22:06:59 2014 +0100
Use output device mapping for draw layer too.
Otherwise draw layer items don't get scaled at all for tiled
rendering.
Change-Id: If65d460a83fb29b8eda692cb7c1f2bd9f7283e62
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index cad96f3..a34b95e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -602,7 +602,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
}
// define drawing layer map mode and paint rectangle
- const MapMode aDrawMode = GetDrawMapMode();
+ MapMode aDrawMode = pOutDev->GetMapMode();
+ aDrawMode.SetMapUnit( MAP_100TH_MM );
Rectangle aDrawingRectLogic;
{
commit f1d7daf63ceb4340c9626b07aac121474a2c4c40
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 24 21:16:15 2014 +0100
Turns out document coordinates are already in TWIPs.
This now means that fonts are also correctly scaled,
whereas the 100th mm mapping caused fonts to be scaled
differently to the grid (i.e. looked ugly).
Change-Id: Ib8b913490823a7ba406e52291e52d50053ae32b8
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 8f47511..cad96f3 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -413,7 +413,7 @@ Size ScGridWindow::GetDataAreaSize()
// the data area.
// This doesn't include the final (bottom & right) borders...
- return Size( nX * 1440L / 2540L, nY * 1440L / 2540L );
+ return Size( nX, nY );
}
// Draw ----------------------------------------------------------------
@@ -923,25 +923,14 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
- // Scaling. Must convert from pixels to TWIPs. We know
- // that VirtualDevices use a DPI of 96. We might as well do this
- // calculation now, rather than after another dimension conversion,
- // to minimise errors.
Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
Fraction( nTileWidth);
Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
Fraction( nTileHeight);
- // Now scale back to 100th mm dimensions.
- nTilePosX = nTilePosX * 2540L / 1440L;
- nTilePosY = nTilePosY * 2540L / 1440L;
-
- nTileWidth = nTileWidth * 2540L / 1440L;
- nTileHeight = nTileHeight * 2540L / 1440L;
-
rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) );
MapMode aMapMode( rDevice.GetMapMode() );
- aMapMode.SetMapUnit( MAP_100TH_MM );
+ aMapMode.SetMapUnit( MAP_TWIP );
aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) ); // size
aMapMode.SetScaleX( scaleX );
commit 849167534cf419e29fb539144d0322292bea894f
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 34e626fcd9208b7b6ab82d073fe0649408783a1c
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 7ef7286e85b43ee08906b4db2c7cbcb07c4c4630
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 6caaf7b3c9b18eb8a967276955bfe7fcc8f44b77
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 11:07:33 2014 +0100
Set correct scaling for normal painting.
As we no longer read the scaling from the viewdata, we should
instead set it on the output device when doing normal rendering.
However the grid still doesn't exactly match the external axes yet,
there are probably more rounding errors wherever they are painted.
Change-Id: I25b1bd9b344115578fe892aa94fbf753a3c10c81
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index d322885..8f47511 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -301,6 +301,11 @@ void ScGridWindow::PrePaint()
void ScGridWindow::Paint( const Rectangle& rRect )
{
+ MapMode aMapMode( GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ aMapMode.SetScaleX( pViewData->GetZoomX() * Fraction(0.96) );
+ aMapMode.SetScaleY( pViewData->GetZoomY() * Fraction(0.96) );
+ SetMapMode( aMapMode );
Paint( rRect, this );
}
commit e624b2a454a844f849cb0e52556f031dd0475a7d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 10:35:45 2014 +0100
Use output device scaling to determine cells in draw-area.
Change-Id: Idf4e6ccb72090a55b6a9234cafae21821e3df0b0
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 8cab7fe..d322885 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -342,9 +342,6 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
SCTAB nTab = pViewData->GetTabNo();
- double nPPTX = pViewData->GetPPTX();
- double nPPTY = pViewData->GetPPTY();
-
Rectangle aMirroredPixel = aPixRect;
if ( pDoc->IsLayoutRTL( nTab ) )
{
@@ -354,26 +351,30 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
}
- long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ long nScrX = pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();/*ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );*/
while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
{
++nX1;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();
}
SCCOL nX2 = nX1;
while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
{
++nX2;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
+ nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX2, nTab ), 0 ) ).getX();
}
long nScrY = 0;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
+ while ( nScrY < aPixRect.Top() && nY1 < MAXROW )
+ {
+ ++nY1;
+ nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY1, nTab ) ) ).getY();
+ }
SCROW nY2 = nY1;
- if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
+ while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW )
{
++nY2;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
+ nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY();
}
Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev ); // nicht weiterzeichnen
commit 73db34d9b367af7373ccb619b8747283c3db4931
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 52ab9e3a7289f236f07c0686ae5836bcde4ce557
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:38:50 2014 +0100
Don't scale grid and cell dimensions multiple times.
Previously we had multiple layers of scaling, with rounding
errors propagating, leading to up to 5% differences in expected
and rendered sheet widths -- for tiled rendering dimensions have
to scale accurately as we may paint the same tile at multiple zoom
levels, by eliminating multiple scaling and letting the output
device instead deal with the scaling once we can eliminate these
errors. (However currently rendering of text/images isn't quite right.)
Change-Id: I0a725fd5c030f3c089c2bbd25947088c321eb2d4
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index a6b7b90..4313856 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -278,7 +278,7 @@ void ScDocument::FillInfo(
RowInfo* pThisRowInfo = &pRowInfo[nArrRow];
pThisRowInfo->pCellInfo = NULL; // wird unten belegt
- sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * fRowScale );
+ sal_uInt16 nHeight = nDocHeight;
if (!nHeight)
nHeight = 1;
@@ -393,11 +393,7 @@ void ScDocument::FillInfo(
{
if (!ColHidden(nX, nTab))
{
- sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale);
- if (!nThisWidth)
- nThisWidth = 1;
-
- pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth;
+ pRowInfo[0].pCellInfo[nArrCol].nWidth = GetColWidth( nX, nTab );
}
}
}
@@ -418,9 +414,7 @@ void ScDocument::FillInfo(
// TODO: Optimize this loop.
if (!ColHidden(nX, nTab))
{
- sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale);
- if (!nThisWidth)
- nThisWidth = 1;
+ int nThisWidth = GetColWidth( nX, nTab );
pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; //! dies sollte reichen
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ee86806..8cab7fe 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -711,7 +711,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
else
aOutputData.SetSolidBackground(true);
- pContentDev->SetMapMode(MAP_PIXEL);
aOutputData.DrawDocumentBackground();
if ( bGridFirst && ( bGrid || bPage ) )
@@ -918,18 +917,27 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
+ // Scaling. Must convert from pixels to TWIPs. We know
+ // that VirtualDevices use a DPI of 96. We might as well do this
+ // calculation now, rather than after another dimension conversion,
+ // to minimise errors.
+ Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
+ Fraction( nTileWidth);
+ Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
+ Fraction( nTileHeight);
+
+ // Now scale back to 100th mm dimensions.
+ nTilePosX = nTilePosX * 2540L / 1440L;
+ nTilePosY = nTilePosY * 2540L / 1440L;
+
+ nTileWidth = nTileWidth * 2540L / 1440L;
+ nTileHeight = nTileHeight * 2540L / 1440L;
+
rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) );
- // setup the output device to draw the tile
MapMode aMapMode( rDevice.GetMapMode() );
- aMapMode.SetMapUnit( MAP_TWIP );
- aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) );
+ aMapMode.SetMapUnit( MAP_100TH_MM );
+ aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) ); // size
- // Scaling. Must convert from pixels to twips. We know
- // that VirtualDevises use a DPI of 96.
- Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
- Fraction( nTileWidth);
- Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
- Fraction( nTileHeight);
aMapMode.SetScaleX( scaleX );
aMapMode.SetScaleY( scaleY );
rDevice.SetMapMode( aMapMode );
commit 9ba6c62eff5941d43a65b20cd3d1102c92efba4a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:35:16 2014 +0100
Return TWIPS for calc document size.
We already use TWIPS for other uses of tiled rendering, so might
as well stay consistent.
Change-Id: I5897480f152c1ee9734443296d152436a049e32d
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index eccb895..614d219 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -322,10 +322,18 @@ public:
virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
+ // Paint a tile -- all tile dimensions are in TWIPS.
+ // It is possible to request an infinitely large area, i.e. you are not
+ // restricted to the area in GetDataAreaSize.
void PaintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight );
+ // Get the area in the document that contains renderable content. This
+ // is primarily a guide as to the area that should be rendered for read
+ // only documents, however for writeable documents you probably want to
+ // dynamically grab more cells in case the user wants to write to them etc.
+ // This returns a size in TWIPS, suitable for use in PaintTile.
Size GetDataAreaSize();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index cbd2ad8..ee86806 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -403,11 +403,11 @@ Size ScGridWindow::GetDataAreaSize()
nY += pDoc->GetRowHeight( i, nTab );
}
- // TODO: the scaling is wrong.
- // TODO: this also ignores any images / etc., which could be outside
+ // TODO: this ignores any images / etc., which could be outside
// the data area.
- return Size( nX, nY );
+ // This doesn't include the final (bottom & right) borders...
+ return Size( nX * 1440L / 2540L, nY * 1440L / 2540L );
}
// Draw ----------------------------------------------------------------
commit 222b183967671bff55efc109530b2e1758eb2753
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 18 09:33:16 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).
Change-Id: I6db1986e6cb1e5f3889ec3a462d999a9eab57331
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 84fcf8a..eccb895 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -326,6 +326,7 @@ public:
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight );
+ Size GetDataAreaSize();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 00993eb..ca18caa 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -463,10 +463,15 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
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( 3200, 3200 );
+ // 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();
+
+ // We simply return the data area -- it is however possible to request
+ // tiles to be rendered outside this area, ie this is the minimum that
+ // the client should allow the user to see.
+ return pGridWindow->GetDataAreaSize();
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 3db37cb..cbd2ad8 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -380,6 +380,36 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = false;
}
+Size ScGridWindow::GetDataAreaSize()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nStartCol = 0, nEndCol = MAXCOL;
+ SCROW nStartRow = 0, nEndRow = MAXROW;
+
+ SCTAB nTab = pViewData->GetTabNo();
+
+ pDoc->ShrinkToDataArea( nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow );
+
+ long nX = 0;
+ for ( SCCOL i = 0; i <= nEndCol; i++ )
+ {
+ nX += pDoc->GetColWidth( i, nTab );
+ }
+
+ long nY = 0;
+ for ( SCROW i = 0; i <= nEndRow; i++ )
+ {
+ nY += pDoc->GetRowHeight( i, nTab );
+ }
+
+ // TODO: the scaling is wrong.
+ // TODO: this also ignores any images / etc., which could be outside
+ // the data area.
+
+ return Size( nX, nY );
+}
+
// Draw ----------------------------------------------------------------
void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode,
OutputDevice* pOutDev )
@@ -480,6 +510,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
Fraction aZoomX = pViewData->GetZoomX();
Fraction aZoomY = pViewData->GetZoomY();
+
ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );
commit a01dec95b1f52a112e1114aa3910f2542237da81
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 18 08:28:04 2014 +0100
Allow overriding of device for Paint, and use that for Tiles.
Paint handles figuring out which cells are within the visible area
for us etc.
Gridwin being a Window which paints to itself is a bit of a pain,
since we now need to be able to reroute painting calls to alternative
output devices, however these changes seem to be sufficient to at least
get the cells in the desired tile rendered.
Change-Id: I7bd1434c97acc6e9ef6e1e63cbcf039b987c88e4
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index dede149..84fcf8a 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -292,6 +292,7 @@ protected:
virtual void Resize( const Size& rSize );
virtual void PrePaint() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
+ virtual void Paint( const Rectangle& rRect, OutputDevice* pOutDev);
virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
virtual void LoseFocus() SAL_OVERRIDE;
@@ -361,7 +362,7 @@ public:
using Window::Draw;
void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
ScUpdateMode eMode = SC_UPDATE_ALL,
- OutputDevice* pOutDev = 0 );
+ OutputDevice* pOutDev = 0);
void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index eafcdf1..3db37cb 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -301,6 +301,11 @@ void ScGridWindow::PrePaint()
void ScGridWindow::Paint( const Rectangle& rRect )
{
+ Paint( rRect, this );
+}
+
+void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
+{
ScDocument* pDoc = pViewData->GetDocument();
if ( pDoc->IsInInterpreter() )
{
@@ -330,7 +335,7 @@ void ScGridWindow::Paint( const Rectangle& rRect )
bIsInPaint = true;
- Rectangle aPixRect = LogicToPixel( rRect );
+ Rectangle aPixRect = pOutDev->LogicToPixel( rRect );
SCCOL nX1 = pViewData->GetPosX(eHWhich);
SCROW nY1 = pViewData->GetPosY(eVWhich);
@@ -371,8 +376,7 @@ void ScGridWindow::Paint( const Rectangle& rRect )
ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
}
- Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen
-
+ Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev ); // nicht weiterzeichnen
bIsInPaint = false;
}
@@ -588,7 +592,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
}
// get logic positions
- aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
+ aDrawingRectLogic = pOutDev->PixelToLogic(aDrawingRectPixel, aDrawMode);
}
// device for document content, used by overlay manager
@@ -846,7 +850,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
DrawRect( Rectangle( aStart,aEnd ) );
SetMapMode(pViewData->GetLogicMode());
- pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ),
+ pEditView->Paint( pOutDev->PixelToLogic( Rectangle( Point( nScrX, nScrY ),
Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) );
SetMapMode(MAP_PIXEL);
}
@@ -906,7 +910,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
pDrawView->AddWindowToPaintView( &rDevice );
}
- Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
+ Paint( Rectangle( Point(nTilePosX, nTilePosY),
+ rDevice.PixelToLogic(Size(nOutputWidth, nOutputHeight))),
+ &rDevice );
if ( pDrawView )
{
commit bc6d906a61f9b565c5839bd765c7dffee4ea7d80
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 16:19:56 2014 +0100
Calc: Add tiled rendering device to the paint view.
This prevents the previous warnings of
SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), \
this should never be needed
Change-Id: I76cb7c9ed4d45bfcbd297f697314309b4e036f80
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 020fb4e..eafcdf1 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -34,6 +34,7 @@
#include "gridwin.hxx"
#include "viewdata.hxx"
+#include "drawview.hxx"
#include "output.hxx"
#include "document.hxx"
#include "attrib.hxx"
@@ -898,7 +899,19 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
aMapMode.SetScaleY( scaleY );
rDevice.SetMapMode( aMapMode );
+ ScTabViewShell* pTabViewSh = pViewData->GetViewShell();
+ SdrView* pDrawView = pTabViewSh->GetScDrawView();
+ if ( pDrawView )
+ {
+ pDrawView->AddWindowToPaintView( &rDevice );
+ }
+
Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
+
+ if ( pDrawView )
+ {
+ pDrawView->DeleteWindowFromPaintView( &rDevice );
+ }
}
void ScGridWindow::CheckNeedsRepaint()
commit 98dabcdb5a9fabadc7a8cd68c238dc9c3d28633a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 15:00:02 2014 +0100
Render tiles from calc.
Currently the document size and number of cells to be rendered
is hardcoded, this will need some more work to select the correct
cells for a given tile (i.e. cells from location). Also, there
isn't really a "size" for a calc sheet, so presumably we'd need
to instead return the area containing cells that aren't empty,
whilst still being able to render larger tiles? (And in any case
the client will need to be aware of this and provide an appropriate
interface, i.e. the current LO UI simply extends the sheet ad-infinitum.)
We also currently get some warnings most likely related to the way
we push our OutputDevice into the rendering methods:
SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), \
this should never be needed
Change-Id: Ia9d64d7de6c22d5b401350f88497a7ec106f1973
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 17b02f8..dede149 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -360,7 +360,8 @@ public:
using Window::Draw;
void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
- ScUpdateMode eMode = SC_UPDATE_ALL );
+ ScUpdateMode eMode = SC_UPDATE_ALL,
+ OutputDevice* pOutDev = 0 );
void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 57a80b5..00993eb 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -466,7 +466,7 @@ 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();
+ return Size( 3200, 3200 );
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index fa697ee5..020fb4e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -376,9 +376,14 @@ void ScGridWindow::Paint( const Rectangle& rRect )
}
// Draw ----------------------------------------------------------------
-
-void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode )
+void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode,
+ OutputDevice* pOutDev )
{
+ if ( !pOutDev )
+ {
+ pOutDev = this;
+ }
+
ScModule* pScMod = SC_MOD();
bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
@@ -470,7 +475,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
Fraction aZoomX = pViewData->GetZoomX();
Fraction aZoomY = pViewData->GetZoomY();
- ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
+ ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );
@@ -585,7 +590,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
}
- OutputDevice* pContentDev = this; // device for document content, used by overlay manager
+ // device for document content, used by overlay manager
+ // We usually paint to ourselves, but allow other devices for tiled rendering.
+ OutputDevice* pContentDev = pOutDev;
SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with SdrPaintWindow directly
{
@@ -602,7 +609,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
{
// #i74769# Use new BeginDrawLayers() interface
Region aDrawingRegion(aDrawingRectLogic);
- pTargetPaintWindow = pDrawView->BeginDrawLayers(this, aDrawingRegion);
+ pTargetPaintWindow = pDrawView->BeginDrawLayers(pOutDev, aDrawingRegion);
OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
// #i74769# get target device from SdrPaintWindow, this may be the prerender
@@ -875,13 +882,23 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
- (void) rDevice;
- (void) nOutputWidth;
- (void) nOutputHeight;
- (void) nTilePosX;
- (void) nTilePosY;
- (void) nTileWidth;
- (void) nTileHeight;
+ rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) );
+ // setup the output device to draw the tile
+ MapMode aMapMode( rDevice.GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) );
+
+ // Scaling. Must convert from pixels to twips. We know
+ // that VirtualDevises use a DPI of 96.
+ Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
+ Fraction( nTileWidth);
+ Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
+ Fraction( nTileHeight);
+ aMapMode.SetScaleX( scaleX );
+ aMapMode.SetScaleY( scaleY );
+ rDevice.SetMapMode( aMapMode );
+
+ Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
}
void ScGridWindow::CheckNeedsRepaint()
commit 01b24915298c7baade7e9a6118a91bbdc4d4b793
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 f65a6ea62bbe62954ee39d345298a50d6f8b3b25
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 599fc5829c5ced9741e938505456934d899caf6f
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 93c7216cc278b3b0a0140f4b7635cc9597dfb47d
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 0ba3d66229b89a7d58363b1792bd1f9f43330644
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 82b19a54516c0905c44f152bd045153b66368918
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 bf77ec23ab9a93534bbcc28cf55bb95360524c9d
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 69c6adbed8f17ea0921b5349db0186d828ac7141
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 9adb80588bcdacf6815afcd41af57bc5f8200dbb
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 abbdf7c448ca6b399664c13535de37784be218b6
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 fa33c7c4f20c4b6bfabbd5ec73cdc37c674bace9
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 f862b73f7cad27722bb92f906e95a21ff1e06d37
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 89e6334a24d7b59e697e1edcdce97fd36f618515
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 7f63db7494c68affc05726d2b0be6818cc9de39a
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,
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list