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/qa/cppunit/pdfexport/pdfexport.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/qa/cppunit/pdfexport/pdfexport.cxx')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 057b20ee2da8..2cc5ec6345a4 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -855,6 +855,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; |