sw/source/core/inc/unoflatpara.hxx     |    1 +
 sw/source/core/unocore/unoflatpara.cxx |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 708e52a551daa27932dfae072a16e3512c72cf92
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Nov 28 13:59:22 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Nov 28 14:28:19 2023 +0100

    tdf#153693: improve SwXFlatParagraph::isModified check
    
    The response from LanguageTool server may take some seconds, during which
    the user may type more characters of an unfinished word. A result of the
    check started using an incomplete text should be discarded in this case.
    
    The code in GrammarCheckingIterator::ProcessResult that applies the check
    results first calls isModified to decide if it should apply the result,
    or to discard it. Before the change, SwXFlatParagraph::isModified only
    checked that its underlying node is still referenced; but it could only
    get nullified in SwXTextMarkup::Impl::Notify (only when the node dies),
    or in SwXTextMarkup::ClearTextNode, called in SwXFlatParagraph::changeText
    and SwXFlatParagraph::changeAttributes. Any external changes of the node
    didn't mark SwXFlatParagraph "modified".
    
    This change stores the initial text of the paragraph, from the moment of
    creation of SwXFlatParagraph; and then compares it to the current text of
    the node in isModified.
    
    Change-Id: Ia9a2e74b256152fe311db874c66f7e5347183f12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160021
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/core/inc/unoflatpara.hxx 
b/sw/source/core/inc/unoflatpara.hxx
index 77e07af399b9..9fd768d277a9 100644
--- a/sw/source/core/inc/unoflatpara.hxx
+++ b/sw/source/core/inc/unoflatpara.hxx
@@ -98,6 +98,7 @@ private:
     SwXFlatParagraph & operator = ( const SwXFlatParagraph & ) = delete;
 
     OUString maExpandText;
+    OUString maOrigText;
 };
 
 class SwXFlatParagraphIterator final :
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index ac3ebb4c6698..0f158e49fc82 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -68,6 +68,7 @@ CreateFlatParagraphIterator(SwDoc & rDoc, sal_Int32 const 
nTextMarkupType,
 SwXFlatParagraph::SwXFlatParagraph( SwTextNode& rTextNode, OUString 
aExpandText, const ModelToViewHelper& rMap )
     : SwXFlatParagraph_Base(& rTextNode, rMap)
     , maExpandText(std::move(aExpandText))
+    , maOrigText(rTextNode.GetText())
 {
 }
 
@@ -233,7 +234,7 @@ sal_Bool SAL_CALL SwXFlatParagraph::isChecked( ::sal_Int32 
nType )
 sal_Bool SAL_CALL SwXFlatParagraph::isModified()
 {
     SolarMutexGuard aGuard;
-    return nullptr == GetTextNode();
+    return !GetTextNode() || GetTextNode()->GetText() != maOrigText;
 }
 
 // text::XFlatParagraph:

Reply via email to