summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/editeng/editview.cxx7
-rw-r--r--include/editeng/editview.hxx2
-rw-r--r--sc/source/ui/inc/gridwin.hxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx72
4 files changed, 15 insertions, 68 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index a422cb55c85e..17ecb94b9dd1 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -978,7 +978,7 @@ static void LOKSendSpellPopupMenu(const weld::Menu& rMenu, LanguageType nGuessLa
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str());
}
-void EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void> &rCallBack)
+bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void> &rCallBack)
{
OutputDevice& rDevice = pImpEditView->GetOutputDevice();
Point aPos(rDevice.PixelToLogic(rPosPixel));
@@ -987,7 +987,7 @@ void EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac
Reference< linguistic2::XSpellChecker1 > xSpeller( pImpEditView->pEditEngine->pImpEditEngine->GetSpeller() );
ESelection aOldSel = GetSelection();
if ( !(xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true )) )
- return;
+ return false;
// PaMtoEditCursor returns Logical units
tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
@@ -1167,7 +1167,7 @@ void EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac
xPopupMenu->remove("autocorrectdlg");
LOKSendSpellPopupMenu(*xPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
- return;
+ return true;
}
OString sId = xPopupMenu->popup_at_rect(pPopupParent, aTempRect);
@@ -1267,6 +1267,7 @@ void EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac
{
SetSelection( aOldSel );
}
+ return true;
}
OUString EditView::SpellIgnoreWord()
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 61b659dfb152..6d3a09664767 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -305,7 +305,7 @@ public:
bool IsCursorAtWrongSpelledWord();
bool IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong = false );
- void ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void>& rCallBack);
+ bool ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbackInfo&,void>& rCallBack);
OUString SpellIgnoreWord();
void InsertField( const SvxFieldItem& rFld );
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 12535cd313e0..988bf55d2a17 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -283,8 +283,6 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
bool GetEditUrl( const Point& rPos,
OUString* pName=nullptr, OUString* pUrl=nullptr, OUString* pTarget=nullptr );
- bool IsSpellErrorAtPos( const Point& rPos, SCCOL nCol1, SCROW nRow );
-
bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex,
SCCOL* pAddX, SCROW* pAddY );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1357a543659c..5a8c9625c332 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3229,12 +3229,9 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
if (aPos.Col() >= 0 && (aSpellCheckCell.meType == CELLTYPE_STRING || aSpellCheckCell.meType == CELLTYPE_EDIT))
nColSpellError = aPos.Col();
+ // Is there a missspelled word somewhere in the cell?
+ // A "yes" does not mean that the word under the mouse pointer is wrong though.
bSpellError = (mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY));
- if (bSpellError)
- {
- // Check and see if a misspelled word is under the mouse pointer.
- bSpellError = IsSpellErrorAtPos(aPosPixel, nColSpellError, nCellY);
- }
}
// #i18735# First select the item under the mouse pointer.
@@ -3248,7 +3245,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
if ( !bEdit )
{
// Edit cell with spelling errors?
- // tdf#127341 the formally used GetEditUrl(aPosPixel) additionally
+ // tdf#127341 the formerly used GetEditUrl(aPosPixel) additionally
// to bSpellError activated EditMode here for right-click on URL
// which prevents the regular context-menu from appearing. Since this
// is more expected than the context-menu for editing an URL, I removed
@@ -3300,13 +3297,18 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
const OUString sOldText = pHdl ? pHdl->GetEditString() : "";
+ // Only done/shown if a misspelled word is actually under the mouse pointer.
Link<SpellCallbackInfo&,void> aLink = LINK( this, ScGridWindow, PopupSpellingHdl );
- pEditView->ExecuteSpellPopup(aMenuPos, aLink);
+ bDone = pEditView->ExecuteSpellPopup(aMenuPos, aLink);
if (pHdl && pHdl->GetEditString() != sOldText)
pHdl->EnterHandler();
- bDone = true;
+ if (!bDone && nColSpellError != nCellX)
+ {
+ // NOTE: This call can change the selection, and the view state (edit mode, etc).
+ SelectForContextMenu(aPosPixel, nCellX, nCellY);
+ }
}
}
else if ( !bMouse )
@@ -5767,60 +5769,6 @@ bool ScGridWindow::GetEditUrl( const Point& rPos,
return false;
}
-bool ScGridWindow::IsSpellErrorAtPos( const Point& rPos, SCCOL nCol1, SCROW nRow )
-{
- if (!mpSpellCheckCxt)
- return false;
-
- SCTAB nTab = mrViewData.GetTabNo();
- ScDocShell* pDocSh = mrViewData.GetDocShell();
- ScDocument& rDoc = pDocSh->GetDocument();
-
- ScAddress aCellPos(nCol1, nRow, nTab);
- ScRefCellValue aCell(rDoc, aCellPos);
- if (aCell.meType != CELLTYPE_STRING && aCell.meType != CELLTYPE_EDIT)
- return false;
-
- const std::vector<editeng::MisspellRanges>* pRanges = mpSpellCheckCxt->getMisspellRanges(nCol1, nRow);
- if (!pRanges)
- return false;
-
- const ScPatternAttr* pPattern = rDoc.GetPattern(nCol1, nRow, nTab);
-
- tools::Rectangle aEditRect = mrViewData.GetEditArea(eWhich, nCol1, nRow, this, pPattern, false);
- if (rPos.Y() < aEditRect.Top())
- return false;
-
- std::shared_ptr<ScFieldEditEngine> pEngine = createEditEngine(pDocSh, *pPattern);
-
- Size aPaperSize(1000000, 1000000);
- pEngine->SetPaperSize(aPaperSize);
-
- if (aCell.meType == CELLTYPE_EDIT)
- pEngine->SetTextCurrentDefaults(*aCell.mpEditText);
- else
- pEngine->SetTextCurrentDefaults(aCell.mpString->getString());
-
- tools::Long nTextWidth = static_cast<tools::Long>(pEngine->CalcTextWidth());
-
- MapMode aEditMode = mrViewData.GetLogicMode(eWhich);
- tools::Rectangle aLogicEdit = PixelToLogic(aEditRect, aEditMode);
- Point aLogicClick = PixelToLogic(rPos, aEditMode);
-
- aLogicEdit.setWidth(nTextWidth + 1);
-
- if (!aLogicEdit.Contains(aLogicClick))
- return false;
-
- pEngine->SetControlWord(pEngine->GetControlWord() | EEControlBits::ONLINESPELLING);
- pEngine->SetAllMisspellRanges(*pRanges);
-
- EditView aTempView(pEngine.get(), this);
- aTempView.SetOutputArea(aLogicEdit);
-
- return aTempView.IsWrongSpelledWordAtPos(rPos);
-}
-
bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange )
{
ScDocument& rDoc = mrViewData.GetDocument();