diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2020-09-15 10:07:27 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-09-22 12:08:00 +0200 |
commit | 8727e36b4305fa6957bd74d8efc631a3a4b27a1a (patch) | |
tree | 9fe3525dd91347e1277441a80f465c4bffe8acbe /sw | |
parent | d5d58d3dc02267469375f06735a7d6f9a4d9f9e3 (diff) |
Added new command to delete the comment thread
Change-Id: I16d46787a6972afb0c3ab2e56482888082af1d27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102695
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/AnnotationWin.hxx | 1 | ||||
-rw-r--r-- | sw/inc/PostItMgr.hxx | 1 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/sdi/_annotsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 5 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 17 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationMenuButton.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin2.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/shells/annotsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 16 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/popupmenu/annotation.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/popupmenu/annotation.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/annotationmenu.ui | 8 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/notebookbar_groupedbar_full.ui | 7 |
18 files changed, 114 insertions, 1 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 4d920621405e..f76f1ccc33e7 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -194,6 +194,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window void SetResolved(bool resolved); void ToggleResolved(); void ToggleResolvedForThread(); + void DeleteThread(); bool IsResolved() const; bool IsThreadResolved(); diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 743e78503b47..ae79c7245b37 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -204,6 +204,7 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener void Delete(const OUString& aAuthor); void Delete(sal_uInt32 nPostItId); void Delete(); + void DeleteCommentThread(sal_uInt32 nPostItId); void ToggleResolved(sal_uInt32 nPostItId); void ToggleResolvedForThread(sal_uInt32 nPostItId); diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 105afabe2927..50e6560d25c8 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -741,6 +741,7 @@ #define FN_FORMAT_ALL_NOTES (FN_NOTES+8) #define FN_RESOLVE_NOTE (FN_NOTES+9) #define FN_RESOLVE_NOTE_THREAD (FN_NOTES+10) +#define FN_DELETE_COMMENT_THREAD (FN_NOTES+11) // Region: Parameter #define FN_PARAM_MOVE_COUNT (FN_PARAM+2) diff --git a/sw/sdi/_annotsh.sdi b/sw/sdi/_annotsh.sdi index fa1772a4c46e..6397720e63e5 100644 --- a/sw/sdi/_annotsh.sdi +++ b/sw/sdi/_annotsh.sdi @@ -24,6 +24,12 @@ interface _Annotation StateMethod = GetNoteState ; ] + FN_DELETE_COMMENT_THREAD + [ + ExecMethod = NoteExec ; + StateMethod = GetNoteState ; + ] + FN_DELETE_NOTE_AUTHOR [ ExecMethod = NoteExec ; diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index 76dd10f4b329..f2a77c5cd138 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -957,6 +957,11 @@ interface BaseText ExecMethod = ExecField ; StateMethod = StateField; ] + FN_DELETE_COMMENT_THREAD + [ + ExecMethod = ExecField ; + StateMethod = StateField; + ] FN_RESOLVE_NOTE [ ExecMethod = ExecField ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index f088f6356ec0..6a394660c04f 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7176,6 +7176,23 @@ SfxVoidItem DeleteComment FN_DELETE_COMMENT GroupId = SfxGroupId::Edit; ] +SfxVoidItem DeleteCommentThread FN_DELETE_COMMENT_THREAD +(SvxPostItIdItem Id SID_ATTR_POSTIT_ID) +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Edit; +] + SfxVoidItem ResolveComment FN_RESOLVE_NOTE (SvxPostItIdItem Id SID_ATTR_POSTIT_ID) [ diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx b/sw/source/uibase/docvw/AnnotationMenuButton.cxx index accf2e54e780..fcfba42eefe5 100644 --- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx +++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx @@ -77,6 +77,8 @@ void AnnotationMenuButton::Select() mrSidebarWin.ExecuteCommand(FN_RESOLVE_NOTE_THREAD); else if (sIdent == "delete") mrSidebarWin.ExecuteCommand(FN_DELETE_COMMENT); + else if (sIdent == "deletethread") + mrSidebarWin.ExecuteCommand(FN_DELETE_COMMENT_THREAD); else if (sIdent == "deleteby") mrSidebarWin.ExecuteCommand(FN_DELETE_NOTE_AUTHOR); else if (sIdent == "deleteall") @@ -96,6 +98,7 @@ void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt ) pButtonPopup->EnableItem(pButtonPopup->GetItemId("resolvethread"), false); pButtonPopup->EnableItem(pButtonPopup->GetItemId("unresolvethread"), false); pButtonPopup->EnableItem(pButtonPopup->GetItemId("delete"), false ); + pButtonPopup->EnableItem(pButtonPopup->GetItemId("deletethread"), false ); pButtonPopup->EnableItem(pButtonPopup->GetItemId("deleteby"), false ); pButtonPopup->EnableItem(pButtonPopup->GetItemId("deleteall"), false ); pButtonPopup->EnableItem(pButtonPopup->GetItemId("formatall"), false ); @@ -107,6 +110,7 @@ void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt ) pButtonPopup->EnableItem(pButtonPopup->GetItemId("resolvethread"), !mrSidebarWin.IsThreadResolved()); pButtonPopup->EnableItem(pButtonPopup->GetItemId("unresolvethread"), mrSidebarWin.IsThreadResolved()); pButtonPopup->EnableItem(pButtonPopup->GetItemId("delete"), !mrSidebarWin.IsProtected()); + pButtonPopup->EnableItem(pButtonPopup->GetItemId("deletethread")); pButtonPopup->EnableItem(pButtonPopup->GetItemId("deleteby")); pButtonPopup->EnableItem(pButtonPopup->GetItemId("deleteall")); pButtonPopup->EnableItem(pButtonPopup->GetItemId("formatall")); diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 2c9ee46f7127..ba08ea6d65b0 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -255,6 +255,22 @@ void SwAnnotationWin::ToggleResolvedForThread() mrMgr.LayoutPostIts(); } +void SwAnnotationWin::DeleteThread() +{ + // Go to the top and delete each comment one by one + SwAnnotationWin *current, *topNote; + current = topNote = GetTopReplyNote(); + SwAnnotationWin* next = mrMgr.GetNextPostIt(KEY_PAGEDOWN, current); + + while(next && next->GetTopReplyNote() == topNote) + { + current->mnEventId = Application::PostUserEvent( LINK( current, SwAnnotationWin, DeleteHdl), nullptr, true ); + current = next; + next = mrMgr.GetNextPostIt(KEY_PAGEDOWN, current); + } + current->mnEventId = Application::PostUserEvent( LINK( current, SwAnnotationWin, DeleteHdl), nullptr, true ); +} + bool SwAnnotationWin::IsResolved() const { return static_cast<SwPostItField*>(mpFormatField->GetField())->GetResolved(); diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 243cc6997c07..f0f92d9a7d9c 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1266,6 +1266,9 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot) //Delete(); // do not kill the parent of our open popup menu mnEventId = Application::PostUserEvent( LINK( this, SwAnnotationWin, DeleteHdl), nullptr, true ); break; + case FN_DELETE_COMMENT_THREAD: + DeleteThread(); + break; case FN_RESOLVE_NOTE: ToggleResolved(); DoResize(); diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 3f0e6f530469..3e4901d7449a 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1570,6 +1570,30 @@ void SwPostItMgr::Delete(sal_uInt32 nPostItId) LayoutPostIts(); } +void SwPostItMgr::DeleteCommentThread(sal_uInt32 nPostItId) +{ + mpWrtShell->StartAllAction(); + + SwRewriter aRewriter; + aRewriter.AddRule(UndoArg1, SwResId(STR_CONTENT_TYPE_SINGLE_POSTIT)); + + // We have no undo ID at the moment. + + IsPostitFieldWithPostitId aFilter(nPostItId); + FieldDocWatchingStack aStack(mvPostItFields, *mpView->GetDocShell(), aFilter); + const SwFormatField* pField = aStack.pop(); + // pField now contains our AnnotationWin object + if (pField) { + SwAnnotationWin* pWin = GetSidebarWin(pField); + pWin->DeleteThread(); + } + PrepareView(); + mpWrtShell->EndAllAction(); + mbLayout = true; + CalcRects(); + LayoutPostIts(); +} + void SwPostItMgr::ToggleResolved(sal_uInt32 nPostItId) { mpWrtShell->StartAllAction(); diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 5582f669547d..4ad16692e624 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -1112,6 +1112,7 @@ void SwAnnotationShell::NoteExec(SfxRequest const &rReq) case FN_REPLY: case FN_POSTIT: case FN_DELETE_COMMENT: + case FN_DELETE_COMMENT_THREAD: case FN_RESOLVE_NOTE: case FN_RESOLVE_NOTE_THREAD: if ( pPostItMgr->HasActiveSidebarWin() ) @@ -1164,6 +1165,7 @@ void SwAnnotationShell::GetNoteState(SfxItemSet &rSet) case FN_HIDE_NOTE: case FN_HIDE_ALL_NOTES: case FN_DELETE_COMMENT: + case FN_DELETE_COMMENT_THREAD: { if( !pPostItMgr || !pPostItMgr->HasActiveAnnotationWin() ) diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 8be81830cf09..7123c8825f49 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -345,8 +345,22 @@ void SwTextShell::ExecField(SfxRequest &rReq) { GetView().GetPostItMgr()->DeleteActiveSidebarWin(); } + break; + } + case FN_DELETE_COMMENT_THREAD: + { + const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); + if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr()) + { + GetView().GetPostItMgr()->DeleteCommentThread(pIdItem->GetValue().toUInt32()); + } + else if ( GetView().GetPostItMgr() && + GetView().GetPostItMgr()->HasActiveSidebarWin() ) + { + GetView().GetPostItMgr()->DeleteActiveSidebarWin(); + } + break; } - break; case FN_RESOLVE_NOTE: { const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml index 993d5cbd0479..fcd660e9ad51 100644 --- a/sw/uiconfig/sglobal/menubar/menubar.xml +++ b/sw/uiconfig/sglobal/menubar/menubar.xml @@ -147,6 +147,7 @@ <menu:menuitem menu:id=".uno:ResolveComment" menu:style="text"/> <menu:menuitem menu:id=".uno:ResolveCommentThread" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteComment" menu:style="text"/> + <menu:menuitem menu:id=".uno:DeleteCommentThread" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteAuthor" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteAllNotes" menu:style="text"/> </menu:menupopup> diff --git a/sw/uiconfig/sglobal/popupmenu/annotation.xml b/sw/uiconfig/sglobal/popupmenu/annotation.xml index 1805d2d62f7c..42c89cd7c8bc 100644 --- a/sw/uiconfig/sglobal/popupmenu/annotation.xml +++ b/sw/uiconfig/sglobal/popupmenu/annotation.xml @@ -23,6 +23,7 @@ <menu:menuitem menu:id=".uno:ResolveCommentThread"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:DeleteComment"/> + <menu:menuitem menu:id=".uno:DeleteCommentThread"/> <menu:menuitem menu:id=".uno:DeleteAuthor"/> <menu:menuitem menu:id=".uno:DeleteAllNotes"/> <menu:menuitem menu:id=".uno:FormatAllNotes"/> diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index f2bde8f51e67..dc0aac9e3f19 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -152,6 +152,7 @@ <menu:menuitem menu:id=".uno:ResolveComment" menu:style="text"/> <menu:menuitem menu:id=".uno:ResolveCommentThread" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteComment" menu:style="text"/> + <menu:menuitem menu:id=".uno:DeleteCommentThread" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteAuthor" menu:style="text"/> <menu:menuitem menu:id=".uno:DeleteAllNotes" menu:style="text"/> </menu:menupopup> diff --git a/sw/uiconfig/swriter/popupmenu/annotation.xml b/sw/uiconfig/swriter/popupmenu/annotation.xml index 87a294bc50c0..acdc6551ea97 100644 --- a/sw/uiconfig/swriter/popupmenu/annotation.xml +++ b/sw/uiconfig/swriter/popupmenu/annotation.xml @@ -23,6 +23,7 @@ <menu:menuitem menu:id=".uno:ResolveComment"/> <menu:menuitem menu:id=".uno:ResolveCommentThread"/> <menu:menuitem menu:id=".uno:DeleteComment"/> + <menu:menuitem menu:id=".uno:DeleteCommentThread"/> <menu:menuitem menu:id=".uno:DeleteAuthor"/> <menu:menuitem menu:id=".uno:DeleteAllNotes"/> <menu:menuitem menu:id=".uno:FormatAllNotes"/> diff --git a/sw/uiconfig/swriter/ui/annotationmenu.ui b/sw/uiconfig/swriter/ui/annotationmenu.ui index 7e669fc13f4b..b4b719a59398 100644 --- a/sw/uiconfig/swriter/ui/annotationmenu.ui +++ b/sw/uiconfig/swriter/ui/annotationmenu.ui @@ -60,6 +60,14 @@ </object> </child> <child> + <object class="GtkMenuItem" id="deletethread"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="annotationmenu|deletethread">Delete _Comment Thread</property> + <property name="use_underline">True</property> + </object> + </child> + <child> <object class="GtkMenuItem" id="deleteby"> <property name="visible">True</property> <property name="can_focus">False</property> diff --git a/sw/uiconfig/swriter/ui/notebookbar_groupedbar_full.ui b/sw/uiconfig/swriter/ui/notebookbar_groupedbar_full.ui index bf6c61250d69..3ac48a87082c 100644 --- a/sw/uiconfig/swriter/ui/notebookbar_groupedbar_full.ui +++ b/sw/uiconfig/swriter/ui/notebookbar_groupedbar_full.ui @@ -323,6 +323,13 @@ </object> </child> <child> + <object class="GtkMenuItem" id="MenuComments-DeleteCommentThread"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="action_name">.uno:DeleteCommentThread</property> + </object> + </child> + <child> <object class="GtkMenuItem" id="MenuComments-ResolveComment"> <property name="visible">True</property> <property name="can_focus">False</property> |