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 <jluth@mail.com>
(cherry picked from commit 57cdbd3b8195a6dcf5a5d35d99d3801c419d56a6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161097
diff --git a/sw/CppunitTest_sw_uiwriter9.mk b/sw/CppunitTest_sw_uiwriter9.mk
new file mode 100644
index 0000000..6b770c4
--- /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 00847e8..85d36b1 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 0000000..2ee0437
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf158785_hyperlink.fodt
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<office:document  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
 <office:body>
  <office:text>
   <text:p>–<text:a xlink:type="simple" xlink:href="http://www.dordt.edu/">www.dordt.edu</text:a>–</text:p>
  </office:text>
 </office:body>
</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx
new file mode 100644
index 0000000..b6dea5a
--- /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 <swmodeltestbase.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/scheduler.hxx>
#include <com/sun/star/table/TableBorder2.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <comphelper/propertysequence.hxx>
#include <swdtflvr.hxx>
#include <o3tl/string_view.hxx>

#include <view.hxx>
#include <wrtsh.hxx>
#include <unotxdoc.hxx>
#include <ndtxt.hxx>
#include <toxmgr.hxx>
#include <IDocumentFieldsAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <fmtinfmt.hxx>

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 acee839..db11d4e 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() )
                {