[Libreoffice-commits] core.git: 2 commits - libreofficekit/qa libreofficekit/source

Miklos Vajna vmiklos at collabora.co.uk
Fri May 22 05:57:38 PDT 2015


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    6 ++++--
 libreofficekit/source/gtk/lokdocview.cxx            |   12 +++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit 124c937f3bd6a7538dc6664ab9556fcfb3f27088
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri May 22 13:34:47 2015 +0100

    lokdocview: it's enough to query the document size once
    
    Change-Id: Id99c9f1a814bc5f935eeb4e301ef3014ccb0bd07

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d4f21e1..b2b7f2c 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -50,6 +50,8 @@ struct LOKDocView_Impl
 
     LibreOfficeKit* m_pOffice;
     LibreOfficeKitDocument* m_pDocument;
+    long m_nDocumentWidthTwips;
+    long m_nDocumentHeightTwips;
     /// View or edit mode.
     bool m_bEdit;
     /// Position and size of the visible cursor.
@@ -239,6 +241,8 @@ LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
     m_fZoom(1),
     m_pOffice(0),
     m_pDocument(0),
+    m_nDocumentWidthTwips(0),
+    m_nDocumentHeightTwips(0),
     m_bEdit(false),
     m_aVisibleCursor({0, 0, 0, 0}),
     m_bCursorOverlayVisible(false),
@@ -745,11 +749,8 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
 {
     const int nTileSizePixels = 256;
 
-    // Get document size and find out how many rows / columns we need.
-    long nDocumentWidthTwips, nDocumentHeightTwips;
-    m_pDocument->pClass->getDocumentSize(m_pDocument, &nDocumentWidthTwips, &nDocumentHeightTwips);
-    long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips);
-    long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips);
+    long nDocumentWidthPixels = twipToPixel(m_nDocumentWidthTwips);
+    long nDocumentHeightPixels = twipToPixel(m_nDocumentHeightTwips);
     // Total number of rows / columns in this document.
     guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
@@ -1179,6 +1180,7 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
     {
         pDocView->m_pImpl->m_pDocument->pClass->initializeForRendering(pDocView->m_pImpl->m_pDocument);
         pDocView->m_pImpl->m_pDocument->pClass->registerCallback(pDocView->m_pImpl->m_pDocument, &LOKDocView_Impl::callbackWorker, pDocView);
+        pDocView->m_pImpl->m_pDocument->pClass->getDocumentSize(pDocView->m_pImpl->m_pDocument, &pDocView->m_pImpl->m_nDocumentWidthTwips, &pDocView->m_pImpl->m_nDocumentHeightTwips);
         g_timeout_add(600, &LOKDocView_Impl::handleTimeout, pDocView);
         pDocView->m_pImpl->renderDocument(0);
     }
commit 2807bcc186c976e55b6844d3459e2b0fbb92cdb8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri May 22 13:23:33 2015 +0100

    gtktiledviewer: avoid a number of pointless re-rendering on startup
    
    Change-Id: Ia7f63a6fa7505da50e6580ea009975e06a0cb65c

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index ae6cfa6..d066a83 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -363,7 +363,6 @@ int main( int argc, char* argv[] )
     GtkWidget* pComboBox = gtk_combo_box_text_new();
     gtk_container_add( GTK_CONTAINER(pPartSelectorToolItem), pComboBox );
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartSelectorToolItem, -1 );
-    g_signal_connect( G_OBJECT(pComboBox), "changed", G_CALLBACK(changePart), NULL );
 
     pPartSelector = GTK_COMBO_BOX_TEXT(pComboBox);
 
@@ -374,7 +373,6 @@ int main( int argc, char* argv[] )
     GtkWidget* pPartModeComboBox = gtk_combo_box_text_new();
     gtk_container_add( GTK_CONTAINER(pPartModeSelectorToolItem), pPartModeComboBox );
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
-    g_signal_connect( G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), NULL );
 #endif
 
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
@@ -458,8 +456,12 @@ int main( int argc, char* argv[] )
 #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
     populatePartSelector();
     populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) );
+    // Connect these signals after populating the selectors, to avoid re-rendering on setting the default part/partmode.
+    g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0);
 #endif
 
+    g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0);
+
     gtk_main();
 
     pOffice->pClass->destroy( pOffice );


More information about the Libreoffice-commits mailing list