summaryrefslogtreecommitdiff
path: root/schema
diff options
context:
space:
mode:
authorSkyler Grey <skyler.grey@collabora.com>2023-09-14 08:48:16 +0000
committerMiklos Vajna <vmiklos@collabora.com>2023-10-20 08:53:34 +0200
commit32c588dd1164aa2fc4c8120ddb74bd510cc082f9 (patch)
tree080aeedb6ead986f54080c75c9edad53cd452c9f /schema
parentd52982f4b3ba3f54adf21a9f185c726fb1a3db9a (diff)
tdf#86790: Add support for a word-style styleref
STYLEREF is a field type in Word which changes its content based on nearby paragraphs. For example, upon creating a styleref referencing "Heading 1" you will see the text of the nearest "Heading 1"-styled paragraph that is above the field. This patch implements STYLEREF in Writer as a cross-reference. By using "insert>cross-reference>styles" you'll be presented with a list of styles. Selecting one and clicking "insert" will create a field which has text from the "most relevant" instance of the style. To find the most relevant instance we first search up for paragraphs with the style, and if there are any we take the closest. If there weren't any, we search down for paragraphs with the style. This patch also updates our use of STYLEREF for chapters exported to docx by using it for all chapters not only those in headers and footers. This allows us to approximate more chapter field functionality even when moving between Writer and Word. Finally, this patch adds some tests for STYLEREF: - testTdf86790 tests that the "sample file with STYLEREF" document from tdf#86790 has the correct fields - testStyleRefSearchUp tests that the STYLEREF searches up when there are bits of text both above and below it - testStyleRefSearchDown tests that the STYLEREF searches down when there are bits of text below it only - testMarginalStyleRef tests that the STYLEREF searches from the page top when it is placed in a footer - testFootnotetyleRef tests that the STYLEREF searches from the reference mark when it is placed in a footnote Still TODO: - [ ] Update documentation - [ ] Implement reverse-searching (\l) and nondelimiter suppression (\t) - Probably these 2 will be in a followup patch Change-Id: I25dd7a6940abee5651a784b9059fe23b32547d6c Signed-off-by: Skyler Grey <skyler.grey@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157456 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'schema')
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng23
1 files changed, 23 insertions, 0 deletions
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 6b52ab7307df..ec0a86afaae4 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -2179,6 +2179,29 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:element>
</rng:define>
+ <!-- TODO no proposal -->
+ <rng:define name="loext-style-reference">
+ <rng:element name="loext:style-ref">
+ <rng:interleave>
+ <rng:ref name="text-common-ref-content"/>
+ <rng:optional>
+ <rng:attribute name="text:reference-format">
+ <rng:choice>
+ <rng:value>text</rng:value>
+ <rng:value>direction</rng:value>
+ <rng:value>number</rng:value>
+ <rng:value>number-no-superior</rng:value>
+ <rng:value>number-all-superior</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ </rng:interleave>
+ </rng:element>
+ </rng:define>
+ <rng:define name="paragraph-content" combine="choice">
+ <rng:ref name="loext-style-reference"/>
+ </rng:define>
+
<rng:define name="loext-qrcode">
<rng:element name="loext:qrcode">
<rng:attribute name="office:string-value">