[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 2 14:16:00 UTC 2019


 sw/qa/extras/tiledrendering/data/image-comment.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx     |   46 +++++++++++++++++++++
 sw/source/uibase/docvw/PostItMgr.cxx               |    9 +++-
 3 files changed, 54 insertions(+), 1 deletion(-)

New commits:
commit 225930119543975697d3f5f042e271f0ec6c6b15
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Aug 2 12:31:00 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Aug 2 16:15:02 2019 +0200

    sw comments on frames: no overlay in the LOK API, either: insert case
    
    This is similar to commit 28fcb7d86765194b4015e7023449333f43aba0c5 (sw
    comments on frames: no overlay in the LOK API, either, 2019-07-16), but
    that one handled the initial fetch of comment states, while this one
    does the incremental updates.
    
    With this, there is no overlay on commented images right after inserting
    them.
    
    Change-Id: I060303806a6611b113b4813300ed1cafd0b654fa
    Reviewed-on: https://gerrit.libreoffice.org/76859
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

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
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/image-comment.odt 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())
             {


More information about the Libreoffice-commits mailing list