sw/source/core/edit/edlingu.cxx      |   19 +++++++++++++++----
 sw/source/uibase/uiview/viewling.cxx |    9 ++++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit e07b9c5142af838648a4d03a0bdce76612cf7535
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Mar 8 13:58:28 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Mar 9 10:43:06 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>

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() )
commit d814941b31b4f9cc8b6e9bd4ddc5188015529707
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Mar 8 13:54:08 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Mar 9 10:42:53 2022 +0100

    sw_redlinehide: get text from shell, not node in ExecSpellPopup()
    
    Change-Id: I0160c4927a2f5e71f5025c2162a103f67ed03723
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131209
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/uibase/uiview/viewling.cxx 
b/sw/source/uibase/uiview/viewling.cxx
index 93b2d5577da9..854108274fbe 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -692,7 +692,14 @@ bool SwView::ExecSpellPopup(const Point& rPt)
                 // get paragraph text
                 OUString aParaText;
                 if (pNode)
-                    aParaText = pNode->GetText();    // this may include 
hidden text but that should be Ok
+                {
+                    pCursorShell->Push();
+                    pCursorShell->MovePara(GoCurrPara, fnParaStart);
+                    pCursorShell->SetMark();
+                    pCursorShell->MovePara(GoCurrPara, fnParaEnd);
+                    aParaText = pCursorShell->GetSelText();
+                    pCursorShell->Pop(SwCursorShell::PopMode::DeleteCurrent);
+                }
                 else
                 {
                     OSL_FAIL("text node expected but not found" );

Reply via email to