summaryrefslogtreecommitdiff
path: root/sw/source/core/text
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-02-08 08:25:52 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-02-08 08:07:27 +0000
commit58b7b180297116997df6bfab7cbcf90d38d25f06 (patch)
tree72bb3a927d0669ffa825530458339ebb39c096c2 /sw/source/core/text
parentdcc52933cac1bf08c3e487bd3a12fb035d96eac2 (diff)
sw layout xml dump: show offset of text frames
This can be non-zero for follows in case a text frame is split into a master and follows. Also handle offset/follow of text frames when showing frame text, so only the relevant substring is shown in split frames. Change-Id: Ic3cb6daacf3a1771652afc9b64312585a8258a25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146648 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/text')
-rw-r--r--sw/source/core/text/xmldump.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index e81c77a9cefc..ba7a4d14ac4c 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -353,8 +353,14 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
{
aText = aText.replace( i, '*' );
}
- OString aText8 =OUStringToOString( aText,
- RTL_TEXTENCODING_UTF8 );
+ auto nTextOffset = static_cast<sal_Int32>(pTextFrame->GetOffset());
+ sal_Int32 nTextLength = aText.getLength() - nTextOffset;
+ if (const SwTextFrame* pTextFrameFollow = pTextFrame->GetFollow())
+ {
+ nTextLength = static_cast<sal_Int32>(pTextFrameFollow->GetOffset() - pTextFrame->GetOffset());
+ }
+ OString aText8
+ = OUStringToOString(aText.subView(nTextOffset, nTextLength), RTL_TEXTENCODING_UTF8);
(void)xmlTextWriterWriteString( writer,
reinterpret_cast<const xmlChar *>(aText8.getStr( )) );
if (const SwParaPortion* pPara = pTextFrame->GetPara())
@@ -527,6 +533,8 @@ void SwTextFrame::dumpAsXmlAttributes( xmlTextWriterPtr writer ) const
if (m_pPrecede != nullptr)
(void)xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "precede" ), "%" SAL_PRIuUINT32, static_cast<SwTextFrame*>(m_pPrecede)->GetFrameId() );
+
+ (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("offset"), BAD_CAST(OString::number(static_cast<sal_Int32>(mnOffset)).getStr()));
}
void SwSectionFrame::dumpAsXmlAttributes( xmlTextWriterPtr writer ) const