diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-25 09:19:02 +0100 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-25 13:04:31 +0100 |
commit | 17f223c195867df8356a9e8c86981d88ce3b4b05 (patch) | |
tree | a3fb545cc6dada0e30ed904d791b6d5269f9bf02 /desktop | |
parent | d465dfb209948a795e393bfc4a05485e893f24d0 (diff) |
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
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/Executable_gtktiledviewer.mk | 4 | ||||
-rw-r--r-- | desktop/qa/gtktiledviewer/gtktiledviewer.cxx | 76 |
2 files changed, 10 insertions, 70 deletions
diff --git a/desktop/Executable_gtktiledviewer.mk b/desktop/Executable_gtktiledviewer.mk index 6295f5eebba2..a0bf8ead8baa 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 f5690b43fa9a..2c80a8d65014 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; |