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

umeshkadam umesh.kadam at synerzip.com
Mon Mar 17 08:58:09 PDT 2014


 sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                 |   19 ++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx             |   20 ++++++++++-----
 3 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit ac5078a46632ef7efbdce9340c0b023d7f455d14
Author: umeshkadam <umesh.kadam at synerzip.com>
Date:   Thu Mar 13 16:14:36 2014 +0530

    FDO#76107 : RT file gets corrupted for files having paragraph/page comments
    
    - In case of multiple paragraph comments/ page comments there used to be a
      mismatch while relating the comment id's in document.xml and comments.xml
    - This was happening because the annotation mark id's were getting overwritten.
    - Fixed this issue and added UT for the same.
    
    Change-Id: Ie0ac6b5c865555d143115a79b3fc146f9a4ef5fc
    Reviewed-on: https://gerrit.libreoffice.org/8602
    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/paragraphWithComments.docx b/sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx
new file mode 100644
index 0000000..84a6f20
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index f312494..aea7db3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2751,6 +2751,25 @@ DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testParagraphWithComments, "paragraphWithComments.docx")
+{
+    /* Comment id's were getting overwritten for annotation mark(s),
+       which was causing a mismatch in the relationship for comment id's
+       in document.xml and comment.xml
+    */
+    xmlDocPtr pXmlDoc  = parseExport("word/document.xml");
+    xmlDocPtr pXmlComm = parseExport("word/comments.xml");
+    if(!pXmlDoc)
+        return;
+
+    sal_Int32 idInDocXml     = 0;
+    sal_Int32 idInCommentXml = -1; //intentionally assigning -1 so that it differs from idInDocXml
+    //and also because getXpath does not assert.
+    idInDocXml     = getXPath(pXmlDoc,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32();
+    idInCommentXml = getXPath(pXmlComm,"/w:comments/w:comment[1]","id").toInt32();
+    CPPUNIT_ASSERT_EQUAL( idInDocXml, idInCommentXml );
+}
+
 DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx")
 {
     // fdo#76015 : Document contains oleobject in header xml.
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ac4f211..eab3f90 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -884,12 +884,20 @@ void DocxAttributeOutput::DoWriteAnnotationMarks()
         const OString& rName = *it;
 
         // Output the annotation mark
-        sal_uInt16 nId = m_nNextAnnotationMarkId++;
-        m_rOpenedAnnotationMarksIds[rName] = nId;
-        m_pSerializer->singleElementNS( XML_w, XML_commentRangeStart,
-            FSNS( XML_w, XML_id ), OString::number( nId ).getStr(  ),
-            FSEND );
-        m_sLastOpenedAnnotationMark = rName;
+        /* Ensure that the existing Annotation Marks are not overwritten
+           as it causes discrepancy when DocxAttributeOutput::PostitField
+           refers to this map & while mapping comment id's in document.xml &
+           comment.xml.
+        */
+        if ( m_rOpenedAnnotationMarksIds.end() == m_rOpenedAnnotationMarksIds.find( rName ) )
+        {
+            sal_uInt16 nId = m_nNextAnnotationMarkId++;
+            m_rOpenedAnnotationMarksIds[rName] = nId;
+            m_pSerializer->singleElementNS( XML_w, XML_commentRangeStart,
+                FSNS( XML_w, XML_id ), OString::number( nId ).getStr(  ),
+                FSEND );
+            m_sLastOpenedAnnotationMark = rName;
+        }
     }
     m_rAnnotationMarksStart.clear();
 


More information about the Libreoffice-commits mailing list