sw/qa/extras/tiledrendering/data/findandreplaceincomments.odt |binary sw/qa/extras/tiledrendering/tiledrendering.cxx | 34 ++++++++++ sw/qa/extras/tiledrendering/tiledrenderingmodeltestbase.cxx | 7 ++ sw/source/core/crsr/viscrs.cxx | 11 --- 4 files changed, 42 insertions(+), 10 deletions(-)
New commits: commit 31168e9fe5e07a0ec6f3c3a164a94389ccf4ae1c Author: Gülşah Köse <gulsah.k...@collabora.com> AuthorDate: Thu Feb 13 18:51:13 2025 +0300 Commit: Gülşah Köse <gulsah.k...@collabora.com> CommitDate: Fri Feb 21 13:10:42 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181994 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 0f0cd9ed3403..345a902ad507 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -45,6 +45,8 @@ #include <unotools/mediadescriptor.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/scopeguard.hxx> +#include <unotools/searchopt.hxx> #include <drawdoc.hxx> #include <ndtxt.hxx> @@ -3920,6 +3922,38 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf159626_blackPatternFill) CPPUNIT_ASSERT(nPureBlackPixels / 10 > nEdgePlusWhitePlusAntialiasPixels); } +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/qa/extras/tiledrendering/tiledrenderingmodeltestbase.cxx b/sw/qa/extras/tiledrendering/tiledrenderingmodeltestbase.cxx index 0c7f1437b2d9..dbc781b90f43 100644 --- a/sw/qa/extras/tiledrendering/tiledrenderingmodeltestbase.cxx +++ b/sw/qa/extras/tiledrendering/tiledrenderingmodeltestbase.cxx @@ -40,6 +40,7 @@ protected: tools::Rectangle m_aInvalidation; /// Union of all invalidations. tools::Rectangle m_aInvalidations; + tools::Rectangle m_aCursorRectangle; Size m_aDocumentSize; OString m_aTextSelection; bool m_bFound; @@ -231,6 +232,12 @@ 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; diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index ad11b3a8294d..e492544a4805 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;