summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-03-08 13:58:28 +0100
committerAndras Timar <andras.timar@collabora.com>2022-03-14 20:47:41 +0100
commit14fb031f9e6b39cb824acb008d092edca8fec115 (patch)
treeac4ea011b978451eeca8577009ac92dde1169bc0
parentColibre: Fix wrong color, the ones which doesn not follow Monoline (part2) (diff)
downloadcore-14fb031f9e6b39cb824acb008d092edca8fec115.tar.gz
core-14fb031f9e6b39cb824acb008d092edca8fec115.zip
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.stahl@allotropia.de> (cherry picked from commit e07b9c5142af838648a4d03a0bdce76612cf7535) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131199 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--sw/source/core/edit/edlingu.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 51e63d16c6f3..312465ba255e 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() )