diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 301e1319c1d8..0734ba4cb7a2 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -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++; + OUString word = OUString(rRes.aText.subView(rError.nErrorStart, rError.nErrorLength)); + bool ignored = xIgnoreAll->getEntry(word).is(); - 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 ) + if (!ignored) { - if ( rProperty.Name == "LineColor" ) + 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; - } - else if ( rProperty.Name == "LineType" ) - { - 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 diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index ad9d47f4430f..4c77d614dbf3 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -2022,8 +2022,9 @@ void SwTextShell::Execute(SfxRequest &rReq) SwPaM *pPaM = rWrtSh.GetCursor(); if (pPaM) SwEditShell::IgnoreGrammarErrorAt( *pPaM ); - if (xDictionary.is()) + if (xDictionary.is() && pPaM) { + linguistic::AddEntryToDic( xDictionary, pPaM->GetText(), false, OUString() ); // refresh the layout of all paragraphs (workaround to launch a dictionary event) xDictionary->setActive(false); xDictionary->setActive(true);