diff options
author | PriyankaGaikwad <priyanka.gaikwad@synerzip.com> | 2014-03-20 19:39:30 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-22 14:47:06 +0100 |
commit | 802b6aaed855376b24d09acd5aa91abf80a9f71a (patch) | |
tree | 8cf29b643c1a3c550e1baaa7d70cf7c7398fd735 | |
parent | 3d5349f290deead4d47708ac8e30da47a76b9177 (diff) |
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
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo76163.docx | bin | 0 -> 41001 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 1 |
4 files changed, 22 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo76163.docx b/sw/qa/extras/ooxmlexport/data/fdo76163.docx Binary files differnew file mode 100644 index 000000000000..0c7cc7027ce9 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo76163.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 966e52cef79e..e9be6b6c2af0 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 e287f71c866b..4b433c931bf0 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 da94c87370c0..308cce8ccd5e 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 { |