[Libreoffice-commits] core.git: sw/qa sw/source

Vinaya Mandke vinaya.mandke at synerzip.com
Fri Aug 8 00:38:04 PDT 2014


 sw/qa/extras/ooxmlexport/data/fdo81945.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |    9 +++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx  |   18 +++++++++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 60fad3fabb26a50ea238bed2f046670c6e5678f7
Author: Vinaya Mandke <vinaya.mandke at synerzip.com>
Date:   Wed Aug 6 19:38:40 2014 +0530

    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

diff --git a/sw/qa/extras/ooxmlexport/data/fdo81945.docx b/sw/qa/extras/ooxmlexport/data/fdo81945.docx
new file mode 100644
index 0000000..51dee9c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo81945.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 36ae02b..9867cce 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 cfd3ef4..5888d32 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();


More information about the Libreoffice-commits mailing list