include/svx/svxids.hrc                                               |    4 
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |   14 
 svx/sdi/svx.sdi                                                      |   36 +
 sw/sdi/_textsh.sdi                                                   |   14 
 sw/source/uibase/inc/olmenu.hxx                                      |    3 
 sw/source/uibase/lingu/olmenu.cxx                                    |   74 +++
 sw/source/uibase/shells/textsh1.cxx                                  |  197 
+++++-----
 sw/source/uibase/uiview/viewling.cxx                                 |   21 -
 8 files changed, 269 insertions(+), 94 deletions(-)

New commits:
commit 6564a1ab1e873cbc9e36f7f301d4a3c14d86861e
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Mon Nov 18 19:15:07 2019 +0100
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Sun Nov 24 12:17:41 2019 +0100

    SpellingPopup: Create separate SID for Ignore / IgnoreAll / suggestion.
    
    Change-Id: I20f41f511ea38f960f081f92bc36e095f7752d28
    Reviewed-on: https://gerrit.libreoffice.org/83599
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>
    Tested-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 6e9cd310f9ad..2842dcf5a77f 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -355,7 +355,9 @@ class SvxSetItem;
 #define SID_SPELL_DIALOG                                ( SID_SVX_START + 243 )
 #define SID_INSERT_DRAW                                 ( SID_SVX_START + 244 )
 #define SID_THESAURUS                                   ( SID_SVX_START + 245 )
-#define SID_APPLY_SPELLCHECKING                         ( SID_SVX_START + 246 )
+#define SID_SPELLCHECK_IGNORE                           ( SID_SVX_START + 246 )
+#define SID_SPELLCHECK_IGNORE_ALL                       ( SID_SVX_START + 247 )
+#define SID_SPELLCHECK_APPLY_SUGGESTION                 ( SID_SVX_START + 248 )
 
 // CAUTION! Range <250 .. 250> used by EditEngine (!)
 
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index aa5173877eae..75a6a98c62a2 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2678,9 +2678,19 @@
           <value xml:lang="en-US">Language Status</value>
         </prop>
       </node>
-      <node oor:name=".uno:ApplySpellChecking" oor:op="replace">
+      <node oor:name=".uno:SpellCheckIgnore" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Apply Spell Checking</value>
+          <value xml:lang="en-US">Ignore</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SpellCheckIgnoreAll" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">IgnoreAll</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SpellCheckApplySuggestion" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Apply Suggestion</value>
         </prop>
       </node>
       <node oor:name=".uno:ChooseControls" oor:op="replace">
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index d417b2ef9967..d191813d3ca6 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12170,7 +12170,41 @@ SfxVoidItem EditQrCode SID_EDIT_QRCODE
     GroupId = SfxGroupId::Edit;
 ]
 
-SfxVoidItem ApplySpellChecking SID_APPLY_SPELLCHECKING
+SfxVoidItem SpellCheckIgnore SID_SPELLCHECK_IGNORE
+(SfxStringItem Type FN_PARAM_1)
+[
+    AutoUpdate = FALSE,
+    FastCall = TRUE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = SfxGroupId::Format;
+]
+
+SfxVoidItem SpellCheckIgnoreAll SID_SPELLCHECK_IGNORE_ALL
+(SfxStringItem Type FN_PARAM_1)
+[
+    AutoUpdate = FALSE,
+    FastCall = TRUE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = SfxGroupId::Format;
+]
+
+SfxVoidItem SpellCheckApplySuggestion SID_SPELLCHECK_APPLY_SUGGESTION
 (SfxStringItem ApplyRule FN_PARAM_1)
 [
     AutoUpdate = FALSE,
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 94bcc81cd5ac..102699cbad19 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1740,7 +1740,19 @@ interface BaseText
         StateMethod = GetState ;
     ]
 
-    SID_APPLY_SPELLCHECKING
+    SID_SPELLCHECK_IGNORE
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState ;
+    ]
+
+    SID_SPELLCHECK_IGNORE_ALL
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState ;
+    ]
+
+    SID_SPELLCHECK_APPLY_SUGGESTION
     [
         ExecMethod = Execute ;
         StateMethod = GetState ;
diff --git a/sw/source/uibase/lingu/olmenu.cxx 
b/sw/source/uibase/lingu/olmenu.cxx
index e09589de550b..ac0fad353974 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -599,21 +599,22 @@ void SwSpellPopup::InitItemCommands(const 
css::uno::Sequence< OUString >& aSugge
 {
     if (comphelper::LibreOfficeKit::isActive())
     {
+        // None is added only for LOK, it means there is no need to execute 
anything
         m_xPopupMenu->SetItemCommand(MN_SHORT_COMMENT, ".uno:None");
         m_xPopupMenu->SetItemCommand(m_nSpellDialogId, 
".uno:SpellingAndGrammarDialog");
         if(m_bGrammarResults)
-            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Grammar");
+            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:SpellCheckIgnoreAll?Type:string=Grammar");
         else
-            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Spelling");
+            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:SpellCheckIgnoreAll?Type:string=Spelling");
         if(m_bGrammarResults)
-            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:ApplySpellChecking?ApplyRule:string=Ignore_Grammar");
+            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:SpellCheckIgnore?Type:string=Grammar");
         else
-            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:ApplySpellChecking?ApplyRule:string=Ignore_Spelling");
+            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:SpellCheckIgnore?Type:string=Spelling");
 
         for(int i = 0; i < aSuggestions.getLength(); ++i)
         {
             sal_uInt16 nItemId = MN_SUGGESTION_START + i;
-            OUString sCommandString = 
OUString(".uno:ApplySpellChecking?ApplyRule:string=Replace_");
+            OUString sCommandString = 
OUString(".uno:SpellCheckApplySuggestion?ApplyRule:string=");
             if(m_bGrammarResults)
                 sCommandString += "Grammar_";
             else if (m_xSpellAlt.is())
@@ -706,7 +707,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
 
     if (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END)
     {
-        OUString sApplyRule("Replace_");
+        OUString sApplyRule("");
         if(m_bGrammarResults)
             sApplyRule += "Grammar_";
         else if (m_xSpellAlt.is())
@@ -714,7 +715,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
         sApplyRule += m_xPopupMenu->GetItemText(nId);
 
         SfxStringItem aApplyItem(FN_PARAM_1, sApplyRule);
-        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING,
 SfxCallMode::SYNCHRON, { &aApplyItem });
+        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_APPLY_SUGGESTION,
 SfxCallMode::SYNCHRON, { &aApplyItem });
     }
     else if(MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
     {
@@ -788,13 +789,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
     }
     else if (nId == MN_IGNORE_SELECTION)
     {
-        SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? 
OUString("Ignore_Grammar") : OUString("Ignore_Spelling"));
-        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING,
 SfxCallMode::SYNCHRON, { &aIgnoreString });
+        SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? 
OUString("Grammar") : OUString("Spelling"));
+        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE,
 SfxCallMode::SYNCHRON, { &aIgnoreString });
     }
     else if (nId == m_nIgnoreWordId)
     {
-        SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? 
OUString("IgnoreAll_Grammar") : OUString("IgnoreAll_Spelling"));
-        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING,
 SfxCallMode::SYNCHRON, { &aIgnoreString });
+        SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? 
OUString("Grammar") : OUString("Spelling"));
+        
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE_ALL,
 SfxCallMode::SYNCHRON, { &aIgnoreString });
     }
     else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || 
nId == m_nAddId)
     {
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 30c5607e51b6..6cc1d1d7b0c8 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1434,55 +1434,57 @@ void SwTextShell::Execute(SfxRequest &rReq)
         }
     }
     break;
-    case SID_APPLY_SPELLCHECKING:
+    case SID_SPELLCHECK_IGNORE:
     {
-        OUString sApplyText;
-        const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
-        if (pItem2)
-            sApplyText = pItem2->GetValue();
+        // If there is not selection, we need to create one, before ignoring
+        if(!rWrtSh.HasSelection())
+        {
+            OUString sApplyText;
+            const SfxStringItem* pItem2 = 
rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+            if (pItem2)
+                sApplyText = pItem2->GetValue();
 
-        const OUString sIgnorePrefix("Ignore_");
-        const OUString sIgnoreAllPrefix("IgnoreAll_");
-        const OUString sSpellingRule("Spelling");
-        const OUString sGrammarRule("Grammar");
-        const OUString aReplacePrefix("Replace_");
+            const OUString sGrammarType("Grammar");
+            const OUString sSpellingType("Spelling");
 
-        // Ignore the word at the cursor pos
-        sal_Int32 nPos = 0;
-        if (-1 != (nPos = sApplyText.indexOf( sIgnorePrefix )))
-        {
-            if(!rWrtSh.HasSelection())
+            if (sApplyText == sGrammarType)
             {
-                sApplyText = sApplyText.replaceAt(nPos, 
sIgnorePrefix.getLength(), "");
-                if (-1 != (nPos = sApplyText.indexOf( 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)
-                        return;
-                }
-                else
-                {
-                    SwRect aToFill;
-                    uno::Reference< linguistic2::XSpellAlternatives >  
xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
-                    if (!xSpellAlt.is())
-                        return;
-                }
+                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)
+                    return;
+            }
+            else if (sApplyText == sSpellingType)
+            {
+                SwRect aToFill;
+                uno::Reference< linguistic2::XSpellAlternatives >  xSpellAlt( 
rWrtSh.GetCorrection(nullptr, aToFill) );
+                if (!xSpellAlt.is())
+                    return;
             }
-
-            SwPaM *pPaM = rWrtSh.GetCursor();
-            if (pPaM)
-                SwEditShell::IgnoreGrammarErrorAt( *pPaM );
         }
-        // Ignore all similar items as the current word
-        else if (-1 != (nPos = sApplyText.indexOf( sIgnoreAllPrefix )))
+
+        SwPaM *pPaM = rWrtSh.GetCursor();
+        if (pPaM)
+            SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+    }
+    break;
+    case SID_SPELLCHECK_IGNORE_ALL:
+    {
+        if(!rWrtSh.HasSelection())
         {
-            sApplyText = sApplyText.replaceAt(nPos, 
sIgnoreAllPrefix.getLength(), "");
-            if(sApplyText == sGrammarRule)
+            OUString sApplyText;
+            const SfxStringItem* pItem2 = 
rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+            if (pItem2)
+                sApplyText = pItem2->GetValue();
+
+            const OUString sGrammarType("Grammar");
+            const OUString sSpellingType("Spelling");
+
+            if(sApplyText == sGrammarType)
             {
                 linguistic2::ProofreadingResult aGrammarCheckRes;
                 sal_Int32 nErrorInResult = -1;
@@ -1510,7 +1512,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
                     }
                 }
             }
-            else if (sApplyText == sSpellingRule)
+            else if (sApplyText == sSpellingType)
             {
                 SwRect aToFill;
                 uno::Reference< linguistic2::XSpellAlternatives >  xSpellAlt( 
rWrtSh.GetCorrection(nullptr, aToFill) );
@@ -1524,95 +1526,100 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 }
             }
         }
-        // Replace text with the suggestion
-        else if (-1 != (nPos = sApplyText.indexOf( aReplacePrefix )))
-        {
-            sApplyText = sApplyText.replaceAt(nPos, 
aReplacePrefix.getLength(), "");
+    }
+    break;
+    case SID_SPELLCHECK_APPLY_SUGGESTION:
+    {
+        OUString sApplyText;
+        const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+        if (pItem2)
+            sApplyText = pItem2->GetValue();
+
+        const OUString sSpellingRule("Spelling_");
+        const OUString sGrammarRule("Grammar_");
 
-            const OUString sSpellingRule2(sSpellingRule + "_");
-            const OUString sGrammarRule2(sGrammarRule + "_");
-            bool bGrammar = false;
-            uno::Reference< linguistic2::XSpellAlternatives >  xSpellAlt;
-            if(-1 != (nPos = sApplyText.indexOf( sGrammarRule2 )))
+        bool bGrammar = false;
+        sal_Int32 nPos = 0;
+        uno::Reference< linguistic2::XSpellAlternatives >  xSpellAlt;
+        if(-1 != (nPos = sApplyText.indexOf( sGrammarRule )))
+        {
+            sApplyText = sApplyText.replaceAt(nPos, sGrammarRule.getLength(), 
"");
+            if(rWrtSh.HasSelection())
             {
-                sApplyText = sApplyText.replaceAt(nPos, 
sGrammarRule2.getLength(), "");
-                if(rWrtSh.HasSelection())
-                {
-                    bGrammar = true;
-                }
-                else
-                {
-                    linguistic2::ProofreadingResult aGrammarCheckRes;
-                    sal_Int32 nErrorInResult = -1;
-                    uno::Sequence< OUString > aSuggestions;
-                    sal_Int32 nErrorPosInText = -1;
-                    SwRect aToFill;
-                    bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, 
nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
-                }
+                bGrammar = true;
             }
-            else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule2 )))
+            else
             {
-                sApplyText = sApplyText.replaceAt(nPos, 
sSpellingRule2.getLength(), "");
+                linguistic2::ProofreadingResult aGrammarCheckRes;
+                sal_Int32 nErrorInResult = -1;
+                uno::Sequence< OUString > aSuggestions;
+                sal_Int32 nErrorPosInText = -1;
                 SwRect aToFill;
-                xSpellAlt.set(rWrtSh.GetCorrection(nullptr, aToFill));
-                bGrammar = false;
+                bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, 
nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
             }
+        }
+        else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
+        {
+            sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), 
"");
+            SwRect aToFill;
+            xSpellAlt.set(rWrtSh.GetCorrection(nullptr, aToFill));
+            bGrammar = false;
+        }
 
-            if (!bGrammar && !xSpellAlt.is())
-                return;
+        if (!bGrammar && !xSpellAlt.is())
+            return;
 
-            bool bOldIns = rWrtSh.IsInsMode();
-            rWrtSh.SetInsMode();
+        bool bOldIns = rWrtSh.IsInsMode();
+        rWrtSh.SetInsMode();
 
-            OUString aTmp( sApplyText );
-            OUString aOrig( bGrammar ? OUString() : xSpellAlt->getWord() );
+        OUString aTmp( sApplyText );
+        OUString aOrig( bGrammar ? OUString() : xSpellAlt->getWord() );
 
-            // if original word has a trailing . (likely the end of a sentence)
-            // and the replacement text hasn't, then add it to the replacement
-            if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
-                aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
-                !aTmp.endsWith("."))
-            {
-                aTmp += ".";
-            }
+        // if original word has a trailing . (likely the end of a sentence)
+        // and the replacement text hasn't, then add it to the replacement
+        if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
+            aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
+            !aTmp.endsWith("."))
+        {
+            aTmp += ".";
+        }
 
-            SwRewriter aRewriter;
+        SwRewriter aRewriter;
 
-            aRewriter.AddRule(UndoArg1, rWrtSh.GetCursorDescr());
-            aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
+        aRewriter.AddRule(UndoArg1, rWrtSh.GetCursorDescr());
+        aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
 
-            OUString aTmpStr = SwResId(STR_START_QUOTE) +
-                aTmp + SwResId(STR_END_QUOTE);
-            aRewriter.AddRule(UndoArg3, aTmpStr);
+        OUString aTmpStr = SwResId(STR_START_QUOTE) +
+            aTmp + SwResId(STR_END_QUOTE);
+        aRewriter.AddRule(UndoArg3, aTmpStr);
 
-            rWrtSh.StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
-            rWrtSh.StartAction();
-            rWrtSh.DelLeft();
+        rWrtSh.StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
+        rWrtSh.StartAction();
+        rWrtSh.DelLeft();
 
-            rWrtSh.Insert( aTmp );
+        rWrtSh.Insert( aTmp );
 
-            /* #102505# EndAction/EndUndo moved down since insertion
-               of temporary auto correction is now undoable two and
-               must reside in the same undo group.*/
+        /* #102505# EndAction/EndUndo moved down since insertion
+           of temporary auto correction is now undoable two and
+           must reside in the same undo group.*/
 
-            // record only if it's NOT already present in autocorrection
-            SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
+        // record only if it's NOT already present in autocorrection
+        SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
 
-            OUString aOrigWord( bGrammar ? OUString() : xSpellAlt->getWord() ) 
;
-            OUString aNewWord( sApplyText );
-            SvxPrepareAutoCorrect( aOrigWord, aNewWord );
+        OUString aOrigWord( bGrammar ? OUString() : xSpellAlt->getWord() ) ;
+        OUString aNewWord( sApplyText );
+        SvxPrepareAutoCorrect( aOrigWord, aNewWord );
 
-            if (xSpellAlt.is())
-                pACorr->PutText( aOrigWord, aNewWord, LanguageTag( 
xSpellAlt->getLocale() ).getLanguageType() );
+        if (xSpellAlt.is())
+            pACorr->PutText( aOrigWord, aNewWord, LanguageTag( 
xSpellAlt->getLocale() ).getLanguageType() );
 
-            /* #102505# EndAction/EndUndo moved down since insertion
-               of temporary auto correction is now undoable two and
-               must reside in the same undo group.*/
-            rWrtSh.EndAction();
-            rWrtSh.EndUndo();
+        /* #102505# EndAction/EndUndo moved down since insertion
+           of temporary auto correction is now undoable two and
+           must reside in the same undo group.*/
+        rWrtSh.EndAction();
+        rWrtSh.EndUndo();
 
-            rWrtSh.SetInsMode( bOldIns );
-        }
+        rWrtSh.SetInsMode( bOldIns );
     }
     break;
     default:
commit 3616bb68f247735c46c1a4cd9568775e77be6441
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Mon Nov 18 14:36:51 2019 +0100
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Sun Nov 24 12:17:30 2019 +0100

    SpellingPopup: lok: Replace the tunneled context menu.
    
    Send the menu structure instead using LOK_CALLBACK_CONTEXT_MENU.
    We need to set commands for menu items to make fillPopupMenu()
    method work.
    We also need to check whether there is any selection during execution
    of menu items. In case of LO core execution the suspicious text is
    selected, however in case of LO online, there is no selection.
    
    Change-Id: Id696ee9976d11f6b57e23a3bcc5b483a1d486639
    Reviewed-on: https://gerrit.libreoffice.org/83598
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>
    Tested-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx
index 984dfb759872..4b67c9090bce 100644
--- a/sw/source/uibase/inc/olmenu.hxx
+++ b/sw/source/uibase/inc/olmenu.hxx
@@ -126,6 +126,8 @@ public:
 
     ~SwSpellPopup();
 
+    void InitItemCommands(const css::uno::Sequence< OUString >& aSuggestions);
+
     PopupMenu& GetMenu()
     {
         return *m_xPopupMenu.get();
@@ -133,7 +135,6 @@ public:
 
     void Execute( const tools::Rectangle& rPopupPos, vcl::Window* pWin );
     void Execute( sal_uInt16 nId );
-
 };
 
 #endif
diff --git a/sw/source/uibase/lingu/olmenu.cxx 
b/sw/source/uibase/lingu/olmenu.cxx
index 566fb9b933d6..e09589de550b 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -422,6 +422,8 @@ SwSpellPopup::SwSpellPopup(
 
     checkRedline();
     m_xPopupMenu->RemoveDisabledEntries( true, true );
+
+    InitItemCommands(aSuggestions);
 }
 
 SwSpellPopup::SwSpellPopup(
@@ -587,10 +589,69 @@ SwSpellPopup::SwSpellPopup(
     {
         m_xPopupMenu->HideItem(MN_EXPLANATION_LINK);
     }
+
+    InitItemCommands(rSuggestions);
 }
 
 SwSpellPopup::~SwSpellPopup() {}
 
+void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& 
aSuggestions)
+{
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        m_xPopupMenu->SetItemCommand(MN_SHORT_COMMENT, ".uno:None");
+        m_xPopupMenu->SetItemCommand(m_nSpellDialogId, 
".uno:SpellingAndGrammarDialog");
+        if(m_bGrammarResults)
+            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Grammar");
+        else
+            m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, 
".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Spelling");
+        if(m_bGrammarResults)
+            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:ApplySpellChecking?ApplyRule:string=Ignore_Grammar");
+        else
+            m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, 
".uno:ApplySpellChecking?ApplyRule:string=Ignore_Spelling");
+
+        for(int i = 0; i < aSuggestions.getLength(); ++i)
+        {
+            sal_uInt16 nItemId = MN_SUGGESTION_START + i;
+            OUString sCommandString = 
OUString(".uno:ApplySpellChecking?ApplyRule:string=Replace_");
+            if(m_bGrammarResults)
+                sCommandString += "Grammar_";
+            else if (m_xSpellAlt.is())
+                sCommandString += "Spelling_";
+            sCommandString += m_xPopupMenu->GetItemText(nItemId);
+            m_xPopupMenu->SetItemCommand(nItemId, sCommandString);
+        }
+
+        PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
+        if(pMenu)
+        {
+            for (auto item : m_aLangTable_Text)
+            {
+                OUString sCommandString = 
OUString(".uno:LanguageStatus?Language:string=Current_") + item.second;
+                pMenu->SetItemCommand(item.first, sCommandString);
+            }
+
+            pMenu->SetItemCommand(MN_SET_SELECTION_NONE, 
".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE");
+            pMenu->SetItemCommand(MN_SET_SELECTION_RESET, 
".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES");
+            pMenu->SetItemCommand(MN_SET_SELECTION_MORE, 
".uno:FontDialog?Page:string=font");
+        }
+
+        pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
+        if(pMenu)
+        {
+            for (auto item : m_aLangTable_Paragraph)
+            {
+                OUString sCommandString = 
OUString(".uno:LanguageStatus?Language:string=Paragraph_") + item.second;
+                pMenu->SetItemCommand(item.first, sCommandString);
+            }
+
+            pMenu->SetItemCommand(MN_SET_PARA_NONE, 
".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE");
+            pMenu->SetItemCommand(MN_SET_PARA_RESET, 
".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES");
+            pMenu->SetItemCommand(MN_SET_PARA_MORE, 
".uno:FontDialogForParagraph");
+        }
+    }
+}
+
 void SwSpellPopup::checkRedline()
 {
     // Let SwView::GetState() already has the logic on when to disable the
@@ -727,7 +788,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
     }
     else if (nId == MN_IGNORE_SELECTION)
     {
-        SfxStringItem aIgnoreString(FN_PARAM_1, "Ignore");
+        SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? 
OUString("Ignore_Grammar") : OUString("Ignore_Spelling"));
         
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING,
 SfxCallMode::SYNCHRON, { &aIgnoreString });
     }
     else if (nId == m_nIgnoreWordId)
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 4db7fd030846..30c5607e51b6 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1441,7 +1441,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
         if (pItem2)
             sApplyText = pItem2->GetValue();
 
-        const OUString sIgnoreString("Ignore");
+        const OUString sIgnorePrefix("Ignore_");
         const OUString sIgnoreAllPrefix("IgnoreAll_");
         const OUString sSpellingRule("Spelling");
         const OUString sGrammarRule("Grammar");
@@ -1449,8 +1449,31 @@ void SwTextShell::Execute(SfxRequest &rReq)
 
         // Ignore the word at the cursor pos
         sal_Int32 nPos = 0;
-        if (sApplyText == sIgnoreString)
+        if (-1 != (nPos = sApplyText.indexOf( sIgnorePrefix )))
         {
+            if(!rWrtSh.HasSelection())
+            {
+                sApplyText = sApplyText.replaceAt(nPos, 
sIgnorePrefix.getLength(), "");
+                if (-1 != (nPos = sApplyText.indexOf( 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)
+                        return;
+                }
+                else
+                {
+                    SwRect aToFill;
+                    uno::Reference< linguistic2::XSpellAlternatives >  
xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
+                    if (!xSpellAlt.is())
+                        return;
+                }
+            }
+
             SwPaM *pPaM = rWrtSh.GetCursor();
             if (pPaM)
                 SwEditShell::IgnoreGrammarErrorAt( *pPaM );
@@ -1513,12 +1536,19 @@ void SwTextShell::Execute(SfxRequest &rReq)
             if(-1 != (nPos = sApplyText.indexOf( sGrammarRule2 )))
             {
                 sApplyText = sApplyText.replaceAt(nPos, 
sGrammarRule2.getLength(), "");
-                linguistic2::ProofreadingResult aGrammarCheckRes;
-                sal_Int32 nErrorInResult = -1;
-                uno::Sequence< OUString > aSuggestions;
-                sal_Int32 nErrorPosInText = -1;
-                SwRect aToFill;
-                bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, 
nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+                if(rWrtSh.HasSelection())
+                {
+                    bGrammar = true;
+                }
+                else
+                {
+                    linguistic2::ProofreadingResult aGrammarCheckRes;
+                    sal_Int32 nErrorInResult = -1;
+                    uno::Sequence< OUString > aSuggestions;
+                    sal_Int32 nErrorPosInText = -1;
+                    SwRect aToFill;
+                    bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, 
nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+                }
             }
             else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule2 )))
             {
diff --git a/sw/source/uibase/uiview/viewling.cxx 
b/sw/source/uibase/uiview/viewling.cxx
index e4390317d5ed..441964d1c9c9 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -66,6 +66,8 @@
 #include <strings.hrc>
 #include <hhcwrp.hxx>
 
+#include <boost/property_tree/json_parser.hpp>
+
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/ui/ContextMenuExecuteEvent.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -91,6 +93,7 @@
 #include <xmloff/odffields.hxx>
 
 #include <editeng/editerr.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <memory>
 
@@ -775,9 +778,23 @@ bool SwView::ExecSpellPopup(const Point& rPt)
                     else
                     {
                         if (comphelper::LibreOfficeKit::isActive())
-                            
xPopup->GetMenu().SetLOKNotifier(SfxViewShell::Current());
+                        {
+                            if (SfxViewShell* pViewShell = 
SfxViewShell::Current())
+                            {
+                                boost::property_tree::ptree aMenu = 
SfxDispatcher::fillPopupMenu(&xPopup->GetMenu());
+                                boost::property_tree::ptree aRoot;
+                                aRoot.add_child("menu", aMenu);
 
-                        xPopup->Execute(aToFill.SVRect(), m_pEditWin);
+                                std::stringstream aStream;
+                                boost::property_tree::write_json(aStream, 
aRoot, true);
+                                
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, 
aStream.str().c_str());
+                            }
+                        }
+                        else
+                        {
+                            boost::property_tree::ptree aMenu = 
SfxDispatcher::fillPopupMenu(&xPopup->GetMenu());
+                            xPopup->Execute(aToFill.SVRect(), m_pEditWin);
+                        }
                     }
                 }
             }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to