summaryrefslogtreecommitdiff
path: root/offapi
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-11-20 17:16:35 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-11-24 12:09:23 +0100
commit7ab349296dac79dad3fec09f60348efcbb9ea17e (patch)
tree7ac058e03eaa0020f93ad185937b0010ee0cbd74 /offapi
parent93eb6a87e30c8716b5e65ce71e3d1d9deffb6425 (diff)
sw: fix copying and deleting of section content via API
The problem happens if a section starts or ends with a table: SwXTextSection::getAnchor() may return a SwXTextRange with one position in a table cell and another position in a different table cell, or outside the table, neither of which is valid to set the cursor via SwXTextViewCurosor::gotoRange(). Introduce a new special mode for SwXTextRange, RANGE_IS_SECTION, analogous to RANGE_IS_TABLE but actually working. Only SwXTextView can be used to create XTransferables, and it requires selecting first via either the SwXTextViewCursor or select(). It's currently not possible to select the content of a section in the ViewShell in these problematic cases, and would be some effort to add. So add a new interface XTransferableTextSupplier that can be used to create XTransferable from the SwXTextRange with RANGE_IS_SECTION. The core CopyRange() and DeleteRange() functions can deal with SwPaMs that start or end in non-text-nodes, so pass the whole section content to these in SwXTextRange::setString() and in SwXTextView::getTransferableFromTextRange(). Change-Id: If7e3210e8a26f5618317c294f2b2f3ed5c217f1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106293 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'offapi')
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/datatransfer/XTransferableTextSupplier.idl44
2 files changed, 45 insertions, 0 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 8d6e21d00a9b..eabb1272588a 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2132,6 +2132,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/datatransfer,\
XTransferableEx \
XTransferableSource \
XTransferableSupplier \
+ XTransferableTextSupplier \
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/datatransfer/clipboard,\
ClipboardEvent \
diff --git a/offapi/com/sun/star/datatransfer/XTransferableTextSupplier.idl b/offapi/com/sun/star/datatransfer/XTransferableTextSupplier.idl
new file mode 100644
index 000000000000..7d91ec9f0c41
--- /dev/null
+++ b/offapi/com/sun/star/datatransfer/XTransferableTextSupplier.idl
@@ -0,0 +1,44 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef __com_sun_star_datatransfer_XTransferableTextSupplier_idl__
+#define __com_sun_star_datatransfer_XTransferableTextSupplier_idl__
+
+#include <com/sun/star/datatransfer/XTransferable.idl>
+#include <com/sun/star/text/XTextRange.idl>
+
+
+module com { module sun { module star { module datatransfer {
+
+/** @since LO 7.2
+ */
+interface XTransferableTextSupplier
+{
+ /** Provide access to a transferable representation of a given text
+ range.
+
+ @param xRange a text range known to the supplier.
+
+ @returns
+ a transferable object representing the given text range.
+
+ @see com::sun::star::datatransfer::XTransferable
+ */
+ XTransferable getTransferableForTextRange(
+ [in] com::sun::star::text::XTextRange xRange);
+
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */