From 3293bfff71748af714b7dfde50476d4db86510d2 Mon Sep 17 00:00:00 2001 From: PriyankaGaikwad Date: Thu, 7 Aug 2014 14:50:36 +0530 Subject: fdo#81946 Corrupt : DOCX file getting corrupt after RT Decription : DOCX file getting corrupt after RT due to the AlternateContent inside sdtContent block XML Difference : In header.xml Original File ... Roundtrip File ......Text Box..... Reviewed on: https://gerrit.libreoffice.org/10805 Change-Id: I32d22f57a52060dd6f0ee784ee0002968d06ac3a --- sw/qa/extras/ooxmlexport/data/fdo81946.docx | Bin 0 -> 34561 bytes sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 9 +++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/fdo81946.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo81946.docx b/sw/qa/extras/ooxmlexport/data/fdo81946.docx new file mode 100644 index 000000000000..b179f58bf81d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo81946.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 9867cceed1a1..4c44216a17a7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -591,6 +591,15 @@ DECLARE_OOXMLEXPORT_TEST(testFdo81945, "fdo81945.docx") assertXPath(pXmlDoc, "//w:sdt//w:sdt", 0); } +DECLARE_OOXMLEXPORT_TEST(testfdo81946, "fdo81946.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); + if (!pXmlDoc) + return; + // make sure AlternateContent should not present in sdt + assertXPath(pXmlDoc, "/w:hdr[1]/w:p[1]/w:sdt[1]/w:sdtContent[1]/w:r[2]/mc:AlternateContent[1]",0); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5888d32dc681..a8bcc8903c5a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -450,6 +450,12 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT if (!TextBoxIsFramePr(rFrmFmt) || m_bWritingHeaderFooter) { + if (m_bStartedCharSdt) + { + // Run-level SDT still open? Close it befor AlternateContent. + EndSdtBlock(); + m_bStartedCharSdt = false; + } m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); m_pSerializer->startElementNS(XML_mc, XML_AlternateContent, FSEND); m_pSerializer->startElementNS(XML_mc, XML_Choice, -- cgit