diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-11-16 21:56:51 -0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-01-28 18:47:18 +0100 |
commit | c68e01ad578baa16ee108137f723a7126163c445 (patch) | |
tree | 1eb0ebef3dfb19de4ad509b02b90201e1857d5dc /offapi | |
parent | d213cdc382744b78b659f02c1e905160376e0b41 (diff) |
sw content controls: enhance preserve id
Follow-up to 100c914d44ae8f362924fe567d7d41d0033ae8ad
which added the initial id preservation for DOCX.
adding DOCX block SDT grabbaging, ODF import/export
[content controls can't exist in DOC format]
The ID field is CRITICAL to preserve for VBA purposes.
This patch adjusts BlockSDT to also round-trip the id
instead of just creating a random one.
m_nRunSdtPrToken <never equals> FSNS(XML_w, XML_id) since 2021
with 5f3af56b2c0ef6c628a7cfe5ce6e86f8e1765f5f,
so I removed that part of the clause.
I had thought about changing the ID to use a string instead of an int,
but then the integer version was adopted to fix a regression
in the commit mentioned earlier.
I think it is AWFUL to have a number as the identifier
when it will be used in StarBASIC. The VBA guys have to deal
with it, but it would be nice to do something reasonable
for LO native access to content controls.
However, the concern would be if we allow VBA macro content created in LO
to be exported to DOCX format - that would cause problems converting
from a string ID to a number ID. VBA editing already is happening to
some extent, and mmeeks seems interested in enabling it.
So over-all it seems best to just stick with an integer ID.
I used the commits for <w:alias> and <w:tag> to compose this patch.
XML_ID already existed in include/xmloff/xmltoken.hxx
and "id" already exists in xmloff/source/token/tokens.txt
The ID can be used in VBA to select a specific control.
The id (which is a positive or negative integer in DOCX)
specifies a unique control - either by passing the number as a string
(of the UNSIGNED value) or by passing as a float (specified with #).
For example:
msgbox ActiveDocument.ContentControls(2587720202#).ID
msgbox ActiveDocument.ContentControls("2587720202").ID
but not as an integer since that is used for index access.
dim index as integer
index = 1
msgbox ActiveDocument.ContentControls(index).ID
make CppunitTest_writerfilter_dmapper CPPUNIT_TEST_NAME=testSdtRunRichText
make CppunitTest_sw_ooxmlexport17 CPPUNIT_TEST_NAME=testDateContentControlExport
make CppunitTest_sw_ooxmlexport18 CPPUNIT_TEST_NAME=testTdf151912
make CppunitTest_sw_core_unocore CPPUNIT_TEST_NAME=testContentControlDate
make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlExport
make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlImport
Change-Id: I5c4022dc932d941fad9da6d75ce899ee1ff66ff5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142818
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'offapi')
-rw-r--r-- | offapi/com/sun/star/text/ContentControl.idl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index 3b6e86b1ac1c..c2fe46757656 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -111,12 +111,14 @@ service ContentControl [optional, property] boolean DropDown; /** The alias: kind of a human-readable title / description, show up on the UI. + -also used by VBA to group controls into a smaller, indexed collection @since LibreOffice 7.5 */ [optional, property] string Alias; /** The tag: similar to Alias, but is meant to be machine-readable. + -also used by VBA to group controls into a smaller, indexed collection @since LibreOffice 7.5 */ |