Blame SOURCES/0342-gtktiledviewer-set-author-name-when-inserting-a-comm.patch

f325b2
From addf504efd94119f08ba227e39c04819925af608 Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Tue, 17 Nov 2015 20:57:49 +0100
f325b2
Subject: [PATCH 342/398] gtktiledviewer: set author name when inserting a
f325b2
 comment
f325b2
f325b2
Change-Id: Iee66687ce813ff801f29e4568329ed2a39f905ba
f325b2
(cherry picked from commit e0080a60ac2fb0a57cbf1ecbeda250e37d8b402e)
f325b2
---
f325b2
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 17 ++++++++++++++++-
f325b2
 1 file changed, 16 insertions(+), 1 deletion(-)
f325b2
f325b2
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
index 86fc9e539b39..7dcd52446344 100644
f325b2
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
@@ -10,6 +10,7 @@
f325b2
 #include <assert.h>
f325b2
 #include <stdio.h>
f325b2
 #include <string.h>
f325b2
+#include <pwd.h>
f325b2
 #include <string>
f325b2
 #include <map>
f325b2
 #include <iostream>
f325b2
@@ -118,6 +119,7 @@ public:
f325b2
     std::shared_ptr<TiledRowColumnBar> m_pRowBar;
f325b2
     std::shared_ptr<TiledRowColumnBar> m_pColumnBar;
f325b2
     std::shared_ptr<TiledCornerButton> m_pCornerButton;
f325b2
+    std::string m_aAuthor;
f325b2
 
f325b2
     TiledWindow()
f325b2
         : m_pDocView(nullptr),
f325b2
@@ -148,6 +150,8 @@ public:
f325b2
         m_pFindbarLabel(nullptr),
f325b2
         m_bFindAll(false)
f325b2
     {
f325b2
+        struct passwd* pPasswd = getpwuid(getuid());
f325b2
+        m_aAuthor = std::string(pPasswd->pw_gecos);
f325b2
     }
f325b2
 };
f325b2
 
f325b2
@@ -799,7 +803,18 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
f325b2
         // notify about the finished Save
f325b2
         gboolean bNotify = (rString == ".uno:Save");
f325b2
 
f325b2
-        lok_doc_view_post_command(pLOKDocView, rString.c_str(), nullptr, bNotify);
f325b2
+        std::string aArguments;
f325b2
+        if (rString == ".uno:InsertAnnotation" && !rWindow.m_aAuthor.empty())
f325b2
+        {
f325b2
+            boost::property_tree::ptree aTree;
f325b2
+            aTree.put(boost::property_tree::ptree::path_type("Author/type", '/'), "string");
f325b2
+            aTree.put(boost::property_tree::ptree::path_type("Author/value", '/'), rWindow.m_aAuthor);
f325b2
+            std::stringstream aStream;
f325b2
+            boost::property_tree::write_json(aStream, aTree);
f325b2
+            aArguments = aStream.str();
f325b2
+        }
f325b2
+
f325b2
+        lok_doc_view_post_command(pLOKDocView, rString.c_str(), (aArguments.empty() ? nullptr : aArguments.c_str()), bNotify);
f325b2
     }
f325b2
 }
f325b2
 
f325b2
-- 
f325b2
2.12.0
f325b2