summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorumeshkadam <umesh.kadam@synerzip.com>2014-03-13 16:14:36 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-17 15:57:42 +0000
commitac5078a46632ef7efbdce9340c0b023d7f455d14 (patch)
tree3d74a14875135e1afeb8b025b8ad0abbb94e9f24
parentab3acb7ef79fcae8776b8d1ce0e81da5698ef516 (diff)
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@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/paragraphWithComments.docxbin0 -> 14255 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx19
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx20
3 files changed, 33 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx b/sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx
new file mode 100644
index 000000000000..84a6f20a13cf
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/paragraphWithComments.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index f3124944bb07..aea7db318dbc 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 ac4f211d4200..eab3f9034db8 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();