summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-19 17:56:35 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-19 20:10:22 +0200
commit288013f25d2e52a76f7ce5368c505a6ccb3b64a2 (patch)
tree7f2ebea4554cd171b22577c38b8105df08191739 /sw/source/uibase
parentaa51bf1e17dfb4a0a95a24e7de7f55d2b44b9472 (diff)
sw: emit LOK_CALLBACK_STATE_CHANGED when cursor enters/leaves a redline
For now only care about the start of the cursor, which can be only at a single redline. Add matching testcase + expose it in the gtktiledviewer status bar for interactive manual testing. Change-Id: Ib61757412d6b54bef64361d4a8563795ca0bab6c
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx25
1 files changed, 19 insertions, 6 deletions
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index da999bd04e25..07edb05c8ed4 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -52,6 +52,7 @@
#include <svl/stritem.hxx>
#include <unotools/moduleoptions.hxx>
#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <svl/visitem.hxx>
#include <redline.hxx>
#include <docary.hxx>
@@ -285,12 +286,12 @@ void SwView::GetState(SfxItemSet &rSet)
{
SwDoc *pDoc = m_pWrtShell->GetDoc();
SwPaM *pCursor = m_pWrtShell->GetCursor();
+ bool bDisable = false;
if (GetDocShell()->HasChangeRecordProtection())
- rSet.DisableItem(nWhich);
- else if (pCursor->HasMark() && !comphelper::LibreOfficeKit::isActive())
+ bDisable = true;
+ else if (pCursor->HasMark())
{
// If the selection does not contain redlines, disable accepting/rejecting changes.
- // Though LibreOfficeKit wants to handle changes by index, so always allow there.
sal_uInt16 index = 0;
const SwRedlineTable& table = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
const SwRangeRedline* redline = table.FindAtPosition( *pCursor->Start(), index );
@@ -311,14 +312,26 @@ void SwView::GetState(SfxItemSet &rSet)
}
}
if( redline == nullptr )
- rSet.DisableItem(nWhich);
+ bDisable = true;
}
- else if (!comphelper::LibreOfficeKit::isActive())
+ else
{
// If the cursor position isn't on a redline, disable
// accepting/rejecting changes.
if (nullptr == pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), nullptr))
- rSet.DisableItem(nWhich);
+ bDisable = true;
+ }
+
+ // LibreOfficeKit wants to handle changes by index, so always allow here.
+ if (bDisable && !comphelper::LibreOfficeKit::isActive())
+ rSet.DisableItem(nWhich);
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ OString aPayload(".uno:TrackedChangeIndex=");
+ sal_uInt16 nRedline = 0;
+ if (pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline))
+ aPayload += OString::number(nRedline);
+ libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload.getStr());
}
}
break;