summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2020-01-20 17:33:41 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2020-01-30 13:42:18 +0100
commit3a248dfe57318af57fc5df89652cb64dfa923e46 (patch)
tree950bc198114faea9724edc034ce99278a3206c19
parentee9a15422561dfae0ae259c1641695f6c5c41388 (diff)
tdf#129237 just add content checks for Input fields
There seems to be fields with content values, which don't use it as the presentation value. So this reverts the content handling code back to the original one and just checks the content value from Input fields in addition to the SetExpression fields. Change-Id: I2abd227883035c559b1fc3f7aacf10769b0e79a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87093 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx25
1 files changed, 16 insertions, 9 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 03c77eda6a83..f5bab69875ae 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5633,17 +5633,24 @@ void DomainMapper_Impl::SetFieldResult(OUString const& rResult)
else
{
uno::Reference< beans::XPropertySet > xFieldProperties( xTextField, uno::UNO_QUERY_THROW);
- OUString sContent;
- bool bCanHaveContent = false;
- try
- { // this will throw for field types without Content property
- uno::Any aValue(xFieldProperties->getPropertyValue(getPropertyName(PROP_CONTENT)));
- bCanHaveContent = true;
- aValue >>= sContent;
+ // In case of SetExpression, and Input fields the field result contains the content of the variable.
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY);
+ // there are fields with a content property, which aren't working correctly with
+ // a generalized try catch of the content, property, so just restrict content
+ // handling to these explicit services.
+ const bool bHasContent = xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression") ||
+ xServiceInfo->supportsService("com.sun.star.text.TextField.Input");
+ // If we already have content set, then use the current presentation
+ OUString sValue;
+ if (bHasContent)
+ {
+ // this will throw for field types without Content
+ uno::Any aValue(xFieldProperties->getPropertyValue(
+ getPropertyName(PROP_CONTENT)));
+ aValue >>= sValue;
}
- catch (...) {}
xFieldProperties->setPropertyValue(
- getPropertyName(bCanHaveContent && sContent.isEmpty()? PROP_CONTENT : PROP_CURRENT_PRESENTATION),
+ getPropertyName(bHasContent && sValue.isEmpty()? PROP_CONTENT : PROP_CURRENT_PRESENTATION),
uno::makeAny( rResult ));
}
}