[Libreoffice-commits] core.git: Branch 'feature/spellig_popup_SID' - 166 commits - accessibility/source android/source basctl/source basic/source bean/com bin/run bin/symstore.sh bridges/source chart2/source comphelper/Library_comphelper.mk comphelper/source compilerplugins/clang configure.ac cui/Library_cui.mk cui/source cui/uiconfig desktop/source download.lst drawinglayer/source editeng/source emfio/inc extensions/source external/python3 filter/source filter/uiconfig forms/source formula/source fpicker/source framework/inc framework/source helpcontent2 i18nlangtag/source i18npool/CustomTarget_breakiterator.mk i18npool/Executable_gendict.mk i18npool/Module_i18npool.mk i18npool/source icon-themes/colibre include/comphelper include/drawinglayer include/editeng include/formula include/i18nlangtag include/i18nutil include/LibreOfficeKit include/sfx2 include/svtools include/svx include/tools include/vcl jurt/com l10ntools/source libreofficekit/qa libreofficekit/source linguistic/source o3tl/qa odk/s ource offapi/com offapi/UnoApi_offapi.mk officecfg/registry oox/source qadevOOo/tests sal/osl sal/qa sal/rtl sax/source sc/inc sc/qa sc/source sc/uiconfig sd/qa sd/source sfx2/source sfx2/uiconfig solenv/CompilerTest_compilerplugins_clang.mk soltools/cpp starmath/source svl/source svtools/inc svtools/source svx/sdi svx/source sw/CppunitTest_sw_rtfexport4.mk sw/inc sw/qa sw/sdi sw/source sw/uiconfig sysui/CustomTarget_share.mk ucb/source uitest/test_main.py uitest/writer_tests UnoControls/source unotools/source vcl/headless vcl/inc vcl/ios vcl/osx vcl/qa vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/workben wizards/com writerfilter/source xmloff/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 22 17:07:26 UTC 2019
Rebased ref, commits from common ancestor:
commit 2fcebe3852c886c43a0f214ed5729f1a506a5039
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: Fri Nov 22 18:05:26 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 ccb430335e9a2f4be610672e965f0c45ef509eaa
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: Fri Nov 22 18:04:05 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 1e97c1aecc4b..4712f40fa7ba 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3462,7 +3462,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
}
- if (aChartHelper.GetWindow())
+ if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
{
if (aPropertyValuesVector[0].Name != "Action")
{
@@ -3494,7 +3494,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 2a9dc36d259a045337a9ab6d6fac964b665f4541
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: Thu Nov 21 14:48:22 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 143727cec71a..802fac4c1093 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 ade3d761742084f81ab8c441162eb0783a563e7d
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: Thu Nov 21 14:48:09 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 3d85fb02edb0..7aae55d310a2 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>
@@ -771,9 +774,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 7fb6147324c6c850359290aa4a550e0953d30a3d
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 19 18:19:37 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 246a10d32ca5..31b34a924446 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -141,103 +141,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 b00ad2a2a591c7a986283ee6b5ac3b9d6cd37e1a
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 19 18:19:37 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 d3d6d8b75b81765deda7e12768dcc16cae03d607
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 19 18:19:37 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 5cd452d6f44ba9c907581e5db54e67d782ac1423
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 19 18:19:37 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 5fdd9bfe699139a56d87604a53aec1178030a3db
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 19 18:19:37 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 49b81a757f57..aca39c36fd1f 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -889,12 +889,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 eb3f74e2d4039ba0424e839ec7f5e88910899f0d
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 19 18:19:37 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 fa1078cdecf7..49b81a757f57 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -955,12 +955,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 460e1f7552291fd6ac415afc2d9e68687cd67b4c
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 19 18:19:37 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 34cdc64758af..143727cec71a 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 88d18eb9eaa0518e1ad59905d35f3aeee0dde496
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 19 18:19:37 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 3e7cd0ca41133ae4227d3591a298ea3810c77332
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 19 18:19:36 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 81482ead343e913bd2124caaf1f51e9d2f35f7d3
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 19 18:19:36 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 9e8490b26564afb26436bc579f2a5410ecd61507
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 19 18:19:36 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 5e220a5be3b2cd02d95545d74bdb59dc945a96dc
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 19 18:19:36 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 9d0132f1d05ff1566e5504df0bab6ccdb13161d9
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 19 18:19:36 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 93ee955c5359e283e2fe88e45b4c02a60525ed11
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
AuthorDate: Mon Nov 18 17:08:00 2019 +0100
Commit: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Tue Nov 19 18:16:18 2019 +0100
tdf#128101 android: fix documents with manual page break
code reads a .ui file to show a menu to edit/delete that pagebreak. That
file was not packaged in the Android viewer and causes an exception that
is not handled and ultimately results in a crash.
Change-Id: Ie73d886daf9202ba12e1b5a241bc7b6d184ae770
Reviewed-on: https://gerrit.libreoffice.org/83104
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
diff --git a/android/source/build.gradle b/android/source/build.gradle
index 5bf49406648e..5ca9a02a4973 100644
--- a/android/source/build.gradle
+++ b/android/source/build.gradle
@@ -149,6 +149,13 @@ task copyUnpackAssets(type: Copy) {
)
}
}
+ // documents with manual page break trigger attempt to read the ui file
+ // would trigger a css::container::NoSuchElementException with osl_File_E_NOENT
+ // if not present and since it is not caught would crash the app...
+ into('config') {
+ from "${liboInstdir}/share/config"
+ include '**/pagebreakmenu.ui'
+ }
}
task copyAssets(type: Copy) {
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 96a9cfecf2b1..b6a0acaae2c4 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -830,8 +830,15 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, sal_uI
{
void* address;
size_t size;
+ // some requests are /assets//foo...
+ size_t offset = sizeof("/assets/")-1;
+ if (cpFilePath[offset] == '/') {
+ __android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", "double-slash in path: %s", cpFilePath);
+ offset++;
+ }
AAssetManager* mgr = lo_get_native_assetmgr();
- AAsset* asset = AAssetManager_open(mgr, cpFilePath + sizeof("/assets/")-1, AASSET_MODE_BUFFER);
+ AAsset* asset = AAssetManager_open(mgr, cpFilePath + offset, AASSET_MODE_BUFFER);
+
if (!asset)
{
address = NULL;
commit b926a068a067e7aff6c8f11ed1098a76c39bf5e8
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Mon Nov 11 07:27:43 2019 +0300
Commit: Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Nov 19 17:15:19 2019 +0100
tdf#128608 ww8import: COL_AUTO == NO FILL, not solid
This fixes problems in the patches for tdf#116071.
Tables have nothing to do with this bug. It just is the most
common place to have a background colour, and then to have
direct formatting that reverts back to COL_AUTO. I created
a unit test using the page background (black), default style
paragraph background (blue), and direct formatting COL_AUTO.
COL_AUTO was turned into WHITE if the fillstyle was set to SOLID.
Change-Id: I8197c040cec5adbdf16f379a88fab5e534ac0c6e
Reviewed-on: https://gerrit.libreoffice.org/82412
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
diff --git a/sw/qa/extras/ww8export/data/tdf128608_fillStyleNoneB.odt b/sw/qa/extras/ww8export/data/tdf128608_fillStyleNoneB.odt
new file mode 100644
index 000000000000..917dc96d40ba
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf128608_fillStyleNoneB.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 96940648ad2b..014274e98bbf 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -202,7 +202,14 @@ DECLARE_WW8EXPORT_TEST(testTdf121111_fillStyleNone, "tdf121111_fillStyleNone.doc
uno::Reference<text::XTextRange> xText(getParagraph(12));
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(xText, "ParaBackColor")));
- CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xText, "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf128608_fillStyleNoneB, "tdf128608_fillStyleNoneB.odt")
+{
+ uno::Reference<text::XTextRange> xText(getParagraph(1));
+ CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(xText, "ParaBackColor")));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("No fill", drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
}
DECLARE_WW8EXPORT_TEST(testTdf112618_textbox_no_bg, "tdf112618_textbox_no_bg.doc")
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index f0d93a16044f..43b376062401 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -4908,13 +4908,8 @@ void SwWW8ImplReader::Read_ParaBackColor(sal_uInt16, const sal_uInt8* pData, sho
if (nLen <= 0)
{
// end of attribute
- if ( m_nInTable )
- m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_BACKGROUND );
- else
- {
- m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), XATTR_FILLSTYLE );
- m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), XATTR_FILLCOLOR );
- }
+ m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), XATTR_FILLSTYLE );
+ m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), XATTR_FILLCOLOR );
}
else
{
@@ -4922,13 +4917,12 @@ void SwWW8ImplReader::Read_ParaBackColor(sal_uInt16, const sal_uInt8* pData, sho
if (nLen != 10)
return;
- if ( m_nInTable )
- NewAttr( SvxBrushItem(ExtractColour(pData, m_bVer67), RES_BACKGROUND) );
+ const Color aColor = ExtractColour(pData, m_bVer67);
+ NewAttr( XFillColorItem(OUString(), aColor) );
+ if ( aColor == COL_AUTO )
+ NewAttr( XFillStyleItem(drawing::FillStyle_NONE) );
else
- {
NewAttr( XFillStyleItem(drawing::FillStyle_SOLID) );
- NewAttr( XFillColorItem(OUString(), ExtractColour(pData, m_bVer67)) );
- }
}
}
commit 8f7274682661baec4c9b160ee2165972bbfa9881
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Nov 19 10:54:57 2019 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Nov 19 17:02:11 2019 +0100
sw: fix invalid downcast of SwDrawFrameFormat in DelContentIndex()
failure in UITest_writer_tests6:
sw/source/core/undo/undobj.cxx:1021:47: runtime error: downcast of address 0x61300019d3c0 which does not point to an object of type 'SwFlyFrameFormat'
0x61300019d3c0:m note: object is of type 'SwDrawFrameFormat'
a2 01 80 19 50 ac d1 9e 14 7f 00 00 00 af 19 00 30 61 00 00 e8 4f 0b 00 b0 61 00 00 40 dd 40 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'SwDrawFrameFormat'
in SwUndoSaveContent::DelContentIndex(SwPosition const&, SwPosition const&, DelContentType) at sw/source/core/undo/undobj.cxx:1021:47 (instdir/program/../program/libswlo.so +0xf8e5833)
Also lose the ridiculous overloading across derived classes.
Change-Id: I19439d0d511c5f8c36b00d8dd02c31f802a44e00
Reviewed-on: https://gerrit.libreoffice.org/83175
Tested-by: Jenkins
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list