From 9b32a016e36fd00c94e17bb5062cf33376d3df3d Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 19 Dec 2023 16:20:25 -0500 Subject: [PATCH] tdf#158785 partial revert "enable hyperlink to be detected ... at the end of text" This reverts lpranam's 7.2.0 regressive commit 3233db0913193855285e1f56492d4617368441b6. The character after a hyperlink should not offer to CTRL-click or jump to the hyperlink target. make CppunitTest_sw_uiwriter9 CPPUNIT_TEST_NAME=testTdf158785 Change-Id: I3f5398cc3a4f29ddf1c50764c311046713d39439 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161042 Tested-by: Jenkins Reviewed-by: Justin Luth --- sw/CppunitTest_sw_uiwriter9.mk | 14 ++++ sw/Module_sw.mk | 1 + .../uiwriter/data/tdf158785_hyperlink.fodt | 10 +++ sw/qa/extras/uiwriter/uiwriter9.cxx | 74 +++++++++++++++++++ sw/source/core/crsr/crstrvl.cxx | 2 - 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 sw/CppunitTest_sw_uiwriter9.mk create mode 100644 sw/qa/extras/uiwriter/data/tdf158785_hyperlink.fodt create mode 100644 sw/qa/extras/uiwriter/uiwriter9.cxx diff --git a/sw/CppunitTest_sw_uiwriter9.mk b/sw/CppunitTest_sw_uiwriter9.mk new file mode 100644 index 000000000000..6b770c4d20da --- /dev/null +++ b/sw/CppunitTest_sw_uiwriter9.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call sw_uiwriter_test,9)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 00847e8aeac5..85d36b1ab514 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -123,6 +123,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uiwriter6 \ CppunitTest_sw_uiwriter7 \ CppunitTest_sw_uiwriter8 \ + CppunitTest_sw_uiwriter9 \ CppunitTest_sw_layoutwriter \ CppunitTest_sw_layoutwriter2 \ CppunitTest_sw_layoutwriter3 \ diff --git a/sw/qa/extras/uiwriter/data/tdf158785_hyperlink.fodt b/sw/qa/extras/uiwriter/data/tdf158785_hyperlink.fodt new file mode 100644 index 000000000000..2ee043781a2c --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf158785_hyperlink.fodt @@ -0,0 +1,10 @@ + + + + + + www.dordt.edu + + + diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx new file mode 100644 index 000000000000..b6dea5a8e798 --- /dev/null +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +class SwUiWriterTest9 : public SwModelTestBase +{ +public: + SwUiWriterTest9() + : SwModelTestBase("/sw/qa/extras/uiwriter/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf158785) +{ + // given a document with a hyperlink surrounded by N-dashes (–www.dordt.edu–) + createSwDoc("tdf158785_hyperlink.fodt"); + SwDoc& rDoc = *getSwDoc(); + SwWrtShell* pWrtShell = rDoc.GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + // go to the end of the hyperlink + pWrtShell->SttEndDoc(/*bStart=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + // get last point that will be part of the hyperlink (current position 1pt wide). + Point aLogicL(pWrtShell->GetCharRect().Center()); + Point aLogicR(aLogicL); + + // sanity check - we really are right by the hyperlink + aLogicL.AdjustX(-1); + SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr); + pWrtShell->GetContentAtPos(aLogicL, aContentAtPos); + CPPUNIT_ASSERT_EQUAL(IsAttrAtPos::InetAttr, aContentAtPos.eContentAtPos); + + // The test: the position of the N-dash should not indicate hyperlink properties + // cursor pos would NOT be considered part of the hyperlink, but increase for good measure... + aLogicR.AdjustX(1); + pWrtShell->GetContentAtPos(aLogicR, aContentAtPos); + CPPUNIT_ASSERT_EQUAL(IsAttrAtPos::NONE, aContentAtPos.eContentAtPos); +} + +} // end of anonymouse namespace +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index acee83905967..db11d4ea334a 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1793,8 +1793,6 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt, sal_Int32 index = aPos.GetContentIndex(); pTextAttr = pTextNd->GetTextAttrAt(index, RES_TXTATR_INETFMT); - if(!pTextAttr && index > 0) - pTextAttr = pTextNd->GetTextAttrAt(index - 1, RES_TXTATR_INETFMT); // "detect" only INetAttrs with URLs if( pTextAttr && !pTextAttr->GetINetFormat().GetValue().isEmpty() ) {