summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/textsh1.cxx
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-11-16 15:17:57 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-11-23 15:38:43 +0100
commit4fa12ed8fee1f69ecf999ee334721772422a6456 (patch)
tree0f277b68866a5c30d74c5f5646448e25744833df /sw/source/uibase/shells/textsh1.cxx
parent816f7c4bbb9ecd2c0fca68e8fc7a276b7e793153 (diff)
SpellingPopup: Convert "IgnoreAll" menu item to use a slot ID (grammar).
When the popup is in grammar mode. "IgnoreAll_Grammar" rule triggers this method. When openning the spelling popup we have the suspicious text selected, so we don't need the mouse position to apply the changes. I updated GetGrammarCorrection() method accordingly. Change-Id: Iaf86544ea5f7dbc4afa2889772a5a38c5fd5707e
Diffstat (limited to 'sw/source/uibase/shells/textsh1.cxx')
-rw-r--r--sw/source/uibase/shells/textsh1.cxx41
1 files changed, 38 insertions, 3 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index fc940da44737..510c25432e32 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -103,6 +103,8 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
+#include <com/sun/star/linguistic2/XDictionary.hpp>
#include <editeng/unolingu.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <doc.hxx>
@@ -1437,19 +1439,52 @@ void SwTextShell::Execute(SfxRequest &rReq)
sApplyText = pItem2->GetValue();
const OUString sIgnoreString("Ignore");
- //const OUString sIgnoreAllPrefix("IgnoreAll_");
+ const OUString sIgnoreAllPrefix("IgnoreAll_");
//const OUString sSpellingRule("Spelling");
- //const OUString sGrammarRule("Grammar");
+ const OUString sGrammarRule("Grammar");
//const OUString aReplacePrefix("Replace_");
// Ignore the word at the cursor pos
- //sal_Int32 nPos = 0;
+ sal_Int32 nPos = 0;
if (sApplyText == sIgnoreString)
{
SwPaM *pPaM = rWrtSh.GetCursor();
if (pPaM)
SwEditShell::IgnoreGrammarErrorAt( *pPaM );
}
+ // Ignore all similar items as the current word
+ else if (-1 != (nPos = sApplyText.indexOf( sIgnoreAllPrefix )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sIgnoreAllPrefix.getLength(), "");
+ if(sApplyText == sGrammarRule)
+ {
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
+ SwRect aToFill;
+ bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ if(bCorrectionRes)
+ {
+ try{
+ uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
+ aGrammarCheckRes.xProofreader->ignoreRule(
+ aGrammarCheckRes.aErrors[ nErrorInResult ].aRuleIdentifier,
+ aGrammarCheckRes.aLocale );
+ // refresh the layout of the actual paragraph (faster)
+ SwPaM *pPaM = rWrtSh.GetCursor();
+ if (pPaM)
+ SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+ // refresh the layout of all paragraphs (workaround to launch a dictionary event)
+ xDictionary->setActive(false);
+ xDictionary->setActive(true);
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+ }
}
break;
default: