sw/qa/core/text/text.cxx | 14 ++++---------- sw/qa/extras/layout/layout.cxx | 9 ++++++--- sw/qa/extras/uiwriter/uiwriter4.cxx | 9 ++++----- sw/source/core/text/porexp.cxx | 15 +++++++++------ sw/source/core/text/porexp.hxx | 6 ++++-- sw/source/core/text/porfld.cxx | 10 +++++----- sw/source/core/text/porfld.hxx | 3 ++- sw/source/core/text/porglue.cxx | 19 +++++++++---------- sw/source/core/text/porglue.hxx | 4 ++-- sw/source/core/text/porhyph.hxx | 3 +++ sw/source/core/text/porlay.cxx | 16 ++++++++-------- sw/source/core/text/porlay.hxx | 6 ++++-- sw/source/core/text/porlin.cxx | 16 ++++++++++++++-- sw/source/core/text/porlin.hxx | 5 ++++- sw/source/core/text/pormulti.cxx | 21 ++++++++++++++++----- sw/source/core/text/pormulti.hxx | 3 ++- sw/source/core/text/porrst.cxx | 8 +++++--- sw/source/core/text/porrst.hxx | 3 ++- sw/source/core/text/portxt.cxx | 7 ++++--- sw/source/core/text/portxt.hxx | 3 ++- sw/source/core/text/txthyph.cxx | 10 ++++++++++ sw/source/core/text/xmldump.cxx | 15 +++++++++------ 22 files changed, 128 insertions(+), 77 deletions(-)
New commits: commit 678446780446ae568ee8b1b814158c54ea5e393f Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 31 20:14:05 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Apr 1 08:10:40 2022 +0200 sw layout xml dump: handle hyph portions Also pass around the text frame's text / offset. This allows showing the text of the portions even inside multi-portions, which is not possible with the a11y-based approach. Change-Id: Ief8963ed0514fbe4b2abb24e93777865ec1d9242 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132366 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 0d5d6f94b3bc..ec04039d8e15 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -187,17 +187,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testChineseAutoFirstLineIndent) xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Get the line width of the first line for the 1st paragraph. - sal_Int32 nFirstLineWidth = getXPath(pXmlDoc, - "//body/txt[1]/SwParaPortion/SwLineLayout[1]/" - "SwParaPortion/SwLineLayout/SwLinePortion", - "width") - .toInt32(); + sal_Int32 nFirstLineWidth + = getXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout[1]", "width").toInt32(); // Get the line width of the first line for the 2nd paragraph. - sal_Int32 nSecondLineWidth = getXPath(pXmlDoc, - "//body/txt[2]/SwParaPortion/SwLineLayout[1]/" - "SwParaPortion/SwLineLayout/SwLinePortion", - "width") - .toInt32(); + sal_Int32 nSecondLineWidth + = getXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout[1]", "width").toInt32(); // Tdf#129448: the changing of line-height should not affect the auto first line indent. // As a result, the first line width of the two paragraphs should be the same. diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e0530dc58541..937ca47ba270 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -1435,9 +1435,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testNoLineBreakAtSlash) pXmlObj->nodesetval->nodeTab[0]->name))); xmlXPathFreeObject(pXmlObj); - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "Blah blah bla bla bla "); - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "Foostrasse"); - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[3]", "Portion", "13/c/2, etc."); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + "Blah blah bla bla bla "); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[1]", + "portion", "Foostrasse"); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[2]", + "portion", "13/c/2, etc."); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153) diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index b3825a1535e5..6c3d3578ca26 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -1635,18 +1635,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf35021_tabOverMarginDemo) sal_Int32 nMargin = getXPath(pXmlDoc, "//body/txt[1]/infos/prtBounds", "width").toInt32(); // left tab was 3381 because it got its own full line sal_Int32 nWidth - = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabLeft']", "width").toInt32(); + = getXPath(pXmlDoc, "//SwFixPortion[@type='PortionType::TabLeft']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Left Tab width is ~4479", nMargin < nWidth); // center tab was 842 - nWidth - = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabCenter']", "width").toInt32(); + nWidth = getXPath(pXmlDoc, "//SwFixPortion[@type='PortionType::TabCenter']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Center Tab width is ~3521", nMargin < nWidth); // right tab was probably the same as center tab. - nWidth = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabRight']", "width").toInt32(); + nWidth = getXPath(pXmlDoc, "//SwFixPortion[@type='PortionType::TabRight']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Right Tab width is ~2907", sal_Int32(2500) < nWidth); // decimal tab was 266 nWidth - = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabDecimal']", "width").toInt32(); + = getXPath(pXmlDoc, "//SwFixPortion[@type='PortionType::TabDecimal']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Decimal Tab width is ~4096", nMargin < nWidth); #endif } diff --git a/sw/source/core/text/porexp.cxx b/sw/source/core/text/porexp.cxx index efacc3d5644a..f38e7b1f7a8c 100644 --- a/sw/source/core/text/porexp.cxx +++ b/sw/source/core/text/porexp.cxx @@ -38,11 +38,12 @@ void SwExpandPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Special( GetLen(), OUString(), GetWhichPor() ); } -void SwExpandPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwExpandPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwExpandPortion")); - - SwTextPortion::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); (void)xmlTextWriterEndElement(pWriter); } @@ -219,16 +220,18 @@ void SwBlankPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Special( GetLen(), OUString( m_cChar ), GetWhichPor() ); } -void SwBlankPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwBlankPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwBlankPortion")); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("char"), BAD_CAST(OUString(m_cChar).toUtf8().getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("multi"), BAD_CAST(OString::boolean(m_bMulti).getStr())); - SwExpandPortion::dumpAsXml(pWriter); - (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/porexp.hxx b/sw/source/core/text/porexp.hxx index 6911c7d9113c..82de5b1be4fc 100644 --- a/sw/source/core/text/porexp.hxx +++ b/sw/source/core/text/porexp.hxx @@ -34,7 +34,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; /// Non-breaking space or non-breaking hyphen. @@ -58,7 +59,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; class SwPostItsPortion : public SwExpandPortion diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 8c586530eff8..b7f2f6f81905 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -472,14 +472,14 @@ void SwFieldPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Special( GetLen(), m_aExpand, GetWhichPor(), nH, nW, m_pFont.get() ); } -void SwFieldPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwFieldPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldPortion")); - SwExpandPortion::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); - (void)xmlTextWriterStartElement(pWriter, BAD_CAST("expand")); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(m_aExpand.toUtf8().getStr())); - (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("expand"), BAD_CAST(m_aExpand.toUtf8().getStr())); (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index ec2ee7a61c51..b4c6865dabdb 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -108,7 +108,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; /** diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx index 00116bf68194..5f1fd2a7dc8d 100644 --- a/sw/source/core/text/porglue.cxx +++ b/sw/source/core/text/porglue.cxx @@ -129,14 +129,14 @@ void SwGluePortion::Join( SwGluePortion *pVictim ) delete pVictim; } -void SwGluePortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwGluePortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwGluePortion")); - SwLinePortion::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); - (void)xmlTextWriterStartElement(pWriter, BAD_CAST("fix-width")); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(m_nFixWidth).getStr())); - (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fix-width"), BAD_CAST(OString::number(m_nFixWidth).getStr())); (void)xmlTextWriterEndElement(pWriter); } @@ -157,15 +157,14 @@ SwFixPortion::SwFixPortion() SetWhichPor( PortionType::Fix ); } -void SwFixPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwFixPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFixPortion")); - SwGluePortion::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); - (void)xmlTextWriterStartElement(pWriter, BAD_CAST("fix")); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fix"), BAD_CAST(OString::number(m_nFix).getStr())); - (void)xmlTextWriterEndElement(pWriter); (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/porglue.hxx b/sw/source/core/text/porglue.hxx index e6924659f435..d46962d454bb 100644 --- a/sw/source/core/text/porglue.hxx +++ b/sw/source/core/text/porglue.hxx @@ -45,7 +45,7 @@ public: virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override; virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const override; }; class SwFixPortion : public SwGluePortion @@ -57,7 +57,7 @@ public: void SetFix( const sal_uInt16 nNewFix ) { m_nFix = nNewFix; } sal_uInt16 GetFix() const { return m_nFix; } - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const override; }; class SwMarginPortion : public SwGluePortion diff --git a/sw/source/core/text/porhyph.hxx b/sw/source/core/text/porhyph.hxx index 43341ce1daf9..dc3c6651d0a8 100644 --- a/sw/source/core/text/porhyph.hxx +++ b/sw/source/core/text/porhyph.hxx @@ -36,6 +36,9 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; + + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; class SwHyphStrPortion : public SwHyphPortion diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index bca9c41daea7..e3b8f3bd6cf7 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -794,12 +794,12 @@ void SwLineLayout::MaxAscentDescent( SwTwips& _orAscent, } } -void SwLineLayout::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwLineLayout::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwLineLayout")); - (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); - - SwTextPortion::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); (void)xmlTextWriterEndElement(pWriter); } @@ -2586,12 +2586,12 @@ const SwDropPortion *SwParaPortion::FindDropPortion() const return nullptr; } -void SwParaPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwParaPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwParaPortion")); - (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); - - SwLineLayout::dumpAsXml(pWriter); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index c5b838e0bc5b..eb0d5e8bf768 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -241,7 +241,8 @@ public: const SwLinePortion* _pDontConsiderPortion = nullptr, const bool _bNoFlyCntPorAndLinePor = false ) const; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; /// Collection of SwLineLayout instances, represents the paragraph text in Writer layout. @@ -324,7 +325,8 @@ public: const SwDropPortion *FindDropPortion() const; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; inline void SwParaPortion::ResetPreps() diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 82e5255def9e..16bc46b58ebf 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -317,9 +317,17 @@ void SwLinePortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Special( GetLen(), OUString(), GetWhichPor(), Height(), Width() ); } -void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwLinePortion")); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); + + (void)xmlTextWriterEndElement(pWriter); +} + +void SwLinePortion::dumpAsXmlAttributes(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex nOffset) const +{ (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name())); (void)xmlTextWriterWriteAttribute( @@ -334,7 +342,11 @@ void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterWriteAttribute( pWriter, BAD_CAST("type"), BAD_CAST(sw::PortionTypeToString(GetWhichPor()))); - (void)xmlTextWriterEndElement(pWriter); + OUString aText = rText.copy(sal_Int32(nOffset), sal_Int32(GetLen())); + for (int i = 0; i < 32; ++i) + aText = aText.replace(i, '*'); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("portion"), + BAD_CAST(aText.toUtf8().getStr())); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx index 4801fadfe9f1..3da76ce5cfb2 100644 --- a/sw/source/core/text/porlin.hxx +++ b/sw/source/core/text/porlin.hxx @@ -173,7 +173,10 @@ public: void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; } void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; } - virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& rOffset) const; + void dumpAsXmlAttributes(xmlTextWriterPtr writer, const OUString& rText, + TextFrameIndex nOffset) const; }; inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion) diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index d47b281ac9a9..c798a0dfc519 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -134,15 +134,26 @@ void SwMultiPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Text( GetLen(), GetWhichPor() ); } -void SwMultiPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwMultiPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwMultiPortion")); - (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name())); + dumpAsXmlAttributes(pWriter, rText, nOffset); + // Indentionally not incrementing nOffset here, one of the child portions will do that. - for (const SwLineLayout* pLine = &GetRoot(); pLine; pLine = pLine->GetNext()) + const SwLineLayout* pLine = &GetRoot(); + while (pLine) { - pLine->dumpAsXml(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwLineLayout")); + pLine->dumpAsXmlAttributes(pWriter, rText, nOffset); + const SwLinePortion* pPor = pLine->GetFirstPortion(); + while (pPor) + { + pPor->dumpAsXml(pWriter, rText, nOffset); + pPor = pPor->GetNextPortion(); + } + (void)xmlTextWriterEndElement(pWriter); + pLine = pLine->GetNext(); } (void)xmlTextWriterEndElement(pWriter); diff --git a/sw/source/core/text/pormulti.hxx b/sw/source/core/text/pormulti.hxx index 045276bdd4b9..00389e796c7a 100644 --- a/sw/source/core/text/pormulti.hxx +++ b/sw/source/core/text/pormulti.hxx @@ -150,7 +150,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; class SwDoubleLinePortion : public SwMultiPortion diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index fe76923bc337..2a61f67f76c2 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -202,14 +202,16 @@ void SwBreakPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Text( GetLen(), GetWhichPor() ); } -void SwBreakPortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwBreakPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& + nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwBreakPortion")); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("text-height"), BAD_CAST(OString::number(m_nTextHeight).getStr())); - SwLinePortion::dumpAsXml(pWriter); - (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx index db4c974f25de..66552eea3c7d 100644 --- a/sw/source/core/text/porrst.hxx +++ b/sw/source/core/text/porrst.hxx @@ -77,7 +77,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0"; void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; } diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 112eb26328b8..cf827ab6c3bf 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -792,14 +792,15 @@ void SwHolePortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Text( GetLen(), GetWhichPor() ); } -void SwHolePortion::dumpAsXml(xmlTextWriterPtr pWriter) const +void SwHolePortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, TextFrameIndex& nOffset) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHolePortion")); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("blank-width"), BAD_CAST(OString::number(m_nBlankWidth).getStr())); - SwLinePortion::dumpAsXml(pWriter); - (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx index 297fca5e8525..77ec0a9f1363 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -74,7 +74,8 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const override; - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const override; }; class SwFieldMarkPortion : public SwTextPortion diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index 7f9f6f6cd611..e9f6a9d0e64a 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -355,6 +355,16 @@ void SwHyphPortion::HandlePortion( SwPortionHandler& rPH ) const rPH.Special( GetLen(), OUString('-'), GetWhichPor() ); } +void SwHyphPortion::dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText, + TextFrameIndex& nOffset) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwHyphPortion")); + dumpAsXmlAttributes(pWriter, rText, nOffset); + nOffset += GetLen(); + + (void)xmlTextWriterEndElement(pWriter); +} + bool SwHyphPortion::Format( SwTextFormatInfo &rInf ) { const SwLinePortion *pLast = rInf.GetLast(); diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx index 6bd2219e82e1..13215bca13c9 100644 --- a/sw/source/core/text/xmldump.cxx +++ b/sw/source/core/text/xmldump.cxx @@ -486,19 +486,22 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const if (const SwParaPortion* pPara = pTextFrame->GetPara()) { (void)xmlTextWriterStartElement(writer, BAD_CAST("SwParaPortion")); - (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pPara); + TextFrameIndex nOffset(0); + const OUString& rText = pTextFrame->GetText(); + pPara->dumpAsXmlAttributes(writer, rText, nOffset); const SwLineLayout* pLine = pPara; + if (pTextFrame->IsFollow()) + { + nOffset += pTextFrame->GetOffset(); + } while (pLine) { (void)xmlTextWriterStartElement(writer, BAD_CAST("SwLineLayout")); - (void)xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", pLine); - (void)xmlTextWriterWriteAttribute( - writer, BAD_CAST("height"), - BAD_CAST(OString::number(pLine->Height()).getStr())); + pLine->dumpAsXmlAttributes(writer, rText, nOffset); const SwLinePortion* pPor = pLine->GetFirstPortion(); while (pPor) { - pPor->dumpAsXml(writer); + pPor->dumpAsXml(writer, rText, nOffset); pPor = pPor->GetNextPortion(); } (void)xmlTextWriterEndElement(writer);