summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx8
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx18
-rw-r--r--sw/inc/unotxdoc.hxx8
-rw-r--r--sw/inc/viscrs.hxx3
-rw-r--r--sw/source/core/crsr/viscrs.cxx12
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx44
6 files changed, 93 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 46d31769ee18..73db97680c38 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -359,6 +359,13 @@ static void populatePartSelector()
lok_doc_view_get_part( LOK_DOC_VIEW(pDocView) ) );
}
+static void signalSize(LOKDocView* /*pLOKDocView*/, gpointer /*pData*/)
+{
+ g_bPartSelectorBroadcast = false;
+ populatePartSelector();
+ g_bPartSelectorBroadcast = true;
+}
+
static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
{
int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
@@ -567,6 +574,7 @@ int main( int argc, char* argv[] )
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
+ g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d13fb9b6fc99..b864d6f0ac06 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -114,6 +114,7 @@ enum
COMMAND_CHANGED,
SEARCH_NOT_FOUND,
PART_CHANGED,
+ SIZE_CHANGED,
HYPERLINK_CLICKED,
LAST_SIGNAL
@@ -581,6 +582,8 @@ callback (gpointer pData)
gtk_widget_set_size_request(GTK_WIDGET(pDocView),
twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom),
twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom));
+
+ g_signal_emit(pDocView, doc_view_signals[SIZE_CHANGED], 0, NULL);
}
break;
case LOK_CALLBACK_SET_PART:
@@ -1707,6 +1710,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
G_TYPE_INT);
/**
+ * LOKDocView::size-changed:
+ * @pDocView: the #LOKDocView on which the signal is emitted
+ * @aCommand: NULL, we just notify that want to notify the UI elements that are interested.
+ */
+ doc_view_signals[SIZE_CHANGED] =
+ g_signal_new("size-changed",
+ G_TYPE_FROM_CLASS(pGObjectClass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ /**
* LOKDocView::hyperlinked-clicked:
* @pDocView: the #LOKDocView on which the signal is emitted
* @aHyperlink: the URI which the application should handle
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 562752342036..612ea7ce8ac7 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -406,6 +406,14 @@ public:
long nTileHeight ) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::getDocumentSize().
virtual Size getDocumentSize() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::setPart().
+ virtual void setPart(int nPart) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getParts().
+ virtual int getParts() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getPart().
+ virtual int getPart() SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::getPartName().
+ virtual OUString getPartName(int nPart) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::registerCallback().
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 159fb2ffbc41..525b551b9867 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -43,6 +43,9 @@ class SwVisCrsr
vcl::Cursor m_aTextCrsr;
const SwCrsrShell* m_pCrsrShell;
+ /// For LibreOfficeKit only - remember what page we were at the last time.
+ sal_uInt16 m_nPageLastTime;
+
void _SetPosAndShow();
public:
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 44805c67e402..6ff459641d94 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -67,6 +67,7 @@ MapMode* SwSelPaintRects::s_pMapMode = 0;
// Starting from here: classes / methods for the non-text-cursor
SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
: m_pCrsrShell( pCShell )
+ , m_nPageLastTime(0)
{
pCShell->GetWin()->SetCursor( &m_aTextCrsr );
m_bIsVisible = m_aTextCrsr.IsVisible();
@@ -179,6 +180,17 @@ void SwVisCrsr::_SetPosAndShow()
if (m_pCrsrShell->isTiledRendering())
{
+ // notify about page number change (if that happened)
+ sal_uInt16 nPage, nVirtPage;
+ const_cast<SwCrsrShell*>(m_pCrsrShell)->GetPageNum(nPage, nVirtPage);
+ if (nPage != m_nPageLastTime)
+ {
+ m_nPageLastTime = nPage;
+ OString aPayload = OString::number(nPage - 1);
+ m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+ }
+
+ // notify about the cursor position & size
Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
OString sRect = aSVRect.toString();
m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index d453ad84f4b8..aceb6f409903 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3152,6 +3152,50 @@ Size SwXTextDocument::getDocumentSize()
aDocSize.Height() + 2L * DOCUMENTBORDER);
}
+void SwXTextDocument::setPart(int nPart)
+{
+ SolarMutexGuard aGuard;
+
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ if (!pWrtShell)
+ return;
+
+ pWrtShell->GotoPage(nPart + 1, true);
+}
+
+int SwXTextDocument::getParts()
+{
+ SolarMutexGuard aGuard;
+
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ if (!pWrtShell)
+ return 0;
+
+ return pWrtShell->GetPageCnt();
+}
+
+int SwXTextDocument::getPart()
+{
+ SolarMutexGuard aGuard;
+
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ if (!pWrtShell)
+ return 0;
+
+ sal_uInt16 nPage, nLogPage;
+ OUString sDisplay;
+ pWrtShell->GetPageNumber(-1, pWrtShell->IsCrsrVisible(), nPage, nLogPage, sDisplay);
+
+ return nPage - 1;
+}
+
+OUString SwXTextDocument::getPartName(int nPart)
+{
+ SolarMutexGuard aGuard;
+
+ return OUString(SW_RES(STR_PAGE)) + OUString::number(nPart + 1);
+}
+
void SwXTextDocument::initializeForTiledRendering()
{
SolarMutexGuard aGuard;