sw/inc/AnnotationWin.hxx                  |    2 --
 sw/qa/uitest/navigator/tdf137274.py       |    7 ++++++-
 sw/source/uibase/docvw/AnnotationWin.cxx  |   19 -------------------
 sw/source/uibase/docvw/AnnotationWin2.cxx |    2 ++
 sw/source/uibase/docvw/PostItMgr.cxx      |    6 ++++--
 uitest/uitest/test.py                     |    3 +++
 6 files changed, 15 insertions(+), 24 deletions(-)

New commits:
commit 4a68adb1a63af4d477d827e579c73b9add1d0559
Author:     Gökay Şatır <gokaysa...@gmail.com>
AuthorDate: Thu Sep 7 16:09:00 2023 +0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Sep 11 19:36:37 2023 +0200

    SW comments: Provide parent / child relations without position.
    
    Signed-off-by: Gökay Şatır <gokaysa...@gmail.com>
    Change-Id: I7acba74ef0717bc07a675be17fc1909680138f00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156689
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 19aa67dbfc5d..700293b61a84 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -81,8 +81,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
         sal_uInt32 MoveCaret();
 
-        /// Calculate parent postit id of current annotation window
-        sal_uInt32 CalcParent();
         void       InitAnswer(OutlinerParaObject const & rText);
 
         bool IsProtected() const;
diff --git a/sw/qa/uitest/navigator/tdf137274.py 
b/sw/qa/uitest/navigator/tdf137274.py
index 5192045b8264..5273ddcb2f91 100644
--- a/sw/qa/uitest/navigator/tdf137274.py
+++ b/sw/qa/uitest/navigator/tdf137274.py
@@ -9,6 +9,7 @@
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict
+import time
 
 class tdf137274(UITestCase):
 
@@ -59,7 +60,11 @@ class tdf137274(UITestCase):
             self.ui_test.wait_until_child_is_available('Comment2')
 
             # xComments needs reassigned after content tree change
-            xComments = self.get_item(xContentTree, 'Comments')
+            while True:
+                xComments = self.get_item(xContentTree, 'Comments')
+                if '1' in xComments.getChildren():
+                    break
+                time.sleep(self.ui_test.get_default_sleep())
             self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
 
             xComments.executeAction("EXPAND", tuple())
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index 7ebdbead067b..16acc0cbf589 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -387,25 +387,6 @@ sal_uInt32 SwAnnotationWin::MoveCaret()
            : 1 + CountFollowing();
 }
 
-// returns a non-zero postit parent id, if exists, otherwise 0 for root 
comments
-sal_uInt32 SwAnnotationWin::CalcParent()
-{
-    SwTextField* pTextField = mpFormatField->GetTextField();
-    SwPosition aPosition( pTextField->GetTextNode(), pTextField->GetStart() );
-    SwTextAttr * const pTextAttr =
-        pTextField->GetTextNode().GetTextAttrForCharAt(
-            aPosition.GetContentIndex() - 1,
-            RES_TXTATR_ANNOTATION );
-    const SwField* pField = pTextAttr ? pTextAttr->GetFormatField().GetField() 
: nullptr;
-    sal_uInt32 nParentId = 0;
-    if (pField && pField->Which() == SwFieldIds::Postit)
-    {
-        const SwPostItField* pPostItField = static_cast<const 
SwPostItField*>(pField);
-        nParentId = pPostItField->GetPostItId();
-    }
-    return nParentId;
-}
-
 // counts how many SwPostItField we have right after the current one
 sal_uInt32 SwAnnotationWin::CountFollowing()
 {
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index e8852a87f6e0..c5ca676895c0 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1118,6 +1118,8 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
                 // Get newly created SwPostItField and set its paraIdParent
                 auto pPostItField = mrMgr.GetLatestPostItField();
                 pPostItField->SetParentId(GetTopReplyNote()->GetParaId());
+                
pPostItField->SetParentPostItId(GetTopReplyNote()->GetPostItField()->GetPostItId());
+                
pPostItField->SetParentName(GetTopReplyNote()->GetPostItField()->GetName());
             }
             break;
         }
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index 07bf10be55c0..a0fda9fd7caa 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -746,7 +746,7 @@ void SwPostItMgr::LayoutPostIts()
                             pItem->mpPostIt = pPostIt;
                             if (mpAnswer)
                             {
-                                if (static_cast<bool>(pPostIt->CalcParent())) 
//do we really have another note in front of this one
+                                if 
(pPostIt->GetPostItField()->GetParentPostItId() != 0) //do we really have 
another note in front of this one
                                     pPostIt->InitAnswer(*mpAnswer);
                                 mpAnswer.reset();
                             }
@@ -756,7 +756,9 @@ void SwPostItMgr::LayoutPostIts()
                             pItem->mLayoutStatus,
                             
GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor));
                         pPostIt->SetSidebarPosition(pPage->eSidebarPosition);
-                        
pPostIt->SetFollow(static_cast<bool>(pPostIt->CalcParent()));
+
+                        if (pPostIt->GetPostItField()->GetParentPostItId() != 
0)
+                            pPostIt->SetFollow(true);
 
                         tools::Long aPostItHeight = 0;
                         if (bShowNotes)
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 5442d46b1d90..c07667cd621a 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -43,6 +43,9 @@ class UITest(object):
             if component is not None:
                 return component
 
+    def get_default_sleep(self):
+        return DEFAULT_SLEEP
+
     def wait_for_top_focus_window(self, id):
         while True:
             win = self._xUITest.getTopFocusWindow()

Reply via email to