summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-02-20 13:30:48 +0530
committerpranavk <pranavk@collabora.co.uk>2017-02-20 09:38:15 +0000
commit3d10c608b05f648c5ff09f68a76b88090572b831 (patch)
treeddc3b64031a7672a7b9a3c646f8b5a81071c7057 /sd
parent357fae01a15b88a53873278cccb1040b4d46bdba (diff)
sd lok: Implement comment callback notifications
Change-Id: Ibd3d2467a4bbac520987fa71a6d14994f58dd055 Reviewed-on: https://gerrit.libreoffice.org/34460 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 9101cc047030..8d318854ed31 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -19,6 +19,8 @@
#include "sddll.hxx"
+#include <boost/property_tree/json_parser.hpp>
+
#include <com/sun/star/beans/XMultiPropertyStates.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
@@ -37,6 +39,7 @@
#include <sal/macros.h>
#include <svl/style.hxx>
#include <svl/itempool.hxx>
+#include <unotools/datetime.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/syslocale.hxx>
#include <unotools/saveopt.hxx>
@@ -61,6 +64,8 @@
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
#include <svx/postattr.hxx>
#include <svx/svdetc.hxx>
@@ -102,6 +107,39 @@ using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::office;
+namespace {
+
+ void lcl_CommentNotification(const OUString& rEventName, const sd::ViewShellBase& rViewShell, Reference<XAnnotation>& rxAnnotation)
+ {
+ // callbacks only if tiled annotations are explicltly turned off by LOK client
+ if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
+ return;
+
+ boost::property_tree::ptree aAnnotation;
+ aAnnotation.put("action", (rEventName == "OnAnnotationInserted" ? "Add" :
+ (rEventName == "OnAnnotationRemoved" ? "Remove" :
+ (rEventName == "OnAnnotationChanged" ? "Modify" : "???"))));
+ aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
+ if (rEventName != "OnAnnotationRemoved")
+ {
+ aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
+ aAnnotation.put("author", rxAnnotation->getAuthor());
+ aAnnotation.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime()));
+ uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
+ aAnnotation.put("text", xText->getString());
+ }
+
+ boost::property_tree::ptree aTree;
+ aTree.add_child("comment", aAnnotation);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ std::string aPayload = aStream.str();
+
+ rViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
+ }
+
+} // anonymous ns
+
namespace sd {
SfxItemPool* GetAnnotationPool()
@@ -238,6 +276,12 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje
{
if( aEvent.EventName == "OnAnnotationInserted" || aEvent.EventName == "OnAnnotationRemoved" || aEvent.EventName == "OnAnnotationChanged" )
{
+ Reference<XAnnotation> xAnnotation(aEvent.Source, uno::UNO_QUERY);
+ if (xAnnotation.is())
+ {
+ // Inform our LOK clients
+ lcl_CommentNotification(aEvent.EventName, mrBase, xAnnotation);
+ }
UpdateTags();
}
}