[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sw/inc sw/source

Scott Clarke (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 27 15:14:24 UTC 2019


 sw/inc/AnnotationWin.hxx                  |   15 ++++++++++
 sw/inc/PostItMgr.hxx                      |    3 ++
 sw/source/uibase/docvw/AnnotationWin.cxx  |   37 +++++++++++++++++++++++++-
 sw/source/uibase/docvw/AnnotationWin2.cxx |    7 ++---
 sw/source/uibase/docvw/PostItMgr.cxx      |   42 ++++++++++++++++++++++++++++++
 5 files changed, 99 insertions(+), 5 deletions(-)

New commits:
commit 8a3b994f4dc6b1679bff300865fe637fb4df8a04
Author:     Scott Clarke <scott.clarke at codethink.co.uk>
AuthorDate: Wed Jun 19 17:12:22 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Aug 27 17:12:39 2019 +0200

    tdf#119228 Add accessors for resolved state
    
    Co-authored-by: Jim MacArthur <jim.macarthur at codethink.co.uk>
    (cherry picked from commit f4f5e3f98aee5d9d1679edab8248a4cfd12f74ce)
    
    Change-Id: Ic4051f4e7fda11eade1e50ce70bed11f70f0742d
    Reviewed-on: https://gerrit.libreoffice.org/78182
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 7402eaf58d3c..5682a846d486 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -189,6 +189,17 @@ class SwAnnotationWin : public vcl::Window
         /// Allows adjusting the point or mark of the selection to a document coordinate.
         void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
 
+        // Various access functions for 'resolved' status
+        void SetResolved(bool resolved);
+        void ToggleResolved();
+        void ToggleResolvedForThread();
+        bool IsResolved() const;
+        bool IsThreadResolved();
+
+        /// Find the first annotation for the thread which this annotation is in.
+        /// This may be the same annotation as this one.
+        SwAnnotationWin*   GetTopReplyNote();
+
     private:
         VclPtr<MenuButton> CreateMenuButton();
         virtual void    LoseFocus() override;
@@ -204,10 +215,6 @@ class SwAnnotationWin : public vcl::Window
 
         sal_uInt32 CountFollowing();
 
-        /// Find the first annotation for the thread which this annotation is in.
-        /// This may be the same annotation as this one.
-        SwAnnotationWin*   GetTopReplyNote();
-
         SvxLanguageItem GetLanguage();
 
         VclBuilder      maBuilder;
@@ -241,6 +248,8 @@ class SwAnnotationWin : public vcl::Window
         long            mPageBorder;
         bool            mbAnchorRectChanged;
 
+        bool            mbResolvedStateUpdated;
+
         std::vector<basegfx::B2DRange> maAnnotationTextRanges;
 
         bool            mbMouseOver;
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 9650996c50f3..4a241dfcbb8a 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -204,6 +204,8 @@ class SwPostItMgr: public SfxListener
         void Delete(const OUString& aAuthor);
         void Delete(sal_uInt32 nPostItId);
         void Delete();
+        void ToggleResolved(sal_uInt32 nPostItId);
+        void ToggleResolvedForThread(sal_uInt32 nPostItId);
 
         void ExecuteFormatAllDialog(SwView& rView);
         void FormatAll(const SfxItemSet &rNewAttr);
@@ -211,6 +213,7 @@ class SwPostItMgr: public SfxListener
         void Hide( const OUString& rAuthor );
         void Hide();
         void Show();
+        void UpdateResolvedStatus(sw::annotation::SwAnnotationWin* topNote);
 
         void Rescale();
 
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index cc034f072e1c..9516d011ea99 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -84,6 +84,7 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
     , mAnchorRect()
     , mPageBorder(0)
     , mbAnchorRectChanged(false)
+    , mbResolvedStateUpdated(false)
     , mbMouseOver(false)
     , mLayoutStatus(SwPostItHelper::INVISIBLE)
     , mbReadonly(false)
@@ -210,9 +211,42 @@ void SwAnnotationWin::SetPostItText()
     Invalidate();
 }
 
+void SwAnnotationWin::SetResolved(bool resolved)
+{
+    static_cast<SwPostItField*>(mpFormatField->GetField())->SetResolved(resolved);
+    mrSidebarItem.bShow = !IsResolved();
+
+    mbResolvedStateUpdated = true;
+    UpdateData();
+    Invalidate();
+}
+
+void SwAnnotationWin::ToggleResolved()
+{
+    SetResolved(!IsResolved());
+}
+
+void SwAnnotationWin::ToggleResolvedForThread()
+{
+    GetTopReplyNote()->ToggleResolved();
+    mrMgr.UpdateResolvedStatus(GetTopReplyNote());
+    mrMgr.LayoutPostIts();
+}
+
+bool SwAnnotationWin::IsResolved() const
+{
+    return static_cast<SwPostItField*>(mpFormatField->GetField())->GetResolved();
+}
+
+bool SwAnnotationWin::IsThreadResolved()
+{
+    // Not const because GetTopReplyNote isn't.
+    return GetTopReplyNote()->IsResolved();
+}
+
 void SwAnnotationWin::UpdateData()
 {
-    if ( mpOutliner->IsModified() )
+    if ( mpOutliner->IsModified() || mbResolvedStateUpdated)
     {
         IDocumentUndoRedo & rUndoRedo(
             mrView.GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
@@ -239,6 +273,7 @@ void SwAnnotationWin::UpdateData()
     }
     mpOutliner->ClearModifyFlag();
     mpOutliner->GetUndoManager().Clear();
+    mbResolvedStateUpdated = false;
 }
 
 void SwAnnotationWin::Delete()
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 5af53cdcdd44..a3015ddfcae8 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -1578,6 +1578,32 @@ void SwPostItMgr::Delete(sal_uInt32 nPostItId)
     LayoutPostIts();
 }
 
+void SwPostItMgr::ToggleResolvedForThread(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->ToggleResolvedForThread();
+    }
+
+    PrepareView();
+    mpWrtShell->EndAllAction();
+    mbLayout = true;
+    CalcRects();
+    LayoutPostIts();
+}
+
+
 void SwPostItMgr::Delete()
 {
     mpWrtShell->StartAllAction();
@@ -2420,6 +2446,22 @@ void SwPostItMgr::GetAllSidebarWinForFrame( const SwFrame& rFrame,
     }
 }
 
+void SwPostItMgr::UpdateResolvedStatus(sw::annotation::SwAnnotationWin* topNote) {
+    // Given the topmost note as an argument, scans over all notes and sets the
+    // 'resolved' state of each descendant of the top notes to the resolved state
+    // of the top note.
+    bool resolved = topNote->IsResolved();
+    for (auto const& pPage : mPages)
+    {
+        for(auto b = pPage->mvSidebarItems.begin(); b!= pPage->mvSidebarItems.end(); ++b)
+        {
+            if((*b)->pPostIt->GetTopReplyNote() == topNote) {
+               (*b)->pPostIt->SetResolved(resolved);
+            }
+        }
+    }
+}
+
 void SwNoteProps::ImplCommit() {}
 void SwNoteProps::Notify( const css::uno::Sequence< OUString >& ) {}
 
commit 05579a9a02493db4bb2cf01610d5453a00c28edd
Author:     Jim MacArthur <jim-github at mode7.co.uk>
AuthorDate: Sun Jul 7 11:10:30 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Aug 27 17:12:17 2019 +0200

    AnnotationWin: Restore lines from annotations to comment anchor
    
    This changes all the uses of GetTopReplyNote, which were using
    nullptr to indicate the top reply.
    
    (cherry picked from commit 03263d6fffb711f4cf3527c77949253c97ff40fb)
    
    Change-Id: Ibb9b5fac5644a5d6d283e8ea2fa80b988ca0693e
    Reviewed-on: https://gerrit.libreoffice.org/78181
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 5295c93f641e..7402eaf58d3c 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -203,7 +203,11 @@ class SwAnnotationWin : public vcl::Window
         DECL_LINK(DeleteHdl, void*, void);
 
         sal_uInt32 CountFollowing();
+
+        /// Find the first annotation for the thread which this annotation is in.
+        /// This may be the same annotation as this one.
         SwAnnotationWin*   GetTopReplyNote();
+
         SvxLanguageItem GetLanguage();
 
         VclBuilder      maBuilder;
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index a045b7146aa1..39bea61bfdf5 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -742,7 +742,7 @@ void SwAnnotationWin::SetPosAndSize()
             }
             SwAnnotationWin* pWin = GetTopReplyNote();
             // #i111964#
-            if ( pWin && pWin->Anchor() )
+            if ( pWin != this && pWin->Anchor() )
             {
                 pWin->Anchor()->SetAnchorState(AnchorState::End);
             }
@@ -1348,7 +1348,7 @@ void SwAnnotationWin::SetViewState(ViewState bViewState)
                 mpAnchor->SetAnchorState(AnchorState::All);
                 SwAnnotationWin* pWin = GetTopReplyNote();
                 // #i111964#
-                if ( pWin && pWin->Anchor() )
+                if ( pWin != this && pWin->Anchor() )
                 {
                     pWin->Anchor()->SetAnchorState(AnchorState::End);
                 }
@@ -1390,7 +1390,8 @@ void SwAnnotationWin::SetViewState(ViewState bViewState)
                                                   ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote()
                                                   : nullptr;
                     // #i111964#
-                    if ( pTopWinSelf && ( pTopWinSelf != pTopWinActive ) &&
+                    if ( ( pTopWinSelf != this ) &&
+                         ( pTopWinSelf != pTopWinActive ) &&
                          pTopWinSelf->Anchor() )
                     {
                         if ( pTopWinSelf != mrMgr.GetActiveSidebarWin() )


More information about the Libreoffice-commits mailing list