Kaydet (Commit) 60fad3fa authored tarafından Vinaya Mandke's avatar Vinaya Mandke Kaydeden (comit) Miklos Vajna

fdo#81945 [DOCX] Round Tripped file corrupted due to nested SDTs

Original File contains two separate SDTs which are getting
nested during RT as follows:-

sdtStart [MARK] rPr [MARK] sdtEND RunSTART
          ==PREPEND==> sdtStart [MARK] sdtEND RunSTART rPr RunEND
Now Another SDT starts
sdtStart [MARK] sdtEND RunSTART rPr RunEND [MARK] sdtStart
          ==PREPEND==>  sdtStart [MARK] sdtStart sdtEND RunSTART rPr RunEND

So, in such cases wait before closing the earlier sdt, to avoid nesting. Thus the [MARK]
can be retained in the corrrect position, to start the new SDT and end the earlier SDT.

Reviewed on:
	https://gerrit.libreoffice.org/10803

Change-Id: Ia86f94c0587a5d44ab23391ea9ac38f86b5dd250
üst 396fa3b6
...@@ -582,6 +582,15 @@ DECLARE_OOXMLEXPORT_TEST(testEditTime, "fdo81341.docx") ...@@ -582,6 +582,15 @@ DECLARE_OOXMLEXPORT_TEST(testEditTime, "fdo81341.docx")
} }
} }
DECLARE_OOXMLEXPORT_TEST(testFdo81945, "fdo81945.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "//w:sdt//w:sdt", 0);
}
#endif #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -1004,11 +1004,18 @@ void DocxAttributeOutput::EndRun() ...@@ -1004,11 +1004,18 @@ void DocxAttributeOutput::EndRun()
// level down, to be able to prepend the actual run start attribute (just // level down, to be able to prepend the actual run start attribute (just
// before "postponed run start") // before "postponed run start")
m_pSerializer->mark(); // let's call it "actual run start" m_pSerializer->mark(); // let's call it "actual run start"
bool bCloseEarlierSDT = false;
if (m_bEndCharSdt) if (m_bEndCharSdt)
{ {
// This is the common case: "close sdt before the current run" was requrested by the next run. // This is the common case: "close sdt before the current run" was requrested by the next run.
EndSdtBlock();
// if another sdt starts in this run, then wait
// as closing the sdt now, might cause nesting of sdts
if (m_nRunSdtPrToken > 0)
bCloseEarlierSDT = true;
else
EndSdtBlock();
m_bEndCharSdt = false; m_bEndCharSdt = false;
m_bStartedCharSdt = false; m_bStartedCharSdt = false;
} }
...@@ -1131,6 +1138,15 @@ void DocxAttributeOutput::EndRun() ...@@ -1131,6 +1138,15 @@ void DocxAttributeOutput::EndRun()
m_nRunSdtPrToken = 0; m_nRunSdtPrToken = 0;
lcl_deleteAndResetTheLists( m_pRunSdtPrTokenChildren, m_pRunSdtPrDataBindingAttrs, m_aRunSdtPrAlias ); lcl_deleteAndResetTheLists( m_pRunSdtPrTokenChildren, m_pRunSdtPrDataBindingAttrs, m_aRunSdtPrAlias );
} }
if (bCloseEarlierSDT)
{
m_pSerializer->mark();
EndSdtBlock();
m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
bCloseEarlierSDT = false;
}
m_pSerializer->mergeTopMarks(); m_pSerializer->mergeTopMarks();
WritePostponedMath(); WritePostponedMath();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment