[Libreoffice-commits] core.git: 2 commits - include/LibreOfficeKit libreofficekit/source sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed May 27 08:33:35 PDT 2015
include/LibreOfficeKit/LibreOfficeKitEnums.h | 8 ++++----
libreofficekit/source/gtk/lokdocview.cxx | 25 +++++++++++++++++++++----
sw/source/core/view/viewsh.cxx | 10 ++++++++++
sw/source/uibase/uiview/view2.cxx | 2 --
4 files changed, 35 insertions(+), 10 deletions(-)
New commits:
commit 8cbb94a2b79dcaf9675125da800b64a85bae52dc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed May 27 17:12:28 2015 +0200
lokdocview: handle LOK_CALLBACK_DOCUMENT_SIZE_CHANGED
Change-Id: Ib1b99221afbf9810bad5fd49fbf62c7a20fd28e4
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f150279..ebb09e7 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:
commit 63a40c45018ad2e6f4a660a520a5907beb1d7801
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed May 27 17:12:00 2015 +0200
LOK: change PAGE_COUNT to a more generic DOCUMENT_SIZE
Change-Id: If94af4072c321358d7bd4d678eeed181dc0f44db
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index bbcd5b9..66237e4 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -143,12 +143,12 @@ typedef enum
LOK_CALLBACK_SEARCH_NOT_FOUND,
/**
- * Number of pages changed in the document.
+ * Size of the document changed.
*
- * Clients should assume that data returned by an earlier
- * lok::Document::getDocumentSize() call is no longer valid.
+ * Payload format is "width, height", i.e. clients get the new size without
+ * having to do an explicit lok::Document::getDocumentSize() call.
*/
- LOK_CALLBACK_PAGE_COUNT_CHANGED,
+ LOK_CALLBACK_DOCUMENT_SIZE_CHANGED,
/**
* The current part number is changed.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 3c163d9..32fe222 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -78,6 +78,7 @@
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
#include <svx/sdrpaintwindow.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#if !HAVE_FEATURE_DESKTOP
#include <vcl/sysdata.hxx>
@@ -989,6 +990,15 @@ void SwViewShell::SizeChgNotify()
const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType();
OUString sDisplay = rNum.GetNumStr( nVirtNum );
PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay );
+
+ if (isTiledRendering())
+ {
+ Size aDocSize = GetDocSize();
+ std::stringstream ss;
+ ss << aDocSize.Width() + 2L * DOCUMENTBORDER << ", " << aDocSize.Height() + 2L * DOCUMENTBORDER;
+ OString sRect = ss.str().c_str();
+ libreOfficeKitCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr());
+ }
}
}
}
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index a8ce619..b6f947d 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -147,7 +147,6 @@
#include <vcl/settings.hxx>
#include <boost/scoped_ptr.hpp>
-#include <LibreOfficeKit/LibreOfficeKitEnums.h>
const char sStatusDelim[] = " : ";
const char sStatusComma[] = " , ";
@@ -1281,7 +1280,6 @@ void SwView::Execute(SfxRequest &rReq)
/// invalidate page numbering field
void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
{
- GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_PAGE_COUNT_CHANGED, 0);
OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
// Used to distinguish which tooltip to show
More information about the Libreoffice-commits
mailing list