summaryrefslogtreecommitdiff
path: root/libreofficekit/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-27 17:12:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-27 17:33:06 +0200
commit8cbb94a2b79dcaf9675125da800b64a85bae52dc (patch)
tree9ce5e197129188e4d8e9dd319286835558de2483 /libreofficekit/source
parent63a40c45018ad2e6f4a660a520a5907beb1d7801 (diff)
lokdocview: handle LOK_CALLBACK_DOCUMENT_SIZE_CHANGED
Change-Id: Ib1b99221afbf9810bad5fd49fbf62c7a20fd28e4
Diffstat (limited to 'libreofficekit/source')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f15027984f7f..ebb09e75c8bc 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -170,6 +170,8 @@ struct LOKDocView_Impl
* the tiles that intersect with pPartial.
*/
void renderDocument(GdkRectangle* pPartial);
+ /// Sets rWidth and rHeight from a "width, height" string.
+ void payloadToSize(const char* pPayload, long& rWidth, long& rHeight);
/// Returns the GdkRectangle of a width,height,x,y string.
static GdkRectangle payloadToRectangle(const char* pPayload);
/// Returns the GdkRectangles of a w,h,x,y;w2,h2,x2,y2;... string.
@@ -844,6 +846,21 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
}
}
+void LOKDocView_Impl::payloadToSize(const char* pPayload, long& rWidth, long& rHeight)
+{
+ rWidth = rHeight = 0;
+ gchar** ppCoordinates = g_strsplit(pPayload, ", ", 2);
+ gchar** ppCoordinate = ppCoordinates;
+ if (!*ppCoordinate)
+ return;
+ rWidth = atoi(*ppCoordinate);
+ ++ppCoordinate;
+ if (!*ppCoordinate)
+ return;
+ rHeight = atoi(*ppCoordinate);
+ g_strfreev(ppCoordinates);
+}
+
GdkRectangle LOKDocView_Impl::payloadToRectangle(const char* pPayload)
{
GdkRectangle aRet;
@@ -913,8 +930,8 @@ const char* LOKDocView_Impl::callbackTypeToString(int nType)
return "LOK_CALLBACK_STATUS_INDICATOR_FINISH";
case LOK_CALLBACK_SEARCH_NOT_FOUND:
return "LOK_CALLBACK_SEARCH_NOT_FOUND";
- case LOK_CALLBACK_PAGE_COUNT_CHANGED:
- return "LOK_CALLBACK_PAGE_COUNT_CHANGED";
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+ return "LOK_CALLBACK_DOCUMENT_SIZE_CHANGED";
case LOK_CALLBACK_SET_PART:
return "LOK_CALLBACK_SET_PART";
}
@@ -1014,9 +1031,9 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
searchNotFound(pCallback->m_aPayload);
}
break;
- case LOK_CALLBACK_PAGE_COUNT_CHANGED:
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
{
- m_pDocument->pClass->getDocumentSize(m_pDocument, &m_nDocumentWidthTwips, &m_nDocumentHeightTwips);
+ LOKDocView_Impl::payloadToSize(pCallback->m_aPayload.c_str(), m_nDocumentWidthTwips, m_nDocumentHeightTwips);
}
break;
case LOK_CALLBACK_SET_PART: