[Libreoffice-commits] core.git: sw/qa sw/source

Vinaya Mandke vinaya.mandke at synerzip.com
Thu May 22 02:03:41 PDT 2014


 sw/qa/extras/ooxmlexport/data/fdo78910.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   15 +++++++++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit 3c87d89bca61732cb2ee679e278863bd56bbdddd
Author: Vinaya Mandke <vinaya.mandke at synerzip.com>
Date:   Wed May 21 11:42:07 2014 +0530

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo78910.docx b/sw/qa/extras/ooxmlexport/data/fdo78910.docx
new file mode 100644
index 0000000..e8a090b
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo78910.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a82f810..8d5323c 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 91562d7..25019ba 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


More information about the Libreoffice-commits mailing list