summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2015-07-20 22:41:56 -0400
committerNorbert Thiebaud <nthiebaud@gmail.com>2015-08-16 05:05:44 +0000
commit0a22f4fd6d7496678822731a7bdd37687f717adf (patch)
treeb834160637f8755f223f21ea8d14427ea80b622b /sw
parentc0a7b924d020afdcfd61a8fd116b4dd2fbdab778 (diff)
Spell-check wrong-dirty text upon showing context menu.
This makes for a better user experience when the idle jobs haven't yet ran on some text to check for spelling. This can happen when the user is on a device with insufficient compute power and/or other idle jobs with higher-priority take precedence. This change leap-frogs the spell-checking idle job when the user might already know they mistyped a word and look for a quick fix via the context menu. Change-Id: Id1f7b4555050ded329ebeb56502f893ee7b2bc35 Reviewed-on: https://gerrit.libreoffice.org/17252 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/uiview/viewling.cxx27
1 files changed, 24 insertions, 3 deletions
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index f074cbf7e896..1758a2fc8222 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -54,6 +54,7 @@
#include <edtwin.hxx>
#include <crsskip.hxx>
#include <ndtxt.hxx>
+#include <txtfrm.hxx>
#include <vcl/lstbox.hxx>
#include <cmdid.h>
#include <globals.hrc>
@@ -641,6 +642,29 @@ bool SwView::ExecSpellPopup(const Point& rPt)
m_pWrtShell->Push();
SwRect aToFill;
+ SwCrsrShell *pCrsrShell = static_cast<SwCrsrShell*>(m_pWrtShell);
+ SwPaM *pCrsr = pCrsrShell->GetCrsr();
+ SwPosition aPoint(*pCrsr->GetPoint());
+ const SwTextNode *pNode = aPoint.nNode.GetNode().GetTextNode();
+
+ // Spell-check in case the idle jobs haven't had a chance to kick in.
+ // This makes it possible to suggest spelling corrections for
+ // wrong words independent of the spell-checking idle job.
+ if (pNode && pNode->IsWrongDirty() &&
+ m_pWrtShell->ISA(SwCrsrShell) && !pCrsrShell->IsTableMode() &&
+ !pCrsr->HasMark() && !pCrsr->IsMultiSelection())
+ {
+ SwContentFrm *pFrm = pCrsr->GetContentNode()->getLayoutFrm(
+ pCrsrShell->GetLayout(),
+ &rPt, &aPoint, false);
+ if (pFrm)
+ {
+ SwRect aRepaint(static_cast<SwTextFrm*>(pFrm)->_AutoSpell(nullptr, 0));
+ if (aRepaint.HasArea())
+ m_pWrtShell->InvalidateWindows(aRepaint);
+ }
+ }
+
// decide which variant of the context menu to use...
// if neither spell checking nor grammar checking provides suggestions use the
// default context menu.
@@ -669,9 +693,6 @@ bool SwView::ExecSpellPopup(const Point& rPt)
{
// get paragraph text
OUString aParaText;
- SwPosition aPoint( *m_pWrtShell->GetCrsr()->GetPoint() );
- const SwTextNode *pNode = dynamic_cast< const SwTextNode * >(
- &aPoint.nNode.GetNode() );
if (pNode)
aParaText = pNode->GetText(); // this may include hidden text but that should be Ok
else