Bugzilla – Attachment 173630 Details for
Bug 65535
Correcting a misspelled word with a comment in the middle erases the comment (see comment 38)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
0001-sw-spell-do-not-suggest-replacements-if-it-deletes-a.patch
0001-sw-spell-do-not-suggest-replacements-if-it-deletes-a.patch (text/plain), 4.82 KB, created by
Justin L
on 2021-07-16 11:13:15 UTC
(
hide
)
Description:
0001-sw-spell-do-not-suggest-replacements-if-it-deletes-a.patch
Filename:
MIME Type:
Creator:
Justin L
Created:
2021-07-16 11:13:15 UTC
Size:
4.82 KB
patch
obsolete
>From f656a3843d6d175d6431202f476ea46474e6acf8 Mon Sep 17 00:00:00 2001 >From: Justin Luth <justin_luth@sil.org> >Date: Fri, 16 Jul 2021 11:17:23 +0200 >Subject: [PATCH] sw spell: do not suggest replacements if it deletes an anchor > >Comments mid-word are anchored with CH_TXTATR_INWORD which is >of course ignored by the spell checker. But if the word is misspelled, >then the replacement word would delete the anchor and its contents. > >The easiet solution is to simply not provide any suggestions, >forcing the user to fix it manually. That's what I've done. >(But if the user "fixes" it in the spelling dialog, it >will bring about disaster still.) > >A (very) much harder solution would be to copy the anchor >(and all of its attributes) to the new word. > >Well, this one was hard enough to do, so I'll leave the tough >one for an expert to improve upon. > >Images/Frames have a similar problem, but they don't use a >CH_TXTATR_INWORD, and so they can't be handled in >exactly the same way. So probably better not to even >accept this patch, and just wait for it to be done right. > >Change-Id: I9d2f3789c4d554f4da2f8b40f2b712773f799498 >--- > .../source/spellcheck/spell/sspellimp.cxx | 16 ++++++++++++- > sw/source/core/txtnode/txtedt.cxx | 23 ++++++++++++++++++- > 2 files changed, 37 insertions(+), 2 deletions(-) > >diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx >index c4bb53aa14b3..4263ac6b8365 100644 >--- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx >+++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx >@@ -518,7 +518,21 @@ Reference< XSpellAlternatives > SAL_CALL SpellChecker::spell( > return nullptr; > > Reference< XSpellAlternatives > xAlt; >- if (!isValid( rWord, rLocale, rProperties )) >+ // A bit of a hack to allow a no-suggestion list when non-manual correction is dangerous. >+ // This re-uses a concept from elsewhere in spelling, but only a maxSuggestion of zero is used. >+ sal_Int16 nMaxSuggestions = -1; >+ const PropertyValue* pVal = std::find_if(rProperties.begin(), rProperties.end(), >+ [](const PropertyValue& rVal) { return UPN_MAX_NUMBER_OF_SUGGESTIONS == rVal.Name; }); >+ if (pVal != rProperties.end()) >+ pVal->Value >>= nMaxSuggestions; >+ >+ if (!nMaxSuggestions) >+ { >+ xAlt = SpellAlternatives::CreateSpellAlternatives(rWord, LinguLocaleToLanguage(rLocale), >+ SpellFailure::SPELLING_ERROR, >+ Sequence<OUString>(0)); >+ } >+ else if (!isValid(rWord, rLocale, rProperties)) > { > xAlt = GetProposals( rWord, rLocale ); > } >diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx >index 907214aea3fb..b5da6cdd6236 100644 >--- a/sw/source/core/txtnode/txtedt.cxx >+++ b/sw/source/core/txtnode/txtedt.cxx >@@ -26,6 +26,7 @@ > #include <editeng/fontitem.hxx> > #include <editeng/hangulhanja.hxx> > #include <i18nutil/transliteration.hxx> >+#include <linguistic/lngprops.hxx> > #include <SwSmartTagMgr.hxx> > #include <o3tl/safeint.hxx> > #include <osl/diagnose.h> >@@ -1028,9 +1029,29 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs) > { > if (pArgs->xSpeller.is()) > { >+ Sequence< PropertyValue > aPropVals(0); >+ // A bit of a hack - to force users to manually fix spelling of words that >+ // contain a comment in the middle of the word (which otherwise would be lost). >+ if (bContainsComments) >+ { >+ sal_Int32 nPosition = m_Text.indexOf(CH_TXTATR_INWORD, aScanner.GetBegin()); >+ while (nPosition != -1 && nPosition < aScanner.GetEnd()) >+ { >+ const SwTextAttr* pTextAttr = GetTextAttrForCharAt(nPosition); >+ if (pTextAttr && pTextAttr->Which() == RES_TXTATR_ANNOTATION) >+ { >+ aPropVals = Sequence<PropertyValue>(1); >+ aPropVals[0].Name = UPN_MAX_NUMBER_OF_SUGGESTIONS; >+ aPropVals[0].Value <<= sal_Int16(0); >+ break; >+ } >+ nPosition = m_Text.indexOf(CH_TXTATR_INWORD, nPosition + 1); >+ } >+ } >+ > SvxSpellWrapper::CheckSpellLang( pArgs->xSpeller, eActLang ); > pArgs->xSpellAlt = pArgs->xSpeller->spell( rWord, static_cast<sal_uInt16>(eActLang), >- Sequence< PropertyValue >() ); >+ aPropVals); > } > if( pArgs->xSpellAlt.is() ) > { >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 65535
:
80511
|
107675
|
107713
|
151919
|
152037
| 173630