sw/source/core/edit/edlingu.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
New commits: commit c29caa41f826e0f3f7850d6276407a937c512957 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Mar 8 13:58:28 2022 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sat Mar 12 11:16:27 2022 +0100 tdf#147416 sw_redlinehide: fix spell checking popup The problem is that SwEditShell::GetCorrection() uses the SwTextNode text without filtering redlines. Using ExpandMode::ReplaceMode should work as it will replace CH_TXTATR_INWORD with nothing and CH_TXTATR_BREAKWORD with ZWSP. Unfortunately there isn't yet a mode that can handle fieldmarks as they are displayed in the layout. Change-Id: Ia243d90309fdd7b6ca159c5df2f4d98725400c5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131210 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit e07b9c5142af838648a4d03a0bdce76612cf7535) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131198 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index a393afdb225c..03e230f11d2f 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -839,11 +839,16 @@ void SwEditShell::HandleCorrectionError(const OUString& aText, SwPosition aPos, SwRect& rSelectRect) { // save the start and end positions of the line and the starting point + SwNode const& rNode(GetCursor()->GetPoint()->nNode.GetNode()); Push(); LeftMargin(); - const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex(); + const sal_Int32 nLineStart = &rNode == &GetCursor()->GetPoint()->nNode.GetNode() + ? GetCursor()->GetPoint()->nContent.GetIndex() + : 0; RightMargin(); - const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex(); + const sal_Int32 nLineEnd = &rNode == &GetCursor()->GetPoint()->nNode.GetNode() + ? GetCursor()->GetPoint()->nContent.GetIndex() + : rNode.GetTextNode()->Len(); Pop(PopMode::DeleteCurrent); // make sure the selection build later from the data below does @@ -926,8 +931,14 @@ uno::Reference< XSpellAlternatives > if (pWrong->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin)) { const OUString aText(pNode->GetText().copy(nBegin, nLen)); - OUString aWord = aText.replaceAll(OUStringChar(CH_TXTATR_BREAKWORD), "") - .replaceAll(OUStringChar(CH_TXTATR_INWORD), ""); + // TODO: this doesn't handle fieldmarks properly + ModelToViewHelper const aConversionMap(*pNode, GetLayout(), + ExpandMode::ExpandFields | ExpandMode::ExpandFootnote | ExpandMode::ReplaceMode + | (GetLayout()->IsHideRedlines() ? ExpandMode::HideDeletions : ExpandMode(0)) + | (GetViewOptions()->IsShowHiddenChar() ? ExpandMode(0) : ExpandMode::HideInvisible)); + auto const nBeginView(aConversionMap.ConvertToViewPosition(nBegin)); + OUString const aWord(aConversionMap.getViewText().copy(nBeginView, + aConversionMap.ConvertToViewPosition(nBegin+nLen) - nBeginView)); uno::Reference< XSpellChecker1 > xSpell( ::GetSpellChecker() ); if( xSpell.is() )