tdf#101592 sw: track changes state is doc-specific, not view-specific

So update the bindings of all views after changing it.

Change-Id: I5355f40ba27be521dcdf343b08305f3736979bbb
Reviewed-on: https://gerrit.libreoffice.org/28233
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2016-08-19 09:58:33 +02:00
parent e420085f6f
commit d890ec2f13
5 changed files with 57 additions and 3 deletions

View File

@@ -29,6 +29,9 @@
#include <svl/srchitem.hxx> #include <svl/srchitem.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <unotools/tempfile.hxx> #include <unotools/tempfile.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <cairo.h> #include <cairo.h>
#include <lib/init.hxx> #include <lib/init.hxx>
@@ -42,7 +45,8 @@ public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"), DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
m_nSelectionBeforeSearchResult(0), m_nSelectionBeforeSearchResult(0),
m_nSelectionAfterSearchResult(0), m_nSelectionAfterSearchResult(0),
m_bModified(false) m_bModified(false),
m_nTrackChanges(0)
{ {
} }
@@ -93,6 +97,7 @@ public:
void testContextMenuImpress(); void testContextMenuImpress();
void testNotificationCompression(); void testNotificationCompression();
void testRedlineWriter(); void testRedlineWriter();
void testTrackChanges();
CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles); CPPUNIT_TEST(testGetStyles);
@@ -121,6 +126,7 @@ public:
CPPUNIT_TEST(testContextMenuImpress); CPPUNIT_TEST(testContextMenuImpress);
CPPUNIT_TEST(testNotificationCompression); CPPUNIT_TEST(testNotificationCompression);
CPPUNIT_TEST(testRedlineWriter); CPPUNIT_TEST(testRedlineWriter);
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent; uno::Reference<lang::XComponent> mxComponent;
@@ -137,6 +143,7 @@ public:
// for testModifiedStatus // for testModifiedStatus
osl::Condition m_aStateChangedCondition; osl::Condition m_aStateChangedCondition;
bool m_bModified; bool m_bModified;
int m_nTrackChanges;
// for testContextMenu{Calc, Writer} // for testContextMenu{Calc, Writer}
osl::Condition m_aContextMenuCondition; osl::Condition m_aContextMenuCondition;
@@ -226,6 +233,8 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean(); m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean();
m_aStateChangedCondition.set(); m_aStateChangedCondition.set();
} }
else if (aPayload.startsWith(".uno:TrackChanges=") && aPayload.endsWith("=true"))
++m_nTrackChanges;
} }
break; break;
case LOK_CALLBACK_CONTEXT_MENU: case LOK_CALLBACK_CONTEXT_MENU:
@@ -790,6 +799,29 @@ void DesktopLOKTest::testModifiedStatus()
comphelper::LibreOfficeKit::setActive(false); 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() void DesktopLOKTest::testSheetOperations()
{ {
comphelper::LibreOfficeKit::setActive(); comphelper::LibreOfficeKit::setActive();

View File

@@ -1032,7 +1032,8 @@ static void doc_iniUnoCommands ()
OUString(".uno:NumberFormatPercent"), OUString(".uno:NumberFormatPercent"),
OUString(".uno:NumberFormatDate"), OUString(".uno:NumberFormatDate"),
OUString(".uno:SortAscending"), OUString(".uno:SortAscending"),
OUString(".uno:SortDescending") OUString(".uno:SortDescending"),
OUString(".uno:TrackChanges"),
}; };
util::URL aCommandURL; util::URL aCommandURL;

View File

@@ -116,6 +116,7 @@ public:
GtkToolItem* m_pJustifypara; GtkToolItem* m_pJustifypara;
GtkToolItem* m_pInsertAnnotation; GtkToolItem* m_pInsertAnnotation;
GtkToolItem* m_pDeleteComment; GtkToolItem* m_pDeleteComment;
GtkToolItem* m_pTrackChanges;
GtkWidget* m_pFormulabarEntry; GtkWidget* m_pFormulabarEntry;
GtkWidget* m_pScrolledWindow; GtkWidget* m_pScrolledWindow;
std::map<GtkToolItem*, std::string> m_aToolItemCommandNames; std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
@@ -165,6 +166,7 @@ public:
m_pJustifypara(nullptr), m_pJustifypara(nullptr),
m_pInsertAnnotation(nullptr), m_pInsertAnnotation(nullptr),
m_pDeleteComment(nullptr), m_pDeleteComment(nullptr),
m_pTrackChanges(nullptr),
m_pFormulabarEntry(nullptr), m_pFormulabarEntry(nullptr),
m_pScrolledWindow(nullptr), m_pScrolledWindow(nullptr),
m_bToolItemBroadcast(true), 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_pRedo, bEdit, rWindow);
setSensitiveIfInEdit(rWindow.m_pPasteButton, bEdit, rWindow); setSensitiveIfInEdit(rWindow.m_pPasteButton, bEdit, rWindow);
setSensitiveIfInEdit(rWindow.m_pSaveButton, bEdit, rWindow); setSensitiveIfInEdit(rWindow.m_pSaveButton, bEdit, rWindow);
setSensitiveIfInEdit(rWindow.m_pTrackChanges, bEdit, rWindow);
} }
/// LOKDocView changed command state -> inform the tool button. /// 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"); lcl_registerToolItem(rWindow, rWindow.m_pDeleteComment, ".uno:DeleteComment");
gtk_widget_set_sensitive(GTK_WIDGET(rWindow.m_pDeleteComment), false); 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 // Formula bar
GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new(); GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
rWindow.m_pFormulabarEntry = gtk_entry_new(); rWindow.m_pFormulabarEntry = gtk_entry_new();

View File

@@ -970,7 +970,8 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
aEvent.FeatureURL.Path == "SuperScript" || aEvent.FeatureURL.Path == "SuperScript" ||
aEvent.FeatureURL.Path == "Strikeout" || aEvent.FeatureURL.Path == "Strikeout" ||
aEvent.FeatureURL.Path == "Underline" || aEvent.FeatureURL.Path == "Underline" ||
aEvent.FeatureURL.Path == "ModifiedStatus") aEvent.FeatureURL.Path == "ModifiedStatus" ||
aEvent.FeatureURL.Path == "TrackChanges")
{ {
bool bTemp = false; bool bTemp = false;
aEvent.State >>= bTemp; aEvent.State >>= bTemp;

View File

@@ -600,6 +600,14 @@ void SwView::Execute(SfxRequest &rReq)
? nsRedlineMode_t::REDLINE_ON : 0; ? nsRedlineMode_t::REDLINE_ON : 0;
const sal_uInt16 nMode = m_pWrtShell->GetRedlineMode(); const sal_uInt16 nMode = m_pWrtShell->GetRedlineMode();
m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); 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; break;