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

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