include/vcl/pdfwriter.hxx                    |   12 ++
 toolkit/source/helper/formpdfexport.cxx      |   36 +++++++
 vcl/inc/pdf/pdfwriter_impl.hxx               |    4 
 vcl/qa/cppunit/pdfexport/data/tdf105972.fodt |  133 +++++++++++++++++++++++++++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx       |   39 +++++++
 vcl/source/gdi/pdfwriter_impl.cxx            |   47 ++++++++-
 6 files changed, 266 insertions(+), 5 deletions(-)

New commits:
commit 0a9a603a08c119f419eb8c39772c74173f07bd6b
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue May 17 13:43:17 2022 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Sep 16 08:21:44 2022 +0200

    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
    
    (cherry picked from commit 5938db731bd5f74182acb890102deee813635513)
    
    Conflicts:
            vcl/source/gdi/pdfwriter_impl.cxx
    
    Change-Id: I8d6ffac51d576a8c243b9c6d5be2c3517bc0125a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140016
    Tested-by: Miklos Vajna <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index 1a59a66c66f1..1e9492f41a79 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -193,6 +193,11 @@ public:
         Signature
     };
 
+    enum FormatType
+    {
+        Text, Number
+    };
+
     enum ErrorCode
     {
         // transparent object occurred and was draw opaque because
@@ -379,13 +384,18 @@ public:
         bool                Password;   // visible echo off
         bool                FileSelect; // field is a file selector
         sal_Int32           MaxLen;     // maximum field length in characters, 
0 means unlimited
+        FormatType          Format;
+        OUString            CurrencySymbol;
+        sal_Int32           DecimalAccuracy;
+        bool                PrependCurrencySymbol;
 
         EditWidget()
                 : AnyWidget( vcl::PDFWriter::Edit ),
                   MultiLine( false ),
                   Password( false ),
                   FileSelect( false ),
-                  MaxLen( 0 )
+                  MaxLen( 0 ),
+                  Format( FormatType::Text )
         {}
 
         virtual std::shared_ptr<AnyWidget> Clone() const override
diff --git a/toolkit/source/helper/formpdfexport.cxx 
b/toolkit/source/helper/formpdfexport.cxx
index 7e762a9ff152..1e76f9bfcc75 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -492,6 +492,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;
+                }
             }
 
 
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 5fc1e34863ba..c6f13f65cd91 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -468,6 +468,10 @@ struct PDFWidget : public PDFAnnotation
     sal_Int32                   m_nTabOrder; // lowest number gets first in 
tab order
     sal_Int32                   m_nRadioGroup;
     sal_Int32                   m_nMaxLen;
+    PDFWriter::FormatType       m_nFormat;
+    OUString                    m_aCurrencySymbol;
+    sal_Int32                   m_nDecimalAccuracy;
+    bool                        m_bPrependCurrencySymbol;
     bool                        m_bSubmit;
     bool                        m_bSubmitGet;
     sal_Int32                   m_nDest;
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf105972.fodt 
b/vcl/qa/cppunit/pdfexport/data/tdf105972.fodt
new file mode 100644
index 000000000000..694c0ddb0b95
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf105972.fodt
@@ -0,0 +1,133 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
<office:meta><meta:creation-date>2022-05-17T10:53:27.044915889</meta:creation-date><dc:date>2022-05-17T12:56:48.901634442</dc:date><meta:editing-duration>PT1M36S</meta:editing-duration><meta:editing-cycles>3</meta:editing-cycles><meta:generator>LibreOfficeDev/7.4.0.0.alpha1$Linux_X86_64
 
LibreOffice_project/817b8fe7001a83cb74910eb09b7c14a3b95b8a39</meta:generator><meta:document-statistic
 meta:table-count="0" meta:image-count="0" meta:object-count="0" 
meta:page-count="1" meta:paragraph-count="1" meta:word-count="0" 
meta:character-count="0" meta:non-whitespace-character-count="0"/></office:meta>
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation 
Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit 
Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif 
CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="graphic">
+   <style:graphic-properties svg:stroke-color="#3465a4" 
draw:fill-color="#729fcf" fo:wrap-option="no-wrap" 
draw:shadow-offset-x="0.1181in" draw:shadow-offset-y="0.1181in" 
draw:start-line-spacing-horizontal="0.1114in" 
draw:start-line-spacing-vertical="0.1114in" 
draw:end-line-spacing-horizontal="0.1114in" 
draw:end-line-spacing-vertical="0.1114in" style:flow-with-text="false"/>
+   <style:paragraph-properties style:text-autospace="ideograph-alpha" 
style:line-break="strict" style:writing-mode="lr-tb" 
style:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" 
loext:opacity="0%" loext:color-lum-mod="100%" loext:color-lum-off="0%" 
style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" 
fo:country="US" style:letter-kerning="true" style:font-name-asian="Noto Serif 
CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" 
style:country-asian="CN" style:font-name-complex="Lohit Devanagari1" 
style:font-size-complex="12pt" style:language-complex="hi" 
style:country-complex="IN"/>
+  </style:default-style>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" 
style:punctuation-wrap="hanging" style:line-break="strict" 
style:tab-stop-distance="0.4925in" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" 
loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" 
fo:language="en" fo:country="US" style:letter-kerning="true" 
style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" 
style:language-asian="zh" style:country-asian="CN" 
style:font-name-complex="Lohit Devanagari1" style:font-size-complex="12pt" 
style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" 
loext:hyphenation-no-caps="false"/>
+  </style:default-style>
+  <style:default-style style:family="table">
+   <style:table-properties table:border-model="collapsing"/>
+  </style:default-style>
+  <style:default-style style:family="table-row">
+   <style:table-row-properties fo:keep-together="auto"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text"/>
+  <text:outline-style style:name="Outline">
+   <text:outline-level-style text:level="1" loext:num-list-format="%1%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="2" loext:num-list-format="%2%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="3" loext:num-list-format="%3%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="4" loext:num-list-format="%4%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="5" loext:num-list-format="%5%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="6" loext:num-list-format="%6%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="7" loext:num-list-format="%7%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="8" loext:num-list-format="%8%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="9" loext:num-list-format="%9%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="10" loext:num-list-format="%10%" 
style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+  </text:outline-style>
+  <text:notes-configuration text:note-class="footnote" style:num-format="1" 
text:start-value="0" text:footnotes-position="page" 
text:start-numbering-at="document"/>
+  <text:notes-configuration text:note-class="endnote" style:num-format="i" 
text:start-value="0"/>
+  <text:linenumbering-configuration text:number-lines="false" 
text:offset="0.1965in" style:num-format="1" text:number-position="left" 
text:increment="5"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="gr1" style:family="graphic">
+   <style:graphic-properties style:wrap="run-through" 
style:number-wrapped-paragraphs="no-limit" style:vertical-pos="middle" 
style:vertical-rel="line" style:horizontal-pos="from-left" 
style:horizontal-rel="paragraph" 
draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" 
style:flow-with-text="false"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="8.5in" fo:page-height="11in" 
style:num-format="1" style:print-orientation="portrait" 
fo:margin-top="0.7874in" fo:margin-bottom="0.7874in" fo:margin-left="0.7874in" 
fo:margin-right="0.7874in" style:writing-mode="lr-tb" 
style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.278in" style:layout-grid-ruby-height="0.139in" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
style:footnote-max-height="0in" loext:margin-gutter="0in">
+    <style:footnote-sep style:width="0.0071in" 
style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in" 
style:line-style="solid" style:adjustment="left" style:rel-width="25%" 
style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style/>
+  </style:page-layout>
+  <style:style style:name="dp1" style:family="drawing-page">
+   <style:drawing-page-properties draw:background-size="full"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1" 
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <office:forms form:automatic-focus="false" form:apply-design-mode="false">
+    <form:form form:name="Form" form:apply-filter="true" 
form:command-type="table" 
form:control-implementation="ooo:com.sun.star.form.component.Form" 
office:target-frame="">
+     <form:properties>
+      <form:property form:property-name="PropertyChangeNotificationEnabled" 
office:value-type="boolean" office:boolean-value="true"/>
+      <form:property form:property-name="TargetURL" office:value-type="string" 
office:string-value=""/>
+     </form:properties>
+     <form:formatted-text form:name="CurrencyField" 
form:control-implementation="ooo:com.sun.star.form.component.CurrencyField" 
xml:id="control1" form:id="control1" form:current-value="1234" 
form:input-required="false" form:validation="true" form:min-value="-1000000" 
form:max-value="1000000">
+      <form:properties>
+       <form:property form:property-name="ControlTypeinMSO" 
office:value-type="float" office:value="0"/>
+       <form:property form:property-name="CurrencySymbol" 
office:value-type="string" office:string-value="€"/>
+       <form:property form:property-name="DecimalAccuracy" 
office:value-type="float" office:value="4"/>
+       <form:property form:property-name="DefaultControl" 
office:value-type="string" 
office:string-value="com.sun.star.form.control.CurrencyField"/>
+       <form:property form:property-name="MouseWheelBehavior" 
office:value-type="float" office:value="0"/>
+       <form:property form:property-name="ObjIDinMSO" 
office:value-type="float" office:value="65535"/>
+       <form:property form:property-name="PrependCurrencySymbol" 
office:value-type="boolean" office:boolean-value="true"/>
+      </form:properties>
+     </form:formatted-text>
+    </form:form>
+   </office:forms>
+   <text:sequence-decls>
+    <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+   </text:sequence-decls>
+   <text:p text:style-name="Standard"><draw:control text:anchor-type="as-char" 
draw:z-index="0" draw:name="Control 1" draw:style-name="gr1" 
draw:text-style-name="P1" svg:width="2.563in" svg:height="0.5732in" 
draw:control="control1"/></text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 6bfb34251e0d..abac407424ba 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -853,6 +853,45 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963)
     CPPUNIT_ASSERT_EQUAL(1, nYellowPathCount);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972)
+{
+    vcl::filter::PDFDocument aDocument;
+    load(u"tdf105972.fodt", aDocument);
+
+    // The document has one page.
+    std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+
+    auto pAnnots = 
dynamic_cast<vcl::filter::PDFArrayElement*>(aPages[0]->Lookup("Annots"));
+    CPPUNIT_ASSERT(pAnnots);
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), 
pAnnots->GetElements().size());
+
+    for (const auto& aElement : aDocument.GetElements())
+    {
+        auto pObject = 
dynamic_cast<vcl::filter::PDFObjectElement*>(aElement.get());
+        if (!pObject)
+            continue;
+        auto pType = 
dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("FT"));
+        if (pType && pType->GetValue() == "Tx")
+        {
+            auto pT = 
dynamic_cast<vcl::filter::PDFLiteralStringElement*>(pObject->Lookup("T"));
+            CPPUNIT_ASSERT(pT);
+            CPPUNIT_ASSERT_EQUAL(OString("CurrencyField"), pT->GetValue());
+
+            auto pAA = 
dynamic_cast<vcl::filter::PDFDictionaryElement*>(pObject->Lookup("AA"));
+            CPPUNIT_ASSERT(pAA);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), 
pAA->GetItems().size());
+
+            auto pF = 
dynamic_cast<vcl::filter::PDFDictionaryElement*>(pAA->LookupElement("F"));
+            CPPUNIT_ASSERT(pF);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), 
pF->GetItems().size());
+            auto pJS = 
dynamic_cast<vcl::filter::PDFLiteralStringElement*>(pF->LookupElement("JS"));
+            CPPUNIT_ASSERT_EQUAL(OString("AFNumber_Format\\(4, 0, 0, 0, 
\"\\\\u20ac\",true\\);"),
+                                 pJS->GetValue());
+        }
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442)
 {
     vcl::filter::PDFDocument aDocument;
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index d38328855ce2..29ed236204a5 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -43,6 +43,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <o3tl/numeric.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 )
         {
@@ -11014,6 +11049,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 );

Reply via email to