summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx34
-rw-r--r--desktop/source/lib/init.cxx3
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx12
-rw-r--r--sfx2/source/control/unoctitm.cxx3
-rw-r--r--sw/source/uibase/uiview/view2.cxx8
5 files changed, 57 insertions, 3 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a1e7cc04df93..b356535e1a4d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -29,6 +29,9 @@
#include <svl/srchitem.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <unotools/tempfile.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
#include <cairo.h>
#include <lib/init.hxx>
@@ -42,7 +45,8 @@ public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
m_nSelectionBeforeSearchResult(0),
m_nSelectionAfterSearchResult(0),
- m_bModified(false)
+ m_bModified(false),
+ m_nTrackChanges(0)
{
}
@@ -93,6 +97,7 @@ public:
void testContextMenuImpress();
void testNotificationCompression();
void testRedlineWriter();
+ void testTrackChanges();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -121,6 +126,7 @@ public:
CPPUNIT_TEST(testContextMenuImpress);
CPPUNIT_TEST(testNotificationCompression);
CPPUNIT_TEST(testRedlineWriter);
+ CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -137,6 +143,7 @@ public:
// for testModifiedStatus
osl::Condition m_aStateChangedCondition;
bool m_bModified;
+ int m_nTrackChanges;
// for testContextMenu{Calc, Writer}
osl::Condition m_aContextMenuCondition;
@@ -226,6 +233,8 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean();
m_aStateChangedCondition.set();
}
+ else if (aPayload.startsWith(".uno:TrackChanges=") && aPayload.endsWith("=true"))
+ ++m_nTrackChanges;
}
break;
case LOK_CALLBACK_CONTEXT_MENU:
@@ -790,6 +799,29 @@ void DesktopLOKTest::testModifiedStatus()
comphelper::LibreOfficeKit::setActive(false);
}
+void DesktopLOKTest::testTrackChanges()
+{
+ // Load a document and create two views.
+ LibLibreOffice_Impl aOffice;
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ pDocument->pClass->createView(pDocument);
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+ Scheduler::ProcessEventsToIdle();
+
+ // Enable trak changes and assert that both views get notified.
+ m_nTrackChanges = 0;
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, false);
+ Scheduler::ProcessEventsToIdle();
+ // This was 1, only the active view was notified.
+ CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
void DesktopLOKTest::testSheetOperations()
{
comphelper::LibreOfficeKit::setActive();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 17955e850197..6199979fa094 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1032,7 +1032,8 @@ static void doc_iniUnoCommands ()
OUString(".uno:NumberFormatPercent"),
OUString(".uno:NumberFormatDate"),
OUString(".uno:SortAscending"),
- OUString(".uno:SortDescending")
+ OUString(".uno:SortDescending"),
+ OUString(".uno:TrackChanges"),
};
util::URL aCommandURL;
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index bd6650ba341d..5a134d02a599 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -116,6 +116,7 @@ public:
GtkToolItem* m_pJustifypara;
GtkToolItem* m_pInsertAnnotation;
GtkToolItem* m_pDeleteComment;
+ GtkToolItem* m_pTrackChanges;
GtkWidget* m_pFormulabarEntry;
GtkWidget* m_pScrolledWindow;
std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
@@ -165,6 +166,7 @@ public:
m_pJustifypara(nullptr),
m_pInsertAnnotation(nullptr),
m_pDeleteComment(nullptr),
+ m_pTrackChanges(nullptr),
m_pFormulabarEntry(nullptr),
m_pScrolledWindow(nullptr),
m_bToolItemBroadcast(true),
@@ -1117,6 +1119,7 @@ static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pD
setSensitiveIfInEdit(rWindow.m_pRedo, bEdit, rWindow);
setSensitiveIfInEdit(rWindow.m_pPasteButton, bEdit, rWindow);
setSensitiveIfInEdit(rWindow.m_pSaveButton, bEdit, rWindow);
+ setSensitiveIfInEdit(rWindow.m_pTrackChanges, bEdit, rWindow);
}
/// LOKDocView changed command state -> inform the tool button.
@@ -1709,6 +1712,15 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
lcl_registerToolItem(rWindow, rWindow.m_pDeleteComment, ".uno:DeleteComment");
gtk_widget_set_sensitive(GTK_WIDGET(rWindow.m_pDeleteComment), false);
+ // Track changes
+ rWindow.m_pTrackChanges = gtk_toggle_tool_button_new();
+ gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(rWindow.m_pTrackChanges), "media-record-symbolic");
+ gtk_tool_item_set_tooltip_text(rWindow.m_pTrackChanges, "Track Changes");
+ gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), rWindow.m_pTrackChanges, -1);
+ g_signal_connect(G_OBJECT(rWindow.m_pTrackChanges), "toggled", G_CALLBACK(toggleToolItem), nullptr);
+ lcl_registerToolItem(rWindow, rWindow.m_pTrackChanges, ".uno:TrackChanges");
+ gtk_widget_set_sensitive(GTK_WIDGET(rWindow.m_pTrackChanges), false);
+
// Formula bar
GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
rWindow.m_pFormulabarEntry = gtk_entry_new();
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 14c28ce384d1..c7d4a88ea236 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -970,7 +970,8 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
aEvent.FeatureURL.Path == "SuperScript" ||
aEvent.FeatureURL.Path == "Strikeout" ||
aEvent.FeatureURL.Path == "Underline" ||
- aEvent.FeatureURL.Path == "ModifiedStatus")
+ aEvent.FeatureURL.Path == "ModifiedStatus" ||
+ aEvent.FeatureURL.Path == "TrackChanges")
{
bool bTemp = false;
aEvent.State >>= bTemp;
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 2f6b28f56b46..e07f72363295 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -600,6 +600,14 @@ void SwView::Execute(SfxRequest &rReq)
? nsRedlineMode_t::REDLINE_ON : 0;
const sal_uInt16 nMode = m_pWrtShell->GetRedlineMode();
m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+
+ // Notify all view shells of this document, as the track changes mode is document-global.
+ SwDocShell* pDocShell = GetDocShell();
+ for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(pDocShell); pViewFrame; pViewFrame = SfxViewFrame::GetNext(*pViewFrame, pDocShell))
+ {
+ pViewFrame->GetBindings().Invalidate(FN_REDLINE_ON);
+ pViewFrame->GetBindings().Update(FN_REDLINE_ON);
+ }
}
}
break;