[Libreoffice-commits] core.git: Branch 'feature/spellig_popup_SID' - 160 commits - accessibility/inc accessibility/source android/source animations/source avmedia/source basctl/source basegfx/source basic/source bridges/source canvas/source canvas/workben chart2/inc chart2/IwyuFilter_chart2.yaml chart2/qa chart2/source comphelper/qa comphelper/source compilerplugins/clang connectivity/source cppuhelper/qa cppuhelper/source cppu/source cpputools/source cui/qa cui/source cui/uiconfig dbaccess/qa dbaccess/source dbaccess/win32 desktop/qa desktop/source desktop/win32 download.lst drawinglayer/inc drawinglayer/IwyuFilter_drawinglayer.yaml drawinglayer/source dtrans/source editeng/source embeddedobj/source embedserv/source emfio/source eventattacher/source extensions/source external/libwps external/libxml2 external/libxslt external/poppler filter/source forms/source formula/source fpicker/Library_fps.mk fpicker/Module_fpicker.mk fpicker/source fpicker/WinResTarget_fps.mk framework/inc framework/IwyuFil ter_framework.yaml framework/source helpcompiler/inc helpcompiler/source helpcontent2 hwpfilter/source i18nlangtag/source i18npool/source i18nutil/source idlc/source idl/source include/comphelper include/formula include/oox include/osl include/sfx2 include/svl include/svtools include/svx include/vcl include/xmloff include/xmlscript instsetoo_native/util io/source jvmfwk/plugins libreofficekit/qa lingucomponent/source linguistic/source o3tl/qa odk/source offapi/com officecfg/registry oox/CppunitTest_oox_drawingml.mk oox/inc oox/Module_oox.mk oox/qa oox/source osx/soffice.xcodeproj package/source pyuno/inc pyuno/source registry/source registry/tools remotebridges/source reportdesign/inc reportdesign/source sal/osl sal/qa sal/rtl sal/textenc sccomp/source schema/libreoffice sc/inc scp2/source sc/qa scripting/source sc/source sc/uiconfig sdext/source sd/inc sd/qa sd/source setup_native/source sfx2/source shell/inc shell/qa shell/source slideshow/source slideshow/test solenv/bin solenv/c lang-format solenv/flatpak-manifest.in solenv/gbuild sot/source starmath/source stoc/source store/source svgio/source svl/qa svl/source svtools/inc svtools/source svx/CppunitTest_svx_unit.mk svx/inc svx/qa svx/sdi svx/source sw/inc sw/qa sw/sdi sw/source test/source testtools/source toolkit/source tools/source ucbhelper/source ucb/source unotools/source unoxml/source uui/source vbahelper/source vcl/backendtest vcl/headless vcl/inc vcl/opengl vcl/qa vcl/qt5 vcl/README vcl/source vcl/unx vcl/win vcl/workben winaccessibility/source writerfilter/source writerperfect/source xmlhelp/source xmloff/inc xmloff/source xmloff/util xmlscript/source xmlsecurity/qa xmlsecurity/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sat Nov 23 14:59:28 UTC 2019
Rebased ref, commits from common ancestor:
commit 3437e328a69b25c42638446e0633491035603057
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: Sat Nov 23 15:38:44 2019 +0100
lok: Chart context menu: Disable menu items which are not available.
Change-Id: Id7487c581759389e66ca513381d6706f3ae49980
diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx
index 72c2daaa9367..9d6cd7e2e97b 100644
--- a/chart2/source/controller/inc/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx
@@ -103,6 +103,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 ab04c1a941ec..6d820bef9598 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -44,6 +44,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>
@@ -1281,6 +1282,18 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
PopupMenu* pPopupMenu = static_cast<PopupMenu*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(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 33d3d9dacb8a2f962048cd7ab701380824ae0e21
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: Sat Nov 23 15:38:44 2019 +0100
lok: Chart context menu: Replace tunneled context menu with JS context menu.
Change-Id: I36db90887bff86036093ce0732db6fc6c76e79f6
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 83411df39171..ab04c1a941ec 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -83,6 +83,9 @@
#include <sal/log.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
@@ -1275,27 +1278,26 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if (comphelper::LibreOfficeKit::isActive())
{
- PopupMenu* pPopupMenu = static_cast<PopupMenu*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(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*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(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());
}
}
+ else
+ {
- 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 );
+ 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 );
+ }
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 9298be14c0dc..a5100da75627 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3470,7 +3470,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
}
- if (aChartHelper.GetWindow())
+ if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
{
if (aPropertyValuesVector[0].Name != "Action")
{
@@ -3502,7 +3502,17 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
bool bResult = false;
- if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(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.count(nView))
{
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
commit 62a76cc8d6c94b43c1360e436685f031129e5ab1
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: Sat Nov 23 15:38:44 2019 +0100
SpellingPopup: Create separate SID for Ignore / IgnoreAll / suggestion.
Change-Id: I20f41f511ea38f960f081f92bc36e095f7752d28
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 6e9cd310f9ad..2842dcf5a77f 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -355,7 +355,9 @@ class SvxSetItem;
#define SID_SPELL_DIALOG ( SID_SVX_START + 243 )
#define SID_INSERT_DRAW ( SID_SVX_START + 244 )
#define SID_THESAURUS ( SID_SVX_START + 245 )
-#define SID_APPLY_SPELLCHECKING ( SID_SVX_START + 246 )
+#define SID_SPELLCHECK_IGNORE ( SID_SVX_START + 246 )
+#define SID_SPELLCHECK_IGNORE_ALL ( SID_SVX_START + 247 )
+#define SID_SPELLCHECK_APPLY_SUGGESTION ( SID_SVX_START + 248 )
// CAUTION! Range <250 .. 250> used by EditEngine (!)
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index aa5173877eae..75a6a98c62a2 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2678,9 +2678,19 @@
<value xml:lang="en-US">Language Status</value>
</prop>
</node>
- <node oor:name=".uno:ApplySpellChecking" oor:op="replace">
+ <node oor:name=".uno:SpellCheckIgnore" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Apply Spell Checking</value>
+ <value xml:lang="en-US">Ignore</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:SpellCheckIgnoreAll" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">IgnoreAll</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:SpellCheckApplySuggestion" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Apply Suggestion</value>
</prop>
</node>
<node oor:name=".uno:ChooseControls" oor:op="replace">
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index d417b2ef9967..d191813d3ca6 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12170,7 +12170,41 @@ SfxVoidItem EditQrCode SID_EDIT_QRCODE
GroupId = SfxGroupId::Edit;
]
-SfxVoidItem ApplySpellChecking SID_APPLY_SPELLCHECKING
+SfxVoidItem SpellCheckIgnore SID_SPELLCHECK_IGNORE
+(SfxStringItem Type FN_PARAM_1)
+[
+ AutoUpdate = FALSE,
+ FastCall = TRUE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = SfxGroupId::Format;
+]
+
+SfxVoidItem SpellCheckIgnoreAll SID_SPELLCHECK_IGNORE_ALL
+(SfxStringItem Type FN_PARAM_1)
+[
+ AutoUpdate = FALSE,
+ FastCall = TRUE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = SfxGroupId::Format;
+]
+
+SfxVoidItem SpellCheckApplySuggestion SID_SPELLCHECK_APPLY_SUGGESTION
(SfxStringItem ApplyRule FN_PARAM_1)
[
AutoUpdate = FALSE,
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 94bcc81cd5ac..102699cbad19 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1740,7 +1740,19 @@ interface BaseText
StateMethod = GetState ;
]
- SID_APPLY_SPELLCHECKING
+ SID_SPELLCHECK_IGNORE
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
+
+ SID_SPELLCHECK_IGNORE_ALL
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
+
+ SID_SPELLCHECK_APPLY_SUGGESTION
[
ExecMethod = Execute ;
StateMethod = GetState ;
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index e09589de550b..ac0fad353974 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -599,21 +599,22 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge
{
if (comphelper::LibreOfficeKit::isActive())
{
+ // None is added only for LOK, it means there is no need to execute anything
m_xPopupMenu->SetItemCommand(MN_SHORT_COMMENT, ".uno:None");
m_xPopupMenu->SetItemCommand(m_nSpellDialogId, ".uno:SpellingAndGrammarDialog");
if(m_bGrammarResults)
- m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Grammar");
+ m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:SpellCheckIgnoreAll?Type:string=Grammar");
else
- m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Spelling");
+ m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
if(m_bGrammarResults)
- m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:ApplySpellChecking?ApplyRule:string=Ignore_Grammar");
+ m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:SpellCheckIgnore?Type:string=Grammar");
else
- m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:ApplySpellChecking?ApplyRule:string=Ignore_Spelling");
+ m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:SpellCheckIgnore?Type:string=Spelling");
for(int i = 0; i < aSuggestions.getLength(); ++i)
{
sal_uInt16 nItemId = MN_SUGGESTION_START + i;
- OUString sCommandString = OUString(".uno:ApplySpellChecking?ApplyRule:string=Replace_");
+ OUString sCommandString = OUString(".uno:SpellCheckApplySuggestion?ApplyRule:string=");
if(m_bGrammarResults)
sCommandString += "Grammar_";
else if (m_xSpellAlt.is())
@@ -706,7 +707,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
if (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END)
{
- OUString sApplyRule("Replace_");
+ OUString sApplyRule("");
if(m_bGrammarResults)
sApplyRule += "Grammar_";
else if (m_xSpellAlt.is())
@@ -714,7 +715,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
sApplyRule += m_xPopupMenu->GetItemText(nId);
SfxStringItem aApplyItem(FN_PARAM_1, sApplyRule);
- m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aApplyItem });
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_APPLY_SUGGESTION, SfxCallMode::SYNCHRON, { &aApplyItem });
}
else if(MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
{
@@ -788,13 +789,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == MN_IGNORE_SELECTION)
{
- SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Ignore_Grammar") : OUString("Ignore_Spelling"));
- m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aIgnoreString });
+ SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Grammar") : OUString("Spelling"));
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE, SfxCallMode::SYNCHRON, { &aIgnoreString });
}
else if (nId == m_nIgnoreWordId)
{
- SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("IgnoreAll_Grammar") : OUString("IgnoreAll_Spelling"));
- m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aIgnoreString });
+ SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Grammar") : OUString("Spelling"));
+ m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE_ALL, SfxCallMode::SYNCHRON, { &aIgnoreString });
}
else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId)
{
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 30c5607e51b6..6cc1d1d7b0c8 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1434,55 +1434,57 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
break;
- case SID_APPLY_SPELLCHECKING:
+ case SID_SPELLCHECK_IGNORE:
{
- OUString sApplyText;
- const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
- if (pItem2)
- sApplyText = pItem2->GetValue();
+ // If there is not selection, we need to create one, before ignoring
+ if(!rWrtSh.HasSelection())
+ {
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
- const OUString sIgnorePrefix("Ignore_");
- const OUString sIgnoreAllPrefix("IgnoreAll_");
- const OUString sSpellingRule("Spelling");
- const OUString sGrammarRule("Grammar");
- const OUString aReplacePrefix("Replace_");
+ const OUString sGrammarType("Grammar");
+ const OUString sSpellingType("Spelling");
- // Ignore the word at the cursor pos
- sal_Int32 nPos = 0;
- if (-1 != (nPos = sApplyText.indexOf( sIgnorePrefix )))
- {
- if(!rWrtSh.HasSelection())
+ if (sApplyText == sGrammarType)
{
- sApplyText = sApplyText.replaceAt(nPos, sIgnorePrefix.getLength(), "");
- if (-1 != (nPos = sApplyText.indexOf( sGrammarRule )))
- {
- linguistic2::ProofreadingResult aGrammarCheckRes;
- sal_Int32 nErrorInResult = -1;
- uno::Sequence< OUString > aSuggestions;
- sal_Int32 nErrorPosInText = -1;
- SwRect aToFill;
- bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
- if (!bCorrectionRes)
- return;
- }
- else
- {
- SwRect aToFill;
- uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
- if (!xSpellAlt.is())
- return;
- }
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
+ SwRect aToFill;
+ bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ if (!bCorrectionRes)
+ return;
+ }
+ else if (sApplyText == sSpellingType)
+ {
+ SwRect aToFill;
+ uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
+ if (!xSpellAlt.is())
+ return;
}
-
- SwPaM *pPaM = rWrtSh.GetCursor();
- if (pPaM)
- SwEditShell::IgnoreGrammarErrorAt( *pPaM );
}
- // Ignore all similar items as the current word
- else if (-1 != (nPos = sApplyText.indexOf( sIgnoreAllPrefix )))
+
+ SwPaM *pPaM = rWrtSh.GetCursor();
+ if (pPaM)
+ SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+ }
+ break;
+ case SID_SPELLCHECK_IGNORE_ALL:
+ {
+ if(!rWrtSh.HasSelection())
{
- sApplyText = sApplyText.replaceAt(nPos, sIgnoreAllPrefix.getLength(), "");
- if(sApplyText == sGrammarRule)
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
+
+ const OUString sGrammarType("Grammar");
+ const OUString sSpellingType("Spelling");
+
+ if(sApplyText == sGrammarType)
{
linguistic2::ProofreadingResult aGrammarCheckRes;
sal_Int32 nErrorInResult = -1;
@@ -1510,7 +1512,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
}
- else if (sApplyText == sSpellingRule)
+ else if (sApplyText == sSpellingType)
{
SwRect aToFill;
uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
@@ -1524,95 +1526,100 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
}
- // Replace text with the suggestion
- else if (-1 != (nPos = sApplyText.indexOf( aReplacePrefix )))
- {
- sApplyText = sApplyText.replaceAt(nPos, aReplacePrefix.getLength(), "");
+ }
+ break;
+ case SID_SPELLCHECK_APPLY_SUGGESTION:
+ {
+ OUString sApplyText;
+ const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pItem2)
+ sApplyText = pItem2->GetValue();
+
+ const OUString sSpellingRule("Spelling_");
+ const OUString sGrammarRule("Grammar_");
- const OUString sSpellingRule2(sSpellingRule + "_");
- const OUString sGrammarRule2(sGrammarRule + "_");
- bool bGrammar = false;
- uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt;
- if(-1 != (nPos = sApplyText.indexOf( sGrammarRule2 )))
+ bool bGrammar = false;
+ sal_Int32 nPos = 0;
+ uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt;
+ if(-1 != (nPos = sApplyText.indexOf( sGrammarRule )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sGrammarRule.getLength(), "");
+ if(rWrtSh.HasSelection())
{
- sApplyText = sApplyText.replaceAt(nPos, sGrammarRule2.getLength(), "");
- if(rWrtSh.HasSelection())
- {
- bGrammar = true;
- }
- else
- {
- linguistic2::ProofreadingResult aGrammarCheckRes;
- sal_Int32 nErrorInResult = -1;
- uno::Sequence< OUString > aSuggestions;
- sal_Int32 nErrorPosInText = -1;
- SwRect aToFill;
- bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
- }
+ bGrammar = true;
}
- else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule2 )))
+ else
{
- sApplyText = sApplyText.replaceAt(nPos, sSpellingRule2.getLength(), "");
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
SwRect aToFill;
- xSpellAlt.set(rWrtSh.GetCorrection(nullptr, aToFill));
- bGrammar = false;
+ bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
}
+ }
+ else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), "");
+ SwRect aToFill;
+ xSpellAlt.set(rWrtSh.GetCorrection(nullptr, aToFill));
+ bGrammar = false;
+ }
- if (!bGrammar && !xSpellAlt.is())
- return;
+ if (!bGrammar && !xSpellAlt.is())
+ return;
- bool bOldIns = rWrtSh.IsInsMode();
- rWrtSh.SetInsMode();
+ bool bOldIns = rWrtSh.IsInsMode();
+ rWrtSh.SetInsMode();
- OUString aTmp( sApplyText );
- OUString aOrig( bGrammar ? OUString() : xSpellAlt->getWord() );
+ OUString aTmp( sApplyText );
+ OUString aOrig( bGrammar ? OUString() : xSpellAlt->getWord() );
- // if original word has a trailing . (likely the end of a sentence)
- // and the replacement text hasn't, then add it to the replacement
- if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
- aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
- !aTmp.endsWith("."))
- {
- aTmp += ".";
- }
+ // if original word has a trailing . (likely the end of a sentence)
+ // and the replacement text hasn't, then add it to the replacement
+ if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
+ aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
+ !aTmp.endsWith("."))
+ {
+ aTmp += ".";
+ }
- SwRewriter aRewriter;
+ SwRewriter aRewriter;
- aRewriter.AddRule(UndoArg1, rWrtSh.GetCursorDescr());
- aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
+ aRewriter.AddRule(UndoArg1, rWrtSh.GetCursorDescr());
+ aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
- OUString aTmpStr = SwResId(STR_START_QUOTE) +
- aTmp + SwResId(STR_END_QUOTE);
- aRewriter.AddRule(UndoArg3, aTmpStr);
+ OUString aTmpStr = SwResId(STR_START_QUOTE) +
+ aTmp + SwResId(STR_END_QUOTE);
+ aRewriter.AddRule(UndoArg3, aTmpStr);
- rWrtSh.StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
- rWrtSh.StartAction();
- rWrtSh.DelLeft();
+ rWrtSh.StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
+ rWrtSh.StartAction();
+ rWrtSh.DelLeft();
- rWrtSh.Insert( aTmp );
+ rWrtSh.Insert( aTmp );
- /* #102505# EndAction/EndUndo moved down since insertion
- of temporary auto correction is now undoable two and
- must reside in the same undo group.*/
+ /* #102505# EndAction/EndUndo moved down since insertion
+ of temporary auto correction is now undoable two and
+ must reside in the same undo group.*/
- // record only if it's NOT already present in autocorrection
- SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
+ // record only if it's NOT already present in autocorrection
+ SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
- OUString aOrigWord( bGrammar ? OUString() : xSpellAlt->getWord() ) ;
- OUString aNewWord( sApplyText );
- SvxPrepareAutoCorrect( aOrigWord, aNewWord );
+ OUString aOrigWord( bGrammar ? OUString() : xSpellAlt->getWord() ) ;
+ OUString aNewWord( sApplyText );
+ SvxPrepareAutoCorrect( aOrigWord, aNewWord );
- if (xSpellAlt.is())
- pACorr->PutText( aOrigWord, aNewWord, LanguageTag( xSpellAlt->getLocale() ).getLanguageType() );
+ if (xSpellAlt.is())
+ pACorr->PutText( aOrigWord, aNewWord, LanguageTag( xSpellAlt->getLocale() ).getLanguageType() );
- /* #102505# EndAction/EndUndo moved down since insertion
- of temporary auto correction is now undoable two and
- must reside in the same undo group.*/
- rWrtSh.EndAction();
- rWrtSh.EndUndo();
+ /* #102505# EndAction/EndUndo moved down since insertion
+ of temporary auto correction is now undoable two and
+ must reside in the same undo group.*/
+ rWrtSh.EndAction();
+ rWrtSh.EndUndo();
- rWrtSh.SetInsMode( bOldIns );
- }
+ rWrtSh.SetInsMode( bOldIns );
}
break;
default:
commit 3c1222369713e02cc57cfd1895d342c3e94bb8b1
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: Sat Nov 23 15:38:44 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
diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx
index 984dfb759872..4b67c9090bce 100644
--- a/sw/source/uibase/inc/olmenu.hxx
+++ b/sw/source/uibase/inc/olmenu.hxx
@@ -126,6 +126,8 @@ public:
~SwSpellPopup();
+ void InitItemCommands(const css::uno::Sequence< OUString >& aSuggestions);
+
PopupMenu& GetMenu()
{
return *m_xPopupMenu.get();
@@ -133,7 +135,6 @@ public:
void Execute( const tools::Rectangle& rPopupPos, vcl::Window* pWin );
void Execute( sal_uInt16 nId );
-
};
#endif
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 566fb9b933d6..e09589de550b 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -422,6 +422,8 @@ SwSpellPopup::SwSpellPopup(
checkRedline();
m_xPopupMenu->RemoveDisabledEntries( true, true );
+
+ InitItemCommands(aSuggestions);
}
SwSpellPopup::SwSpellPopup(
@@ -587,10 +589,69 @@ SwSpellPopup::SwSpellPopup(
{
m_xPopupMenu->HideItem(MN_EXPLANATION_LINK);
}
+
+ InitItemCommands(rSuggestions);
}
SwSpellPopup::~SwSpellPopup() {}
+void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSuggestions)
+{
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ m_xPopupMenu->SetItemCommand(MN_SHORT_COMMENT, ".uno:None");
+ m_xPopupMenu->SetItemCommand(m_nSpellDialogId, ".uno:SpellingAndGrammarDialog");
+ if(m_bGrammarResults)
+ m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Grammar");
+ else
+ m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:ApplySpellChecking?ApplyRule:string=IgnoreAll_Spelling");
+ if(m_bGrammarResults)
+ m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:ApplySpellChecking?ApplyRule:string=Ignore_Grammar");
+ else
+ m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:ApplySpellChecking?ApplyRule:string=Ignore_Spelling");
+
+ for(int i = 0; i < aSuggestions.getLength(); ++i)
+ {
+ sal_uInt16 nItemId = MN_SUGGESTION_START + i;
+ OUString sCommandString = OUString(".uno:ApplySpellChecking?ApplyRule:string=Replace_");
+ if(m_bGrammarResults)
+ sCommandString += "Grammar_";
+ else if (m_xSpellAlt.is())
+ sCommandString += "Spelling_";
+ sCommandString += m_xPopupMenu->GetItemText(nItemId);
+ m_xPopupMenu->SetItemCommand(nItemId, sCommandString);
+ }
+
+ PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
+ if(pMenu)
+ {
+ for (auto item : m_aLangTable_Text)
+ {
+ OUString sCommandString = OUString(".uno:LanguageStatus?Language:string=Current_") + item.second;
+ pMenu->SetItemCommand(item.first, sCommandString);
+ }
+
+ pMenu->SetItemCommand(MN_SET_SELECTION_NONE, ".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE");
+ pMenu->SetItemCommand(MN_SET_SELECTION_RESET, ".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES");
+ pMenu->SetItemCommand(MN_SET_SELECTION_MORE, ".uno:FontDialog?Page:string=font");
+ }
+
+ pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
+ if(pMenu)
+ {
+ for (auto item : m_aLangTable_Paragraph)
+ {
+ OUString sCommandString = OUString(".uno:LanguageStatus?Language:string=Paragraph_") + item.second;
+ pMenu->SetItemCommand(item.first, sCommandString);
+ }
+
+ pMenu->SetItemCommand(MN_SET_PARA_NONE, ".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE");
+ pMenu->SetItemCommand(MN_SET_PARA_RESET, ".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES");
+ pMenu->SetItemCommand(MN_SET_PARA_MORE, ".uno:FontDialogForParagraph");
+ }
+ }
+}
+
void SwSpellPopup::checkRedline()
{
// Let SwView::GetState() already has the logic on when to disable the
@@ -727,7 +788,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == MN_IGNORE_SELECTION)
{
- SfxStringItem aIgnoreString(FN_PARAM_1, "Ignore");
+ SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Ignore_Grammar") : OUString("Ignore_Spelling"));
m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_APPLY_SPELLCHECKING, SfxCallMode::SYNCHRON, { &aIgnoreString });
}
else if (nId == m_nIgnoreWordId)
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 4db7fd030846..30c5607e51b6 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1441,7 +1441,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
if (pItem2)
sApplyText = pItem2->GetValue();
- const OUString sIgnoreString("Ignore");
+ const OUString sIgnorePrefix("Ignore_");
const OUString sIgnoreAllPrefix("IgnoreAll_");
const OUString sSpellingRule("Spelling");
const OUString sGrammarRule("Grammar");
@@ -1449,8 +1449,31 @@ void SwTextShell::Execute(SfxRequest &rReq)
// Ignore the word at the cursor pos
sal_Int32 nPos = 0;
- if (sApplyText == sIgnoreString)
+ if (-1 != (nPos = sApplyText.indexOf( sIgnorePrefix )))
{
+ if(!rWrtSh.HasSelection())
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sIgnorePrefix.getLength(), "");
+ if (-1 != (nPos = sApplyText.indexOf( sGrammarRule )))
+ {
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
+ SwRect aToFill;
+ bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ if (!bCorrectionRes)
+ return;
+ }
+ else
+ {
+ SwRect aToFill;
+ uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) );
+ if (!xSpellAlt.is())
+ return;
+ }
+ }
+
SwPaM *pPaM = rWrtSh.GetCursor();
if (pPaM)
SwEditShell::IgnoreGrammarErrorAt( *pPaM );
@@ -1513,12 +1536,19 @@ void SwTextShell::Execute(SfxRequest &rReq)
if(-1 != (nPos = sApplyText.indexOf( sGrammarRule2 )))
{
sApplyText = sApplyText.replaceAt(nPos, sGrammarRule2.getLength(), "");
- linguistic2::ProofreadingResult aGrammarCheckRes;
- sal_Int32 nErrorInResult = -1;
- uno::Sequence< OUString > aSuggestions;
- sal_Int32 nErrorPosInText = -1;
- SwRect aToFill;
- bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ if(rWrtSh.HasSelection())
+ {
+ bGrammar = true;
+ }
+ else
+ {
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
+ SwRect aToFill;
+ bGrammar = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ }
}
else if (-1 != (nPos = sApplyText.indexOf( sSpellingRule2 )))
{
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index e4390317d5ed..441964d1c9c9 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -66,6 +66,8 @@
#include <strings.hrc>
#include <hhcwrp.hxx>
+#include <boost/property_tree/json_parser.hpp>
+
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/ContextMenuExecuteEvent.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -91,6 +93,7 @@
#include <xmloff/odffields.hxx>
#include <editeng/editerr.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <memory>
@@ -775,9 +778,23 @@ bool SwView::ExecSpellPopup(const Point& rPt)
else
{
if (comphelper::LibreOfficeKit::isActive())
- xPopup->GetMenu().SetLOKNotifier(SfxViewShell::Current());
+ {
+ if (SfxViewShell* pViewShell = SfxViewShell::Current())
+ {
+ boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(&xPopup->GetMenu());
+ boost::property_tree::ptree aRoot;
+ aRoot.add_child("menu", aMenu);
- xPopup->Execute(aToFill.SVRect(), m_pEditWin);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aRoot, true);
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str());
+ }
+ }
+ else
+ {
+ boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(&xPopup->GetMenu());
+ xPopup->Execute(aToFill.SVRect(), m_pEditWin);
+ }
}
}
}
commit e2294e59a1eccf231190e06c3c532dd8c18689e2
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: Sat Nov 23 15:38:44 2019 +0100
Dispatch: Make fillPopupMenu() method accessible from other modules.
No functional change.
Change-Id: Ifaa6ff038277ef5702ac38d90c7461d664b0aee4
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 97f5dae19ecf..231d5eee1483 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -29,6 +29,8 @@
#include <o3tl/typed_flags_set.hxx>
#include <o3tl/span.hxx>
+#include <boost/property_tree/ptree.hpp>
+#include <vcl/menu.hxx>
#include <initializer_list>
class SfxSlotServer;
@@ -168,6 +170,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 a05abc6cb7cf..9edf43c4ecd6 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -145,103 +145,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.
*/
@@ -2077,4 +1980,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 b5fc479359a14a5b9a1b634f02a9a18e80ae3d0c
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: Sat Nov 23 15:38:43 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
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index e08c5f4a2804..566fb9b933d6 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);
@@ -580,6 +582,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 c2f58bc25cedf8a13a978b52a5bf012809fc38ed
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: Sat Nov 23 15:38:43 2019 +0100
SpellingPopup: Convert suggestion menu items to use slot ID.
Change-Id: Icf1f50d04ab5e7ba467d68613f4101a3fe48589b
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index f04fb6b71880..e08c5f4a2804 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -636,26 +636,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
@@ -688,11 +691,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 bff08a595f18..4db7fd030846 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -128,6 +128,7 @@
#include <xmloff/odffields.hxx>
#include <bookmrk.hxx>
#include <linguistic/misc.hxx>
+#include <editeng/splwrap.hxx>
using namespace ::com::sun::star;
using namespace com::sun::star::beans;
@@ -1444,7 +1445,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;
@@ -1500,6 +1501,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 dc842a4af87ae5f1edd6112ca4f2ff2ac25f5a50
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: Sat Nov 23 15:38:43 2019 +0100
SpellingPopup: Remove m_aSuggestions member variable
We don't need it after the construction. The text is stored by the
menu item.
Change-Id: I54b0392b4564e76d405824bb297e6f993a24a5fb
diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx
index db80e20e931a..984dfb759872 100644
--- a/sw/source/uibase/inc/olmenu.hxx
+++ b/sw/source/uibase/inc/olmenu.hxx
@@ -96,7 +96,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 57260b5b4dd7..f04fb6b71880 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())
@@ -443,7 +444,6 @@ SwSpellPopup::SwSpellPopup(
, m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
, m_pSh(pWrtSh)
, m_xGrammarResult(rResult)
- , m_aSuggestions(rSuggestions)
, m_sExplanationLink()
, m_bGrammarResults(true)
{
@@ -480,7 +480,7 @@ SwSpellPopup::SwSpellPopup(
m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
m_xPopupMenu->InsertSeparator(OString(), nPos++);
- if ( m_aSuggestions.hasElements() ) // suggestions available...
+ if ( rSuggestions.hasElements() ) // suggestions available...
{
Image aImage;
OUString aSuggestionImageUrl;
@@ -496,7 +496,7 @@ SwSpellPopup::SwSpellPopup(
}
sal_uInt16 nItemId = MN_SUGGESTION_START;
- for (const OUString& aEntry : std::as_const(m_aSuggestions))
+ for (const OUString& aEntry : std::as_const(rSuggestions))
{
m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++);
m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE);
@@ -639,15 +639,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(nAltIdx < m_aSuggestions.getLength(), "index out of range");
- if (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)
@@ -682,11 +689,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 65f81c16ccf36a2ad6aa7dae827b3e3b304fc046
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: Sat Nov 23 15:38:43 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.
Change-Id: Ia1e1877f8501beff29f09bc33621c8f03008b7e8
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 1c03f321de69..f0220a8e7ef2 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -897,12 +897,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 4d2e83131636..57260b5b4dd7 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -716,19 +716,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
else if (nId == m_nIgnoreWordId)
{
- uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
- 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().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 510c25432e32..bff08a595f18 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -105,6 +105,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>
@@ -126,6 +127,7 @@
#include <memory>
#include <xmloff/odffields.hxx>
#include <bookmrk.hxx>
+#include <linguistic/misc.hxx>
using namespace ::com::sun::star;
using namespace com::sun::star::beans;
@@ -1440,7 +1442,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_");
@@ -1466,7 +1468,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,
@@ -1484,6 +1486,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 4fa12ed8fee1f69ecf999ee334721772422a6456
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: Sat Nov 23 15:38:43 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
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index ef4c5af85743..1c03f321de69 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -963,12 +963,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 e627534fdf6e..4d2e83131636 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -718,22 +718,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
{
uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
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 fc940da44737..510c25432e32 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -103,6 +103,8 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
+#include <com/sun/star/linguistic2/XDictionary.hpp>
#include <editeng/unolingu.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <doc.hxx>
@@ -1437,19 +1439,52 @@ void SwTextShell::Execute(SfxRequest &rReq)
sApplyText = pItem2->GetValue();
const OUString sIgnoreString("Ignore");
- //const OUString sIgnoreAllPrefix("IgnoreAll_");
+ const OUString sIgnoreAllPrefix("IgnoreAll_");
//const OUString sSpellingRule("Spelling");
- //const OUString sGrammarRule("Grammar");
+ const OUString sGrammarRule("Grammar");
//const OUString aReplacePrefix("Replace_");
// Ignore the word at the cursor pos
- //sal_Int32 nPos = 0;
+ sal_Int32 nPos = 0;
if (sApplyText == sIgnoreString)
{
SwPaM *pPaM = rWrtSh.GetCursor();
if (pPaM)
SwEditShell::IgnoreGrammarErrorAt( *pPaM );
}
+ // Ignore all similar items as the current word
+ else if (-1 != (nPos = sApplyText.indexOf( sIgnoreAllPrefix )))
+ {
+ sApplyText = sApplyText.replaceAt(nPos, sIgnoreAllPrefix.getLength(), "");
+ if(sApplyText == sGrammarRule)
+ {
+ linguistic2::ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< OUString > aSuggestions;
+ sal_Int32 nErrorPosInText = -1;
+ SwRect aToFill;
+ bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill );
+ if(bCorrectionRes)
+ {
+ try{
+ uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
+ aGrammarCheckRes.xProofreader->ignoreRule(
+ aGrammarCheckRes.aErrors[ nErrorInResult ].aRuleIdentifier,
+ aGrammarCheckRes.aLocale );
+ // refresh the layout of the actual paragraph (faster)
+ SwPaM *pPaM = rWrtSh.GetCursor();
+ if (pPaM)
+ SwEditShell::IgnoreGrammarErrorAt( *pPaM );
+ // refresh the layout of all paragraphs (workaround to launch a dictionary event)
+ xDictionary->setActive(false);
+ xDictionary->setActive(true);
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+ }
}
break;
default:
commit 816f7c4bbb9ecd2c0fca68e8fc7a276b7e793153
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: Sat Nov 23 15:38:43 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.
Change-Id: I06ab84efeb955cc02ce3ff531bd8b5c20ddced9e
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 100d2f4fbaf8..6e9cd310f9ad 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -355,6 +355,7 @@ class SvxSetItem;
#define SID_SPELL_DIALOG ( SID_SVX_START + 243 )
#define SID_INSERT_DRAW ( SID_SVX_START + 244 )
#define SID_THESAURUS ( SID_SVX_START + 245 )
+#define SID_APPLY_SPELLCHECKING ( SID_SVX_START + 246 )
// 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 58114eef36c7..aa5173877eae 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2678,6 +2678,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 b501e546e7bb..d417b2ef9967 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12169,3 +12169,20 @@ SfxVoidItem EditQrCode SID_EDIT_QRCODE
ToolBoxConfig = TRUE,
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 bfd47719ca35..94bcc81cd5ac 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1740,5 +1740,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 23435104bfc5..e627534fdf6e 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -711,9 +711,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 41d2fbded1da..fc940da44737 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1429,6 +1429,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 a5b2583cfa41852d526ffe360e3887c71174744a
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: Sat Nov 23 15:38:43 2019 +0100
SpellingPopup: Move setting UPN_IS_GRAMMAR_INTERACTIVE to the constructor.
Change-Id: Ief5470e0a61f0ca40549ab6d3768c795c3f04510
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index ccb4beeb9895..23435104bfc5 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -578,6 +578,8 @@ SwSpellPopup::SwSpellPopup(
checkRedline();
m_xPopupMenu->RemoveDisabledEntries(true, true);
+
+ SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
}
SwSpellPopup::~SwSpellPopup() {}
@@ -697,10 +699,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 50a6e53b896d160c968d142b64a9ed62dc65d5f5
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: Sat Nov 23 15:38:43 2019 +0100
SpellingPopup: lok: Also hide the add menu
Change-Id: Ic6b10d579fe1fb0afe5e80244e84ed456dc6cc87
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index e1ef7a80621d..ccb4beeb9895 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 9d6942c643388228b8f5b99cd37ef6968eab962a
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: Sat Nov 23 15:38:42 2019 +0100
SpellingPopup: Remove unused variables
Change-Id: I3cb3b128ec54f82381bf6f0c17401a5d5fb58a96
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 5be1f29b859c..e1ef7a80621d 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -702,8 +702,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 99aca123223222580f3051d063c717074de60b28
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: Sat Nov 23 15:38:42 2019 +0100
SpellingPopup: Convert selection language items to use slot id
Change-Id: I10a89d7efa957e6b94e793158983c5acf623e511
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 81f336ea0339..5be1f29b859c 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -817,29 +817,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 9003fd73410024a6a40c22cb61f0092341dd0aef
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: Sat Nov 23 15:38:42 2019 +0100
SpellingPopup: Convert paragraph language items to use slot id
Change-Id: I36df4777b408f9defd883d49413847152f6b496f
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index e4dbe6ed9b76..81f336ea0339 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -848,28 +848,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 463d52dfdd8d31a40a8d6867ac2171819cccb635
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: Sat Nov 23 15:38:42 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
diff --git a/sw/source/uibase/inc/textsh.hxx b/sw/source/uibase/inc/textsh.hxx
index af865e56ed63..9ec521afe647 100644
--- a/sw/source/uibase/inc/textsh.hxx
+++ b/sw/source/uibase/inc/textsh.hxx
@@ -83,8 +83,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 8cc000318df0..e4dbe6ed9b76 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -843,8 +843,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)
{
@@ -873,11 +873,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 9f7dee3aeb2b..41d2fbded1da 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -133,7 +133,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 )
+static void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq )
{
FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rWrtSh.GetView()) != nullptr );
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
@@ -187,7 +187,7 @@ void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const
pDlg->SetCurPageId("hyperlink");
else if (nSlot == SID_CHAR_DLG_EFFECT)
pDlg->SetCurPageId("fonteffects");
- else if (nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
+ else if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
pDlg->SetCurPageId("font");
else if (pReq)
{
commit 0bf72934d73fb3c52fbeee25bb63332739b94696
Author: Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sat Nov 23 13:39:36 2019 +0100
Commit: Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Sat Nov 23 14:26:00 2019 +0100
cppcheck: performing initialization in initialization list (sfx2/doctempl)
Change-Id: I91f077fc6c3e74ea1c0470a562e3d762ab3b1439
Reviewed-on: https://gerrit.libreoffice.org/83550
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx
index 02744f627657..bf8d8587b1c2 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -1319,9 +1319,8 @@ const OUString& DocTempl_EntryData_Impl::GetTargetURL()
RegionData_Impl::RegionData_Impl( const SfxDocTemplate_Impl* pParent,
const OUString& rTitle )
+ : mpParent(pParent), maTitle(rTitle)
{
- maTitle = rTitle;
- mpParent = pParent;
}
commit 1347dc450b13cac8643db3ccb2670838dc82d138
Author: Zdeněk Crhonek <zcrhonek at gmail.com>
AuthorDate: Sat Nov 23 09:31:10 2019 +0100
Commit: Zdenek Crhonek <zcrhonek at gmail.com>
CommitDate: Sat Nov 23 13:44:38 2019 +0100
uitest for bug tdf#91217
Change-Id: I0322a3bc821850d5f15aeb690ba80ff7b8129140
Reviewed-on: https://gerrit.libreoffice.org/83546
Tested-by: Jenkins
Reviewed-by: Zdenek Crhonek <zcrhonek at gmail.com>
diff --git a/sc/qa/uitest/calc_tests/data/tdf91217.ods b/sc/qa/uitest/calc_tests/data/tdf91217.ods
new file mode 100644
index 000000000000..c1bb9da85c94
Binary files /dev/null and b/sc/qa/uitest/calc_tests/data/tdf91217.ods differ
diff --git a/sc/qa/uitest/calc_tests9/tdf91217.py b/sc/qa/uitest/calc_tests9/tdf91217.py
new file mode 100644
index 000000000000..103c970e6740
--- /dev/null
+++ b/sc/qa/uitest/calc_tests9/tdf91217.py
@@ -0,0 +1,43 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+#Bug 91217 - Crash when deleting rows
+
+class tdf91217(UITestCase):
+ def test_tdf91217_crash_deleting_rows(self):
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf91217.ods"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ #Select rows 76-1125 in sheet 3 (Daily), right click, Delete Rows. Instant crash.
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A76:A1125"}))
+ self.xUITest.executeCommand(".uno:SelectRow")
+ #delete rows
+ self.xUITest.executeCommand(".uno:DeleteRows")
+ #A1 should be "Dist"
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist")
+ #- Undo-redo
+ self.xUITest.executeCommand(".uno:Undo")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist")
+
+ self.xUITest.executeCommand(".uno:Redo")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist")
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
commit fdff5df464598261ed8d5137e1685bc538b3cb25
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri Nov 22 12:26:08 2019 +0100
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Sat Nov 23 10:05:02 2019 +0100
OfaTreeOptionsDialog::LoadModule: Use range-based for
Change-Id: I2b191dd55dcd9e085b2cde6bacd1e2e3c963fafa
Reviewed-on: https://gerrit.libreoffice.org/83489
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 0195856932c7..69f59f745421 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1653,18 +1653,17 @@ std::unique_ptr<Module> OfaTreeOptionsDialog::LoadModule(
Reference< XNameAccess > xSet(
officecfg::Office::OptionsDialog::Modules::get());
- Sequence< OUString > seqNames = xSet->getElementNames();
- for ( int i = 0; i < seqNames.getLength(); ++i )
+ const Sequence< OUString > seqNames = xSet->getElementNames();
+ for ( const OUString& rModule : seqNames )
{
- OUString sModule( seqNames[i] );
- if ( rModuleIdentifier == sModule )
+ if ( rModuleIdentifier == rModule )
{
// current active module found
pModule.reset(new Module);
pModule->m_bActive = true;
Reference< XNameAccess > xModAccess;
- xSet->getByName( seqNames[i] ) >>= xModAccess;
+ xSet->getByName( rModule ) >>= xModAccess;
if ( xModAccess.is() )
{
// load the nodes of this module
@@ -1672,19 +1671,19 @@ std::unique_ptr<Module> OfaTreeOptionsDialog::LoadModule(
xModAccess->getByName( "Nodes" ) >>= xNodeAccess;
if ( xNodeAccess.is() )
{
- Sequence< OUString > xTemp = xNodeAccess->getElementNames();
+ const Sequence< OUString > xTemp = xNodeAccess->getElementNames();
Reference< XNameAccess > xAccess;
sal_Int32 nIndex = -1;
- for ( int x = 0; x < xTemp.getLength(); ++x )
+ for ( const OUString& rNode : xTemp)
{
- xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
+ xNodeAccess->getByName( rNode ) >>= xAccess;
if ( xAccess.is() )
{
xAccess->getByName( "Index" ) >>= nIndex;
if ( nIndex < 0 )
// append nodes with index < 0
pModule->m_aNodeList.push_back(
- std::unique_ptr<OrderedEntry>(new OrderedEntry(nIndex, xTemp[x])));
+ std::unique_ptr<OrderedEntry>(new OrderedEntry(nIndex, rNode)));
else
{
// search position of the node
@@ -1698,7 +1697,7 @@ std::unique_ptr<Module> OfaTreeOptionsDialog::LoadModule(
// and insert the node on this position
pModule->m_aNodeList.insert(
pModule->m_aNodeList.begin() + y,
- std::unique_ptr<OrderedEntry>(new OrderedEntry( nIndex, xTemp[x] )) );
+ std::unique_ptr<OrderedEntry>(new OrderedEntry( nIndex, rNode )) );
}
}
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list