summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-05-20 11:55:44 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2017-05-31 12:09:15 +0200
commit42ecf7b5f62ed4faabdce80722d1d3f43ca4fb9a (patch)
tree74855f89b930472a9b747848c4a0cae8e7177412 /sd
parentb29363a2ec4509b79fca57842a529b4ce460516e (diff)
lok: impress: add support for undoing comment editing
Conflicts: sd/source/ui/annotations/annotationmanager.cxx Change-Id: I735dd68d658f007ddd44d6acf692ee9b4555eb53 Reviewed-on: https://gerrit.libreoffice.org/37816 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/Annotation.hxx2
-rw-r--r--sd/source/core/annotations/Annotation.cxx21
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx12
3 files changed, 30 insertions, 5 deletions
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx
index a4203575a732..d13496cbdcc9 100644
--- a/sd/inc/Annotation.hxx
+++ b/sd/inc/Annotation.hxx
@@ -39,6 +39,8 @@ void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotat
SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert );
+void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation);
+
sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>& xAnnotation);
const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation);
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index be6ecf1b44fe..50ff84fbba1c 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -102,11 +102,11 @@ public:
virtual void SAL_CALL setDateTime(const util::DateTime & the_value) override;
virtual Reference< XText > SAL_CALL getTextRange() override;
+ void createChangeUndo();
+
private:
// destructor is private and will be called indirectly by the release call virtual ~Annotation() {}
- void createChangeUndo();
-
// override WeakComponentImplHelperBase::disposing()
// This function is called upon disposing the component,
// if your component needs special work when it becomes
@@ -144,6 +144,7 @@ struct AnnotationData
OUString m_Author;
OUString m_Initials;
util::DateTime m_DateTime;
+ OUString m_Text;
void get( const rtl::Reference< Annotation >& xAnnotation )
{
@@ -152,6 +153,8 @@ struct AnnotationData
m_Author = xAnnotation->getAuthor();
m_Initials = xAnnotation->getInitials();
m_DateTime = xAnnotation->getDateTime();
+ Reference<XText> xText(xAnnotation->getTextRange());
+ m_Text = xText->getString();
}
void set( const rtl::Reference< Annotation >& xAnnotation )
@@ -161,6 +164,8 @@ struct AnnotationData
xAnnotation->setAuthor(m_Author);
xAnnotation->setInitials(m_Initials);
xAnnotation->setDateTime(m_DateTime);
+ Reference<XText> xText(xAnnotation->getTextRange());
+ xText->setString(m_Text);
}
};
@@ -381,6 +386,13 @@ SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation
}
}
+void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation)
+{
+ Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
+ if (pAnnotation)
+ pAnnotation->createChangeUndo();
+}
+
sal_uInt32 getAnnotationId(const Reference<XAnnotation>& xAnnotation)
{
Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
@@ -398,7 +410,6 @@ const SdPage* getAnnotationPage(const Reference<XAnnotation>& xAnnotation)
return nullptr;
}
-
namespace
{
std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, Reference<XAnnotation>& rxAnnotation)
@@ -526,12 +537,16 @@ void UndoAnnotation::Undo()
{
maRedoData.get( mxAnnotation );
maUndoData.set( mxAnnotation );
+ Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
+ LOKCommentNotifyAll( CommentNotificationType::Modify, xAnnotation );
}
void UndoAnnotation::Redo()
{
maUndoData.get( mxAnnotation );
maRedoData.set( mxAnnotation );
+ Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
+ LOKCommentNotifyAll( CommentNotificationType::Modify, xAnnotation );
}
} // namespace sd
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 6e61ee2dd5f7..854e6cf226a2 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -406,6 +406,9 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest& rReq)
OUString sText;
if (pArgs)
{
+ if (mpDoc->IsUndoEnabled())
+ mpDoc->BegUndo(SdResId(STR_ANNOTATION_UNDO_EDIT));
+
const SfxPoolItem* pPoolItem = nullptr;
if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_ID, true, &pPoolItem))
{
@@ -417,15 +420,20 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest& rReq)
if (xAnnotation.is() && !sText.isEmpty())
{
+ CreateChangeUndo(xAnnotation);
+
// TODO: Not allow other authors to change others' comments ?
Reference<XText> xText(xAnnotation->getTextRange());
xText->setString(sText);
LOKCommentNotifyAll(CommentNotificationType::Modify, xAnnotation);
}
- }
- UpdateTags(true);
+ if (mpDoc->IsUndoEnabled())
+ mpDoc->EndUndo();
+
+ UpdateTags(true);
+ }
}
void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)