sd/source/ui/annotations/annotationmanager.cxx | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
New commits: commit 3d10c608b05f648c5ff09f68a76b88090572b831 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 13:30:48 2017 +0530 sd lok: Implement comment callback notifications Change-Id: Ibd3d2467a4bbac520987fa71a6d14994f58dd055 Reviewed-on: https://gerrit.libreoffice.org/34460 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: pranavk <pran...@collabora.co.uk> diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 9101cc0..8d31885 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(); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits