diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-17 20:57:49 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-17 20:59:09 +0100 |
commit | e0080a60ac2fb0a57cbf1ecbeda250e37d8b402e (patch) | |
tree | 9f067d64a5e0b16cc3c95969895bd15820869fb9 /libreofficekit/qa | |
parent | 60c51ac007e047a497eea1093f611df0467a5ceb (diff) |
gtktiledviewer: set author name when inserting a comment
Change-Id: Iee66687ce813ff801f29e4568329ed2a39f905ba
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index c65e4a135ddc..fe35f2ec0daa 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -10,6 +10,7 @@ #include <assert.h> #include <stdio.h> #include <string.h> +#include <pwd.h> #include <string> #include <map> #include <iostream> @@ -118,6 +119,7 @@ public: std::shared_ptr<TiledRowColumnBar> m_pRowBar; std::shared_ptr<TiledRowColumnBar> m_pColumnBar; std::shared_ptr<TiledCornerButton> m_pCornerButton; + std::string m_aAuthor; TiledWindow() : m_pDocView(nullptr), @@ -148,6 +150,8 @@ public: m_pFindbarLabel(nullptr), m_bFindAll(false) { + struct passwd* pPasswd = getpwuid(getuid()); + m_aAuthor = std::string(pPasswd->pw_gecos); } }; @@ -800,7 +804,18 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) // notify about the finished Save gboolean bNotify = (rString == ".uno:Save"); - lok_doc_view_post_command(pLOKDocView, rString.c_str(), nullptr, bNotify); + 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); } } |