summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-06-18 17:44:33 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-06-18 19:11:50 +0200
commit351b9aefe3de7c68e907fdc7926d9b508560320e (patch)
treea3ad7ec7fa6953ab51b287106992683056459c9c /sw/qa/extras/uiwriter
parentf251111195a73b1574976c0446910e8da397089a (diff)
sw: implement inserting comments when an as-char image is selected
Only the UI was missing in this case: creating a text selection around the placeholder character does what the user expects. Change-Id: I1068fcee3e3b6d0a6fa47b37beb1bd1b918a82df Reviewed-on: https://gerrit.libreoffice.org/74297 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/data2/image-comment.odtbin0 -> 9847 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx32
2 files changed, 32 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/image-comment.odt b/sw/qa/extras/uiwriter/data2/image-comment.odt
new file mode 100644
index 000000000000..4f0a520bcca3
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/image-comment.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index b283af27b24c..4da4123e3322 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -27,8 +27,12 @@
#include <itabenum.hxx>
#include <fmtfsize.hxx>
#include <xmloff/odffields.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
#include <txtfrm.hxx>
#include <redline.hxx>
+#include <view.hxx>
+#include <cmdid.h>
#include <com/sun/star/style/BreakType.hpp>
namespace
@@ -1357,4 +1361,32 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125310b)
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment)
+{
+ // Load a document with an as-char image in it.
+ SwDoc* pDoc = createDoc("image-comment.odt");
+ SwView* pView = pDoc->GetDocShell()->GetView();
+
+ // Select the image.
+ pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON);
+
+ // Insert a comment while the image is selected.
+ pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT, SfxCallMode::SYNCHRON);
+
+ // Verify that the comment is around the image.
+ // Without the accompanying fix in place, this test would have failed, as FN_POSTIT was disabled
+ // in the frame shell.
+ uno::Reference<text::XTextRange> xPara = getParagraph(1);
+ CPPUNIT_ASSERT_EQUAL(OUString("Text"),
+ getProperty<OUString>(getRun(xPara, 1), "TextPortionType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Annotation"),
+ getProperty<OUString>(getRun(xPara, 2), "TextPortionType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Frame"),
+ getProperty<OUString>(getRun(xPara, 3), "TextPortionType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"),
+ getProperty<OUString>(getRun(xPara, 4), "TextPortionType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Text"),
+ getProperty<OUString>(getRun(xPara, 5), "TextPortionType"));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */