summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-05-19 13:01:25 +0200
committerJan Holesovsky <kendy@collabora.com>2017-05-31 11:55:29 +0200
commit963f71edc20823753694bc69121e9ada8fc9f84e (patch)
tree5a96b42499ad8fffa12fb3961ced24f350302a0e /sd
parentb62e46909905607d81884cca9b1992810dc61fed (diff)
lok: impress: undoing comment deletion doesn't work
Conflicts: sd/source/ui/annotations/annotationmanager.cxx Change-Id: I3399ea4131acde42bdd307a8438a9129a83817f2 Reviewed-on: https://gerrit.libreoffice.org/37821 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/Annotation.hxx9
-rw-r--r--sd/source/core/annotations/Annotation.cxx69
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx62
3 files changed, 82 insertions, 58 deletions
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx
index 27f1d51c969d..a4203575a732 100644
--- a/sd/inc/Annotation.hxx
+++ b/sd/inc/Annotation.hxx
@@ -29,8 +29,12 @@ namespace com { namespace sun { namespace star { namespace office {
class XAnnotation;
} } } }
+class SfxViewShell;
+
namespace sd {
+enum class CommentNotificationType { Add, Modify, Remove };
+
void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation, SdPage* pPage );
SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert );
@@ -39,6 +43,11 @@ sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>&
const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation);
+void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell,
+ css::uno::Reference<css::office::XAnnotation>& rxAnnotation);
+
+void LOKCommentNotifyAll(CommentNotificationType nType,
+ css::uno::Reference<css::office::XAnnotation>& rxAnnotation);
}
#endif
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index d82ba73b863b..1131683e4765 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -21,15 +21,26 @@
#include "osl/time.h"
+#include <boost/property_tree/json_parser.hpp>
+
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/office/XAnnotation.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/lok.hxx>
+#include <comphelper/string.hxx>
#include <cppuhelper/propertysetmixin.hxx>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
+#include <unotools/datetime.hxx>
+#include <tools/datetime.hxx>
+
+#include <sfx2/viewsh.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
#include "Annotation.hxx"
#include "drawdoc.hxx"
#include "notifydocumentevent.hxx"
@@ -387,6 +398,62 @@ const SdPage* getAnnotationPage(const Reference<XAnnotation>& xAnnotation)
return nullptr;
}
+
+namespace
+{
+std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, Reference<XAnnotation>& rxAnnotation)
+{
+ boost::property_tree::ptree aAnnotation;
+ aAnnotation.put("action", (nType == CommentNotificationType::Add ? "Add" :
+ (nType == CommentNotificationType::Remove ? "Remove" :
+ (nType == CommentNotificationType::Modify ? "Modify" : "???"))));
+ aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
+ if (nType != CommentNotificationType::Remove && rxAnnotation.is())
+ {
+ 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());
+ const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
+ aAnnotation.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
+ }
+
+ boost::property_tree::ptree aTree;
+ aTree.add_child("comment", aAnnotation);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+
+ return aStream.str();
+}
+} // unonymous ns
+
+void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell, Reference<XAnnotation>& rxAnnotation)
+{
+ // callbacks only if tiled annotations are explicitly turned off by LOK client
+ if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
+ return ;
+
+ std::string aPayload = lcl_LOKGetCommentPayload(nType, rxAnnotation);
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
+}
+
+void LOKCommentNotifyAll(CommentNotificationType nType, Reference<XAnnotation>& rxAnnotation)
+{
+ // callbacks only if tiled annotations are explicitly turned off by LOK client
+ if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
+ return ;
+
+ std::string aPayload = lcl_LOKGetCommentPayload(nType, rxAnnotation);
+
+ const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+}
+
UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert )
: SdrUndoAction( *rAnnotation.GetModel() )
, mxAnnotation( &rAnnotation )
@@ -423,6 +490,7 @@ void UndoInsertOrRemoveAnnotation::Undo()
else
{
pPage->addAnnotation( xAnnotation, mnIndex );
+ LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
}
}
}
@@ -438,6 +506,7 @@ void UndoInsertOrRemoveAnnotation::Redo()
if( mbInsert )
{
pPage->addAnnotation( xAnnotation, mnIndex );
+ LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
}
else
{
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index d9847a1dd9cd..193d1472c262 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -64,8 +64,6 @@
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
-#include <LibreOfficeKit/LibreOfficeKitEnums.h>
-
#include <svx/postattr.hxx>
#include <svx/svdetc.hxx>
@@ -107,43 +105,6 @@ using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::office;
-namespace {
-
- enum class CommentNotificationType { Add, Modify, Remove };
-
- void lcl_CommentNotification(CommentNotificationType nType, const SfxViewShell* pViewShell, 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", (nType == CommentNotificationType::Add ? "Add" :
- (nType == CommentNotificationType::Remove ? "Remove" :
- (nType == CommentNotificationType::Modify ? "Modify" : "???"))));
- aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
- if (nType != CommentNotificationType::Remove && rxAnnotation.is())
- {
- 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());
- const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
- aAnnotation.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
- }
-
- 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();
-
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
- }
-
-} // anonymous ns
-
namespace sd {
SfxItemPool* GetAnnotationPool()
@@ -291,7 +252,7 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje
Reference< XAnnotation > xAnnotation( aEvent.Source, uno::UNO_QUERY );
if ( xAnnotation.is() )
{
- lcl_CommentNotification(CommentNotificationType::Remove, &mrBase, xAnnotation);
+ LOKCommentNotify(CommentNotificationType::Remove, &mrBase, xAnnotation);
}
}
@@ -460,12 +421,7 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest& rReq)
Reference<XText> xText(xAnnotation->getTextRange());
xText->setString(sText);
- const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- lcl_CommentNotification(CommentNotificationType::Modify, pViewShell, xAnnotation);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ LOKCommentNotifyAll(CommentNotificationType::Modify, xAnnotation);
}
}
@@ -559,12 +515,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
mpDoc->EndUndo();
// Tell our LOK clients about new comment added
- const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- lcl_CommentNotification(CommentNotificationType::Add, pViewShell, xAnnotation);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ LOKCommentNotifyAll(CommentNotificationType::Add, xAnnotation);
UpdateTags(true);
SelectAnnotation( xAnnotation, true );
@@ -652,12 +603,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq )
xAnnotation->setDateTime( getCurrentDateTime() );
// Tell our LOK clients about this (comment modification)
- const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- lcl_CommentNotification(CommentNotificationType::Modify, pViewShell, xAnnotation);
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
+ LOKCommentNotifyAll(CommentNotificationType::Modify, xAnnotation);
UpdateTags(true);
SelectAnnotation( xAnnotation, true );