summaryrefslogtreecommitdiff
path: root/sw/qa/extras/unowriter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-06-20 16:58:06 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-06-20 20:46:56 +0200
commit34c008380b9c17a78b9fde8cfa2102ab14c2392b (patch)
tree6a0c7577f93cf0d7182bef415c01ffccceeb7e1d /sw/qa/extras/unowriter
parente24b27cd1b3139f74c0e2c03dbf1045000ed220e (diff)
sw comments: allow ranges to be created which cover only the placeholder char
First, the old condition was a bit tricky: it wanted to avoid the case when only the placeholder character is covered, but given that start and end can be the same for collapsed ranges, this was true for comments without a range, too. In practice what remains blacklisted is just the case when the PaM has a mark, but it's the same as the point. The change has two motivations: 1) ODF can have '<office:annotation/>...<office:annotation-end/>', where '...' may be content which has no document position itself in the Writer implementation, like at-char anchored images. This change avoids loosing the range of such annotations during ODF roundtrip. 2) This starts adding support for comments on objects which don't have an own document position, though UI for that is still missing. Change-Id: If151b8e00e37e07830c0582b8f0920a91a787363 Reviewed-on: https://gerrit.libreoffice.org/74459 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/unowriter')
-rw-r--r--sw/qa/extras/unowriter/data/image-comment-at-char.odtbin0 -> 10244 bytes
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx16
2 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/data/image-comment-at-char.odt b/sw/qa/extras/unowriter/data/image-comment-at-char.odt
new file mode 100644
index 000000000000..ba959d68ace9
--- /dev/null
+++ b/sw/qa/extras/unowriter/data/image-comment-at-char.odt
Binary files differ
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 4c5d6c417949..2969b5447675 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -533,6 +533,22 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testPasteListener)
CPPUNIT_ASSERT(pListener->GetString().isEmpty());
}
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testImageCommentAtChar)
+{
+ // Load a document with an at-char image in it (and a comment on the image).
+ load(mpTestDocumentPath, "image-comment-at-char.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+
+ // Verify that we have an annotation mark (comment with a text range) in the document.
+ // Without the accompanying fix in place, this test would have failed, as comments lost their
+ // ranges on load when their range only covered the placeholder character of the comment (which
+ // is also the anchor position of the image).
+ IDocumentMarkAccess* pMarks = pDoc->getIDocumentMarkAccess();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), pMarks->getAnnotationMarksCount());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */