diff options
author | Pallavi Jadhav <pallavi.jadhav@synerzip.com> | 2014-03-19 16:29:42 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-19 14:52:22 +0100 |
commit | 20a3792502120d67b1a9fdea641e15ea504359d3 (patch) | |
tree | dae3061e57f97e2734b9a18b1a6276bfff860d3f /sw | |
parent | d2c16eb81a813f709552bd840897047fe98eb131 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo76316.docx | bin | 0 -> 861272 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 |
4 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo76316.docx b/sw/qa/extras/ooxmlexport/data/fdo76316.docx Binary files differnew file mode 100644 index 000000000000..67d37642e113 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo76316.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ee6c51168f2c..9461ba7a2356 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 f3c97d0b558e..1ff6305efb87 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 b5a58d8afb3f..5b55dc8a32cb 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 { |