diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-24 15:35:00 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-25 10:07:11 +0200 |
commit | 752dd8f5299cc2d661becd3b694ede1d037d3b84 (patch) | |
tree | fccf19eb79f44c72dd1d9d26e163320784a45c81 /drawinglayer | |
parent | 02c3cca1fb5a0c2dbdf4ce55a5f07ebb64bcaed7 (diff) |
add a getCaretPositions like getTextArray
Change-Id: I6f5ab6c659a7b6827c1c5f017a740173806504d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101291
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/textlayoutdevice.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index fe541c04a9b3..b8ac0bf73c85 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -357,6 +357,31 @@ namespace drawinglayer::primitive2d return aRetval; } + std::vector< double > TextLayouterDevice::getCaretPositions( + const OUString& rText, + sal_uInt32 nIndex, + sal_uInt32 nLength) const + { + std::vector< double > aRetval; + sal_uInt32 nTextLength(nLength); + const sal_uInt32 nStringLength(rText.getLength()); + + if(nTextLength + nIndex > nStringLength) + { + nTextLength = nStringLength - nIndex; + } + + if(nTextLength) + { + aRetval.reserve(2 * nTextLength); + std::vector<long> aArray(2 * nTextLength); + mrDevice.GetCaretPositions(rText, aArray.data(), nIndex, nLength); + aRetval.assign(aArray.begin(), aArray.end()); + } + + return aRetval; + } + // helper methods for vcl font handling |