diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-12 16:37:19 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-05-17 05:24:02 +0200 |
commit | c5b381b91494057a293f6cb7f1d9798fb40ebea0 (patch) | |
tree | 6d9c037a190c19120b8089eacef847fa162ba0a6 | |
parent | 54f0c89ef7a93b12e6be67716bc55a47b69cb9a6 (diff) |
tdf#148706: map value prop in numericfield to text
Change-Id: Ifc37b0aa8dc657d7a7f05199c8132896d03eb437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134240
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit 3bd7111fe29ce19a007915af87f1f9269d27d9ff)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134183
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | toolkit/source/helper/formpdfexport.cxx | 8 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf148706.odt | bin | 0 -> 9969 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 35 |
3 files changed, 43 insertions, 0 deletions
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index aa5224e377f2..7e762a9ff152 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -314,10 +314,18 @@ namespace toolkitform Any aText; static constexpr OUStringLiteral FM_PROP_TEXT = u"Text"; static constexpr OUStringLiteral FM_PROP_LABEL = u"Label"; + static constexpr OUStringLiteral FM_PROP_VALUE = u"Value"; if ( xPSI->hasPropertyByName( FM_PROP_TEXT ) ) aText = xModelProps->getPropertyValue( FM_PROP_TEXT ); else if ( xPSI->hasPropertyByName( FM_PROP_LABEL ) ) aText = xModelProps->getPropertyValue( FM_PROP_LABEL ); + else if ( xPSI->hasPropertyByName( FM_PROP_VALUE ) ) + { + double aValue; + if (xModelProps->getPropertyValue( FM_PROP_VALUE ) >>= aValue) + aText <<= OUString::number(aValue); + } + if ( aText.hasValue() ) { if( ! (aText >>= Descriptor->Text) ) { SAL_WARN("toolkit.helper", "describePDFControl: unable to assign aText to Descriptor->Text"); diff --git a/vcl/qa/cppunit/pdfexport/data/tdf148706.odt b/vcl/qa/cppunit/pdfexport/data/tdf148706.odt Binary files differnew file mode 100644 index 000000000000..974bb97433f0 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf148706.odt diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index ca54551f0b09..a399986626b0 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -608,6 +608,41 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf107018) CPPUNIT_ASSERT_EQUAL(OString("Pages"), pName->GetValue()); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148706) +{ + // Import the bugdoc and export as PDF. + aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); + saveAsPDF(u"tdf148706.odt"); + + // Parse the export result with pdfium. + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport(); + CPPUNIT_ASSERT(pPdfDocument); + + // The document has one page. + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); + CPPUNIT_ASSERT(pPdfPage); + + // The page has one annotation. + CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getAnnotationCount()); + std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnot = pPdfPage->getAnnotation(0); + + CPPUNIT_ASSERT(pAnnot->hasKey("V")); + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFObjectType::String, pAnnot->getValueType("V")); + OUString aV = pAnnot->getString("V"); + + // Without the fix in place, this test would have failed with + // - Expected: 1821.84 + // - Actual : + CPPUNIT_ASSERT_EQUAL(OUString("1821.84"), aV); + + CPPUNIT_ASSERT(pAnnot->hasKey("DV")); + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFObjectType::String, pAnnot->getValueType("DV")); + OUString aDV = pAnnot->getString("DV"); + + CPPUNIT_ASSERT_EQUAL(OUString("1821.84"), aDV); +} + CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf107089) { vcl::filter::PDFDocument aDocument; |