summaryrefslogtreecommitdiff
path: root/xmloff/source/text/txtfldi.cxx
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-13 09:16:13 +0200
commitffa1798661dab15435190972a98e6277ced05f4e (patch)
tree2a75215dc1ca7635ba6b665adc260ba3e0b2ebf1 /xmloff/source/text/txtfldi.cxx
parent1fd1538e3957a5300dc282b7b97597c75d71e64e (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. 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/+/156912 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff/source/text/txtfldi.cxx')
-rw-r--r--xmloff/source/text/txtfldi.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index 05d95281ef1b..d51d1fb06316 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -407,6 +407,7 @@ XMLTextFieldImportContext::CreateTextFieldImportContext(
case XML_ELEMENT(TEXT, XML_BOOKMARK_REF):
case XML_ELEMENT(TEXT, XML_NOTE_REF):
case XML_ELEMENT(TEXT, XML_SEQUENCE_REF):
+ case XML_ELEMENT(TEXT, XML_STYLE_REF):
pContext = new XMLReferenceFieldImportContext( rImport, rHlp, nToken );
break;
@@ -2509,6 +2510,9 @@ void XMLReferenceFieldImportContext::startFastElement(
case XML_ELEMENT(TEXT, XML_SEQUENCE_REF):
nSource = ReferenceFieldSource::SEQUENCE_FIELD;
break;
+ case XML_ELEMENT(TEXT, XML_STYLE_REF):
+ nSource = ReferenceFieldSource::STYLE;
+ break;
default:
XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
bTypeOK = false;
@@ -2577,6 +2581,7 @@ void XMLReferenceFieldImportContext::PrepareField(
{
case XML_ELEMENT(TEXT, XML_REFERENCE_REF):
case XML_ELEMENT(TEXT, XML_BOOKMARK_REF):
+ case XML_ELEMENT(LO_EXT, XML_STYLE_REF):
xPropertySet->setPropertyValue("SourceName", Any(sName));
break;