summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-05-18 10:47:12 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-05-18 17:37:41 +0200
commit4bd95a0d5c962cc0bb8e90c32300c69ae8e92c1d (patch)
treed655e1fe86fbba62cec014b64d1a93c89865889d /toolkit
parent037cae112958be3894e734d308f5f4b468a2d710 (diff)
tdf#105972: pdf form: export time fields as time type
using AFTime_FormatEx which allows to set a custom format Change-Id: I2d30d9d8340782ed9ad53eb43e1f65728f926b23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134510 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/helper/formpdfexport.cxx32
1 files changed, 30 insertions, 2 deletions
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx
index 28cfedf5e4ae..def4f38d8a61 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -496,6 +496,7 @@ namespace toolkitform
{
case FormComponentType::CURRENCYFIELD:
case FormComponentType::NUMERICFIELD:
+ {
pEditWidget->Format = vcl::PDFWriter::Number;
@@ -525,11 +526,38 @@ namespace toolkitform
SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_PREPENDCURRENCYSYMBOL);
pEditWidget->PrependCurrencySymbol = bPrependCurrencySymbol;
}
- break;
+ } break;
+ case FormComponentType::TIMEFIELD:
+ {
+ pEditWidget->Format = vcl::PDFWriter::Time;
+
+ static constexpr OUStringLiteral FM_PROP_TIMEFORMAT = u"TimeFormat";
+ if ( xPSI->hasPropertyByName( FM_PROP_TIMEFORMAT ) )
+ {
+ sal_Int32 nTimeFormat = 0;
+ if( ! (xModelProps->getPropertyValue( FM_PROP_TIMEFORMAT ) >>= nTimeFormat) )
+ SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_TIMEFORMAT);
+
+ switch ( nTimeFormat )
+ {
+ case 0:
+ pEditWidget->TimeFormat = "HH:MM"; //13:45
+ break;
+ case 1:
+ pEditWidget->TimeFormat = "HH:MM:ss"; //13:45:00
+ break;
+ case 2:
+ pEditWidget->TimeFormat = "h:MMtt"; //01:45 PM
+ break;
+ case 3:
+ pEditWidget->TimeFormat = "h:MM:sstt"; //01:45:00 PM
+ break;
+ }
+ }
+ } break;
}
}
-
// buttons
if ( Descriptor->getType() == vcl::PDFWriter::PushButton )
{