sw/qa/extras/ooxmlexport/data/fdo76163.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 +++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 12 ++++++++++++ sw/source/filter/ww8/docxattributeoutput.hxx | 1 + 4 files changed, 22 insertions(+)
New commits: commit 802b6aaed855376b24d09acd5aa91abf80a9f71a Author: PriyankaGaikwad <priyanka.gaik...@synerzip.com> Date: Thu Mar 20 19:39:30 2014 +0530 fdo#76163 Fix for file corruption which contains fields and hyperlink Field inside a hyperlink closed after the ending tag of hyperlink, which corrupted the RT file. Reviewed on: https://gerrit.libreoffice.org/8688 Change-Id: Ie6fb5eff19c941819ca8c6193b3a6471de12c3e6 diff --git a/sw/qa/extras/ooxmlexport/data/fdo76163.docx b/sw/qa/extras/ooxmlexport/data/fdo76163.docx new file mode 100644 index 0000000..0c7cc70 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo76163.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 966e52c..e9be6b6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2951,6 +2951,15 @@ DECLARE_OOXMLEXPORT_TEST(testFdo76101, "fdo76101.docx") CPPUNIT_ASSERT(4091 >= xmlXPathNodeSetGetLength(pXmlNodes)); } +DECLARE_OOXMLEXPORT_TEST(testFDO76163 , "fdo76163.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + //docx file after RT is getting corrupted. + assertXPath ( pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink/w:r[11]/w:fldChar", "fldCharType", "end" ); +} + DECLARE_OOXMLEXPORT_TEST(test76317_2K10, "test76317_2K10.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e287f71..4b433c9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -734,6 +734,14 @@ void DocxAttributeOutput::EndRun() { if ( m_startedHyperlink ) { + for ( int i = 0; i < m_nFieldsInHyperlink; i++ ) + { + // If fields begin before hyperlink then + // it should end before hyperlink close + EndField_Impl( m_Fields.back( ) ); + if (m_Fields.back().pField) + delete m_Fields.back().pField; + } m_pSerializer->endElementNS( XML_w, XML_hyperlink ); m_startedHyperlink = false; m_nHyperLinkCount--; @@ -769,6 +777,7 @@ void DocxAttributeOutput::EndRun() m_pHyperlinkAttrList = NULL; m_startedHyperlink = true; m_nHyperLinkCount++; + m_nFieldsInHyperlink = 0; } // if there is some redlining in the document, output it @@ -1012,6 +1021,8 @@ void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos ) void DocxAttributeOutput::StartField_Impl( FieldInfos& rInfos, bool bWriteRun ) { + if ( m_startedHyperlink ) + ++m_nFieldsInHyperlink; if ( rInfos.pField && rInfos.eType == ww::eUNKNOWN ) { // Expand unsupported fields @@ -7159,6 +7170,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_closeHyperlinkInPreviousRun( false ), m_startedHyperlink( false ), m_nHyperLinkCount(0), + m_nFieldsInHyperlink( 0 ), m_postponedGraphic( NULL ), m_postponedDiagram( NULL ), m_postponedVMLDrawing(NULL), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index da94c87..308cce8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -773,6 +773,7 @@ private: bool m_startedHyperlink; // Count nested HyperLinks sal_Int32 m_nHyperLinkCount; + sal_Int16 m_nFieldsInHyperlink; struct PostponedGraphic { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits