summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-18 10:01:32 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-19 10:37:54 +0200
commitfd590397606e944e9a2974a2c62759436a5a5b20 (patch)
treed2e692a576bb9a4e535fdcb0448965d6f8e6dd37
parentc57b7875b4f725187faf113da6d563a9ea43164c (diff)
sw redlining: support per-view authors
In case there are multiple SwView instances and SetRedlineAuthor() is called with a non-empty string on them, switching views will keep the SwModule redline author string up to date as expected. (cherry picked from commit cb9362faad9fe702031c5e657a31b1963ad4d374) Conflicts: sw/source/uibase/uno/unotxdoc.cxx Change-Id: I363221049dbacd67d7c8f4ff3e778f8032a3bc43
-rw-r--r--sw/inc/view.hxx2
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx30
-rw-r--r--sw/source/uibase/app/docsh.cxx7
-rw-r--r--sw/source/uibase/inc/uivwimp.hxx3
-rw-r--r--sw/source/uibase/uiview/viewprt.cxx11
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx9
6 files changed, 62 insertions, 0 deletions
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index ff40f2c094ed..acaff3e80585 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -653,6 +653,8 @@ public:
int getPart() const override;
/// See SfxViewShell::dumpAsXml().
void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
+ void SetRedlineAuthor(const OUString& rAuthor);
+ const OUString& GetRedlineAuthor();
};
inline long SwView::GetXScroll() const
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index b6838bd00366..edc8e6b17af0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -189,6 +189,7 @@ public:
void testTdf84695();
void testClassificationPaste();
void testRedlineParam();
+ void testRedlineViewAuthor();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -283,6 +284,7 @@ public:
CPPUNIT_TEST(testTdf84695);
CPPUNIT_TEST(testClassificationPaste);
CPPUNIT_TEST(testRedlineParam);
+ CPPUNIT_TEST(testRedlineViewAuthor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3294,6 +3296,34 @@ void SwUiWriterTest::testRedlineParam()
CPPUNIT_ASSERT_EQUAL(OUString("aaamiddle"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
}
+void SwUiWriterTest::testRedlineViewAuthor()
+{
+ // Test that setting an author at an SwView level has effect.
+
+ // Create a document with minimal content.
+ SwDoc* pDoc = createDoc();
+ SwDocShell* pDocShell = pDoc->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->Insert("middle");
+ SwView* pView = pDocShell->GetView();
+ const OUString aAuthor("A U. Thor");
+ pView->SetRedlineAuthor(aAuthor);
+ pDocShell->SetView(pView);
+
+ // Turn on track changes, and add changes to the start of the document.
+ uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+ pWrtShell->SttDoc();
+ pWrtShell->Insert("aaa");
+
+ // Now assert that SwView::SetRedlineAuthor() had an effect.
+ const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rTable.size());
+ SwRangeRedline* pRedline = rTable[0];
+ // This was 'Unknown Author' instead of 'A U. Thor'.
+ CPPUNIT_ASSERT_EQUAL(aAuthor, pRedline->GetAuthorString());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index e112b71de0d6..14d8cd8fedc1 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1101,7 +1101,14 @@ void SwDocShell::SetView(SwView* pVw)
SetViewShell_Impl(pVw);
m_pView = pVw;
if (m_pView)
+ {
m_pWrtShell = &m_pView->GetWrtShell();
+
+ // Set view-specific redline author.
+ const OUString& rRedlineAuthor = m_pView->GetRedlineAuthor();
+ if (!rRedlineAuthor.isEmpty())
+ SW_MOD()->SetRedlineAuthor(m_pView->GetRedlineAuthor());
+ }
else
m_pWrtShell = nullptr;
}
diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx
index 7713246fc059..6fe798bb1d7d 100644
--- a/sw/source/uibase/inc/uivwimp.hxx
+++ b/sw/source/uibase/inc/uivwimp.hxx
@@ -120,6 +120,9 @@ class SwView_Impl
bool m_bEditingPositionSet;
public:
+ /// Redline author that's specific to this view.
+ OUString m_sRedlineAuthor;
+
SwView_Impl(SwView* pShell);
~SwView_Impl();
diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx
index ddcefec217b4..00f0f5bcad13 100644
--- a/sw/source/uibase/uiview/viewprt.cxx
+++ b/sw/source/uibase/uiview/viewprt.cxx
@@ -65,6 +65,7 @@
#include <svl/slstitm.hxx>
#include <unomid.h>
+#include <uivwimp.hxx>
using namespace ::com::sun::star;
@@ -268,6 +269,16 @@ void SwView::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
+void SwView::SetRedlineAuthor(const OUString& rAuthor)
+{
+ m_pViewImpl->m_sRedlineAuthor = rAuthor;
+}
+
+const OUString& SwView::GetRedlineAuthor()
+{
+ return m_pViewImpl->m_sRedlineAuthor;
+}
+
// Create page printer/additions for SwView and SwPagePreview
VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent,
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index a37764ad8451..1e10d09256a3 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3250,6 +3250,15 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
SwViewOption::SetAppearanceFlag(VIEWOPT_SHADOW , rValue.Value.get<bool>());
+ else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
+ {
+ // Store the author name in the view.
+ pView->SetRedlineAuthor(rValue.Value.get<OUString>());
+ // Let the actual author name pick up the value from the current
+ // view, which would normally happen only during the next view
+ // switch.
+ pDocShell->SetView(pView);
+ }
}
pViewShell->ApplyViewOptions(aViewOption);