summaryrefslogtreecommitdiff
path: root/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2017-07-17 23:25:49 +1000
committerMichael Stahl <mstahl@redhat.com>2017-07-20 21:27:04 +0200
commit8b321625d50f33bbd9ae3eed08d5d2b6b1944248 (patch)
treed2500ac96ef5ab2a10c99a82dba9a596db492795 /sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
parent102b01c80a271ccaec226d7b0bcc960917ea6b57 (diff)
tdf#46852 fix spellcheck continue at beginning
When a spellcheck reaches the end of the document, it is supposed to be able to continue from the beginning of the document to the point at which the spellcheck was started. This was not working in the case where the word at the starting position was replaced due to a spelling correction, which causes the starting position to be lost. Fix this situation by recording the position immediately *before* the spellcheck starting position, so that it will not be affected by a spelling correction *at* the starting position. Change-Id: I9483fd5937dc1e235f6f9639d4856fe15e3d47a6 Reviewed-on: https://gerrit.libreoffice.org/40123 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx')
-rw-r--r--sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index f0b489455d49..f04020dabfbb 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -227,14 +227,20 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck)
}
else
{
- SwPaM* pCursor = pWrtShell->GetCursor();
// mark the start position only if not at start of doc
if(!pWrtShell->IsStartOfDoc())
{
- m_pSpellState->m_xStartRange =
- SwXTextRange::CreateXTextRange(
- *pWrtShell->GetDoc(),
- *pCursor->Start(), pCursor->End());
+ // Record the position *before* the current cursor, as
+ // the word at the current cursor can possibly be
+ // replaced by a spellcheck correction which invalidates
+ // an XTextRange at this position.
+ SwDoc *pDoc = pWrtShell->GetDoc();
+ auto pStart = pWrtShell->GetCursor()->Start();
+ auto pUnoCursor = pDoc->CreateUnoCursor(*pStart);
+ pUnoCursor->Left( 1 );
+ pStart = pUnoCursor->Start();
+ m_pSpellState->m_xStartRange
+ = SwXTextRange::CreateXTextRange(*pDoc, *pStart, nullptr);
}
pWrtShell->SpellStart( SwDocPositions::Start, SwDocPositions::End, SwDocPositions::Curr );
}