summaryrefslogtreecommitdiff
path: root/offapi
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-09 11:49:06 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-03-09 20:12:24 +0100
commit8e7dc248f2787df0e658c4ece33220944fca7f16 (patch)
treeaf8a6063517b33392ad761bf6abf436996d49943 /offapi
parentacfd19df520693bb0e052d08df152befd7832a41 (diff)
sw: add UNO API to find the closest doc model position based on pixel position
The use-case is drag&drop: if an UNO API client registers its drag&drop listener, then it gets a DropTargetDropEvent and has to decide if it wants to handle that event or allow Writer to handle it. In case it decides to handle the event, it would be good to able to e.g. insert a string at the point where the Writer UI indicates it to the user. But DropTargetDropEvent only exposes a pixel position and Writer requires you to have an XTextRange when inserting content. Fix the problem by introducing a new createTextRangeByPixelPosition() which first does a pixel -> logic coordinate conversion (this is window-specific, in case you have multiple windows), then picks the doc model position which is the closest to a logic coordinate. Change-Id: I6a8e69e3c39b9d99209342469653c0e0bd99bf53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112201 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'offapi')
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl46
2 files changed, 47 insertions, 0 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 020149df1311..21adff7c48f1 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3841,6 +3841,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/text,\
XTextViewCursor \
XTextViewCursorSupplier \
XWordCursor \
+ XTextViewTextRangeSupplier \
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ucb,\
AlreadyInitializedException \
diff --git a/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl b/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl
new file mode 100644
index 000000000000..57adf359f756
--- /dev/null
+++ b/offapi/com/sun/star/text/XTextViewTextRangeSupplier.idl
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_text_XTextViewTextRangeSupplier_idl__
+#define __com_sun_star_text_XTextViewTextRangeSupplier_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+#include <com/sun/star/text/awt/Point.idl>
+#include <com/sun/star/text/XTextRange.idl>
+
+module com { module sun { module star { module text {
+
+/** supplies access to a document model position at a view-dependent pixel position.
+
+ @since LibreOffice 7.2
+ */
+interface XTextViewTextRangeSupplier: com::sun::star::uno::XInterface
+{
+ /** @returns
+ the text range of the document position.
+ */
+ com::sun::star::text::XTextRange createTextRangeByPixelPosition([in] com::sun::star::awt::Point PixelPosition);
+
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */