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

Pallavi Jadhav pallavi.jadhav at synerzip.com
Fri Nov 15 08:38:10 PST 2013


 sw/qa/extras/ooxmlexport/data/testFootnote.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |   10 ++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx    |    6 ++++--
 sw/source/filter/ww8/docxattributeoutput.hxx    |    2 ++
 4 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 5cdd6d28d10d815c046b65db48847558259a1d1a
Author: Pallavi Jadhav <pallavi.jadhav at synerzip.com>
Date:   Fri Nov 8 18:48:58 2013 +0530

    LibreOffice Corrupts DOCX files containing Footnotes after Roundtrip
    
    	Issue :
    	1] Extra data was getting written into document.xml after
               </w:document>
       	   This includes :
       		1) <sectPr> tag
       		2) Paragraph tag of <w:footnote w:id="2"> from
                       footnotes.xml
    	2] This is leading to document corruption
    
    	Implementation :
    	1] Enabled a flag inside DocxAttributeOutput::FootnotesEndnotes
    	2] Check value of flag to decide whehter to write section
               properties or not
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    	sw/source/filter/ww8/docxattributeoutput.cxx
    Reviewed on:
    	https://gerrit.libreoffice.org/6644
    
    Change-Id: Iae53fd6bf12bcbac84846bd36823bc08f21f9edf

diff --git a/sw/qa/extras/ooxmlexport/data/testFootnote.docx b/sw/qa/extras/ooxmlexport/data/testFootnote.docx
new file mode 100644
index 0000000..5bba6d8
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/testFootnote.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d182180..7c5738f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1878,6 +1878,16 @@ DECLARE_OOXML_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx")
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 737 ), aGraphicCropStruct.Bottom );
 }
 
+DECLARE_OOXML_TEST(testFootnoteParagraphTag, "testFootnote.docx")
+{
+    /* In footnotes.xml, the paragraph tag inside <w:footnote w:id="2"> was getting written into document.xml.
+     * Check for, paragraph tag is correctly written into footnotes.xml.
+     */
+    xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml");
+    assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]","id","2");
+    assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r/w:rPr/w:rStyle","val","Footnotereference");
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 80c17e3..054e946 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -501,7 +501,7 @@ void DocxAttributeOutput::StartParagraphProperties()
     m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND );
 
     // and output the section break now (if it appeared)
-    if ( m_pSectionInfo )
+    if ( m_pSectionInfo && (!m_setFootnote))
     {
         m_rExport.SectionProperties( *m_pSectionInfo );
         m_pSectionInfo.reset();
@@ -5120,6 +5120,7 @@ void DocxAttributeOutput::FootnoteEndnoteReference()
 
 void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
 {
+    m_setFootnote = true;
     const FootnotesVector& rVector = bFootnotes? m_pFootnotesList->getVector(): m_pEndnotesList->getVector();
 
     sal_Int32 nBody = bFootnotes? XML_footnotes: XML_endnotes;
@@ -6272,7 +6273,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_bParaBeforeAutoSpacing(false),
       m_bParaAfterAutoSpacing(false),
       m_iParaBeforeSpacing(0),
-      m_iParaAfterSpacing(0)
+      m_iParaAfterSpacing(0),
+      m_setFootnote(false)
 {
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 14b22b2..2099116 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -784,6 +784,8 @@ private:
     // store hardcoded value which was set during import.
     sal_Int32 m_iParaBeforeSpacing,m_iParaAfterSpacing;
 
+    bool m_setFootnote;
+
 public:
     DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );
 


More information about the Libreoffice-commits mailing list