diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2014-08-06 19:38:40 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-08 09:37:32 +0200 |
commit | 60fad3fabb26a50ea238bed2f046670c6e5678f7 (patch) | |
tree | 2bce94b89414305703b8f637cdbe790db01fbf4d | |
parent | 396fa3b663efb2f0b125c6328732263133590b3f (diff) |
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
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo81945.docx | bin | 0 -> 14037 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 18 |
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo81945.docx b/sw/qa/extras/ooxmlexport/data/fdo81945.docx Binary files differnew file mode 100644 index 000000000000..51dee9cfe38c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo81945.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 36ae02ba8a89..9867cceed1a1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -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 CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index cfd3ef49915f..5888d32dc681 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1004,11 +1004,18 @@ void DocxAttributeOutput::EndRun() // level down, to be able to prepend the actual run start attribute (just // before "postponed run start") m_pSerializer->mark(); // let's call it "actual run start" + bool bCloseEarlierSDT = false; if (m_bEndCharSdt) { // 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_bStartedCharSdt = false; } @@ -1131,6 +1138,15 @@ void DocxAttributeOutput::EndRun() m_nRunSdtPrToken = 0; 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(); WritePostponedMath(); |