summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-29 17:57:05 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-30 09:50:01 +0200
commit632ee2f56a51531b7dc462dfb3d5c180918e4013 (patch)
treec0db8850100ef00490d42aae8edfb5e80cabce5e
parent078831670df5ed26b4b7bab4461b0abb7b465b67 (diff)
sw: use SwModule::GetRedlineAuthor() in SwTextShell::ExecField()
This avoids some code duplication, and also means that the redline author set by SwDocShell::SetView() affects the inserted Writer comments as well, while those were 'Unknown Author' in the LOK case. Change-Id: Ib51183302ee6904fdf69fb16f27ecfe6df39e6cb (cherry picked from commit e2c240627c8a1a9cea1f9eedfb064214c8e93a39)
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx19
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx9
-rw-r--r--sw/source/uibase/shells/textfld.cxx7
3 files changed, 14 insertions, 21 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index a1833d2d9e74..5ad20594eb3b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -137,8 +137,6 @@ public:
std::shared_ptr<TiledRowColumnBar> m_pRowBar;
std::shared_ptr<TiledRowColumnBar> m_pColumnBar;
std::shared_ptr<TiledCornerButton> m_pCornerButton;
- /// Author string, used for comment insertion.
- std::string m_aAuthor;
/// Rendering arguments, which are the same for all views.
boost::property_tree::ptree m_aRenderingArguments;
@@ -865,7 +863,6 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
GtkWidget* pDocView = lok_doc_view_new_from_widget(LOK_DOC_VIEW(rWindow.m_pDocView), aArguments.c_str());
TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView);
- rNewWindow.m_aAuthor = aAuthor;
// Hide the unused progress bar.
gtk_widget_show_all(rNewWindow.m_pStatusBar);
gtk_widget_hide(rNewWindow.m_pProgressBar);
@@ -917,9 +914,8 @@ static void createModelAndView(const char* pLOPath, const char* pDocPath, const
// Save rendering arguments for views which are created later.
rWindow.m_aRenderingArguments = aTree;
- rWindow.m_aAuthor = getNextAuthor();
aTree.put(boost::property_tree::ptree::path_type(".uno:Author/type", '/'), "string");
- aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), rWindow.m_aAuthor);
+ aTree.put(boost::property_tree::ptree::path_type(".uno:Author/value", '/'), getNextAuthor());
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
@@ -1316,18 +1312,7 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
// notify about the finished Save
gboolean bNotify = (rString == ".uno:Save");
- std::string aArguments;
- if (rString == ".uno:InsertAnnotation" && !rWindow.m_aAuthor.empty())
- {
- boost::property_tree::ptree aTree;
- aTree.put(boost::property_tree::ptree::path_type("Author/type", '/'), "string");
- aTree.put(boost::property_tree::ptree::path_type("Author/value", '/'), rWindow.m_aAuthor);
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree);
- aArguments = aStream.str();
- }
-
- lok_doc_view_post_command(pLOKDocView, rString.c_str(), (aArguments.empty() ? nullptr : aArguments.c_str()), bNotify);
+ lok_doc_view_post_command(pLOKDocView, rString.c_str(), /*pArguments=*/nullptr, bNotify);
}
}
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index edc8e6b17af0..656eb7613b7a 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3322,6 +3322,15 @@ void SwUiWriterTest::testRedlineViewAuthor()
SwRangeRedline* pRedline = rTable[0];
// This was 'Unknown Author' instead of 'A U. Thor'.
CPPUNIT_ASSERT_EQUAL(aAuthor, pRedline->GetAuthorString());
+
+ // Insert a comment and assert that SwView::SetRedlineAuthor() affects this as well.
+ lcl_dispatchCommand(mxComponent, ".uno:.uno:InsertAnnotation", {});
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY);
+ // This was 'Unknown Author' instead of 'A U. Thor'.
+ CPPUNIT_ASSERT_EQUAL(aAuthor, xField->getPropertyValue("Author").get<OUString>());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 652f607d731e..67ef91db6c22 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -71,6 +71,7 @@
#include <PostItMgr.hxx>
#include <calbck.hxx>
#include <memory>
+#include <swmodule.hxx>
using namespace nsSwDocInfoSubType;
@@ -382,10 +383,8 @@ void SwTextShell::ExecField(SfxRequest &rReq)
sAuthor = pAuthorItem->GetValue();
else
{
- SvtUserOptions aUserOpt;
- if( (sAuthor = aUserOpt.GetFullName()).isEmpty())
- if( (sAuthor = aUserOpt.GetID()).isEmpty() )
- sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
+ sal_uInt16 nAuthor = SW_MOD()->GetRedlineAuthor();
+ sAuthor = SW_MOD()->GetRedlineAuthor(nAuthor);
}
const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT);