summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-05-21 11:42:07 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-22 04:03:21 -0500
commit3c87d89bca61732cb2ee679e278863bd56bbdddd (patch)
treef1448b79e719c04baa6d27df6a0a555327922b10
parentb56c9aaa80639f93531ae7aa2a929eca158c4401 (diff)
fdo#78910 Hyperlink and Field start-end mismatch
Originally a Field began inside a hyperlink but ended after the hyperlink. This causes the corruption in MS Word. Incremented the field count if the field is added for the current new hyperlink. Added another variable to store the Field-Count from previous hyperlink. Added UT for the same. Change-Id: Id3c3bee1c8ed9c0755f8fff7efd5d1c5662f2c82 Reviewed-on: https://gerrit.libreoffice.org/9421 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo78910.docxbin0 -> 22596 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx15
3 files changed, 25 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo78910.docx b/sw/qa/extras/ooxmlexport/data/fdo78910.docx
new file mode 100644
index 000000000000..e8a090bee77b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo78910.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a82f81075303..8d5323c5e700 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3486,6 +3486,18 @@ DECLARE_OOXMLEXPORT_TEST(testWordArtWithinDraingtool, "testWordArtWithinDraingto
assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[4]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
}
+DECLARE_OOXMLEXPORT_TEST(testFdo78910, "fdo78910.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+ if (!pXmlDoc)
+ return;
+
+ // This is to ensure that the fld starts and ends inside a hyperlink...
+ assertXPath ( pXmlDoc, "//w:hyperlink[2]/w:r[1]/w:fldChar", "fldCharType", "begin" );
+ assertXPath ( pXmlDoc, "//w:hyperlink[2]/w:r[5]/w:fldChar", "fldCharType", "end" );
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 91562d743fa5..25019ba10f0a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -759,6 +759,13 @@ void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bS
void DocxAttributeOutput::EndRun()
{
+ int nFieldsInPrevHyperlink = m_nFieldsInHyperlink;
+ // Reset m_nFieldsInHyperlink if a new hyperlink is about to start
+ if ( m_pHyperlinkAttrList )
+ {
+ m_nFieldsInHyperlink = 0;
+ }
+
// Write field starts
for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); )
{
@@ -767,6 +774,11 @@ void DocxAttributeOutput::EndRun()
{
StartField_Impl( *pIt );
+ if ( m_pHyperlinkAttrList )
+ {
+ m_nFieldsInHyperlink++;
+ }
+
// Remove the field from the stack if only the start has to be written
// Unknown fields sould be removed too
if ( !pIt->bClose || ( pIt->eType == ww::eUNKNOWN ) )
@@ -791,7 +803,7 @@ void DocxAttributeOutput::EndRun()
{
if ( m_startedHyperlink )
{
- for ( int i = 0; i < m_nFieldsInHyperlink; i++ )
+ for ( int i = 0; i < nFieldsInPrevHyperlink; i++ )
{
// If fields begin before hyperlink then
// it should end before hyperlink close
@@ -836,7 +848,6 @@ void DocxAttributeOutput::EndRun()
m_pHyperlinkAttrList = NULL;
m_startedHyperlink = true;
m_nHyperLinkCount++;
- m_nFieldsInHyperlink = 0;
}
// if there is some redlining in the document, output it