summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-05-18 18:10:09 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-05-18 23:08:21 +0200
commite39ea45caa3712ae2ff077203ef8aef0e16fe41a (patch)
tree400f253175a6cfc72fad3d890ce494b15b6bc4be /toolkit
parent955fd1c534c061b3b6992dfe034b62b46ee2e844 (diff)
tdf#105972: pdf form: export date fields as date type
using AFDate_FormatEx which allows to set a custom format Change-Id: I38839965423794a0278b783c39c612c361a90eea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134543 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/helper/formpdfexport.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx
index def4f38d8a61..1c001cd9e5c5 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -555,6 +555,54 @@ namespace toolkitform
}
}
} break;
+ case FormComponentType::DATEFIELD:
+ {
+ pEditWidget->Format = vcl::PDFWriter::Date;
+
+ static constexpr OUStringLiteral FM_PROP_DATEFORMAT = u"DateFormat";
+ if ( xPSI->hasPropertyByName( FM_PROP_DATEFORMAT ) )
+ {
+ sal_Int32 nDateFormat = 0;
+ if( ! (xModelProps->getPropertyValue( FM_PROP_DATEFORMAT ) >>= nDateFormat) )
+ SAL_WARN("toolkit.helper", "describePDFControl: unable to get property " << FM_PROP_DATEFORMAT);
+
+ switch ( nDateFormat )
+ {
+ case 0:
+ case 1:
+ pEditWidget->DateFormat = "mm/dd/yy"; // Standard (short)
+ break;
+ case 2:
+ case 3:
+ pEditWidget->DateFormat = "mm/dd/yyyy"; // Standard (long)
+ break;
+ case 4:
+ pEditWidget->DateFormat = "dd/mm/yy"; // DD/MM/YY
+ break;
+ case 5:
+ pEditWidget->DateFormat = "mm/dd/yy"; // MM/DD/YY
+ break;
+ case 6:
+ pEditWidget->DateFormat = "yy/mm/dd"; // YY/MM/DD
+ break;
+ case 7:
+ pEditWidget->DateFormat = "dd/mm/yyyy"; // DD/MM/YYYY
+ break;
+ case 8:
+ pEditWidget->DateFormat = "mm/dd/yyyy"; // MM/DD/YYYY
+ break;
+ case 9:
+ pEditWidget->DateFormat = "yyyy/mm/dd"; // YYYY/MM/DD
+ break;
+ case 10:
+ pEditWidget->DateFormat = "yy-mm-dd"; // YY-MM-DD
+ break;
+ case 11:
+ pEditWidget->DateFormat = "yyyy-mm-dd"; // YYYY-MM-DD
+ break;
+ }
+ }
+ } break;
}
}