summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/tiledrendering/data/image-comment.odtbin0 -> 9765 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx46
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx9
3 files changed, 54 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/data/image-comment.odt b/sw/qa/extras/tiledrendering/data/image-comment.odt
new file mode 100644
index 000000000000..0852bedabf7f
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/image-comment.odt
Binary files differ
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.
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 3e7f48844fae..48121d7d8dd5 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -155,10 +155,17 @@ namespace {
const SwPostItField* pField = pWin->GetPostItField();
const SwRect& aRect = pWin->GetAnchorRect();
- const tools::Rectangle aSVRect(aRect.Pos().getX(),
+ tools::Rectangle aSVRect(aRect.Pos().getX(),
aRect.Pos().getY(),
aRect.Pos().getX() + aRect.SSize().Width(),
aRect.Pos().getY() + aRect.SSize().Height());
+
+ if (!pItem->maLayoutInfo.mPositionFromCommentAnchor)
+ {
+ // Comments on frames: anchor position is the corner position, not the whole frame.
+ aSVRect.SetSize(Size(0, 0));
+ }
+
std::vector<OString> aRects;
for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
{