summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-06-06 13:28:51 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2024-06-06 15:51:29 +0200
commitaac625cf1cc502de5d55c0b30afb962147ccf3e1 (patch)
tree039448fdf104ea9c33ffcef9d5359e210946ca67
parentbe462215766a2bc53e50de24e0a95950e0afa6f8 (diff)
writerfilter: import undocumented STYLEREF field heading switch
forum-mso-de-86231.docx contains a funny field that uses undocumented switch: StyleRef \2 \n Word can evaluate it and find the paragraph with style "Heading 2". Translate it to "2" in DomainMapper, which is also evaluated by Word. (regression from commit d4fdafa103bfea94a279d7069ddc50ba92f67d01) Change-Id: I587e6df1ea72642278d93723ed6692ff5011ed57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168495 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
-rw-r--r--sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx26
1 files changed, 22 insertions, 4 deletions
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index 25f9e0630083..3442fac33a59 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -8040,11 +8040,29 @@ void DomainMapper_Impl::CloseFieldCommand()
getPropertyName(PROP_REFERENCE_FIELD_SOURCE),
uno::Any(sal_Int16(text::ReferenceFieldSource::STYLE)));
- uno::Any aStyleDisplayName;
- aStyleDisplayName <<= ConvertTOCStyleName(sFirstParam);
+ OUString styleName(sFirstParam);
+ if (styleName.isEmpty())
+ {
+ for (auto const& rSwitch : vSwitches)
+ {
+ // undocumented Word feature: \1 = "Heading 1" etc.
+ if (rSwitch.getLength() == 2 && rSwitch[0] == '\\'
+ && '1' <= rSwitch[1] && rSwitch[1] <= '9')
+ {
+ styleName = OUString(rSwitch[1]);
+ break;
+ }
+ }
+ }
- xFieldProperties->setPropertyValue(
- getPropertyName(PROP_SOURCE_NAME), aStyleDisplayName);
+ if (!styleName.isEmpty())
+ {
+ uno::Any aStyleDisplayName;
+ aStyleDisplayName <<= ConvertTOCStyleName(styleName);
+
+ xFieldProperties->setPropertyValue(
+ getPropertyName(PROP_SOURCE_NAME), aStyleDisplayName);
+ }
sal_uInt16 nFlags = 0;
OUString sValue;