summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-22 13:34:47 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-27 11:01:17 +0200
commit3cd822d98d766a0528e94419874ff9c79c9feb6b (patch)
tree6b8891f39a786eab9282e114d0c2ea72a432ec2a /libreofficekit
parentd6ea25d094258402a27c74a0938e014236c822b7 (diff)
lokdocview: it's enough to query the document size once
Change-Id: Id99c9f1a814bc5f935eeb4e301ef3014ccb0bd07 (cherry picked from commit 124c937f3bd6a7538dc6664ab9556fcfb3f27088)
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 904760d1eea7..7b2d4c948b2a 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.
@@ -237,6 +239,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),
@@ -743,11 +747,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);
@@ -1172,6 +1173,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);
}