sw/qa/extras/ooxmlexport/data/fdo76316.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 +++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 14 ++++++++++++++ sw/source/filter/ww8/docxattributeoutput.hxx | 2 ++ 4 files changed, 29 insertions(+)
New commits: commit 20a3792502120d67b1a9fdea641e15ea504359d3 Author: Pallavi Jadhav <pallavi.jad...@synerzip.com> Date: Wed Mar 19 16:29:42 2014 +0530 fdo#76316 : File gets corrupt after Roundtrip Issue : DOCX containing nested Hyperlinks, have mismatch xml tags. End tag for outer Hyperlinks does not get closed. Implementation : 1] Added code at Export side to maintain Count of Hyperlinks started and ended. Added check endParagraph() to to close Hyperlink tag if not yet closed but started. 2] Written Export Unit Test case. NOTE : Corruption was occurring on "Without debug-util" build and Crash was occurring on "WITH debug-util build". Reviewed on: https://gerrit.libreoffice.org/8654 Change-Id: I9a0ab48578f3d5f4a13c615f4e42a69e790d3ced diff --git a/sw/qa/extras/ooxmlexport/data/fdo76316.docx b/sw/qa/extras/ooxmlexport/data/fdo76316.docx new file mode 100644 index 0000000..67d3764 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo76316.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ee6c511..9461ba7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2865,6 +2865,19 @@ DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx") assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin"); } +DECLARE_OOXMLEXPORT_TEST(testHyperLinkTagEnded, "fdo76316.docx") +{ + /* XML tag <w:hyperlink> was not getting closed when its inside another + * <w:hyperlink> tag. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) return; + + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[2]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[7]/w:tc[1]/w:tbl[1]/w:tr[2]/w:tc[6]/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:hyperlink[1]/w:hyperlink[1]",1); +} + DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f3c97d0..1ff6305 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -359,6 +359,16 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT --m_nTextFrameLevel; + /* If m_nHyperLinkCount > 0 that means hyperlink tag is not yet colsed. + * This is due to nested hyperlink tags. So close it before end of paragraph. + */ + if(m_nHyperLinkCount > 0) + { + for(sal_Int32 nHyperLinkToClose = 0; nHyperLinkToClose < m_nHyperLinkCount; ++nHyperLinkToClose) + m_pSerializer->endElementNS( XML_w, XML_hyperlink ); + m_nHyperLinkCount = 0; + } + m_pSerializer->endElementNS( XML_w, XML_p ); WriteParagraphSdt(); @@ -712,6 +722,7 @@ void DocxAttributeOutput::EndRun() { m_pSerializer->endElementNS( XML_w, XML_hyperlink ); m_startedHyperlink = false; + m_nHyperLinkCount--; } m_closeHyperlinkInPreviousRun = false; } @@ -743,6 +754,7 @@ void DocxAttributeOutput::EndRun() m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList ); m_pHyperlinkAttrList = NULL; m_startedHyperlink = true; + m_nHyperLinkCount++; } // if there is some redlining in the document, output it @@ -830,6 +842,7 @@ void DocxAttributeOutput::EndRun() m_pSerializer->endElementNS( XML_w, XML_hyperlink ); m_startedHyperlink = false; + m_nHyperLinkCount--; } m_closeHyperlinkInThisRun = false; } @@ -7060,6 +7073,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_closeHyperlinkInThisRun( false ), m_closeHyperlinkInPreviousRun( false ), m_startedHyperlink( false ), + m_nHyperLinkCount(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 b5a58d8..5b55dc8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -771,6 +771,8 @@ private: bool m_closeHyperlinkInThisRun; bool m_closeHyperlinkInPreviousRun; bool m_startedHyperlink; + // Count nested HyperLinks + sal_Int32 m_nHyperLinkCount; struct PostponedGraphic { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits