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

Scott Clarke (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 6 05:29:31 UTC 2019


 sw/inc/AnnotationWin.hxx                 |   17 +++++++++---
 sw/inc/PostItMgr.hxx                     |    3 ++
 sw/source/uibase/docvw/AnnotationWin.cxx |   37 ++++++++++++++++++++++++++-
 sw/source/uibase/docvw/PostItMgr.cxx     |   42 +++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 5 deletions(-)

New commits:
commit f4f5e3f98aee5d9d1679edab8248a4cfd12f74ce
Author:     Scott Clarke <scott.clarke at codethink.co.uk>
AuthorDate: Wed Jun 19 17:12:22 2019 +0100
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Aug 6 07:28:42 2019 +0200

    tdf#119228 Add accessors for resolved state
    
    Change-Id: Ic4051f4e7fda11eade1e50ce70bed11f70f0742d
    Co-authored-by: Jim MacArthur <jim.macarthur at codethink.co.uk>
    Reviewed-on: https://gerrit.libreoffice.org/75859
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 6002ac615660..196aa1d6dc18 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -189,6 +189,17 @@ class SAL_DLLPUBLIC_RTTI 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 SAL_DLLPUBLIC_RTTI 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 SAL_DLLPUBLIC_RTTI 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 19ba52b7aa18..f51aa04723fc 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -204,6 +204,8 @@ class SAL_DLLPUBLIC_RTTI 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 SAL_DLLPUBLIC_RTTI 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 fa4284ab393a..b270c06ec65a 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -89,6 +89,7 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
     , mAnchorRect()
     , mPageBorder(0)
     , mbAnchorRectChanged(false)
+    , mbResolvedStateUpdated(false)
     , mbMouseOver(false)
     , mLayoutStatus(SwPostItHelper::INVISIBLE)
     , mbReadonly(false)
@@ -215,9 +216,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());
@@ -244,6 +278,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 48121d7d8dd5..4dbf891781c1 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -1564,6 +1564,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();
@@ -2406,6 +2432,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 >& ) {}
 


More information about the Libreoffice-commits mailing list