[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 18 commits - chart2/source desktop/source include/sfx2 include/svx officecfg/registry sfx2/source svx/sdi sw/sdi sw/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 26 17:43:05 UTC 2019
chart2/source/controller/inc/CommandDispatchContainer.hxx | 2
chart2/source/controller/main/ChartController_Window.cxx | 47 +-
chart2/source/controller/main/ControllerCommandDispatch.hxx | 3
desktop/source/lib/init.cxx | 14
include/sfx2/dispatch.hxx | 4
include/svx/svxids.hrc | 3
officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 15
sfx2/source/control/dispatch.cxx | 189 ++++-----
svx/sdi/svx.sdi | 51 ++
sw/sdi/_textsh.sdi | 18
sw/source/core/edit/edlingu.cxx | 10
sw/source/uibase/inc/olmenu.hxx | 4
sw/source/uibase/inc/textsh.hxx | 2
sw/source/uibase/lingu/olmenu.cxx | 210 +++++-----
sw/source/uibase/shells/textsh1.cxx | 197 +++++++++
sw/source/uibase/uiview/viewling.cxx | 21 -
16 files changed, 570 insertions(+), 220 deletions(-)
New commits:
commit 8fd190c24d021e91b9849c991250032b23b7bff2
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Nov 22 18:05:26 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 2019 +0100
lok: Chart context menu: Disable menu items which are not available.
Reviewed-on: https://gerrit.libreoffice.org/83605
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 4582222a3ade99584514a86dbaddf0c80f7e7196)
Change-Id: Id7487c581759389e66ca513381d6706f3ae49980
diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx
index cbcf4345377b..61561da08e2f 100644
--- a/chart2/source/controller/inc/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx
@@ -104,6 +104,8 @@ public:
const css::uno::Reference< css::frame::XController > & xChartController,
const css::util::URL & rURL );
+ css::uno::Reference< css::frame::XDispatch > getChartDispatcher() { return m_xChartDispatcher; }
+
void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
DrawCommandDispatch* getDrawCommandDispatch() { return m_pDrawCommandDispatch; }
void setShapeController( ShapeController* pController );
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 6c9ba58839fb..e3d65bd670d7 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -46,6 +46,7 @@
#include <servicenames_charttypes.hxx>
#include "DrawCommandDispatch.hxx"
#include <PopupRequest.hxx>
+#include "ControllerCommandDispatch.hxx"
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
@@ -1283,6 +1284,18 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
PopupMenu* pPopupMenu = static_cast<PopupMenu*>(VCLXMenu::GetImplementation( xPopupMenu )->GetMenu());
+ ControllerCommandDispatch* pCommandDispatch = dynamic_cast<ControllerCommandDispatch*>(m_aDispatchContainer.getChartDispatcher().get());
+ if(pCommandDispatch)
+ {
+ for (sal_uInt16 nPos = 0; nPos < pPopupMenu->GetItemCount(); nPos++)
+ {
+ const sal_uInt16 nItemId = pPopupMenu->GetItemId(nPos);
+ OUString aCommandURL = pPopupMenu->GetItemCommand(nItemId);
+ if(!pCommandDispatch->commandAvailable(aCommandURL))
+ pPopupMenu->EnableItem(nItemId, false);
+ }
+ }
+
boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu);
boost::property_tree::ptree aRoot;
aRoot.add_child("menu", aMenu);
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx b/chart2/source/controller/main/ControllerCommandDispatch.hxx
index 4e105f86702c..b2f2a5e3dc51 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.hxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.hxx
@@ -65,6 +65,8 @@ public:
// late initialisation, especially for adding as listener
virtual void initialize() override;
+ bool commandAvailable( const OUString & rCommand );
+
protected:
// ____ XDispatch ____
virtual void SAL_CALL dispatch(
@@ -96,7 +98,6 @@ private:
const OUString & rURL,
const css::uno::Reference< css::frame::XStatusListener > & xSingleListener );
- bool commandAvailable( const OUString & rCommand );
void updateCommandAvailability();
bool isShapeControllerCommandAvailable( const OUString& rCommand );
commit f5faf300f8c0c9a33978b8560ed136844b0235e6
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Nov 21 16:13:06 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 2019 +0100
lok: Chart context menu: Replace tunneled context menu with JS context menu.
Reviewed-on: https://gerrit.libreoffice.org/83604
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 08d0326cd2125dabb94102adaf06e34fc49974bc)
Change-Id: I36db90887bff86036093ce0732db6fc6c76e79f6
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 9a0c19544c70..6c9ba58839fb 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -84,6 +84,9 @@
#include <comphelper/lok.hxx>
#include <sfx2/lokhelper.hxx>
+#include <boost/property_tree/json_parser.hpp>
+#include <sfx2/dispatch.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#define DRGPIX 2 // Drag MinMove in Pixel
@@ -1273,29 +1276,28 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if ( !xPopupController.is() || !xPopupMenu.is() )
return;
+ xPopupController->setPopupMenu( xPopupMenu );
+
if (comphelper::LibreOfficeKit::isActive())
{
- PopupMenu* pPopupMenu = static_cast<PopupMenu*>(VCLXMenu::GetImplementation(xPopupMenu)->GetMenu());
- pPopupMenu->SetLOKNotifier(SfxViewShell::Current());
-
- // the context menu expects a position related to the document window,
- // not to the chart window
- SfxInPlaceClient* pIPClient = SfxViewShell::Current()->GetIPClient();
- if (pIPClient)
+ if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
- vcl::Window* pRootWin = pIPClient->GetEditWin();
- if (pRootWin)
- {
- Point aOffset = pChartWindow->GetOffsetPixelFrom(*pRootWin);
- aPos += aOffset;
- }
+ PopupMenu* pPopupMenu = static_cast<PopupMenu*>(VCLXMenu::GetImplementation( xPopupMenu )->GetMenu());
+ boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu);
+ 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());
}
}
-
- xPopupController->setPopupMenu( xPopupMenu );
- xPopupMenu->execute( css::uno::Reference< css::awt::XWindowPeer >( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY ),
- css::awt::Rectangle( aPos.X(), aPos.Y(), 0, 0 ),
- css::awt::PopupMenuDirection::EXECUTE_DEFAULT );
+ else
+ {
+ xPopupMenu->execute( css::uno::Reference< css::awt::XWindowPeer >( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY ),
+ css::awt::Rectangle( aPos.X(), aPos.Y(), 0, 0 ),
+ css::awt::PopupMenuDirection::EXECUTE_DEFAULT );
+ }
css::uno::Reference< css::lang::XComponent > xComponent( xPopupController, css::uno::UNO_QUERY );
if ( xComponent.is() )
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5a9cd839fd0c..9f4dfa961a20 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3476,7 +3476,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
}
- if (aChartHelper.GetWindow())
+ if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
{
if (aPropertyValuesVector[0].Name != "Action")
{
@@ -3509,7 +3509,17 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
bool bResult = false;
- if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers[nView])
+ LokChartHelper aChartHelper(SfxViewShell::Current());
+
+ if (aChartHelper.GetWindow() )
+ {
+ util::URL aCommandURL;
+ aCommandURL.Path = aCommand.copy(5);
+ css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
+ aChartDispatcher->dispatch(aCommandURL, comphelper::containerToSequence(aPropertyValuesVector));
+ return;
+ }
+ else if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers[nView])
{
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
commit 16a0e85c9277665b3e74754fff7c690d83a97754
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Nov 24 11:59:31 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 2019 +0100
Fix some loplugin error.
Change-Id: I22c1efbacc5b2d35d49f8183929b6177bf91e93d
Reviewed-on: https://gerrit.libreoffice.org/83602
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 822181788ec011418ac0ce95c57ea70feb4769f1)
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 8d5b0b16641a..5db809e961e0 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -893,7 +893,7 @@ uno::Reference< XSpellAlternatives >
SwCursorMoveState eTmpState( MV_SETONLYTEXT );
SwTextNode *pNode = nullptr;
SwWrongList *pWrong = nullptr;
- if (pPt && GetLayout()->GetCursorOfst( &aPos, *(const_cast<Point*>(pPt)), &eTmpState ))
+ if (pPt && GetLayout()->GetCursorOfst( &aPos, *const_cast<Point*>(pPt), &eTmpState ))
pNode = aPos.nNode.GetNode().GetTextNode();
if (nullptr == pNode)
pNode = pCursor->GetNode().GetTextNode();
@@ -960,7 +960,7 @@ bool SwEditShell::GetGrammarCorrection(
SwCursorMoveState eTmpState( MV_SETONLYTEXT );
SwTextNode *pNode = nullptr;
SwGrammarMarkUp *pWrong = nullptr;
- if (pPt && GetLayout()->GetCursorOfst( &aPos, *(const_cast<Point*>(pPt)), &eTmpState ))
+ if (pPt && GetLayout()->GetCursorOfst( &aPos, *const_cast<Point*>(pPt), &eTmpState ))
pNode = aPos.nNode.GetNode().GetTextNode();
if (nullptr == pNode)
pNode = pCursor->GetNode().GetTextNode();
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index d2a3666c8a05..0f4b1c32e742 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -619,7 +619,7 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge
for(int i = 0; i < aSuggestions.getLength(); ++i)
{
sal_uInt16 nItemId = MN_SUGGESTION_START + i;
- OUString sCommandString = OUString(".uno:SpellCheckApplySuggestion?ApplyRule:string=");
+ OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=";
if(m_bGrammarResults)
sCommandString += "Grammar_";
else if (m_xSpellAlt.is())
@@ -631,9 +631,9 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge
PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
if(pMenu)
{
- for (auto item : m_aLangTable_Text)
+ for (const auto& item : m_aLangTable_Text)
{
- OUString sCommandString = OUString(".uno:LanguageStatus?Language:string=Current_") + item.second;
+ OUString sCommandString = ".uno:LanguageStatus?Language:string=Current_" + item.second;
pMenu->SetItemCommand(item.first, sCommandString);
}
@@ -645,9 +645,9 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge
pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
if(pMenu)
{
- for (auto item : m_aLangTable_Paragraph)
+ for (const auto& item : m_aLangTable_Paragraph)
{
- OUString sCommandString = OUString(".uno:LanguageStatus?Language:string=Paragraph_") + item.second;
+ OUString sCommandString = ".uno:LanguageStatus?Language:string=Paragraph_" + item.second;
pMenu->SetItemCommand(item.first, sCommandString);
}
commit 712f3b1bfdc882813656e19d47d2b867170aecc3
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Nov 18 19:15:07 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 2019 +0100
SpellingPopup: Create separate SID for Ignore / IgnoreAll / suggestion.
Reviewed-on: https://gerrit.libreoffice.org/83599
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 6564a1ab1e873cbc9e36f7f301d4a3c14d86861e)
Change-Id: I20f41f511ea38f960f081f92bc36e095f7752d28
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index f683e76a0754..526518d2a144 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -355,7 +355,9 @@ class SfxStringItem;
#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 ab3a3c3f0f34..c5d11c8206cc 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2631,9 +2631,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 252ffa7991bf..2600e6f13d2c 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12036,7 +12036,41 @@ SfxVoidItem SignSignatureLine SID_SIGN_SIGNATURELINE
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 82f0fff4dae6..1e22b0e43b02 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1711,7 +1711,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 b205861f67c1..d2a3666c8a05 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -604,21 +604,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())
@@ -711,7 +712,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())
@@ -719,7 +720,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)
{
@@ -794,13 +795,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 7b3a72ada421..cb92a7312e93 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1423,55 +1423,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;
@@ -1499,7 +1501,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) );
@@ -1513,95 +1515,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 97e469b3d73a0dcefc4427161392812286571f90
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Nov 18 14:36:51 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 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.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 3616bb68f247735c46c1a4cd9568775e77be6441)
diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx
index b98fb5ba88f9..a08957c87a84 100644
--- a/sw/source/uibase/inc/olmenu.hxx
+++ b/sw/source/uibase/inc/olmenu.hxx
@@ -125,6 +125,8 @@ public:
~SwSpellPopup();
+ void InitItemCommands(const css::uno::Sequence< OUString >& aSuggestions);
+
PopupMenu& GetMenu()
{
return *m_xPopupMenu.get();
@@ -132,7 +134,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 f1618c8c287d..b205861f67c1 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -424,6 +424,8 @@ SwSpellPopup::SwSpellPopup(
checkRedline();
m_xPopupMenu->RemoveDisabledEntries( true, true );
+
+ InitItemCommands(aSuggestions);
}
SwSpellPopup::SwSpellPopup(
@@ -592,10 +594,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
@@ -733,7 +794,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 7320d6baf787..7b3a72ada421 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1430,7 +1430,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");
@@ -1438,8 +1438,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 );
@@ -1502,12 +1525,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 6aed16bc533f..e8755a54acd2 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -65,6 +65,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/lang/XInitialization.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
@@ -88,6 +90,7 @@
#include <xmloff/odffields.hxx>
#include <editeng/editerr.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <memory>
@@ -764,9 +767,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);
+ }
}
}
}
commit 8f30308c165c14518ff9d21782af20e469e27659
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Nov 18 14:36:25 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:28 2019 +0100
Dispatch: Make fillPopupMenu() method accessible from other modules.
No functional change.
Change-Id: Ifaa6ff038277ef5702ac38d90c7461d664b0aee4
Reviewed-on: https://gerrit.libreoffice.org/83597
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 100b98edcc571ff81ff90d04f3f3bd804eb49a1f)
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 9e2f0a0379a2..c7f1f0c61135 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -31,6 +31,8 @@
#include <o3tl/typed_flags_set.hxx>
#include <o3tl/array_view.hxx>
+#include <boost/property_tree/ptree.hpp>
+#include <vcl/menu.hxx>
#include <initializer_list>
class SfxSlotServer;
@@ -186,6 +188,8 @@ public:
SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI );
SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew );
SAL_DLLPRIVATE void InvalidateBindings_Impl(bool);
+
+ static boost::property_tree::ptree fillPopupMenu(Menu* pMenu);
};
#endif
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index f90dd16dd621..4b79888add94 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -138,103 +138,6 @@ struct SfxDispatcher_Impl
std::deque< std::deque<SfxToDo_Impl> > aToDoCopyStack;
};
-namespace {
-
- boost::property_tree::ptree fillPopupMenu(Menu* pMenu)
- {
- // Activate this menu first
- pMenu->HandleMenuActivateEvent(pMenu);
- pMenu->HandleMenuDeActivateEvent(pMenu);
-
- boost::property_tree::ptree aTree;
- // If last item inserted is some valid text
- bool bIsLastItemText = false;
- sal_uInt16 nCount = pMenu->GetItemCount();
- for (sal_uInt16 nPos = 0; nPos < nCount; nPos++)
- {
- boost::property_tree::ptree aItemTree;
- const MenuItemType aItemType = pMenu->GetItemType(nPos);
-
- if (aItemType == MenuItemType::DONTKNOW)
- continue;
-
- if (aItemType == MenuItemType::SEPARATOR)
- {
- if (bIsLastItemText)
- aItemTree.put("type", "separator");
- bIsLastItemText = false;
- }
- else
- {
- const sal_uInt16 nItemId = pMenu->GetItemId(nPos);
- OUString aCommandURL = pMenu->GetItemCommand(nItemId);
-
- if (aCommandURL.isEmpty())
- {
- const SfxSlot *pSlot = SFX_SLOTPOOL().GetSlot(nItemId);
- if (pSlot)
- aCommandURL = pSlot->GetCommandString();
- }
-
- const OUString aItemText = pMenu->GetItemText(nItemId);
- Menu* pPopupSubmenu = pMenu->GetPopupMenu(nItemId);
-
- if (!aItemText.isEmpty())
- aItemTree.put("text", aItemText.toUtf8().getStr());
-
- if (pPopupSubmenu)
- {
- boost::property_tree::ptree aSubmenu = fillPopupMenu(pPopupSubmenu);
- if (aSubmenu.empty())
- continue;
-
- aItemTree.put("type", "menu");
- if (!aCommandURL.isEmpty())
- aItemTree.put("command", aCommandURL.toUtf8().getStr());
- aItemTree.push_back(std::make_pair("menu", aSubmenu));
- }
- else
- {
- // no point in exposing choices that don't have the .uno:
- // command
- if (aCommandURL.isEmpty())
- continue;
-
- aItemTree.put("type", "command");
- aItemTree.put("command", aCommandURL.toUtf8().getStr());
- }
-
- aItemTree.put("enabled", pMenu->IsItemEnabled(nItemId));
-
- MenuItemBits aItemBits = pMenu->GetItemBits(nItemId);
- bool bHasChecks = true;
- if (aItemBits & MenuItemBits::CHECKABLE)
- aItemTree.put("checktype", "checkmark");
- else if (aItemBits & MenuItemBits::RADIOCHECK)
- aItemTree.put("checktype", "radio");
- else if (aItemBits & MenuItemBits::AUTOCHECK)
- aItemTree.put("checktype", "auto");
- else
- bHasChecks = false;
-
- if (bHasChecks)
- aItemTree.put("checked", pMenu->IsItemChecked(nItemId));
- }
-
- if (!aItemTree.empty())
- {
- aTree.push_back(std::make_pair("", aItemTree));
- if (aItemType != MenuItemType::SEPARATOR)
- bIsLastItemText = true;
- }
- }
-
- return aTree;
- }
-
-} // end anonymous namespace
-
-
/** This method checks if the stack of the SfxDispatchers is flushed, or if
push- or pop- commands are pending.
*/
@@ -2073,4 +1976,96 @@ SfxModule* SfxDispatcher::GetModule() const
}
}
+boost::property_tree::ptree SfxDispatcher::fillPopupMenu(Menu* pMenu)
+{
+ // Activate this menu first
+ pMenu->HandleMenuActivateEvent(pMenu);
+ pMenu->HandleMenuDeActivateEvent(pMenu);
+
+ boost::property_tree::ptree aTree;
+ // If last item inserted is some valid text
+ bool bIsLastItemText = false;
+ sal_uInt16 nCount = pMenu->GetItemCount();
+ for (sal_uInt16 nPos = 0; nPos < nCount; nPos++)
+ {
+ boost::property_tree::ptree aItemTree;
+ const MenuItemType aItemType = pMenu->GetItemType(nPos);
+
+ if (aItemType == MenuItemType::DONTKNOW)
+ continue;
+
+ if (aItemType == MenuItemType::SEPARATOR)
+ {
+ if (bIsLastItemText)
+ aItemTree.put("type", "separator");
+ bIsLastItemText = false;
+ }
+ else
+ {
+ const sal_uInt16 nItemId = pMenu->GetItemId(nPos);
+ OUString aCommandURL = pMenu->GetItemCommand(nItemId);
+
+ if (aCommandURL.isEmpty())
+ {
+ const SfxSlot *pSlot = SFX_SLOTPOOL().GetSlot(nItemId);
+ if (pSlot)
+ aCommandURL = pSlot->GetCommandString();
+ }
+
+ const OUString aItemText = pMenu->GetItemText(nItemId);
+ Menu* pPopupSubmenu = pMenu->GetPopupMenu(nItemId);
+
+ if (!aItemText.isEmpty())
+ aItemTree.put("text", aItemText.toUtf8().getStr());
+
+ if (pPopupSubmenu)
+ {
+ boost::property_tree::ptree aSubmenu = fillPopupMenu(pPopupSubmenu);
+ if (aSubmenu.empty())
+ continue;
+
+ aItemTree.put("type", "menu");
+ if (!aCommandURL.isEmpty())
+ aItemTree.put("command", aCommandURL.toUtf8().getStr());
+ aItemTree.push_back(std::make_pair("menu", aSubmenu));
+ }
+ else
+ {
+ // no point in exposing choices that don't have the .uno:
+ // command
+ if (aCommandURL.isEmpty())
+ continue;
+
+ aItemTree.put("type", "command");
+ aItemTree.put("command", aCommandURL.toUtf8().getStr());
+ }
+
+ aItemTree.put("enabled", pMenu->IsItemEnabled(nItemId));
+
+ MenuItemBits aItemBits = pMenu->GetItemBits(nItemId);
+ bool bHasChecks = true;
+ if (aItemBits & MenuItemBits::CHECKABLE)
+ aItemTree.put("checktype", "checkmark");
+ else if (aItemBits & MenuItemBits::RADIOCHECK)
+ aItemTree.put("checktype", "radio");
+ else if (aItemBits & MenuItemBits::AUTOCHECK)
+ aItemTree.put("checktype", "auto");
+ else
+ bHasChecks = false;
+
+ if (bHasChecks)
+ aItemTree.put("checked", pMenu->IsItemChecked(nItemId));
+ }
+
+ if (!aItemTree.empty())
+ {
+ aTree.push_back(std::make_pair("", aItemTree));
+ if (aItemType != MenuItemType::SEPARATOR)
+ bIsLastItemText = true;
+ }
+ }
+
+ return aTree;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fdf2dd4e9761687549538cfeaad080ea385a05ed
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Nov 18 14:33:39 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: lok: Hide unusable items for online
MN_EXPLANATION_LINK is some link, but it's exectued internally,
which means the the link would be executed on the serves side and
not on the client's browser.
m_nCorrectMenuId is a sub menu which allows to specify new autocorrect
rules. Since m_nAddId is also disabled, I expect that extending
the dictionaries / autocorrect rule might be a problem for online.
Change-Id: Id6e8ed078f90a4f25a335a3ab5ec0e3056db648d
Reviewed-on: https://gerrit.libreoffice.org/83596
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 87778faba8c8e7378872119d98a9f1c383aef1fd)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index e980a86fcf7d..f1618c8c287d 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -298,11 +298,13 @@ SwSpellPopup::SwSpellPopup(
vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:SpellingAndGrammarDialog", aModuleName));
m_xPopupMenu->SetItemText(m_nCorrectDialogId,
vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:AutoCorrectDlg", aModuleName));
+
if (comphelper::LibreOfficeKit::isActive())
{
m_xPopupMenu->HideItem(m_nCorrectDialogId);
m_xPopupMenu->HideItem(m_nAddId);
m_xPopupMenu->HideItem(m_nAddMenuId);
+ m_xPopupMenu->HideItem(m_nCorrectMenuId);
}
sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
@@ -585,6 +587,11 @@ SwSpellPopup::SwSpellPopup(
m_xPopupMenu->RemoveDisabledEntries(true, true);
SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ m_xPopupMenu->HideItem(MN_EXPLANATION_LINK);
+ }
}
SwSpellPopup::~SwSpellPopup() {}
commit 3160e24c5444674c8e7c6dc4c3ddaebe35735874
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Nov 17 14:17:59 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Convert suggestion menu items to use slot ID.
Change-Id: Icf1f50d04ab5e7ba467d68613f4101a3fe48589b
(cherry picked from commit c2f58bc25cedf8a13a978b52a5bf012809fc38ed)
Reviewed-on: https://gerrit.libreoffice.org/83590
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 5efa7d4605c8c683bb54a1723d0916e6f0166b52)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index c9105fa27902..e980a86fcf7d 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -641,26 +641,29 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
if (/*m_bGrammarResults && */nId == MN_SHORT_COMMENT)
return; // nothing to do since it is the error message (short comment)
- if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
- (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
+ if (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END)
{
- OUString sNewWord;
- if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
- {
- PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nCorrectMenuId);
- assert(pMenu);
- sNewWord = pMenu->GetItemText(nId);
- }
- else
- sNewWord = m_xPopupMenu->GetItemText(nId);
-
- if (m_bGrammarResults || m_xSpellAlt.is())
+ OUString sApplyRule("Replace_");
+ if(m_bGrammarResults)
+ sApplyRule += "Grammar_";
+ else if (m_xSpellAlt.is())
+ sApplyRule += "Spelling_";
+ sApplyRule += m_xPopupMenu->GetItemText(nId);
+
+ SfxStringItem aApplyItem(FN_PARAM_1, sApplyRule);
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aApplyItem });
+ }
+ else if(MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
+ {
+ if (m_xSpellAlt.is())
{
bool bOldIns = m_pSh->IsInsMode();
m_pSh->SetInsMode();
- OUString aTmp( sNewWord );
- OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() );
+ PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nCorrectMenuId);
+ assert(pMenu);
+ OUString aTmp( pMenu->GetItemText(nId) );
+ OUString aOrig( m_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
@@ -694,11 +697,11 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
// record only if it's NOT already present in autocorrection
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
- OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ;
- SvxPrepareAutoCorrect( aOrigWord, sNewWord );
+ OUString aOrigWord( m_xSpellAlt->getWord() ) ;
+ OUString aNewWord( pMenu->GetItemText(nId) );
+ SvxPrepareAutoCorrect( aOrigWord, aNewWord );
- if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
- pACorr->PutText( aOrigWord, sNewWord, m_nCheckedLanguage );
+ pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
/* #102505# EndAction/EndUndo moved down since insertion
of temporary auto correction is now undoable two and
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 889ba31a2612..7320d6baf787 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -126,6 +126,7 @@
#include <swabstdlg.hxx>
#include <bookmrk.hxx>
#include <linguistic/misc.hxx>
+#include <editeng/splwrap.hxx>
using namespace ::com::sun::star;
using namespace com::sun::star::beans;
@@ -1433,7 +1434,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
const OUString sIgnoreAllPrefix("IgnoreAll_");
const OUString sSpellingRule("Spelling");
const OUString sGrammarRule("Grammar");
- //const OUString aReplacePrefix("Replace_");
+ const OUString aReplacePrefix("Replace_");
// Ignore the word at the cursor pos
sal_Int32 nPos = 0;
@@ -1489,6 +1490,88 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
}
+ // Replace text with the suggestion
+ else if (-1 != (nPos = sApplyText.indexOf( aReplacePrefix )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, aReplacePrefix.getLength(), "");
+
+ const OUString sSpellingRule2(sSpellingRule + "_");
+ const OUString sGrammarRule2(sGrammarRule + "_");
+ bool bGrammar = false;
+ uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt;
+ 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 );
+ }
+ else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule2 )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sSpellingRule2.getLength(), "");
+ SwRect aToFill;
+ xSpellAlt.set(rWrtSh.GetCorrection(nullptr, aToFill));
+ bGrammar = false;
+ }
+
+ if (!bGrammar && !xSpellAlt.is())
+ return;
+
+ bool bOldIns = rWrtSh.IsInsMode();
+ rWrtSh.SetInsMode();
+
+ 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 += ".";
+ }
+
+ SwRewriter aRewriter;
+
+ 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);
+
+ rWrtSh.StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
+ rWrtSh.StartAction();
+ rWrtSh.DelLeft();
+
+ 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.*/
+
+ // 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 );
+
+ 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();
+
+ rWrtSh.SetInsMode( bOldIns );
+ }
}
break;
default:
commit 852b213b22eaaa7d4bae7cba596db12f90b41a24
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Nov 17 13:33:51 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Remove m_aSuggestions member variable
We don't need it after the construction. The text is stored by the
menu item.
(cherry picked from commit dc842a4af87ae5f1edd6112ca4f2ff2ac25f5a50)
Reviewed-on: https://gerrit.libreoffice.org/83589
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 4549de73090284f149ed6ba62818e27739bdaf19)
Change-Id: I54b0392b4564e76d405824bb297e6f993a24a5fb
diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx
index bda8b7ddb3d4..b98fb5ba88f9 100644
--- a/sw/source/uibase/inc/olmenu.hxx
+++ b/sw/source/uibase/inc/olmenu.hxx
@@ -95,7 +95,6 @@ class SW_DLLPUBLIC SwSpellPopup
css::linguistic2::ProofreadingResult m_xGrammarResult;
sal_Int32 m_nGrammarError;
- css::uno::Sequence< OUString > m_aSuggestions;
OUString m_sExplanationLink;
LanguageType m_nCheckedLanguage;
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 5bafea9609e3..c9105fa27902 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -242,12 +242,13 @@ SwSpellPopup::SwSpellPopup(
bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
m_nCheckedLanguage = LANGUAGE_NONE;
+ css::uno::Sequence< OUString > aSuggestions;
if (m_xSpellAlt.is())
{
m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType();
- m_aSuggestions = m_xSpellAlt->getAlternatives();
+ aSuggestions = m_xSpellAlt->getAlternatives();
}
- sal_Int16 nStringCount = static_cast< sal_Int16 >( m_aSuggestions.getLength() );
+ sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() );
SvtLinguConfig aCfg;
@@ -275,7 +276,7 @@ SwSpellPopup::SwSpellPopup(
sal_uInt16 nItemId = MN_SUGGESTION_START;
for (sal_uInt16 i = 0; i < nStringCount; ++i)
{
- const OUString aEntry = m_aSuggestions[ i ];
+ const OUString aEntry = aSuggestions[ i ];
m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), i);
m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE);
if (!aSuggestionImageUrl.isEmpty())
@@ -445,7 +446,6 @@ SwSpellPopup::SwSpellPopup(
, m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
, m_pSh(pWrtSh)
, m_xGrammarResult(rResult)
- , m_aSuggestions(rSuggestions)
, m_sExplanationLink()
, m_bGrammarResults(true)
{
@@ -483,7 +483,7 @@ SwSpellPopup::SwSpellPopup(
m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
m_xPopupMenu->InsertSeparator(OString(), nPos++);
- sal_Int32 nStringCount = m_aSuggestions.getLength();
+ sal_Int32 nStringCount = rSuggestions.getLength();
if ( nStringCount ) // suggestions available...
{
Image aImage;
@@ -502,7 +502,7 @@ SwSpellPopup::SwSpellPopup(
sal_uInt16 nItemId = MN_SUGGESTION_START;
for (sal_Int32 i = 0; i < nStringCount; ++i)
{
- const OUString aEntry = m_aSuggestions[ i ];
+ const OUString aEntry = rSuggestions[ i ];
m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++);
m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE);
if (!aSuggestionImageUrl.isEmpty())
@@ -644,15 +644,22 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
(MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
{
- sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ?
- nId - MN_SUGGESTION_START : nId - MN_AUTOCORR_START;
- OSL_ENSURE( 0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength(), "index out of range" );
- if (0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength() && (m_bGrammarResults || m_xSpellAlt.is()))
+ OUString sNewWord;
+ if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
+ {
+ PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nCorrectMenuId);
+ assert(pMenu);
+ sNewWord = pMenu->GetItemText(nId);
+ }
+ else
+ sNewWord = m_xPopupMenu->GetItemText(nId);
+
+ if (m_bGrammarResults || m_xSpellAlt.is())
{
bool bOldIns = m_pSh->IsInsMode();
m_pSh->SetInsMode();
- OUString aTmp( m_aSuggestions[ nAltIdx ] );
+ OUString aTmp( sNewWord );
OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() );
// if original word has a trailing . (likely the end of a sentence)
@@ -688,11 +695,10 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ;
- OUString aNewWord( m_aSuggestions[ nAltIdx ] );
- SvxPrepareAutoCorrect( aOrigWord, aNewWord );
+ SvxPrepareAutoCorrect( aOrigWord, sNewWord );
if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
- pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
+ pACorr->PutText( aOrigWord, sNewWord, m_nCheckedLanguage );
/* #102505# EndAction/EndUndo moved down since insertion
of temporary auto correction is now undoable two and
commit c9c48701af9e133f682acaa8a5103f2eccd5be9e
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Nov 17 13:18:34 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Convert "IgnoreAll" menu item to use a slot ID (spelling).
When the popup is in spelling mode. "IgnoreAll_Spelling" rule
triggers this method.
Reviewed-on: https://gerrit.libreoffice.org/83588
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 352966952641eed80ae94de57065b0e0896116a6)
Change-Id: Ia1e1877f8501beff29f09bc33621c8f03008b7e8
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 46de98366fa3..8d5b0b16641a 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -890,12 +890,13 @@ uno::Reference< XSpellAlternatives >
return nullptr;
SwPaM* pCursor = GetCursor();
SwPosition aPos( *pCursor->GetPoint() );
- Point aPt( *pPt );
SwCursorMoveState eTmpState( MV_SETONLYTEXT );
SwTextNode *pNode = nullptr;
SwWrongList *pWrong = nullptr;
- if (GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState ))
+ if (pPt && GetLayout()->GetCursorOfst( &aPos, *(const_cast<Point*>(pPt)), &eTmpState ))
pNode = aPos.nNode.GetNode().GetTextNode();
+ if (nullptr == pNode)
+ pNode = pCursor->GetNode().GetTextNode();
if (nullptr != pNode)
pWrong = pNode->GetWrong();
if (nullptr != pWrong && !pNode->IsInProtectSect())
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 95393b285652..5bafea9609e3 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -722,19 +722,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == m_nIgnoreWordId)
{
- uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY );
- if (m_bGrammarResults) {
- SfxStringItem aIgnoreString(FN_PARAM_1, "IgnoreAll_Grammar");
- m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aIgnoreString });
- } else {
- OUString sWord(m_xSpellAlt->getWord());
- linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary,
- sWord, false, OUString() );
- if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is())
- {
- SvxDicError(m_pSh->GetView().GetViewFrame()->GetWindow().GetFrameWeld(), nAddRes);
- }
- }
+ 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 });
}
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 0866fe9ff899..889ba31a2612 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -103,6 +103,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
#include <com/sun/star/linguistic2/XDictionary.hpp>
+#include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
#include <editeng/unolingu.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <doc.hxx>
@@ -124,6 +125,7 @@
#include <xmloff/odffields.hxx>
#include <swabstdlg.hxx>
#include <bookmrk.hxx>
+#include <linguistic/misc.hxx>
using namespace ::com::sun::star;
using namespace com::sun::star::beans;
@@ -1429,7 +1431,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
const OUString sIgnoreString("Ignore");
const OUString sIgnoreAllPrefix("IgnoreAll_");
- //const OUString sSpellingRule("Spelling");
+ const OUString sSpellingRule("Spelling");
const OUString sGrammarRule("Grammar");
//const OUString aReplacePrefix("Replace_");
@@ -1455,7 +1457,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
if(bCorrectionRes)
{
- try{
+ try {
uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
aGrammarCheckRes.xProofreader->ignoreRule(
aGrammarCheckRes.aErrors[ nErrorInResult ].aRuleIdentifier,
@@ -1473,6 +1475,19 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
}
+ else if (sApplyText == sSpellingRule)
+ {
+ SwRect aToFill;
+ uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
+ uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
+ OUString sWord(xSpellAlt->getWord());
+ linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary,
+ sWord, false, OUString() );
+ if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is())
+ {
+ SvxDicError(rWrtSh.GetView().GetFrameWeld(), nAddRes);
+ }
+ }
}
}
break;
commit 7f9c6755b1528bfa2c0c25a36f48509107803460
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Nov 16 15:17:57 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
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
Reviewed-on: https://gerrit.libreoffice.org/83587
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 8eedef976ee5393137298756ad53d199a543fede)
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 030fc4223edf..46de98366fa3 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -956,12 +956,13 @@ bool SwEditShell::GetGrammarCorrection(
SwPaM* pCursor = GetCursor();
SwPosition aPos( *pCursor->GetPoint() );
- Point aPt( *pPt );
SwCursorMoveState eTmpState( MV_SETONLYTEXT );
SwTextNode *pNode = nullptr;
SwGrammarMarkUp *pWrong = nullptr;
- if (GetLayout()->GetCursorOfst( &aPos, aPt, &eTmpState ))
+ if (pPt && GetLayout()->GetCursorOfst( &aPos, *(const_cast<Point*>(pPt)), &eTmpState ))
pNode = aPos.nNode.GetNode().GetTextNode();
+ if (nullptr == pNode)
+ pNode = pCursor->GetNode().GetTextNode();
if (nullptr != pNode)
pWrong = pNode->GetGrammarCheck();
if (nullptr != pWrong && !pNode->IsInProtectSect())
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 0b444d8ea64e..95393b285652 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -724,22 +724,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
{
uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY );
if (m_bGrammarResults) {
- try
- {
- m_xGrammarResult.xProofreader->ignoreRule(
- m_xGrammarResult.aErrors[ m_nGrammarError ].aRuleIdentifier,
- m_xGrammarResult.aLocale );
- // refresh the layout of the actual paragraph (faster)
- SwPaM *pPaM = m_pSh->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& )
- {
- }
+ SfxStringItem aIgnoreString(FN_PARAM_1, "IgnoreAll_Grammar");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aIgnoreString });
} else {
OUString sWord(m_xSpellAlt->getWord());
linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary,
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index f2c8b5a55fde..0866fe9ff899 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -101,6 +101,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>
@@ -1426,19 +1428,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:
commit 6f3d1ccaf0b02deeff82bbd8478a528f3b9a6b5c
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Nov 16 15:14:20 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Convert "Ignore" menu item to use a slot ID.
Introduced a new slot id SID_APPLY_SPELLING, which can be used
to apply any spelling / grammar related changes (e.g. ignore,
ignore all, replace with suggestion, add to dictionary).
In this commit, only the simple ignore is implemented.
Reviewed-on: https://gerrit.libreoffice.org/83583
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 51061b780ba42d2b7673de76a729a4084da5ed2b)
Change-Id: I06ab84efeb955cc02ce3ff531bd8b5c20ddced9e
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 06c8902dadbf..f683e76a0754 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -355,6 +355,7 @@ class SfxStringItem;
#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 )
// 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 e5a430573bf8..ab3a3c3f0f34 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2631,6 +2631,11 @@
<value xml:lang="en-US">Language Status</value>
</prop>
</node>
+ <node oor:name=".uno:ApplySpellChecking" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Apply Spell Checking</value>
+ </prop>
+ </node>
<node oor:name=".uno:ChooseControls" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Insert Controls</value>
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 6d52f0328e1f..252ffa7991bf 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12035,3 +12035,20 @@ SfxVoidItem SignSignatureLine SID_SIGN_SIGNATURELINE
ToolBoxConfig = FALSE,
GroupId = SfxGroupId::Edit;
]
+
+SfxVoidItem ApplySpellChecking SID_APPLY_SPELLCHECKING
+(SfxStringItem ApplyRule 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;
+]
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 5d975daa74f4..82f0fff4dae6 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1711,5 +1711,11 @@ interface BaseText
StateMethod = GetState ;
]
+ SID_APPLY_SPELLCHECKING
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
+
} // end of interface text
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 9d1d42135357..0b444d8ea64e 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -717,9 +717,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == MN_IGNORE_SELECTION)
{
- SwPaM *pPaM = m_pSh->GetCursor();
- if (pPaM)
- SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+ SfxStringItem aIgnoreString(FN_PARAM_1, "Ignore");
+ 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 bbfbe00e6d40..f2c8b5a55fde 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1418,6 +1418,29 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
break;
+ case SID_APPLY_SPELLCHECKING:
+ {
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
+
+ const OUString sIgnoreString("Ignore");
+ //const OUString sIgnoreAllPrefix("IgnoreAll_");
+ //const OUString sSpellingRule("Spelling");
+ //const OUString sGrammarRule("Grammar");
+ //const OUString aReplacePrefix("Replace_");
+
+ // Ignore the word at the cursor pos
+ //sal_Int32 nPos = 0;
+ if (sApplyText == sIgnoreString)
+ {
+ SwPaM *pPaM = rWrtSh.GetCursor();
+ if (pPaM)
+ SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+ }
+ }
+ break;
default:
OSL_ENSURE(false, "wrong dispatcher");
return;
commit 7accd387e188e5ef989d86a97d2bd97f68a64dbe
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Nov 16 13:30:30 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Move setting UPN_IS_GRAMMAR_INTERACTIVE to the constructor.
Change-Id: Ief5470e0a61f0ca40549ab6d3768c795c3f04510
Reviewed-on: https://gerrit.libreoffice.org/83580
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit f71c99d24e210da41414203adde8d2d7872920b4)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index f102c1d30601..9d1d42135357 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -583,6 +583,8 @@ SwSpellPopup::SwSpellPopup(
checkRedline();
m_xPopupMenu->RemoveDisabledEntries(true, true);
+
+ SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
}
SwSpellPopup::~SwSpellPopup() {}
@@ -703,10 +705,6 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == m_nSpellDialogId)
{
- if (m_bGrammarResults)
- {
- SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
- }
m_pSh->Left(CRSR_SKIP_CHARS, false, 1, false );
{
m_pSh->GetView().GetViewFrame()->GetDispatcher()->
commit 05b92c6b548219e563695bd967d23b45439b8e32
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Nov 16 11:13:01 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: lok: Also hide the add menu
Change-Id: Ic6b10d579fe1fb0afe5e80244e84ed456dc6cc87
Reviewed-on: https://gerrit.libreoffice.org/83579
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 9100f5815aedf8bf202322d2ca6d16d7d1f68228)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index ea831c387b1b..f102c1d30601 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -301,6 +301,7 @@ SwSpellPopup::SwSpellPopup(
{
m_xPopupMenu->HideItem(m_nCorrectDialogId);
m_xPopupMenu->HideItem(m_nAddId);
+ m_xPopupMenu->HideItem(m_nAddMenuId);
}
sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
commit 264b3cde0956555a50999ab19ec97bd7d6f7d143
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Nov 16 10:46:28 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:27 2019 +0100
SpellingPopup: Remove unused variables
Change-Id: I3cb3b128ec54f82381bf6f0c17401a5d5fb58a96
Reviewed-on: https://gerrit.libreoffice.org/83578
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 0b7a529b364b36dfc53fcf1bce139e0ced7d2bef)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index f7eedabefaa9..ea831c387b1b 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -708,8 +708,6 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
m_pSh->Left(CRSR_SKIP_CHARS, false, 1, false );
{
- uno::Reference<linguistic2::XSearchableDictionaryList> xDictionaryList( LinguMgr::GetDictionaryList() );
- SvxDicListChgClamp aClamp( xDictionaryList );
m_pSh->GetView().GetViewFrame()->GetDispatcher()->
Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON );
}
commit a36977348ba20836ad471b1c5f1c9334591e2208
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Nov 15 20:47:57 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:26 2019 +0100
SpellingPopup: Convert selection language items to use slot id
Change-Id: I10a89d7efa957e6b94e793158983c5acf623e511
Reviewed-on: https://gerrit.libreoffice.org/83575
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 8400f8ef3b5dcaec4867c27bee7ad8f7820564ad)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 310e24cdd0b9..f7eedabefaa9 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -823,29 +823,20 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else
{
- // Set language for selection or for paragraph...
-
- SfxItemSet aCoreSet( m_pSh->GetView().GetPool(),
- svl::Items<RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
- RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
- RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>{} );
- OUString aNewLangText;
-
if (MN_SET_LANGUAGE_SELECTION_START <= nId && nId <= MN_SET_LANGUAGE_SELECTION_END)
{
- //Set language for current selection
- aNewLangText = m_aLangTable_Text[nId];
- SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_" + m_aLangTable_Text[nId]);
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_SELECTION_NONE)
{
- //Set Language_None for current selection
- SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_LANGUAGE_NONE");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_SELECTION_RESET)
{
- //reset languages for current selection
- SwLangHelper::ResetLanguages( *m_pSh );
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_RESET_LANGUAGES");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_SELECTION_MORE)
{
commit 27bae9c5c57097b2b528692e01f442832b3c049d
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Nov 15 20:42:53 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:26 2019 +0100
SpellingPopup: Convert paragraph language items to use slot id
Change-Id: I36df4777b408f9defd883d49413847152f6b496f
Reviewed-on: https://gerrit.libreoffice.org/83573
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 2c5b9eab220caf666d58e929eafbed568763b2a5)
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index ba5321cdd755..310e24cdd0b9 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -854,28 +854,18 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (MN_SET_LANGUAGE_PARAGRAPH_START <= nId && nId <= MN_SET_LANGUAGE_PARAGRAPH_END)
{
- //Set language for current paragraph
- aNewLangText = m_aLangTable_Paragraph[nId];
- m_pSh->Push(); // save cursor
- SwLangHelper::SelectCurrentPara( *m_pSh );
- SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
- m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_" + m_aLangTable_Paragraph[nId]);
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_PARA_NONE)
{
- //Set Language_None for current paragraph
- m_pSh->Push(); // save cursor
- SwLangHelper::SelectCurrentPara( *m_pSh );
- SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
- m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_LANGUAGE_NONE");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_PARA_RESET)
{
- //reset languages for current paragraph
- m_pSh->Push(); // save cursor
- SwLangHelper::SelectCurrentPara( *m_pSh );
- SwLangHelper::ResetLanguages( *m_pSh );
- m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
+ SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_RESET_LANGUAGES");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
}
else if (nId == MN_SET_PARA_MORE)
{
commit 61cfdbbad55650103e99504c2067d2b47eedd07b
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Nov 15 18:11:40 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Nov 26 18:40:26 2019 +0100
SpellingPopup: Convert char dialog related items to use slot id
After this change we can make sw_CharDialog() a local function.
Change-Id: I34b15fccaed07b5d89f63a69da8c870fff0e9b14
Reviewed-on: https://gerrit.libreoffice.org/83571
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 2f815d3092e8ba15c7f03f789b962569944f1d8a)
diff --git a/sw/source/uibase/inc/textsh.hxx b/sw/source/uibase/inc/textsh.hxx
index 2a6cd78c6149..f582a9ed7c18 100644
--- a/sw/source/uibase/inc/textsh.hxx
+++ b/sw/source/uibase/inc/textsh.hxx
@@ -86,8 +86,6 @@ public:
SfxItemSet CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr);
};
-void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq );
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 250b4cc69c42..ba5321cdd755 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -849,8 +849,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == MN_SET_SELECTION_MORE)
{
- //Open Format/Character Dialog
- sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
+ SfxStringItem aDlgString(FN_PARAM_1, "font");
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_CHAR_DLG, SfxCallMode::SYNCHRON, { &aDlgString });
}
else if (MN_SET_LANGUAGE_PARAGRAPH_START <= nId && nId <= MN_SET_LANGUAGE_PARAGRAPH_END)
{
@@ -879,11 +879,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == MN_SET_PARA_MORE)
{
- m_pSh->Push(); // save cursor
- SwLangHelper::SelectCurrentPara( *m_pSh );
- //Open Format/Character Dialog
- sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
- m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG_FOR_PARAGRAPH );
}
}
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index b6bc638131f7..bbfbe00e6d40 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -131,7 +131,7 @@ using namespace svx::sidebar;
static void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> const & pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq);
-void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq )
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list