simplify and reduce allocation in SwRedlineTable::getTextOfArea

Change-Id: Iea119c61aef1c5459c8c9d00c6e1c7de93ec29c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168156
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-05-29 18:19:23 +02:00
parent a4b95c4a15
commit 941d03968c
+7 -11
View File
@@ -872,33 +872,29 @@ OUString SwRedlineTable::getTextOfArea(size_type rPosStart, size_type rPosEnd) c
SwRangeRedline* pRedline = (*this)[nIdx];
bool bStartWithNonTextNode = false;
SwPaM *pPaM;
bool bDeletePaM = false;
OUString sNew;
if (nullptr == pRedline->GetContentIdx())
{
pPaM = pRedline;
sNew = pRedline->GetText();
}
else // otherwise it is saved in pContentSect, e.g. during ODT import
{
pPaM = new SwPaM(pRedline->GetContentIdx()->GetNode(),
SwPaM aTmpPaM(pRedline->GetContentIdx()->GetNode(),
*pRedline->GetContentIdx()->GetNode().EndOfSectionNode());
if (!pPaM->Start()->nNode.GetNode().GetTextNode())
if (!aTmpPaM.Start()->nNode.GetNode().GetTextNode())
{
bStartWithNonTextNode = true;
}
bDeletePaM = true;
sNew = aTmpPaM.GetText();
}
const OUString sNew = pPaM->GetText();
if (bStartWithNonTextNode &&
sNew[0] == CH_TXTATR_NEWLINE)
{
sRet += pPaM->GetText().subView(1);
sRet += sNew.subView(1);
}
else
sRet += pPaM->GetText();
if (bDeletePaM)
delete pPaM;
sRet += sNew;
}
return sRet;