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>
This commit is contained in:
Gökay Şatır
2023-09-07 16:09:00 +03:00
committed by Miklos Vajna
parent 32102e559e
commit c0187d9f5e
6 changed files with 15 additions and 19 deletions

View File

@@ -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;

View File

@@ -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
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())

View File

@@ -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()
{

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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()