summaryrefslogtreecommitdiff
path: root/offapi
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-11-22 08:40:47 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-11-22 10:07:52 +0100
commit2302ebefb2e25878e8fe1e64d208f265f87d5b9b (patch)
tree3dffdb748e7c81b9d91aef5bc1005efc2192a94c /offapi
parent4c8411a55aa10bafdda35b8e60b6a1a5e1600329 (diff)
sw, createTextRangeByPixelPosition(): fix crash when the position is an image
Using createTextRangeByPixelPosition() with a pixel position that leads to a graphic node resulted in a crash. The direct reason for this is that the makeMark() call in SwXTextRange::SetPositions() returns nullptr in case rPaM points to a graphic node, but later we dereference that result unconditionally. This also uncovers that the XTextRange returned by createTextRangeByPixelPosition() is meant to point to a text node, but a pixel position may be closest to a graphic node. Fix the problem by explicitly checking for graphic nodes; and try to look up the anchor position of such graphics, which will be definitely a text node. In practice this will mean that in case the image's anchor type is as-char, then we'll return a cursor position which will be on the left hand side of the image. Change-Id: Ief58148247fe3cd4371ed245b4eff5b45ca2aa15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143092 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'offapi')
-rw-r--r--offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl7
1 files changed, 6 insertions, 1 deletions
diff --git a/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl b/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl
index 56ea30efc070..faa85578c458 100644
--- a/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl
+++ b/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl
@@ -25,7 +25,12 @@ module com { module sun { module star { module text {
*/
interface XTextViewTextRangeSupplier: com::sun::star::uno::XInterface
{
- /** @returns
+ /** creates the text range of the document model position at a view-dependent pixel position.
+
+ Note that in case the model position is a graphic, then the model position of its anchor is
+ returned.
+
+ @returns
the text range of the document position.
*/
com::sun::star::text::XTextRange createTextRangeByPixelPosition([in] com::sun::star::awt::Point PixelPosition);