From 1b4b1e0659d7dff79d031ff5c8fbb34fad2c71a1 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 1 Nov 2024 14:11:09 +0500 Subject: tdf#163703: export formats for FIELD_ID_ANNOTATION It was omitted from commit 842160190e2996efbd936191eed787f3f79ed7b7 (INTEGRATION: CWS notes2 (1.77.24); FILE MERGED, 2008-02-19), and the field type was skipped from autostyle export phase. With commit 69ed893087f89d176a5ec4b263ce8d75774be72b (tdf#160253: fix list identifier export decision code, 2024-04-24), this surfaced by not exporting comments' formatting. Change-Id: I84a8d5616c37af093404fefb4d1ed3a212000f8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175899 Tested-by: Jenkins Reviewed-by: Mike Kaganski Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175931 --- xmloff/source/text/txtflde.cxx | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 80a98f3dc5c6..1c8d9fb56847 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -176,6 +176,18 @@ uno::Reference GetToplevelText(const uno::Reference& x } return xRet; } + +uno::Reference XTextFromTextRangeProp(const Reference& xPropSet) +{ + try + { + return xPropSet->getPropertyValue(u"TextRange"_ustr).query(); + } + catch (css::uno::Exception&) + { + return {}; + } +} } SvXMLEnumStringMapEntry const aFieldServiceNameMapping[] = @@ -368,7 +380,6 @@ constexpr OUString gsPropertyValue(u"Value"_ustr); constexpr OUString gsPropertyVariableName(u"VariableName"_ustr); constexpr OUString gsPropertyHelp(u"Help"_ustr); constexpr OUString gsPropertyTooltip(u"Tooltip"_ustr); -constexpr OUStringLiteral gsPropertyTextRange(u"TextRange"); XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp, std::unique_ptr pCombinedCharState) @@ -909,8 +920,12 @@ void XMLTextFieldExport::ExportFieldAutoStyle( break; } - case FIELD_ID_SCRIPT: case FIELD_ID_ANNOTATION: + if (auto xText = XTextFromTextRangeProp(xPropSet)) + GetExport().GetTextParagraphExport()->collectTextAutoStyles(xText, bProgress); + break; + + case FIELD_ID_SCRIPT: case FIELD_ID_BIBLIOGRAPHY: case FIELD_ID_DDE: case FIELD_ID_REF_REFERENCE: @@ -1837,16 +1852,7 @@ void XMLTextFieldExport::ExportFieldHelper( } } - css::uno::Reference < css::text::XText > xText; - try - { - css::uno::Any aRet = rPropSet->getPropertyValue(gsPropertyTextRange); - aRet >>= xText; - } - catch ( css::uno::Exception& ) - {} - - if ( xText.is() ) + if (auto xText = XTextFromTextRangeProp(rPropSet)) GetExport().GetTextParagraphExport()->exportText( xText ); else ProcessParagraphSequence(GetStringProperty(gsPropertyContent,rPropSet)); -- cgit