summaryrefslogtreecommitdiff
path: root/sw/source/core/edit
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-03-08 13:58:28 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2022-03-09 10:43:06 +0100
commite07b9c5142af838648a4d03a0bdce76612cf7535 (patch)
tree642a301a82608a602d6855cc49aee13888714a29 /sw/source/core/edit
parentd814941b31b4f9cc8b6e9bd4ddc5188015529707 (diff)
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>
Diffstat (limited to 'sw/source/core/edit')
-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 3c0d8b2e8524..9c6228dffbf7 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -840,11 +840,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
@@ -927,8 +932,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() )