summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-23 15:13:25 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-25 13:04:33 +0100
commit6024ddbfac8e62db50dd5352d610c87d279627de (patch)
treeb239940321e89d7191b7d4a58bc4af9f0aa5891b /libreofficekit
parent3545b78755672321e3017fd25dec756827459fb6 (diff)
LOK Docview: add set_zoom
Change-Id: I902f3a134b4a7dcc721eff3f67376014a4276885
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 4a16db012a3b..99f2b1592ce3 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: */