sw/qa/extras/tiledrendering/data/findandreplaceincomments.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx                |   39 ++++++++++
 sw/source/core/crsr/viscrs.cxx                                |   11 --
 3 files changed, 40 insertions(+), 10 deletions(-)

New commits:
commit c7e44b695bf5653ce676231ba1ffd770d1a72018
Author:     Gülşah Köse <gulsah.k...@collabora.com>
AuthorDate: Thu Feb 13 18:51:13 2025 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Feb 21 11:38:47 2025 +0100

    cool#11216 Remove unnecessary control to invalidate cursor
    
    bPostItActive control is introduced by 
b9cc6653606c829805c6c01b9613a3a25d81c20b
    Then new annotation changes introduced by 
69c546e1e7a697217f273baa7c1729ff823efd76
    makes this control unnecessary so removed the test 
testWriterCommentInsertCursor
    introduced in first commit.
    
    To keep that control makes buggy finding text via "Find and Replace"
    dialog in comments. It never moves the visible cursor if the text
    matches only in comments
    
    Now it fixed.
    
    Signed-off-by: Gülşah Köse <gulsah.k...@collabora.com>
    Change-Id: Ice60b4de2ae65c400b49153c3a0a4f3cccb7ad87
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181634
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/tiledrendering/data/findandreplaceincomments.odt 
b/sw/qa/extras/tiledrendering/data/findandreplaceincomments.odt
new file mode 100644
index 000000000000..a34186b43eea
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/findandreplaceincomments.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9de9f6706dc4..d90b2b15efe8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -58,6 +58,7 @@
 #include <test/lokcallback.hxx>
 #include <sfx2/msgpool.hxx>
 #include <comphelper/scopeguard.hxx>
+#include <unotools/searchopt.hxx>
 
 #include <drawdoc.hxx>
 #include <ndtxt.hxx>
@@ -116,6 +117,7 @@ protected:
     int m_nRedlineTableEntryModified;
     int m_nTrackedChangeIndex;
     bool m_bFullInvalidateSeen;
+    tools::Rectangle m_aCursorRectangle;
     OString m_sHyperlinkText;
     OString m_sHyperlinkLink;
     OString m_aFormFieldButton;
@@ -295,6 +297,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const 
char* pPayload)
                     boost::property_tree::ptree &aChild = 
aTree.get_child("hyperlink");
                     m_sHyperlinkText = OString(aChild.get("text", ""));
                     m_sHyperlinkLink = OString(aChild.get("link", ""));
+
+                    OString 
aRectangle(aTree.get_child("rectangle").get_value<std::string>());
+                    uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::fromUtf8(aRectangle));
+                    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), 
aSeq.getLength());
+                    m_aCursorRectangle = 
tools::Rectangle(Point(aSeq[0].toInt32(), aSeq[1].toInt32()), 
Size(aSeq[2].toInt32(), aSeq[3].toInt32()));
                 }
             }
             break;
@@ -4780,6 +4787,38 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testLoadVisibleArea)
     CPPUNIT_ASSERT(pPage3->IsInvalidContent());
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testFindAndReplaceInComments)
+{
+    comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
+    SvtSearchOptions aSearchOpt;
+    aSearchOpt.SetNotes(true);
+    aSearchOpt.Commit();
+    comphelper::ScopeGuard g([] {
+            
comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(false);
+            SvtSearchOptions aOpt;
+            aOpt.SetNotes(false);
+            aOpt.Commit();
+            });
+
+    SwXTextDocument* pXTextDocument = 
createDoc("findandreplaceincomments.odt");
+    CPPUNIT_ASSERT(pXTextDocument);
+
+    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    Scheduler::ProcessEventsToIdle();
+    setupLibreOfficeKitViewCallback(pWrtShell->GetSfxViewShell());
+
+    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence({
+        { "SearchItem.SearchString", uno::Any(OUString("test")) },
+    }));
+    comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected greater than: 2000 (2108)
+    // - Actual  : 1418
+    CPPUNIT_ASSERT_GREATER(static_cast<tools::Long>(2000), 
m_aCursorRectangle.getY());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 2226e77d96ae..343d4e71ff21 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -208,18 +208,9 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * 
pViewShell)
     bool bIsCursorPosChanged = m_aTextCursor.GetPos() != aRect.Pos();
 
     m_aTextCursor.SetSize( aRect.SSize() );
-
     m_aTextCursor.SetPos( aRect.Pos() );
 
-    bool bPostItActive = false;
-    SwView* pView = dynamic_cast<SwView*>(m_pCursorShell->GetSfxViewShell());
-    if (pView)
-    {
-        if (SwPostItMgr* pPostItMgr = pView->GetPostItMgr())
-            bPostItActive = pPostItMgr->GetActiveSidebarWin() != nullptr;
-    }
-
-    if (comphelper::LibreOfficeKit::isActive() && !bPostItActive)
+    if (comphelper::LibreOfficeKit::isActive())
     {
         // notify about page number change (if that happened)
         sal_uInt16 nPage, nVirtPage;

Reply via email to