drawinglayer/source/primitive2d/textlayoutdevice.cxx | 25 ++++++++++++++++++ include/drawinglayer/primitive2d/textlayoutdevice.hxx | 5 +++ 2 files changed, 30 insertions(+)
New commits: commit 752dd8f5299cc2d661becd3b694ede1d037d3b84 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Aug 24 15:35:00 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Aug 25 10:07:11 2020 +0200 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 <caol...@redhat.com> 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 diff --git a/include/drawinglayer/primitive2d/textlayoutdevice.hxx b/include/drawinglayer/primitive2d/textlayoutdevice.hxx index 597e1b34de09..10f0fc0b23c1 100644 --- a/include/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/include/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -105,6 +105,11 @@ namespace drawinglayer::primitive2d const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const; + + ::std::vector< double > getCaretPositions( + const OUString& rText, + sal_uInt32 nIndex, + sal_uInt32 nLength) const; }; // helper methods for vcl font handling _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits