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
This commit is contained in:
committed by
Miklos Vajna
parent
d2c16eb81a
commit
20a3792502
BIN
sw/qa/extras/ooxmlexport/data/fdo76316.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo76316.docx
Normal file
Binary file not shown.
@@ -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");
|
||||
|
@@ -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),
|
||||
|
@@ -771,6 +771,8 @@ private:
|
||||
bool m_closeHyperlinkInThisRun;
|
||||
bool m_closeHyperlinkInPreviousRun;
|
||||
bool m_startedHyperlink;
|
||||
// Count nested HyperLinks
|
||||
sal_Int32 m_nHyperLinkCount;
|
||||
|
||||
struct PostponedGraphic
|
||||
{
|
||||
|
Reference in New Issue
Block a user