[Libreoffice-commits] core.git: libreofficekit/qa sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Aug 29 17:27:43 UTC 2016
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 19 ++-----------------
sw/qa/extras/uiwriter/uiwriter.cxx | 9 +++++++++
sw/source/uibase/shells/textfld.cxx | 7 +++----
3 files changed, 14 insertions(+), 21 deletions(-)
New commits:
commit e2c240627c8a1a9cea1f9eedfb064214c8e93a39
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Aug 29 17:57:05 2016 +0200
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
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 9bfaa85..e1e86bb4d 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 dd63e8c..5f5e833 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3888,6 +3888,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 04f3ea1..4279963 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -70,6 +70,7 @@
#include <PostItMgr.hxx>
#include <calbck.hxx>
#include <memory>
+#include <swmodule.hxx>
using namespace nsSwDocInfoSubType;
@@ -381,10 +382,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);
More information about the Libreoffice-commits
mailing list