diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-17 17:31:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-17 18:05:28 +0200 |
commit | fff019debf14a0bf8cd358591a686191347f1542 (patch) | |
tree | ba0a6ede0eede8061aabfd699f47d3265b79a353 | |
parent | 902564bfe52e7699cefc80b3334c2eb0a8cacdcf (diff) |
MSWordExportBase: ignore empty annotation marks
Change-Id: I182700a7b74aa65a1eeb39ff702f068a10dd3346
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/empty-annotation-mark.docx | bin | 0 -> 13339 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 7 |
3 files changed, 28 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/empty-annotation-mark.docx b/sw/qa/extras/ooxmlexport/data/empty-annotation-mark.docx Binary files differnew file mode 100644 index 000000000000..854b6d726189 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/empty-annotation-mark.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 20b1301efcab..4dd7dfc9ad1e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -231,6 +231,28 @@ DECLARE_OOXMLEXPORT_TEST(testShapeInFloattable, "shape-in-floattable.docx") } } +DECLARE_OOXMLEXPORT_TEST(testEmptyAnnotationMark, "empty-annotation-mark.docx") +{ + if (mbExported) + { + // Delete the word that is commented, and save again. + uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 3); + CPPUNIT_ASSERT_EQUAL(OUString("with"), xRun->getString()); + xRun->setString(""); + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + xStorable->store(); + + // Then inspect the OOXML markup of the modified document model. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + // There were two commentReference nodes. + assertXPath(pXmlDoc, "//w:commentReference", "id", "0"); + // Empty comment range was not ignored on export, this was 1. + assertXPath(pXmlDoc, "//w:commentRangeStart", 0); + // Ditto. + assertXPath(pXmlDoc, "//w:commentRangeEnd", 0); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 5bb95bcc27dc..e000918604c1 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1806,7 +1806,12 @@ bool MSWordExportBase::GetAnnotationMarks( const SwTxtNode& rNd, sal_Int32 nStt, bool bIsStartOk = ( pMark->GetMarkStart().nNode == nNd ) && ( nBStart >= nStt ) && ( nBStart <= nEnd ); bool bIsEndOk = ( pMark->GetMarkEnd().nNode == nNd ) && ( nBEnd >= nStt ) && ( nBEnd <= nEnd ); - if ( bIsStartOk || bIsEndOk ) + // Annotation marks always have at least one character: the anchor + // point of the comment field. In this case Word wants only the + // comment field, so ignore the annotation mark itself. + bool bSingleChar = pMark->GetMarkStart().nNode == pMark->GetMarkEnd().nNode && nBStart + 1 == nBEnd; + + if ( ( bIsStartOk || bIsEndOk ) && !bSingleChar ) { rArr.push_back( pMark ); } |