diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-06-09 13:59:58 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-06-23 09:53:35 +0200 |
commit | ed8247bdcf8e97eaee9698a2a7874fcb0fe28146 (patch) | |
tree | 4d5492d7ddbb10512224f2c9227fa4c1f18bca29 | |
parent | tdf#155833: apply transform to image even if target is equal to viewbox (diff) | |
download | core-ed8247bdcf8e97eaee9698a2a7874fcb0fe28146.tar.gz core-ed8247bdcf8e97eaee9698a2a7874fcb0fe28146.zip |
tdf#155939 sw: fix infinite loop when changing document language
If there's a footnote in the document, changing the document langauge
goes into an infinite loop in FindParentText(), because the selection
created by ExtendedSelectAll(true) is actually invalid, apparently
the intention is that only very limited functions may be called while it
is active.
Don't handle this invalid "very" extended selection like one created by
ExtendedSelectAll(false).
(regression from commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda)
Change-Id: Icf1032715cf2e0a05bf485039c483440c08bb6bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152797
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit ca9341cf60f3f9350662d30b61f6eadefca24667)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152819
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 10 |
2 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 1ac7b41988d1..c41a31945966 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -18,6 +18,10 @@ #include <vcl/scheduler.hxx> #include <vcl/settings.hxx> #include <vcl/filter/PDFiumLibrary.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <svx/svxids.hrc> +#include <view.hxx> #include <ndtxt.hxx> #include <swdtflvr.hxx> #include <wrtsh.hxx> @@ -175,6 +179,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE)); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testExtendedSelectAllHang) +{ + createSwDoc(); + SwDoc* const pDoc = getSwDoc(); + SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + pWrtShell->InsertFootnote(""); + pWrtShell->StartOfSection(); + SwView* pView = pDoc->GetDocShell()->GetView(); + SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Default_Spanish (Bolivia)"); + // this looped + pView->GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, + { &aLangString }); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineMoveInsertInDelete) { createSwDoc(); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 03cecdbbd8bf..f234c9db5b8d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -867,6 +867,16 @@ SwNode const* SwCursorShell::ExtendedSelectedAll() const typename SwCursorShell::StartsWith SwCursorShell::StartsWith_() { SwShellCursor const*const pShellCursor = getShellCursor(false); + // first, check if this is invalid; ExtendedSelectAll(true) may result in + // a) an ordinary selection that is valid + // b) a selection that is extended + // c) a selection that is invalid and will cause FindParentText to loop + SwNode const& rEndOfExtras(GetDoc()->GetNodes().GetEndOfExtras()); + if (pShellCursor->Start()->nNode.GetIndex() <= rEndOfExtras.GetIndex() + && rEndOfExtras.GetIndex() < pShellCursor->End()->nNode.GetIndex()) + { + return StartsWith::None; // *very* extended, no ExtendedSelectedAll handling! + } SwStartNode const*const pStartNode(FindParentText(*pShellCursor)); if (auto const ret = ::StartsWith(*pStartNode); ret != StartsWith::None) { |