From 752dd8f5299cc2d661becd3b694ede1d037d3b84 Mon Sep 17 00:00:00 2001
From: Caolán McNamara <caolanm@redhat.com>
Date: Mon, 24 Aug 2020 15:35:00 +0100
Subject: add a getCaretPositions like getTextArray
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: I6f5ab6c659a7b6827c1c5f017a740173806504d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101291
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
---
 .../source/primitive2d/textlayoutdevice.cxx        | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'drawinglayer')

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
 
-- 
cgit