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 /vcl/source/gdi/pdfwriter_impl.cxx | |
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 'vcl/source/gdi/pdfwriter_impl.cxx')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index fcd81ebb521f..9d8a66b108b4 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -44,6 +44,7 @@ #include <i18nlangtag/languagetag.hxx> #include <o3tl/numeric.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/temporary.hxx> #include <officecfg/Office/Common.hxx> #include <osl/file.hxx> #include <osl/thread.h> @@ -4382,11 +4383,45 @@ bool PDFWriterImpl::emitWidgetAnnotations() } } } - if( rWidget.m_eType == PDFWriter::Edit && rWidget.m_nMaxLen > 0 ) + if( rWidget.m_eType == PDFWriter::Edit ) { - aLine.append( "/MaxLen " ); - aLine.append( rWidget.m_nMaxLen ); - aLine.append( "\n" ); + if ( rWidget.m_nMaxLen > 0 ) + { + aLine.append( "/MaxLen " ); + aLine.append( rWidget.m_nMaxLen ); + aLine.append( "\n" ); + } + + if ( rWidget.m_nFormat == PDFWriter::Number ) + { + OString aHexText; + + if ( !rWidget.m_aCurrencySymbol.isEmpty() ) + { + // Get the hexadecimal code + sal_UCS4 cChar = rWidget.m_aCurrencySymbol.iterateCodePoints(&o3tl::temporary(sal_Int32(1)), -1); + aHexText = "\\\\u" + OString::number(cChar, 16); + } + + aLine.append("/AA<<\n"); + aLine.append("/F<</JS(AFNumber_Format\\("); + aLine.append(OString::number(rWidget.m_nDecimalAccuracy)); + aLine.append(", 0, 0, 0, \""); + aLine.append( aHexText ); + aLine.append("\","); + aLine.append(OString::boolean(rWidget.m_bPrependCurrencySymbol)); + aLine.append("\\);)"); + aLine.append("/S/JavaScript>>\n"); + aLine.append("/K<</JS(AFNumber_Keystroke\\("); + aLine.append(OString::number(rWidget.m_nDecimalAccuracy)); + aLine.append(", 0, 0, 0, \""); + aLine.append( aHexText ); + aLine.append("\","); + aLine.append(OString::boolean(rWidget.m_bPrependCurrencySymbol)); + aLine.append("\\);)"); + aLine.append("/S/JavaScript>>\n"); + aLine.append(">>\n"); + } } if( rWidget.m_eType == PDFWriter::PushButton ) { @@ -10976,6 +11011,10 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa if( rEdit.FileSelect && m_aContext.Version > PDFWriter::PDFVersion::PDF_1_3 ) rNewWidget.m_nFlags |= 0x00100000; rNewWidget.m_nMaxLen = rEdit.MaxLen; + rNewWidget.m_nFormat = rEdit.Format; + rNewWidget.m_aCurrencySymbol = rEdit.CurrencySymbol; + rNewWidget.m_nDecimalAccuracy = rEdit.DecimalAccuracy; + rNewWidget.m_bPrependCurrencySymbol = rEdit.PrependCurrencySymbol; rNewWidget.m_aValue = rEdit.Text; createDefaultEditAppearance( rNewWidget, rEdit ); |