diff options
author | Pallavi Jadhav <pallavi.jadhav@synerzip.com> | 2013-11-08 18:48:58 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-15 17:37:44 +0100 |
commit | 5cdd6d28d10d815c046b65db48847558259a1d1a (patch) | |
tree | f58b3026ccd825a026c32c0fc62727f47784a1e3 /sw | |
parent | 85ff539bb1b6fa90c16f80e44df5df0962521f72 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/testFootnote.docx | bin | 0 -> 24191 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 |
4 files changed, 16 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/testFootnote.docx b/sw/qa/extras/ooxmlexport/data/testFootnote.docx Binary files differnew file mode 100644 index 000000000000..5bba6d8c9524 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/testFootnote.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d182180579b5..7c5738f30ea8 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 80c17e3eeb63..054e946aaefe 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 14b22b2ab4c5..20991164b4d4 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 ); |