summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-19 09:58:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-19 17:02:11 +0200
commit2fa72bab4452a629fe6912d8278c5959cecfb454 (patch)
treeae8a4a7a1d486b74c8a375686174315fe9f3c9a4
parent787c1a5e777f891bc0ffade69560fad09d0e8677 (diff)
tdf#101592 sw: track changes state is doc-specific, not view-specific
So update the bindings of all views after changing it. Reviewed-on: https://gerrit.libreoffice.org/28233 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit d890ec2f130188af9d998abf5968f06e7218b7a4) Conflicts: desktop/qa/desktop_lib/test_desktop_lib.cxx Change-Id: I5355f40ba27be521dcdf343b08305f3736979bbb
-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 29b3d0224b73..ffacd4c8458a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -30,6 +30,9 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <unotools/tempfile.hxx>
#include <vcl/svapp.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
#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(testModifiedStatus);
@@ -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:
@@ -793,6 +802,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 cc2ab9f5d101..0a9f2b2a3018 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1046,7 +1046,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 9e369f464e70..1d7791804f75 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 face8274dda6..77a86ba4a726 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1120,7 +1120,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 69e7dc970050..70dd0b373577 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -604,6 +604,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;