diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-20 20:06:57 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-27 14:07:15 +0100 |
commit | e205e96acd1670fde25b558cfedde0ce27a75b7c (patch) | |
tree | 27a0fef38eed16356227da692b86ee4f3c8f5cd1 /sw | |
parent | 9869ab08b9921d551b87da947da827a3e1fbd0d7 (diff) |
tdf#114973 sw: don't allow every body SwTextFrame to be hidden
Check this in SwTextFrame::IsHiddenNow() for the first one in the body.
Also fix a bad entry in SwScriptInfo::m_HiddenChg that is then possible
because it wasn't called on empty frames before.
Change-Id: If57f8d1a30229cfbf97225b386365ae384c5083c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147347
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit b1814b7cc851c4346f6cfa81c5be74c46f42e90f)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/porlay.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 13453253a837..a4287066c828 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -1016,7 +1016,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode, { const Range& rRange = aHiddenMulti.GetRange( i ); const sal_Int32 nStart = rRange.Min(); - const sal_Int32 nEnd = rRange.Max() + 1; + const sal_Int32 nEnd = rRange.Max() + (rText.isEmpty() ? 0 : 1); m_HiddenChg.push_back( TextFrameIndex(nStart) ); m_HiddenChg.push_back( TextFrameIndex(nEnd) ); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 8d478867709e..82546e533954 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1438,6 +1438,27 @@ bool SwTextFrame::IsHiddenNow() const ( bHiddenCharsHidePara && !pVsh->GetViewOptions()->IsShowHiddenChar() ) ) { + // in order to put the cursor in the body text, one paragraph must + // be visible - check this for the 1st body paragraph + if (IsInDocBody() && FindPrevCnt() == nullptr) + { + bool isAllHidden(true); + for (SwContentFrame const* pNext = FindNextCnt(true); + pNext != nullptr; pNext = pNext->FindNextCnt(true)) + { + if (!pNext->IsTextFrame() + || !static_cast<SwTextFrame const*>(pNext)->IsHiddenNow()) + { + isAllHidden = false; + break; + } + } + if (isAllHidden) + { + SAL_INFO("sw.core", "unhiding one body paragraph"); + return false; + } + } return true; } } |