sw/source/core/text/xmldump.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 58b7b180297116997df6bfab7cbcf90d38d25f06
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Feb 8 08:25:52 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Feb 8 08:07:27 2023 +0000

    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 <vmik...@collabora.com>
    Tested-by: Jenkins

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

Reply via email to