[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 7 commits - editeng/source include/editeng sc/sdi sc/source sd/sdi sd/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 17 18:22:30 UTC 2020
editeng/source/editeng/editview.cxx | 54 ++++++++++++++++++
include/editeng/editview.hxx | 1
sc/sdi/docsh.sdi | 2
sc/source/ui/docshell/docsh4.cxx | 101 +++++++++++++++++++++++++++++++++-
sd/sdi/_docsh.sdi | 12 ++++
sd/source/ui/docshell/docshel3.cxx | 106 +++++++++++++++++++++++++++++++++---
6 files changed, 266 insertions(+), 10 deletions(-)
New commits:
commit cf615bfd0d75ff29dbddd13a18678b9340baa6cf
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 19:36:38 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:59:02 2020 +0100
sc lok: Implement execution of SID_SPELLCHECK_APPLY_SUGGESTION
Used by online spellchecking context menu.
Change-Id: Id065d366d5ef2ddb3ecf78d202a7264b6962ec8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90601
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 6a670f1aa36630d493b53b19da875395b3173469)
diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi
index 364bd3adaa69..99019d55ff6f 100644
--- a/sc/sdi/docsh.sdi
+++ b/sc/sdi/docsh.sdi
@@ -76,6 +76,7 @@ interface TableDocument
SID_NOTEBOOKBAR [ ExecMethod = Execute; StateMethod = GetState; ]
SID_LANGUAGE_STATUS [ ExecMethod = Execute; StateMethod = GetState; ]
SID_SPELLCHECK_IGNORE_ALL [ ExecMethod = Execute; StateMethod = GetState; ]
+ SID_SPELLCHECK_APPLY_SUGGESTION [ ExecMethod = Execute; StateMethod = GetState; ]
}
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 0cef828429fa..8d9d5ce9cb12 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1320,6 +1320,30 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
}
break;
+ case SID_SPELLCHECK_APPLY_SUGGESTION:
+ {
+ ScViewData* pViewData = GetViewData();
+ if (!pViewData)
+ return;
+
+ EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
+ if (!pEditView)
+ return;
+
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
+
+ const OUString sSpellingRule("Spelling_");
+ sal_Int32 nPos = 0;
+ if(-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), "");
+ pEditView->InsertText( sApplyText );
+ }
+ }
+ break;
default:
{
// small (?) hack -> forwarding of the slots to TabViewShell
commit b08c317c9311cbeede67c62b5071e28a17b2060e
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 19:16:19 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:58:55 2020 +0100
sc lok: Implement execution of SID_SPELLCHECK_IGNORE_ALL
Used by online spellchecking context menu.
Change-Id: I31779a38f467838d3719a0d32cbf37e335432d38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90600
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 103d65b733e099764fdf8aa3f4889dbc6ca49ff6)
diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi
index fdb22acf3e0c..364bd3adaa69 100644
--- a/sc/sdi/docsh.sdi
+++ b/sc/sdi/docsh.sdi
@@ -75,6 +75,7 @@ interface TableDocument
SID_SHARE_DOC [ ExecMethod = Execute; StateMethod = GetState; ]
SID_NOTEBOOKBAR [ ExecMethod = Execute; StateMethod = GetState; ]
SID_LANGUAGE_STATUS [ ExecMethod = Execute; StateMethod = GetState; ]
+ SID_SPELLCHECK_IGNORE_ALL [ ExecMethod = Execute; StateMethod = GetState; ]
}
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index bc1661696fb0..0cef828429fa 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1296,6 +1296,30 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
}
break;
+ case SID_SPELLCHECK_IGNORE_ALL:
+ {
+ ScViewData* pViewData = GetViewData();
+ if (!pViewData)
+ return;
+
+ EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
+ if (!pEditView)
+ return;
+
+ OUString sIgnoreText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sIgnoreText = pItem2->GetValue();
+
+ const OUString sSpellingType("Spelling");
+ if(sIgnoreText == sSpellingType)
+ {
+ ESelection aOldSel = pEditView->GetSelection();
+ pEditView->SpellIgnoreWord();
+ pEditView->SetSelection( aOldSel );
+ }
+ }
+ break;
default:
{
// small (?) hack -> forwarding of the slots to TabViewShell
commit 0d4ed3c7fd00cf22e65f2a6ca9f68db8d6d66591
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 18:45:11 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:58:47 2020 +0100
sc lok: Implement execution of SID_LANGUAGE_STATUS...
Also for selection and paragraph which is used by the
spellchecking context menu.
Change-Id: I583caf48b9176ef4d6971cfe3b445080d01dc531
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90599
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit ac83f2da9c21c3986fc50ee7203e43bc1f93cf31)
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index d30202cf10c8..bc1661696fb0 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -116,6 +116,8 @@ using namespace ::com::sun::star;
#include <memory>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <helpids.h>
+#include <editeng/eeitem.hxx>
+#include <editeng/langitem.hxx>
#include <svx/xdef.hxx>
@@ -1182,10 +1184,15 @@ void ScDocShell::Execute( SfxRequest& rReq )
if ( !aLangText.isEmpty() )
{
LanguageType eLang, eLatin, eCjk, eCtl;
+ const OUString aSelectionLangPrefix("Current_");
+ const OUString aParagraphLangPrefix("Paragraph_");
const OUString aDocLangPrefix("Default_");
const OUString aNoLang("LANGUAGE_NONE");
const OUString aResetLang("RESET_LANGUAGES");
+ bool bSelection = false;
+ bool bParagraph = false;
+
ScDocument& rDoc = GetDocument();
rDoc.GetLanguage( eLatin, eCjk, eCtl );
@@ -1226,8 +1233,52 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
}
}
+ else if (-1 != (nPos = aLangText.indexOf( aSelectionLangPrefix )))
+ {
+ bSelection = true;
+ aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" );
+ }
+ else if (-1 != (nPos = aLangText.indexOf( aParagraphLangPrefix )))
+ {
+ bParagraph = true;
+ aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" );
+ }
- if ( eLang != eLatin )
+ if (bSelection || bParagraph)
+ {
+ ScViewData* pViewData = GetViewData();
+ if (!pViewData)
+ return;
+
+ EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
+ if (!pEditView)
+ return;
+
+ const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aLangText );
+ SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
+
+ SfxItemSet aAttrs = pEditView->GetEditEngine()->GetEmptyItemSet();
+ if (nScriptType == SvtScriptType::LATIN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
+ if (nScriptType == SvtScriptType::COMPLEX)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
+ if (nScriptType == SvtScriptType::ASIAN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
+ ESelection aOldSel;
+ if (bParagraph)
+ {
+ ESelection aSel = pEditView->GetSelection();
+ aOldSel = aSel;
+ aSel.nStartPos = 0;
+ aSel.nEndPos = EE_TEXTPOS_ALL;
+ pEditView->SetSelection( aSel );
+ }
+
+ pEditView->SetAttribs( aAttrs );
+ if (bParagraph)
+ pEditView->SetSelection( aOldSel );
+ }
+ else if ( eLang != eLatin )
{
if ( ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell() )
{
commit 5a1f851763f9fa81a1f0e152b3940ccf146eabfe
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 17:20:22 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:17:00 2020 +0100
sd lok: Implement execution of SID_SPELLCHECK_APPLY_SUGGESTION
Used by online spellchecking context menu.
Change-Id: I9d7430b4ef45af1641fc985cf4588d45ba497ee9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90598
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit a00a3d681ec95841a5f6a879b05c6438d18161b4)
diff --git a/sd/sdi/_docsh.sdi b/sd/sdi/_docsh.sdi
index 8644b752702c..02de70858ab0 100644
--- a/sd/sdi/_docsh.sdi
+++ b/sd/sdi/_docsh.sdi
@@ -83,5 +83,11 @@ interface DrawDocument
ExecMethod = Execute ;
StateMethod = GetState ;
]
+
+ SID_SPELLCHECK_APPLY_SUGGESTION
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
}
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index 15a54620d071..3d51bf023858 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -394,6 +394,27 @@ void DrawDocShell::Execute( SfxRequest& rReq )
}
}
break;
+ case SID_SPELLCHECK_APPLY_SUGGESTION:
+ {
+ SdrView* pSdrView = mpViewShell->GetDrawView();
+ if (!pSdrView)
+ return;
+
+ EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
+
+ const OUString sSpellingRule("Spelling_");
+ sal_Int32 nPos = 0;
+ if(-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), "");
+ rEditView.InsertText( sApplyText );
+ }
+ }
+ break;
case SID_NOTEBOOKBAR:
{
commit 32cc18c985b49d14553ce335d903a5305534e18b
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 17:14:33 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:16:44 2020 +0100
sd lok: Implement execution of SID_SPELLCHECK_IGNORE_ALL
Used by online spellchecking context menu.
Change-Id: Iad3dafedbfed1605ba06f7f87ed91117c9b1a8e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90597
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 268327c2fb37ff553a2c348a6beca4e309b0653f)
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 621a7d3bcfff..24d0947d7de5 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1199,6 +1199,11 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
}
}
+OUString EditView::SpellIgnoreWord()
+{
+ return pImpEditView->SpellIgnoreWord();
+}
+
void EditView::SelectCurrentWord( sal_Int16 nWordType )
{
EditSelection aCurSel( pImpEditView->GetEditSelection() );
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 8d2a5ef2853d..b516e4484eb1 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -260,6 +260,7 @@ public:
bool IsCursorAtWrongSpelledWord();
bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
void ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void> const * pCallBack );
+ OUString SpellIgnoreWord();
void InsertField( const SvxFieldItem& rFld );
const SvxFieldItem* GetFieldUnderMousePointer() const;
diff --git a/sd/sdi/_docsh.sdi b/sd/sdi/_docsh.sdi
index 29db81db02d2..8644b752702c 100644
--- a/sd/sdi/_docsh.sdi
+++ b/sd/sdi/_docsh.sdi
@@ -77,5 +77,11 @@ interface DrawDocument
ExecMethod = Execute;
StateMethod = GetState;
]
+
+ SID_SPELLCHECK_IGNORE_ALL
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
}
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index 212ca38c27eb..15a54620d071 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -373,6 +373,27 @@ void DrawDocShell::Execute( SfxRequest& rReq )
Broadcast(SfxHint(SfxHintId::LanguageChanged));
}
break;
+ case SID_SPELLCHECK_IGNORE_ALL:
+ {
+ SdrView* pSdrView = mpViewShell->GetDrawView();
+ if (!pSdrView)
+ return;
+
+ EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
+ OUString sIgnoreText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sIgnoreText = pItem2->GetValue();
+
+ const OUString sSpellingType("Spelling");
+ if(sIgnoreText == sSpellingType)
+ {
+ ESelection aOldSel = rEditView.GetSelection();
+ rEditView.SpellIgnoreWord();
+ rEditView.SetSelection( aOldSel );
+ }
+ }
+ break;
case SID_NOTEBOOKBAR:
{
commit a9fff9be8ef9dbbe8097a48669475db9146d2a30
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 16:24:48 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:16:20 2020 +0100
sd lok: Implement execution of SID_LANGUAGE_STATUS...
Also for selection and paragraph which is used by the
spellchecking context menu.
Change-Id: Ie242175605185b3083aa529b54acc183aee1d47b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90596
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 6167264dace8e10fe66537bcf64eaa5904232786)
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index 8aab98e8dd65..212ca38c27eb 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -44,6 +44,8 @@
#include <editeng/editobj.hxx>
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
+#include <drawview.hxx>
+#include <editeng/editeng.hxx>
#include <sdmod.hxx>
#include <drawdoc.hxx>
@@ -278,6 +280,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(SID_LANGUAGE_STATUS);
if (pItem)
aNewLangTxt = pItem->GetValue();
+
if (aNewLangTxt == "*" )
{
// open the dialog "Tools/Options/Language Settings - Language"
@@ -295,25 +298,70 @@ void DrawDocShell::Execute( SfxRequest& rReq )
// setting the new language...
if (!aNewLangTxt.isEmpty())
{
+ const OUString aSelectionLangPrefix("Current_");
+ const OUString aParagraphLangPrefix("Paragraph_");
const OUString aDocumentLangPrefix("Default_");
const OUString aStrNone("LANGUAGE_NONE");
const OUString aStrResetLangs("RESET_LANGUAGES");
+
+ bool bSelection = false;
+ bool bParagraph = false;
+
SdDrawDocument* pDoc = mpViewShell->GetDoc();
sal_Int32 nPos = -1;
if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix )))
{
aNewLangTxt = aNewLangTxt.replaceAt( nPos, aDocumentLangPrefix.getLength(), "" );
+
+ if (aNewLangTxt == aStrNone)
+ lcl_setLanguage( pDoc, OUString(), true );
+ else if (aNewLangTxt == aStrResetLangs)
+ lcl_setLanguage( pDoc, OUString() );
+ else
+ lcl_setLanguage( pDoc, aNewLangTxt );
}
- else
+ else if (-1 != (nPos = aNewLangTxt.indexOf( aSelectionLangPrefix )))
+ {
+ bSelection = true;
+ aNewLangTxt = aNewLangTxt.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" );
+ }
+ else if (-1 != (nPos = aNewLangTxt.indexOf( aParagraphLangPrefix )))
+ {
+ bParagraph = true;
+ aNewLangTxt = aNewLangTxt.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" );
+ }
+
+ if (bSelection || bParagraph)
{
- break;
+ SdrView* pSdrView = mpViewShell->GetDrawView();
+ if (!pSdrView)
+ return;
+
+ EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
+ const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aNewLangTxt );
+ SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
+
+ SfxItemSet aAttrs = rEditView.GetEditEngine()->GetEmptyItemSet();
+ if (nScriptType == SvtScriptType::LATIN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
+ if (nScriptType == SvtScriptType::COMPLEX)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
+ if (nScriptType == SvtScriptType::ASIAN)
+ aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
+ ESelection aOldSel;
+ if (bParagraph)
+ {
+ ESelection aSel = rEditView.GetSelection();
+ aOldSel = aSel;
+ aSel.nStartPos = 0;
+ aSel.nEndPos = EE_TEXTPOS_ALL;
+ rEditView.SetSelection( aSel );
+ }
+
+ rEditView.SetAttribs( aAttrs );
+ if (bParagraph)
+ rEditView.SetSelection( aOldSel );
}
- if (aNewLangTxt == aStrNone)
- lcl_setLanguage( pDoc, OUString(), true );
- else if (aNewLangTxt == aStrResetLangs)
- lcl_setLanguage( pDoc, OUString() );
- else
- lcl_setLanguage( pDoc, aNewLangTxt );
if ( pDoc->GetOnlineSpell() )
{
commit 55e147a40a480ff08c717aa2be9cbca567f07414
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 15:49:29 2020 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 13:10:04 2020 +0100
lok: Send spelling popup menu structure for mobile (calc and impress).
Similar to how writer behaves. Instead of using tunneling,
we send the menu structure with the commands.
By now this commands are not executed by the document shell
of calc / impress. I'll implement that in separate commits.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90595
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit d7fa4fc8b64769f0d25b87ff33b8d1b8e96572d9)
Change-Id: If342c83143a9a7c2ec74b99027f6d4ba8b44ef08
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 20a4baeaee04..621a7d3bcfff 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -64,6 +64,9 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <boost/property_tree/json_parser.hpp>
+#include <sfx2/dispatch.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -849,6 +852,41 @@ bool EditView::IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWron
return pImpEditView->IsWrongSpelledWord( aPaM , bMarkIfWrong );
}
+static void LOKSendSpellPopupMenu(Menu* pMenu, LanguageType nGuessLangWord,
+ LanguageType nGuessLangPara, sal_uInt16 nSuggestions)
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ // First we need to set item commends for the context menu.
+ OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
+ OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
+
+ pMenu->SetItemCommand(pMenu->GetItemId("ignore"), ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
+ pMenu->SetItemCommand(MN_WORDLANGUAGE, ".uno:LanguageStatus?Language:string=Current_" + aTmpWord);
+ pMenu->SetItemCommand(MN_PARALANGUAGE, ".uno:LanguageStatus?Language:string=Paragraph_" + aTmpPara);
+
+ for(int i = 0; i < nSuggestions; ++i)
+ {
+ sal_uInt16 nItemId = MN_ALTSTART + i;
+ OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=Spelling_" + pMenu->GetItemText(nItemId);
+ pMenu->SetItemCommand(nItemId, sCommandString);
+ }
+
+ // Then we generate the menu structure and send it to the client code.
+ if (SfxViewShell* pViewShell = SfxViewShell::Current())
+ {
+ boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pMenu);
+ boost::property_tree::ptree aRoot;
+ aRoot.add_child("menu", aMenu);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aRoot, true);
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str());
+ return;
+ }
+}
+
void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void> const * pCallBack )
{
Point aPos ( pImpEditView->GetWindow()->PixelToLogic( rPosPixel ) );
@@ -1033,7 +1071,16 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
if (comphelper::LibreOfficeKit::isActive())
- aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+ {
+ // For mobile, send the context menu structure
+ if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
+ {
+ LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
+ return;
+ }
+ else // For desktop, we use the tunneled dialog
+ aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+ }
sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
More information about the Libreoffice-commits
mailing list