[Libreoffice-commits] core.git: sw/inc sw/sdi sw/source

Pranav Kant pranavk at collabora.co.uk
Fri Jan 27 13:02:15 UTC 2017


 sw/inc/PostItMgr.hxx                 |    1 
 sw/sdi/swriter.sdi                   |    2 -
 sw/source/uibase/docvw/PostItMgr.cxx |   42 +++++++++++++++++++++++++++++++++++
 sw/source/uibase/shells/textfld.cxx  |   11 +++++++--
 4 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit d83deb9d50b0cacdec7aa1d6e264de398898806e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Jan 23 17:49:49 2017 +0530

    lok: Allow to delete comment by post it id
    
    Change-Id: I61971dfe3a2630ba33c029ce7865bd7077e235cc
    Reviewed-on: https://gerrit.libreoffice.org/33613
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index f27c1e4..b15e23d 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 9f10c6d..135af78 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 209a9d9..450f14c1f 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 b5e2c46..8ee0ad9 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() )


More information about the Libreoffice-commits mailing list