diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-19 17:56:35 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-19 20:10:22 +0200 |
commit | 288013f25d2e52a76f7ce5368c505a6ccb3b64a2 (patch) | |
tree | 7f2ebea4554cd171b22577c38b8105df08191739 | |
parent | in GetInt...() check !isFinite() instead of isNan() (diff) | |
download | core-288013f25d2e52a76f7ce5368c505a6ccb3b64a2.tar.gz core-288013f25d2e52a76f7ce5368c505a6ccb3b64a2.zip |
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
-rw-r--r-- | desktop/source/lib/init.cxx | 1 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 28 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewstat.cxx | 25 |
5 files changed, 65 insertions, 10 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 39e6c6599690..47a5ca78d115 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1203,6 +1203,7 @@ static void doc_iniUnoCommands () OUString(".uno:SortAscending"), OUString(".uno:SortDescending"), OUString(".uno:TrackChanges"), + OUString(".uno:AcceptTrackedChange"), }; util::URL aCommandURL; diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 2576f9904ff7..385203d0dc42 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -97,6 +97,7 @@ public: GtkWidget* m_pStatusBar; GtkWidget* m_pProgressBar; GtkWidget* m_pStatusbarLabel; + GtkWidget* m_pRedlineLabel; GtkWidget* m_pZoomLabel; GtkToolItem* m_pSaveButton; GtkToolItem* m_pCopyButton; @@ -145,6 +146,7 @@ public: m_pStatusBar(nullptr), m_pProgressBar(nullptr), m_pStatusbarLabel(nullptr), + m_pRedlineLabel(nullptr), m_pZoomLabel(nullptr), m_pSaveButton(nullptr), m_pCopyButton(nullptr), @@ -786,7 +788,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) lok_doc_view_set_visible_area(LOK_DOC_VIEW(pDocView), &aVisibleArea); } } - std::string aZoom = std::to_string(int(fZoom * 100)) + std::string("%"); + std::string aZoom = std::string("Zoom: ") + std::to_string(int(fZoom * 100)) + std::string("%"); gtk_label_set_text(GTK_LABEL(rWindow.m_pZoomLabel), aZoom.c_str()); } @@ -1159,6 +1161,15 @@ static void signalCommand(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pD rWindow.m_aToolItemSensitivities[pItem] = bSensitive; } } + else if (aKey == ".uno:TrackedChangeIndex") + { + std::string aText = std::string("Current redline: "); + if (aValue.empty()) + aText += "none"; + else + aText += aValue; + gtk_label_set_text(GTK_LABEL(rWindow.m_pRedlineLabel), aText.c_str()); + } } } @@ -1800,7 +1811,9 @@ static GtkWidget* createWindow(TiledWindow& rWindow) gtk_widget_set_hexpand(rWindow.m_pStatusbarLabel, TRUE); gtk_container_add(GTK_CONTAINER(pStatusBar), rWindow.m_pStatusbarLabel); - rWindow.m_pZoomLabel = gtk_label_new("100%"); + rWindow.m_pRedlineLabel = gtk_label_new("Current redline: none"); + gtk_container_add(GTK_CONTAINER(pStatusBar), rWindow.m_pRedlineLabel); + rWindow.m_pZoomLabel = gtk_label_new("Zoom: 100%"); gtk_container_add(GTK_CONTAINER(pStatusBar), rWindow.m_pZoomLabel); gtk_widget_show_all(pWindow); @@ -1813,6 +1826,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow) gtk_widget_hide(rWindow.m_pFormulabarEntry); // Hide the non-progressbar children of the status bar by default. gtk_widget_hide(rWindow.m_pStatusbarLabel); + gtk_widget_hide(rWindow.m_pRedlineLabel); gtk_widget_hide(rWindow.m_pZoomLabel); g_aWindows[pWindow] = rWindow; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 9c3ed15f5dd4..49d9c40a1858 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -971,7 +971,8 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c aEvent.FeatureURL.Path == "Strikeout" || aEvent.FeatureURL.Path == "Underline" || aEvent.FeatureURL.Path == "ModifiedStatus" || - aEvent.FeatureURL.Path == "TrackChanges") + aEvent.FeatureURL.Path == "TrackChanges" || + aEvent.FeatureURL.Path == "AcceptTrackedChange") { bool bTemp = false; aEvent.State >>= bTemp; 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; |