diff options
author | Gökay Şatır <gokaysatir@collabora.com> | 2023-11-22 12:15:31 +0300 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-09 09:32:25 +0100 |
commit | 7a179efac47776df917b7e8e18f9d91973c485db (patch) | |
tree | a8c77c71d2226521c61369f80e2e34069adeb401 /linguistic/source | |
parent | cf767af8de12157155eaf525ee845b196826aeb9 (diff) |
tdf#150716 - Partially solves the issue.
This PR fixes the IgnoreAll issue. "Ignore" functionality needs another PR.
Grammar checker and spell checker have different implementations. IgnoreAll functionality is implemented for spell checker but not grammar checker.
This PR implements IgnoreAll for grammar checkers.
Note: Ignore All function is valid per editing session. The ignored words is reset after the session is closed.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
Change-Id: I7c2b77b18e0a26a6a1c5fa9e8e66075a34612884
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159813
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit c0a619aa945c852652dc353dbe4c42cabbc2b779)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161699
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'linguistic/source')
-rw-r--r-- | linguistic/source/gciterator.cxx | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 2ef50fbeab27..2f1232289c10 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/linguistic2/XDictionary.hpp> #include <com/sun/star/linguistic2/XSupportedLocales.hpp> #include <com/sun/star/linguistic2/XProofreader.hpp> #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> @@ -409,39 +410,54 @@ void GrammarCheckingIterator::ProcessResult( uno::Sequence< text::TextMarkupDescriptor > aDescriptors( nErrors + 1 ); text::TextMarkupDescriptor * pDescriptors = aDescriptors.getArray(); + uno::Reference< linguistic2::XDictionary > xIgnoreAll = ::GetIgnoreAllList(); + sal_Int32 ignoredCount = 0; + // at pos 0 .. nErrors-1 -> all grammar errors for (const linguistic2::SingleProofreadingError &rError : rRes.aErrors) { - text::TextMarkupDescriptor &rDesc = *pDescriptors++; - - rDesc.nType = rError.nErrorType; - rDesc.nOffset = rError.nErrorStart; - rDesc.nLength = rError.nErrorLength; - - // the proofreader may return SPELLING but right now our core - // does only handle PROOFREADING if the result is from the proofreader... - // (later on we may wish to color spelling errors found by the proofreader - // differently for example. But no special handling right now. - if (rDesc.nType == text::TextMarkupType::SPELLCHECK) - rDesc.nType = text::TextMarkupType::PROOFREADING; - - uno::Reference< container::XStringKeyMap > xKeyMap( - new LngXStringKeyMap()); - for( const beans::PropertyValue& rProperty : rError.aProperties ) + OUString word(rRes.aText.subView(rError.nErrorStart, rError.nErrorLength)); + bool ignored = xIgnoreAll->getEntry(word).is(); + + if (!ignored) { - if ( rProperty.Name == "LineColor" ) - { - xKeyMap->insertValue(rProperty.Name, - rProperty.Value); - rDesc.xMarkupInfoContainer = xKeyMap; - } - else if ( rProperty.Name == "LineType" ) + text::TextMarkupDescriptor &rDesc = *pDescriptors++; + + rDesc.nType = rError.nErrorType; + rDesc.nOffset = rError.nErrorStart; + rDesc.nLength = rError.nErrorLength; + + // the proofreader may return SPELLING but right now our core + // does only handle PROOFREADING if the result is from the proofreader... + // (later on we may wish to color spelling errors found by the proofreader + // differently for example. But no special handling right now. + if (rDesc.nType == text::TextMarkupType::SPELLCHECK) + rDesc.nType = text::TextMarkupType::PROOFREADING; + + uno::Reference< container::XStringKeyMap > xKeyMap(new LngXStringKeyMap()); + for( const beans::PropertyValue& rProperty : rError.aProperties ) { - xKeyMap->insertValue(rProperty.Name, - rProperty.Value); - rDesc.xMarkupInfoContainer = xKeyMap; + if ( rProperty.Name == "LineColor" ) + { + xKeyMap->insertValue(rProperty.Name, rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } + else if ( rProperty.Name == "LineType" ) + { + xKeyMap->insertValue(rProperty.Name, rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } } } + else + ignoredCount++; + } + + if (ignoredCount != 0) + { + aDescriptors.realloc(aDescriptors.getLength() - ignoredCount); + pDescriptors = aDescriptors.getArray(); + pDescriptors += aDescriptors.getLength() - 1; } // at pos nErrors -> sentence markup |