summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-01-23 17:49:49 +0530
committerpranavk <pranavk@collabora.co.uk>2017-01-27 13:01:33 +0000
commitd83deb9d50b0cacdec7aa1d6e264de398898806e (patch)
treea8c874b50fc60980920f44391625ff5eb4b2db1d
parent6e463381b43d888a632e652a873f2b5abe7e5458 (diff)
lok: Allow to delete comment by post it id
Change-Id: I61971dfe3a2630ba33c029ce7865bd7077e235cc Reviewed-on: https://gerrit.libreoffice.org/33613 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
-rw-r--r--sw/inc/PostItMgr.hxx1
-rw-r--r--sw/sdi/swriter.sdi2
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx42
-rw-r--r--sw/source/uibase/shells/textfld.cxx11
4 files changed, 53 insertions, 3 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index f27c1e4b1d7b..b15e23dcae6e 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -218,6 +218,7 @@ class SwPostItMgr: public SfxListener
void SetLayout() { mbLayout = true; };
void Delete(const OUString& aAuthor);
+ void Delete(sal_uInt32 nPostItId);
void Delete();
void ExecuteFormatAllDialog(SwView& rView);
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 9f10c6d6a6e6..135af78fe402 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7080,7 +7080,7 @@ SfxVoidItem ReplyComment FN_REPLY
]
SfxVoidItem DeleteComment FN_DELETE_COMMENT
-()
+(SvxPostItIdItem Id SID_ATTR_POSTIT_ID)
[
AutoUpdate = FALSE,
FastCall = FALSE,
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 209a9d940614..450f14c1f9ff 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -59,6 +59,7 @@
#include <swmodule.hxx>
#include <annotation.hrc>
+#include <utlui.hrc>
#include "cmdid.h"
#include <sfx2/request.hxx>
@@ -1350,6 +1351,22 @@ public:
}
};
+class IsPostitFieldWithPostitId : public FilterFunctor
+{
+ sal_uInt32 m_nPostItId;
+public:
+ explicit IsPostitFieldWithPostitId(sal_uInt32 nPostItId)
+ : m_nPostItId(nPostItId)
+ {}
+
+ bool operator()(const SwFormatField* pField) const override
+ {
+ if (pField->GetField()->GetTyp()->Which() != RES_POSTITFLD)
+ return false;
+ return static_cast<const SwPostItField*>(pField->GetField())->GetPostItId() == m_nPostItId;
+ }
+};
+
//Manages the passed in vector by automatically removing entries if they are deleted
//and automatically adding entries if they appear in the document and match the
@@ -1476,6 +1493,31 @@ void SwPostItMgr::Delete(const OUString& rAuthor)
LayoutPostIts();
}
+void SwPostItMgr::Delete(sal_uInt32 nPostItId)
+{
+ mpWrtShell->StartAllAction();
+ if (HasActiveSidebarWin() &&
+ static_cast<sw::annotation::SwAnnotationWin*>(mpActivePostIt.get())->GetPostItField()->GetPostItId() == nPostItId)
+ {
+ SetActiveSidebarWin(nullptr);
+ }
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_CONTENT_TYPE_SINGLE_POSTIT));
+ mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
+
+ IsPostitFieldWithPostitId aFilter(nPostItId);
+ FieldDocWatchingStack aStack(mvPostItFields, *mpView->GetDocShell(), aFilter);
+ const SwFormatField* pField = aStack.pop();
+ if (mpWrtShell->GotoField(*pField))
+ mpWrtShell->DelRight();
+ mpWrtShell->EndUndo();
+ PrepareView();
+ mpWrtShell->EndAllAction();
+ mbLayout = true;
+ CalcRects();
+ LayoutPostIts();
+}
+
void SwPostItMgr::Delete()
{
mpWrtShell->StartAllAction();
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index b5e2c465c281..8ee0ad910d57 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -328,11 +328,18 @@ void SwTextShell::ExecField(SfxRequest &rReq)
}
break;
case FN_DELETE_COMMENT:
- if ( GetView().GetPostItMgr() &&
- GetView().GetPostItMgr()->HasActiveSidebarWin() )
+ {
+ const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
+ if (pIdItem && pIdItem->GetValue() && GetView().GetPostItMgr())
+ {
+ GetView().GetPostItMgr()->Delete(pIdItem->GetValue());
+ }
+ else if ( GetView().GetPostItMgr() &&
+ GetView().GetPostItMgr()->HasActiveSidebarWin() )
{
GetView().GetPostItMgr()->DeleteActiveSidebarWin();
}
+ }
break;
case FN_DELETE_ALL_NOTES:
if ( GetView().GetPostItMgr() )