diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-09-23 11:34:28 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-09-23 13:15:30 +0200 |
commit | 82b9ff35649cd67ca16296676d2ad1e4eff15493 (patch) | |
tree | 01ee7cd8972dd305316e1eb4a5ca36523847bd29 /sw/qa/core/text/text.cxx | |
parent | 1cfa1e7a0976dce86a8b4168119c9c6f015ff5ce (diff) |
sw content controls, combo box: add PDF export
Map it to vcl::PDFWriter::ComboBoxWidget, which knows that this has list
items + allows free-form user input as well.
PDF 32000-1:2008 Table 230 documents those field flag bits.
Change-Id: Ifb99625c2ab8792b756ad52a3f6d599507c5773f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140480
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core/text/text.cxx')
-rw-r--r-- | sw/qa/core/text/text.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 245f8c230ca6..0084ac52bae2 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -751,6 +751,32 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont) CPPUNIT_ASSERT_EQUAL(24.0f, pAnnotation->getFormFontSize(pPdfDocument.get())); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testComboContentControlPDF) +{ + // Given a file with a combo box content control: + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::COMBO_BOX); + + // When exporting to PDF: + StoreToTempFile("writer_pdf_Export"); + + // Then make sure that a combo box form widget is emitted: + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = LoadPdfFromTempFile(); + std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the combo box content control was exported as plain text. + CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount()); + std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0); + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType()); + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox, + pAnnotation->getFormFieldType(pPdfDocument.get())); + // 19th bit: combo box, not dropdown. + CPPUNIT_ASSERT(pAnnotation->getFormFieldFlags(pPdfDocument.get()) & 0x00040000); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |