officeotron: elements under w:pPr element in wrong order

re-use existing logic to make this output in spec-compliant order

Change-Id: I5de88629295ee3eac1852fe67eedea4f1be7c087
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195394
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
This commit is contained in:
Noel Grandin
2025-12-12 14:03:36 +01:00
committed by Michael Stahl
parent e2b5ff965e
commit 2b6e7bf5c0
2 changed files with 46 additions and 49 deletions
@@ -683,9 +683,6 @@ CPPUNIT_TEST_FIXTURE(Test, testfdo79668)
{
createSwDoc("fdo79668.docx");
//FIXME: validation error in OOXML export: Errors: 12
skipValidation();
saveAndReload(TestFilter::DOCX);
// fdo#79668: Document was Crashing on DebugUtil build while Saving
// because of repeated attribute value in same element.
+46 -46
View File
@@ -1476,55 +1476,55 @@ void DocxAttributeOutput::StartParagraphProperties()
}
}
// Write the elements in the spec order
const sal_Int32 aParagraphPropertiesOrder[] =
{
FSNS( XML_w, XML_pStyle ),
FSNS( XML_w, XML_keepNext ),
FSNS( XML_w, XML_keepLines ),
FSNS( XML_w, XML_pageBreakBefore ),
FSNS( XML_w, XML_framePr ),
FSNS( XML_w, XML_widowControl ),
FSNS( XML_w, XML_numPr ),
FSNS( XML_w, XML_suppressLineNumbers ),
FSNS( XML_w, XML_pBdr ),
FSNS( XML_w, XML_shd ),
FSNS( XML_w, XML_tabs ),
FSNS( XML_w, XML_suppressAutoHyphens ),
FSNS( XML_w, XML_kinsoku ),
FSNS( XML_w, XML_wordWrap ),
FSNS( XML_w, XML_overflowPunct ),
FSNS( XML_w, XML_topLinePunct ),
FSNS( XML_w, XML_autoSpaceDE ),
FSNS( XML_w, XML_autoSpaceDN ),
FSNS( XML_w, XML_bidi ),
FSNS( XML_w, XML_adjustRightInd ),
FSNS( XML_w, XML_snapToGrid ),
FSNS( XML_w, XML_spacing ),
FSNS( XML_w, XML_ind ),
FSNS( XML_w, XML_contextualSpacing ),
FSNS( XML_w, XML_mirrorIndents ),
FSNS( XML_w, XML_suppressOverlap ),
FSNS( XML_w, XML_jc ),
FSNS( XML_w, XML_textDirection ),
FSNS( XML_w, XML_textAlignment ),
FSNS( XML_w, XML_textboxTightWrap ),
FSNS( XML_w, XML_outlineLvl ),
FSNS( XML_w, XML_divId ),
FSNS( XML_w, XML_cnfStyle ),
FSNS( XML_w, XML_rPr ),
FSNS( XML_w, XML_sectPr ),
FSNS( XML_w, XML_pPrChange )
};
void DocxAttributeOutput::InitCollectedParagraphProperties()
{
m_pLRSpaceAttrList.clear();
m_pParagraphSpacingAttrList.clear();
// Write the elements in the spec order
static const sal_Int32 aOrder[] =
{
FSNS( XML_w, XML_pStyle ),
FSNS( XML_w, XML_keepNext ),
FSNS( XML_w, XML_keepLines ),
FSNS( XML_w, XML_pageBreakBefore ),
FSNS( XML_w, XML_framePr ),
FSNS( XML_w, XML_widowControl ),
FSNS( XML_w, XML_numPr ),
FSNS( XML_w, XML_suppressLineNumbers ),
FSNS( XML_w, XML_pBdr ),
FSNS( XML_w, XML_shd ),
FSNS( XML_w, XML_tabs ),
FSNS( XML_w, XML_suppressAutoHyphens ),
FSNS( XML_w, XML_kinsoku ),
FSNS( XML_w, XML_wordWrap ),
FSNS( XML_w, XML_overflowPunct ),
FSNS( XML_w, XML_topLinePunct ),
FSNS( XML_w, XML_autoSpaceDE ),
FSNS( XML_w, XML_autoSpaceDN ),
FSNS( XML_w, XML_bidi ),
FSNS( XML_w, XML_adjustRightInd ),
FSNS( XML_w, XML_snapToGrid ),
FSNS( XML_w, XML_spacing ),
FSNS( XML_w, XML_ind ),
FSNS( XML_w, XML_contextualSpacing ),
FSNS( XML_w, XML_mirrorIndents ),
FSNS( XML_w, XML_suppressOverlap ),
FSNS( XML_w, XML_jc ),
FSNS( XML_w, XML_textDirection ),
FSNS( XML_w, XML_textAlignment ),
FSNS( XML_w, XML_textboxTightWrap ),
FSNS( XML_w, XML_outlineLvl ),
FSNS( XML_w, XML_divId ),
FSNS( XML_w, XML_cnfStyle ),
FSNS( XML_w, XML_rPr ),
FSNS( XML_w, XML_sectPr ),
FSNS( XML_w, XML_pPrChange )
};
// postpone the output so that we can later [in EndParagraphProperties()]
// prepend the properties before the run
m_pSerializer->mark(Tag_InitCollectedParagraphProperties, comphelper::containerToSequence(aOrder));
m_pSerializer->mark(Tag_InitCollectedParagraphProperties, comphelper::containerToSequence(aParagraphPropertiesOrder));
}
void DocxAttributeOutput::WriteCollectedParagraphProperties()
@@ -4297,10 +4297,10 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
const UIName & sParaStyleName = pFormattingChanges->GetFormatName();
if (pChangesSet || !sParaStyleName.isEmpty())
{
m_pSerializer->mark(Tag_Redline_2);
m_pSerializer->startElementNS(XML_w, XML_pPr);
m_pSerializer->mark(Tag_Redline_2, comphelper::containerToSequence(aParagraphPropertiesOrder));
if (!sParaStyleName.isEmpty())
{
OString sStyleName;
@@ -4337,9 +4337,9 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
m_pLRSpaceAttrList = std::move(pLRSpaceAttrList_Original);
m_pParagraphSpacingAttrList = std::move(pParagraphSpacingAttrList_Original);
m_pSerializer->endElementNS( XML_w, XML_pPr );
m_pSerializer->mergeTopMarks(Tag_Redline_2);
m_pSerializer->mergeTopMarks(Tag_Redline_2, sax_fastparser::MergeMarks::PREPEND);
m_pSerializer->endElementNS( XML_w, XML_pPr );
}
}
}