sw/source/uibase/docvw/AnnotationWin.cxx  |   19 +++++++++++++++++--
 sw/source/uibase/docvw/AnnotationWin2.cxx |   13 ++++++-------
 sw/source/uibase/docvw/PostItMgr.cxx      |   27 ++++++++++++++++++++++++++-
 sw/source/uibase/shells/textfld.cxx       |    4 ++--
 4 files changed, 51 insertions(+), 12 deletions(-)

New commits:
commit bc582eef43ad425b89cf4fad579177afe1405224
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Sun Sep 13 19:29:39 2020 +0530
Commit:     Pranam Lashkari <lpra...@collabora.com>
CommitDate: Tue Sep 22 15:09:44 2020 +0200

    changed FN_RESOLVE_NOTE behaviour to resolve single note
    
    Earlier it used to resolve the entire thread
    and there was no way to resolve a single comment in thread
    
    Change-Id: I471c5b575dd365d52653835be5b0d40009bb5cfa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102581
    Tested-by: Jenkins
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>

diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index 926085b31e84..cc29dff12090 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -284,8 +284,23 @@ bool SwAnnotationWin::IsResolved() const
 
 bool SwAnnotationWin::IsThreadResolved()
 {
-    // Not const because GetTopReplyNote isn't.
-    return GetTopReplyNote()->IsResolved();
+    /// First Get the top note
+    // then itereate downwards checking resolved status
+    SwAnnotationWin *pTopNote, *TopNote;
+    pTopNote = TopNote = GetTopReplyNote();
+    if (!pTopNote->IsResolved())
+        return false;
+
+    SwAnnotationWin* pSidebarWin = mrMgr.GetNextPostIt(KEY_PAGEDOWN, pTopNote);
+
+    while (pSidebarWin && pSidebarWin->GetTopReplyNote() == TopNote)
+    {
+        pTopNote = pSidebarWin;
+        if (!pTopNote->IsResolved())
+            return false;
+        pSidebarWin = mrMgr.GetNextPostIt(KEY_PAGEDOWN, pSidebarWin);
+    }
+    return true;
 }
 
 void SwAnnotationWin::UpdateData()
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index d9ec987b58b9..fc0289e5bf5f 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -178,7 +178,7 @@ void SwAnnotationWin::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rec
     }
 
     sal_uInt32 boxHeight = mpMetadataAuthor->GetSizePixel().Height() + 
mpMetadataDate->GetSizePixel().Height();
-    boxHeight += IsThreadResolved() ? 
mpMetadataResolved->GetSizePixel().Height() : 0;
+    boxHeight += IsResolved() ? mpMetadataResolved->GetSizePixel().Height() : 
0;
 
     rRenderContext.SetLineColor();
     tools::Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + 
mpMetadataAuthor->GetSizePixel().Width(),
@@ -573,7 +573,7 @@ void SwAnnotationWin::InitControls()
     mpSidebarTextControl->Show();
     mpMetadataAuthor->Show();
     mpMetadataDate->Show();
-    if(IsThreadResolved()) { mpMetadataResolved->Show(); }
+    if(IsResolved()) { mpMetadataResolved->Show(); }
     mpVScrollbar->Show();
 }
 
@@ -895,7 +895,7 @@ void SwAnnotationWin::DoResize()
 
     aHeight -= GetMetaHeight();
     mpMetadataAuthor->Show();
-    if(IsThreadResolved()) { mpMetadataResolved->Show(); }
+    if(IsResolved()) { mpMetadataResolved->Show(); }
     mpMetadataDate->Show();
     mpSidebarTextControl->SetQuickHelpText(OUString());
     unsigned int numFields = GetNumFields();
@@ -920,7 +920,7 @@ void SwAnnotationWin::DoResize()
                                          aHeight + 
aSizeOfMetadataControls.Height(),
                                          aSizeOfMetadataControls.Width(),
                                          aSizeOfMetadataControls.Height() );
-        if(IsThreadResolved()) {
+        if(IsResolved()) {
             mpMetadataResolved->setPosSizePixel( 0,
                                                  aHeight + 
aSizeOfMetadataControls.Height()*2,
                                                  
aSizeOfMetadataControls.Width(),
@@ -1259,8 +1259,7 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
             mnEventId = Application::PostUserEvent( LINK( this, 
SwAnnotationWin, DeleteHdl), nullptr, true );
             break;
         case FN_RESOLVE_NOTE:
-            GetTopReplyNote()->ToggleResolved();
-            mrMgr.UpdateResolvedStatus(GetTopReplyNote());
+            ToggleResolved();
             DoResize();
             Invalidate();
             mrMgr.LayoutPostIts();
@@ -1391,7 +1390,7 @@ sal_Int32 SwAnnotationWin::GetMetaHeight()
 
 sal_Int32 SwAnnotationWin::GetNumFields()
 {
-    return IsThreadResolved() ? 3 : 2;
+    return IsResolved() ? 3 : 2;
 }
 
 sal_Int32 SwAnnotationWin::GetMinimumSizeWithMeta() const
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index a6e3c3956ab1..6df734b2ec2d 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -1551,6 +1551,31 @@ void SwPostItMgr::Delete(sal_uInt32 nPostItId)
     LayoutPostIts();
 }
 
+void SwPostItMgr::ToggleResolved(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->ToggleResolved();
+    }
+
+    PrepareView();
+    mpWrtShell->EndAllAction();
+    mbLayout = true;
+    CalcRects();
+    LayoutPostIts();
+}
+
 void SwPostItMgr::ToggleResolvedForThread(sal_uInt32 nPostItId)
 {
     mpWrtShell->StartAllAction();
@@ -2424,7 +2449,7 @@ void SwPostItMgr::ShowHideResolvedNotes(bool visible) {
     {
         for(auto b = pPage->mvSidebarItems.begin(); b!= 
pPage->mvSidebarItems.end(); ++b)
         {
-            if ((*b)->pPostIt->IsThreadResolved())
+            if ((*b)->pPostIt->IsResolved())
             {
                 (*b)->pPostIt->SetResolved(true);
                 (*b)->pPostIt->GetSidebarItem().bShow = visible;
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index f08c01f2c5fc..851e9bd34782 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -332,10 +332,10 @@ void SwTextShell::ExecField(SfxRequest &rReq)
             const SvxPostItIdItem* pIdItem = 
rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID);
             if (pIdItem && !pIdItem->GetValue().isEmpty() && 
GetView().GetPostItMgr())
             {
-                
GetView().GetPostItMgr()->ToggleResolvedForThread(pIdItem->GetValue().toUInt32());
+                
GetView().GetPostItMgr()->ToggleResolved(pIdItem->GetValue().toUInt32());
             }
+            break;
         }
-        break;
         case FN_DELETE_ALL_NOTES:
             if ( GetView().GetPostItMgr() )
                 GetView().GetPostItMgr()->Delete();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to