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>
This commit is contained in:
parent
5601c0845c
commit
c0a619aa94
2 changed files with 43 additions and 26 deletions
|
@ -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,8 +410,16 @@ 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)
|
||||
{
|
||||
OUString word = OUString(rRes.aText.subView(rError.nErrorStart, rError.nErrorLength));
|
||||
bool ignored = xIgnoreAll->getEntry(word).is();
|
||||
|
||||
if (!ignored)
|
||||
{
|
||||
text::TextMarkupDescriptor &rDesc = *pDescriptors++;
|
||||
|
||||
|
@ -425,24 +434,31 @@ void GrammarCheckingIterator::ProcessResult(
|
|||
if (rDesc.nType == text::TextMarkupType::SPELLCHECK)
|
||||
rDesc.nType = text::TextMarkupType::PROOFREADING;
|
||||
|
||||
uno::Reference< container::XStringKeyMap > xKeyMap(
|
||||
new LngXStringKeyMap());
|
||||
uno::Reference< container::XStringKeyMap > xKeyMap(new LngXStringKeyMap());
|
||||
for( const beans::PropertyValue& rProperty : rError.aProperties )
|
||||
{
|
||||
if ( rProperty.Name == "LineColor" )
|
||||
{
|
||||
xKeyMap->insertValue(rProperty.Name,
|
||||
rProperty.Value);
|
||||
xKeyMap->insertValue(rProperty.Name, rProperty.Value);
|
||||
rDesc.xMarkupInfoContainer = xKeyMap;
|
||||
}
|
||||
else if ( rProperty.Name == "LineType" )
|
||||
{
|
||||
xKeyMap->insertValue(rProperty.Name,
|
||||
rProperty.Value);
|
||||
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
|
||||
// nSentenceLength: includes the white-spaces following the sentence end...
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue