summaryrefslogtreecommitdiff
path: root/sw/qa/extras/tiledrendering/tiledrendering.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/tiledrendering/tiledrendering.cxx')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index f5814504c16c..5851faa56534 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -100,6 +100,7 @@ public:
void testCreateViewTextSelection();
void testRedlineColors();
void testCommentEndTextEdit();
+ void testCommentInsert();
void testCursorPosition();
void testPaintCallbacks();
void testUndoRepairResult();
@@ -159,6 +160,7 @@ public:
CPPUNIT_TEST(testCreateViewTextSelection);
CPPUNIT_TEST(testRedlineColors);
CPPUNIT_TEST(testCommentEndTextEdit);
+ CPPUNIT_TEST(testCommentInsert);
CPPUNIT_TEST(testCursorPosition);
CPPUNIT_TEST(testPaintCallbacks);
CPPUNIT_TEST(testUndoRepairResult);
@@ -735,6 +737,8 @@ public:
boost::property_tree::ptree m_aRedlineTableChanged;
/// Redline table modified payload
boost::property_tree::ptree m_aRedlineTableModified;
+ /// Post-it / annotation payload.
+ boost::property_tree::ptree m_aComment;
ViewCallback(SfxViewShell* pViewShell, std::function<void(ViewCallback&)> const & rBeforeInstallFunc = {})
: m_bOwnCursorInvalidated(false),
@@ -882,6 +886,14 @@ public:
m_aRedlineTableModified = m_aRedlineTableModified.get_child("redline");
}
break;
+ case LOK_CALLBACK_COMMENT:
+ {
+ m_aComment.clear();
+ std::stringstream aStream(pPayload);
+ boost::property_tree::read_json(aStream, m_aComment);
+ m_aComment = m_aComment.get_child("comment");
+ }
+ break;
}
}
};
@@ -1641,6 +1653,40 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
}
+void SwTiledRenderingTest::testCommentInsert()
+{
+ // Load a document with an as-char image in it.
+ comphelper::LibreOfficeKit::setActive();
+ comphelper::LibreOfficeKit::setTiledAnnotations(false);
+ SwXTextDocument* pXTextDocument = createDoc("image-comment.odt");
+ SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
+ SwView* pView = pDoc->GetDocShell()->GetView();
+
+ // Select the image.
+ pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON);
+ // Make sure SwTextShell is replaced with SwDrawShell right now, not after 120 ms, as set in the
+ // SwView ctor.
+ pView->StopShellTimer();
+
+ // Add a comment.
+ uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame()->GetFrame().GetFrameInterface();
+ uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence(
+ {
+ {"Text", uno::makeAny(OUString("some text"))},
+ {"Author", uno::makeAny(OUString("me"))},
+ });
+ ViewCallback aView(SfxViewShell::Current());
+ comphelper::dispatchCommand(".uno:InsertAnnotation", xFrame, aPropertyValues);
+ Scheduler::ProcessEventsToIdle();
+ OString aAnchorPos(aView.m_aComment.get_child("anchorPos").get_value<std::string>().c_str());
+ // Without the accompanying fix in place, this test would have failed with
+ // - Expected: 1418, 1418, 0, 0
+ // - Actual : 1418, 1418, 1024, 1024
+ // i.e. the anchor position was a non-empty rectangle.
+ CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 0"), aAnchorPos);
+ comphelper::LibreOfficeKit::setTiledAnnotations(true);
+}
+
void SwTiledRenderingTest::testCursorPosition()
{
// Load a document and register a callback, should get an own cursor.