diff options
author | Gökay Şatır <gokaysatir@gmail.com> | 2023-09-07 16:09:00 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-10-05 16:46:15 +0200 |
commit | c0187d9f5e6ab5129b6fc4682555f2f8775d6f67 (patch) | |
tree | 7e419fa6515752d46de422486619adf1d83d6bc8 | |
parent | 32102e559eed6eadf2ea146e212a330a3bc897ca (diff) |
SW comments: Provide parent / child relations without position.
Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I7acba74ef0717bc07a675be17fc1909680138f00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157019
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/inc/AnnotationWin.hxx | 2 | ||||
-rw-r--r-- | sw/qa/uitest/navigator/tdf137274.py | 7 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin2.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 6 | ||||
-rw-r--r-- | uitest/uitest/test.py | 3 |
6 files changed, 15 insertions, 19 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 62b20cb352cc..07f3ed8e83f9 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 IsReadOnlyOrProtected() 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 e57f90532294..5ed6780b455a 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -374,20 +374,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(); - if (SwPosition aPosition(pTextField->GetTextNode(), pTextField->GetStart()); - aPosition.GetContentIndex() > 0) - if (const SwTextAttr* pTextAttr = pTextField->GetTextNode().GetTextAttrForCharAt( - aPosition.GetContentIndex() - 1, RES_TXTATR_ANNOTATION)) - if (const SwField* pField = pTextAttr->GetFormatField().GetField()) - if (pField->Which() == SwFieldIds::Postit) - return static_cast<const SwPostItField*>(pField)->GetPostItId(); - return 0; -} - // 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 5e8f7a86886e..6a97433272b6 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1065,6 +1065,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 64579d75124b..64f5ff4f47d5 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -734,7 +734,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(); } @@ -744,7 +744,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 d160b9564d0f..602b03c2a9f7 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -46,6 +46,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() |