summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-03-10 16:13:53 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-03-16 09:38:05 +0100
commit0262693b327c947ef69581e61a966546c9ebb8da (patch)
tree9af58b8060ec4bd5c2d005581899eb9c3f16bf40
parent5fb4e35f3454cb49bf5e5f611224216862f6f611 (diff)
lok::Document: add resetSelection()
Change-Id: Ib24003178bb576ff1450d674d74ef8978b350b92
-rw-r--r--desktop/source/lib/init.cxx14
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h2
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx8
-rw-r--r--include/vcl/ITiledRenderable.hxx5
-rw-r--r--libreofficekit/source/gtk/lokdocview.c5
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx8
7 files changed, 44 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bf10c6847d86..ee986c515722 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -221,6 +221,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
int nType,
int nX,
int nY);
+static void doc_resetSelection (LibreOfficeKitDocument* pThis);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -252,6 +253,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
+ m_pDocumentClass->resetSelection = doc_resetSelection;
gDocumentClass = m_pDocumentClass;
}
@@ -757,6 +759,18 @@ static void doc_setGraphicSelection(LibreOfficeKitDocument* pThis, int nType, in
pDoc->setGraphicSelection(nType, nX, nY);
}
+static void doc_resetSelection(LibreOfficeKitDocument* pThis)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->resetSelection();
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 29f07b34df1d..e2ad1930108d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -142,6 +142,8 @@ struct _LibreOfficeKitDocumentClass
int nType,
int nX,
int nY);
+ /// @see lok::Document::resetSelection
+ void (*resetSelection)(LibreOfficeKitDocument* pThis);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 2993193fb31e..c19aa504cbac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -153,6 +153,14 @@ public:
{
mpDoc->pClass->setGraphicSelection(mpDoc, nType, nX, nY);
}
+
+ /**
+ * Gets rid of any text or graphic selection.
+ */
+ inline void resetSelection()
+ {
+ mpDoc->pClass->resetSelection(mpDoc);
+ }
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 7f63b1f7d681..6bd75a477c7b 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -122,6 +122,11 @@ public:
* @see lok::Document::setGraphicSelection().
*/
virtual void setGraphicSelection(int /*nType*/, int /*nX*/, int /*nY*/) { }
+
+ /**
+ * @see lok::Document::resetSelection().
+ */
+ virtual void resetSelection() { }
};
} // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 3980a50edd8c..cb967ffdd76b 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -973,6 +973,11 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
if (!pDocView->m_bEdit && bEdit)
g_info("lok_docview_set_edit: entering edit mode");
+ else if (pDocView->m_bEdit && !bEdit)
+ {
+ g_info("lok_docview_set_edit: leaving edit mode");
+ pDocView->pDocument->pClass->resetSelection(pDocView->pDocument);
+ }
pDocView->m_bEdit = bEdit;
g_signal_emit(pDocView, docview_signals[EDIT_CHANGED], 0, bWasEdit);
gtk_widget_queue_draw(GTK_WIDGET(pDocView->pEventBox));
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index b840385b5ac7..778d073837ea 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -419,6 +419,8 @@ public:
virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::setGraphicSelection().
virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::resetSelection().
+ virtual void resetSelection() SAL_OVERRIDE;
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 6c0b8932e89d..e806a50668c2 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3242,6 +3242,14 @@ void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY)
}
}
+void SwXTextDocument::resetSelection()
+{
+ SolarMutexGuard aGuard;
+
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->ResetSelect(0, false);
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);