summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-01-23 18:36:40 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-01-30 14:19:27 +0100
commit2817f07fdd942cea6574043971534bf089b527ce (patch)
treea1abff54867c83ee3e1e33cc9dfcc87c94ce32b9
parent46e04a712e97f9095ef4da7f0e52f50cf2bfbb32 (diff)
tdf#45589 sw: split text portions at bookmarks
Always create the portion, not just when the IsViewMetaChars is active. This has the advantage that nothing has to be invalidated when toggling, and the disadvantage that kerning at bookmark positions will never happen. Change-Id: I78943f337eef5c64cff33f6df6ff1a10acb1b8bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87363 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx2
-rw-r--r--sw/source/core/inc/scriptinfo.hxx1
-rw-r--r--sw/source/core/text/itrform2.cxx4
-rw-r--r--sw/source/core/text/porlay.cxx12
4 files changed, 18 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 23449e274557..27c66c141357 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -499,7 +499,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf124594, "tdf124594.docx")
// only "Er horte leise Schritte hinter", which means the 1st line of the 2nd paragraph was
// split into two by a Special portion, i.e. the top margin of the shape was too large.
assertXPath(pDump, "/root/page/body/txt[2]/Text[1]", "Portion",
- "Er horte leise Schritte hinter sich. Das bedeutete nichts Gutes. Wer wurde ihm ");
+ "Er horte leise Schritte hinter sich. Das bedeutete nichts Gutes. Wer wu"); // ... until the bookmark.
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTextInput, "textinput.odt")
diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx
index e70ded7166b0..6d7ad0f4dfff 100644
--- a/sw/source/core/inc/scriptinfo.hxx
+++ b/sw/source/core/inc/scriptinfo.hxx
@@ -181,6 +181,7 @@ public:
return m_HiddenChg[ nCnt ];
}
TextFrameIndex NextHiddenChg(TextFrameIndex nPos) const;
+ TextFrameIndex NextBookmark(TextFrameIndex nPos) const;
static void CalcHiddenRanges(const SwTextNode& rNode,
MultiSelection& rHiddenMulti,
std::vector<std::pair<sw::mark::IBookmark const*, MarkKind>> * pBookmarks);
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index e7d375299c26..3285f7f5ede9 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -962,6 +962,10 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
const TextFrameIndex nNextHidden = m_pScriptInfo->NextHiddenChg(rInf.GetIdx());
nNextChg = std::min( nNextChg, nNextHidden );
+ // bookmarks
+ const TextFrameIndex nNextBookmark = m_pScriptInfo->NextBookmark(rInf.GetIdx());
+ nNextChg = std::min(nNextChg, nNextBookmark);
+
// Turbo boost:
// We assume that font characters are not larger than twice
// as wide as height.
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index b6f70e7da060..aa0bbf6860c3 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1674,6 +1674,18 @@ TextFrameIndex SwScriptInfo::NextHiddenChg(TextFrameIndex const nPos) const
return TextFrameIndex(COMPLETE_STRING);
}
+TextFrameIndex SwScriptInfo::NextBookmark(TextFrameIndex const nPos) const
+{
+ for (auto const& it : m_Bookmarks)
+ {
+ if (nPos < it.first)
+ {
+ return it.first;
+ }
+ }
+ return TextFrameIndex(COMPLETE_STRING);
+}
+
// Takes a string and replaced the hidden ranges with cChar.
sal_Int32 SwScriptInfo::MaskHiddenRanges( const SwTextNode& rNode, OUStringBuffer & rText,
const sal_Int32 nStt, const sal_Int32 nEnd,