[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sd/inc sd/source
Marco Cecchetti
marco.cecchetti at collabora.com
Wed May 31 09:59:20 UTC 2017
sd/inc/Annotation.hxx | 2 ++
sd/source/core/annotations/Annotation.cxx | 21 ++++++++++++++++++---
sd/source/ui/annotations/annotationmanager.cxx | 12 ++++++++++--
3 files changed, 30 insertions(+), 5 deletions(-)
New commits:
commit 4a69d02be64257aae8bbae12d856f192de85b863
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Sat May 20 11:55:44 2017 +0200
lok: impress: add support for undoing comment editing
Conflicts:
sd/source/ui/annotations/annotationmanager.cxx
Change-Id: I735dd68d658f007ddd44d6acf692ee9b4555eb53
Reviewed-on: https://gerrit.libreoffice.org/37822
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
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 1131683e4765..a87766d6f83f 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) throw (RuntimeException, std::exception) override;
virtual Reference< XText > SAL_CALL getTextRange() throw (RuntimeException, std::exception) 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 193d1472c262..79e07d76c6cd 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)
More information about the Libreoffice-commits
mailing list