office-gobmx/schema
Justin Luth 54599383a2 sw content controls: enhance preserve id
Follow-up to 100c914d44
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 5f3af56b2c,
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>
2022-12-16 07:34:20 +00:00
..
libreoffice sw content controls: enhance preserve id 2022-12-16 07:34:20 +00:00
mathml2 Fix typo in code 2020-08-30 13:51:58 +02:00
odf1.0
odf1.1
odf1.2
odf1.3 schema: update to ODF 1.3 OS 2021-06-10 19:07:36 +02:00
README.md Updated README.md files to represent current code / use Markdown format 2021-04-07 17:47:16 +02:00

Schemas for Validating ODF Files

Schemas that can be used for validating ODF files

subdirs:

  • mathml2: W3C MathML 2.0 XML Schema (needed for Math embedded objects)
  • odf1.0, odf1.1, odf1.2: official OASIS RelaxNG schemas
  • odf1.3: current OASIS draft ODF 1.3 RelaxNG schema
  • libreoffice: draft ODF schema, with additional LO extensions

The extension schema in libreoffice/ is used by all unit tests if --with-export-validation is given, which is the default.

Notably this means that if you add a new feature to the ODF filters and you add the required unit test for the new feature, then most likely the test will fail with a complaint from the validator; in this case the schema needs to be updated to contain the new elements and attributes.

The extension schema uses the RelaxNG "include" feature to refer to the ODF schema; this means that it only contains those parts of the schema that actually need to be changed - this works well in many cases because the ODF schema is quite well structured with many named patterns, but unfortunately there are a few places where that isn't the case and large chunks needed to be copied to override them.

In the easy case, to add an attribute you just want to search for the corresponding element, which will have a "foo-attlist" named pattern, and then add another attribute like this:

<rng:define name="draw-enhanced-geometry-attlist" combine="interleave"> rng:optional <rng:attribute name="drawooo:sub-view-size"> <rng:ref name="string"/> </rng:attribute> </rng:optional> </rng:define>

Currently only the features that are actually exported in the unit tests have been added to the schema; there is still some work to do here to add everything; the crashtesting script also does ODF validation of all files and now also uses the custom schema.

Unfortunately it turned out that there are a lot of extensions already for which no proposal exists [1], and in many cases not even an entry on the Wiki [2], so clearly something like this extension schema is needed.

[1] git grep TODO schema/libreoffice

[2] https://wiki.documentfoundation.org/Development/ODF_Implementer_Notes/List_of_LibreOffice_ODF_Extensions