summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-11-28 13:59:22 +0300
committerMichael Stahl <michael.stahl@allotropia.de>2023-11-29 11:20:19 +0100
commit9810b3c06c709ffef15932fe24106b503ea4ff46 (patch)
tree3c8a1c5dfdc29491b2b2d749482d67a10395de1e
parenttdf#158202 Candy Impress template background (diff)
downloadcore-9810b3c06c709ffef15932fe24106b503ea4ff46.tar.gz
core-9810b3c06c709ffef15932fe24106b503ea4ff46.zip
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.kaganski@collabora.com> (cherry picked from commit 708e52a551daa27932dfae072a16e3512c72cf92) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160032 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/source/core/inc/unoflatpara.hxx1
-rw-r--r--sw/source/core/unocore/unoflatpara.cxx3
2 files changed, 3 insertions, 1 deletions
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 c5c2ef94e441..8a55a993753d 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: