summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx28
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx25
2 files changed, 46 insertions, 7 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 69f965c2d8dc..f203fcaa3ae8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -27,6 +27,7 @@
#include <wrtsh.hxx>
#include <view.hxx>
#include <UndoManager.hxx>
+#include <cmdid.h>
#include <sfx2/viewsh.hxx>
#include <sfx2/lokhelper.hxx>
@@ -128,6 +129,7 @@ private:
int m_nInvalidations;
int m_nRedlineTableSizeChanged;
int m_nRedlineTableEntryModified;
+ int m_nTrackedChangeIndex;
};
SwTiledRenderingTest::SwTiledRenderingTest()
@@ -136,7 +138,8 @@ SwTiledRenderingTest::SwTiledRenderingTest()
m_nSelectionAfterSearchResult(0),
m_nInvalidations(0),
m_nRedlineTableSizeChanged(0),
- m_nRedlineTableEntryModified(0)
+ m_nRedlineTableEntryModified(0),
+ m_nTrackedChangeIndex(-1)
{
}
@@ -157,6 +160,7 @@ void SwTiledRenderingTest::callback(int nType, const char* pPayload, void* pData
void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
{
+ OString aPayload(pPayload);
switch (nType)
{
case LOK_CALLBACK_INVALIDATE_TILES:
@@ -220,6 +224,19 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
++m_nRedlineTableEntryModified;
}
break;
+ case LOK_CALLBACK_STATE_CHANGED:
+ {
+ OString aTrackedChangeIndexPrefix(".uno:TrackedChangeIndex=");
+ if (aPayload.startsWith(aTrackedChangeIndexPrefix))
+ {
+ OString sIndex = aPayload.copy(aTrackedChangeIndexPrefix.getLength());
+ if (sIndex.isEmpty())
+ m_nTrackedChangeIndex = -1;
+ else
+ m_nTrackedChangeIndex = sIndex.toInt32();
+ }
+ }
+ break;
}
}
@@ -1274,6 +1291,15 @@ void SwTiledRenderingTest::testTrackChangesCallback()
// This was 0, as LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED wasn't sent.
CPPUNIT_ASSERT_EQUAL(1, m_nRedlineTableSizeChanged);
+ CPPUNIT_ASSERT_EQUAL(-1, m_nTrackedChangeIndex);
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ SfxItemSet aSet(pWrtShell->GetDoc()->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_ACCEPT_DIRECT);
+ SfxVoidItem aItem(FN_REDLINE_ACCEPT_DIRECT);
+ aSet.Put(aItem);
+ pWrtShell->GetView().GetState(aSet);
+ // This failed, LOK_CALLBACK_STATE_CHANGED wasn't sent.
+ CPPUNIT_ASSERT_EQUAL(0, m_nTrackedChangeIndex);
+
comphelper::LibreOfficeKit::setActive(false);
}
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;