summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/txtedt.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-12-11 19:33:13 +0100
committerLászló Németh <nemeth@numbertext.org>2022-12-13 14:41:41 +0000
commitec8fdffec29de7c80da0c2a440e467c35a297119 (patch)
tree95222302eb3361bb059942f5d46b53476c1da57f /sw/source/core/txtnode/txtedt.cxx
parent57e2245abf50cbd207d5c9c57ed67c055f8afcd6 (diff)
tdf#152492 sw: fix unwanted spell checking of parts of URLs
In new documents, spell checking started to report spelling mistakes within the recognized URLs. Regression from commit 2cca160f8bfc4597cf0ad3aaaf0017a5210ea0ec "tdf#126657, tdf#145104: Don’t set language to none on defined styles". Note: skipping spell checking of recognized URLs was specified by http://specs.openoffice.org/appwide/linguistic/Spellcheckdialog.sxw, see also https://bz.apache.org/ooo/show_bug.cgi?id=40133. Unfortunately, the original implementation caused possible regressions in text layout, so it was reverted in the previous commit. Change-Id: Ic5f84c8ec195677640a8870f2c484f3b6ef8b9db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143946 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/txtnode/txtedt.cxx')
-rw-r--r--sw/source/core/txtnode/txtedt.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 60c4685470dc..b0e0b0d4b6a6 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -992,12 +992,15 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs)
{
const OUString& rWord = aScanner.GetWord();
+ // skip URLs
+ bool bHyperlink = GetTextAttrAt(aScanner.GetBegin(), RES_TXTATR_INETFMT) ? true: false;
+
// get next language for next word, consider language attributes
// within the word
LanguageType eActLang = aScanner.GetCurrentLanguage();
DetectAndMarkMissingDictionaries( GetTextNode()->GetDoc(), pArgs->xSpeller, eActLang );
- if( rWord.getLength() > 0 && LANGUAGE_NONE != eActLang )
+ if( rWord.getLength() > 0 && LANGUAGE_NONE != eActLang && !bHyperlink )
{
if (pArgs->xSpeller.is())
{
@@ -1301,8 +1304,11 @@ SwRect SwTextFrame::AutoSpell_(SwTextNode & rNode, sal_Int32 nActPos)
LanguageType eActLang = aScanner.GetCurrentLanguage();
DetectAndMarkMissingDictionaries( rDoc, xSpell, eActLang );
+ // skip URLs
+ bool bHyperlink = pNode->GetTextAttrAt(nBegin, RES_TXTATR_INETFMT) ? true: false;
+
bool bSpell = xSpell.is() && xSpell->hasLanguage( static_cast<sal_uInt16>(eActLang) );
- if( bSpell && !rWord.isEmpty() )
+ if( bSpell && !rWord.isEmpty() && !bHyperlink )
{
// check for: bAlter => xHyphWord.is()
OSL_ENSURE(!bSpell || xSpell.is(), "NULL pointer");