diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-22 14:02:51 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-22 14:50:24 +0200 |
commit | e0b2dd958badd4b00ae3ad279c63b1bdffc08336 (patch) | |
tree | 98b51d5e6c2e25ae1210925c77369b9d67e5f34e | |
parent | tdf#45589 sw: invalidate on bookmark insertion/deletion (diff) | |
download | core-e0b2dd958badd4b00ae3ad279c63b1bdffc08336.tar.gz core-e0b2dd958badd4b00ae3ad279c63b1bdffc08336.zip |
tdf#45589 sw: add bookmarks to SwScriptInfo
Add a list of bookmark positions in the text frame to SwScriptInfo.
Initialising this turned out to be more complicated than expected.
Change-Id: I1738186b057b0eece80177097a03826365107589
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87202
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 46e04a712e97f9095ef4da7f0e52f50cf2bfbb32)
Change-Id: Id6f93f4fb06437d5d7762d29e5d92b547fc992a3
Note, this is already picked as commit
46e04a712e97f9095ef4da7f0e52f50cf2bfbb32 but it's missing some code.
Change-Id: Ia8182d3ccf14ba67d37e2bce903c620222217101
-rw-r--r-- | sw/source/core/inc/scriptinfo.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 35 |
2 files changed, 35 insertions, 1 deletions
diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx index 67a12bac0d77..e11f3feccd73 100644 --- a/sw/source/core/inc/scriptinfo.hxx +++ b/sw/source/core/inc/scriptinfo.hxx @@ -182,7 +182,6 @@ public: return m_HiddenChg[ nCnt ]; } TextFrameIndex NextHiddenChg(TextFrameIndex nPos) const; - static void selectHiddenTextProperty(const SwTextNode& rNode, MultiSelection &rHiddenMulti); TextFrameIndex NextBookmark(TextFrameIndex nPos) const; MarkKind GetBookmark(TextFrameIndex nPos) const; static void CalcHiddenRanges(const SwTextNode& rNode, diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index d27ab1c059c6..13453253a837 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -2530,6 +2530,41 @@ void SwScriptInfo::selectHiddenTextProperty(const SwTextNode& rNode, pBookmarks->emplace_back(pBookmark, MarkKind::End); } } + + bool bHide = false; + if (pBookmark && pBookmark->IsHidden()) + { + // bookmark is marked as hidden + bHide = true; + + // bookmark is marked as hidden with conditions + if (!pBookmark->GetHideCondition().isEmpty()) + { + SwDoc& rDoc = *const_cast<SwDoc*>(rNode.GetDoc()); + SwCalc aCalc(rDoc); + rDoc.getIDocumentFieldsAccess().FieldsToCalc(aCalc, rNode.GetIndex(), USHRT_MAX); + + SwSbxValue aValue = aCalc.Calculate(pBookmark->GetHideCondition()); + if(!aValue.IsVoidValue()) + { + bHide = aValue.GetBool(); + } + } + } + + if (bHide) + { + // intersect bookmark range with textnode range and add the intersection to rHiddenMulti + + const sal_Int32 nSt = pBookmark->GetMarkStart().nContent.GetIndex(); + const sal_Int32 nEnd = pBookmark->GetMarkEnd().nContent.GetIndex(); + + if( nEnd > nSt ) + { + Range aTmp( nSt, nEnd - 1 ); + rHiddenMulti.Select(aTmp, true); + } + } } } |