[Libreoffice-commits] core.git: Branch 'feature/gtkbmptiledviewer2' - 2 commits - libreofficekit/source sc/source

Andrzej Hunt andrzej.hunt at collabora.com
Tue Jun 24 13:20:14 PDT 2014


 libreofficekit/source/gtk/lokdocview.c |   12 ++++++++++++
 sc/source/ui/view/gridwin4.cxx         |   15 ++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit a41b5c99900d94949413c146677e287a3b7a592f
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 470f150..e3ea993b 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  ----------------------------------------------------------------
@@ -926,25 +926,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 60564dbd87703d90f3bd2c11f9e4357ea5a31ad9
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 )


More information about the Libreoffice-commits mailing list