diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-17 13:43:17 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-17 15:53:52 +0200 |
commit | 5938db731bd5f74182acb890102deee813635513 (patch) | |
tree | 17866dc94a1c780f0472c6fb570c65dbe812e0dd /toolkit | |
parent | f08c890482952820bf95b04872260c68082ef083 (diff) |
tdf#105972: pdf form: export numeric and currency fields as number type
Initial support for AFNumber_Format and AFNumber_Keystroke
More info in
https://experienceleague.adobe.com/docs/experience-manager-learn/assets/FormsAPIReference.pdf?lang=en
This patch adds support for CurrencySymbol,
DecimalAccuracy and PrependCurrencySymbol for now
Change-Id: I8d6ffac51d576a8c243b9c6d5be2c3517bc0125a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134471
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/helper/formpdfexport.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index 1c7757553676..28cfedf5e4ae 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -491,6 +491,42 @@ namespace toolkitform nMaxTextLength = 0; pEditWidget->MaxLen = nMaxTextLength; } + + switch ( nControlType ) + { + case FormComponentType::CURRENCYFIELD: + case FormComponentType::NUMERICFIELD: + + pEditWidget->Format = vcl::PDFWriter::Number; + + static constexpr OUStringLiteral FM_PROP_CURRENCYSYMBOL = u"CurrencySymbol"; + if ( xPSI->hasPropertyByName( FM_PROP_CURRENCYSYMBOL ) ) + { + OUString sCurrencySymbol; + if( ! (xModelProps->getPropertyValue( FM_PROP_CURRENCYSYMBOL ) >>= sCurrencySymbol) ) + SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_CURRENCYSYMBOL); + pEditWidget->CurrencySymbol = sCurrencySymbol; + } + + static constexpr OUStringLiteral FM_PROP_DECIMALACCURACY = u"DecimalAccuracy"; + if ( xPSI->hasPropertyByName( FM_PROP_DECIMALACCURACY ) ) + { + sal_Int32 nDecimalAccuracy = 0; + if( ! (xModelProps->getPropertyValue( FM_PROP_DECIMALACCURACY ) >>= nDecimalAccuracy) ) + SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_DECIMALACCURACY); + pEditWidget->DecimalAccuracy = nDecimalAccuracy; + } + + static constexpr OUStringLiteral FM_PROP_PREPENDCURRENCYSYMBOL = u"PrependCurrencySymbol"; + if ( xPSI->hasPropertyByName( FM_PROP_PREPENDCURRENCYSYMBOL ) ) + { + bool bPrependCurrencySymbol = true; + if( ! (xModelProps->getPropertyValue( FM_PROP_PREPENDCURRENCYSYMBOL ) >>= bPrependCurrencySymbol) ) + SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_PREPENDCURRENCYSYMBOL); + pEditWidget->PrependCurrencySymbol = bPrependCurrencySymbol; + } + break; + } } |