diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-11-01 15:38:58 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-11-05 06:02:23 +0100 |
commit | 80400973e06e08f0c1ab0b9a86418c1bcc4bbd5c (patch) | |
tree | 1fdcfe2262377b6bc6a38968676ac99f3a368482 /vcl/qa/cppunit/pdfexport | |
parent | f825e6d4082c0d0beb1c95b881f6a2ee9bfc9161 (diff) |
tdf#118244 pdfexport: radio buttons use groupname now
The previous implementation grouped radio buttons if their
object name was the same. Likely this is a very old implementation,
because the current radio buttons have a groupname property which
links them together (although that too needed fixing in doc/docx),
and their object names are unique.
The old implementation still works - so that still needs to be
supported, but I think I'll do that in a separate patch, so
that it can be easily reverted if the old implementation is
deprecated.
Edge cases tested:
-groupID of 0 works fine - doesn't have to be 1-based.
-empty group name works fine (but breaks the old impl).
-writer, calc,
Change-Id: I84aebdac18b9edfa5ffcbfb23c15d0f37fcd47d1
Reviewed-on: https://gerrit.libreoffice.org/62742
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'vcl/qa/cppunit/pdfexport')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf118244_radioButtonGroup.odt | bin | 0 -> 12847 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 39 |
2 files changed, 39 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf118244_radioButtonGroup.odt b/vcl/qa/cppunit/pdfexport/data/tdf118244_radioButtonGroup.odt Binary files differnew file mode 100644 index 000000000000..caabc4987c30 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf118244_radioButtonGroup.odt diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 1ee110972865..71fd198a0e35 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -94,6 +94,7 @@ public: void testTdf99680(); void testTdf99680_2(); void testTdf108963(); + void testTdf118244_radioButtonGroup(); #if HAVE_MORE_FONTS /// Test writing ToUnicode CMAP for LTR ligatures. void testTdf115117_1(); @@ -132,6 +133,7 @@ public: CPPUNIT_TEST(testTdf99680); CPPUNIT_TEST(testTdf99680_2); CPPUNIT_TEST(testTdf108963); + CPPUNIT_TEST(testTdf118244_radioButtonGroup); #if HAVE_MORE_FONTS CPPUNIT_TEST(testTdf115117_1); CPPUNIT_TEST(testTdf115117_1a); @@ -872,6 +874,43 @@ void PdfExportTest::testTdf108963() CPPUNIT_ASSERT_EQUAL(1, nYellowPathCount); } +void PdfExportTest::testTdf118244_radioButtonGroup() +{ + vcl::filter::PDFDocument aDocument; + load("tdf118244_radioButtonGroup.odt", aDocument); + + // The document has one page. + std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size()); + + // There are eight radio buttons. + auto pAnnots = dynamic_cast<vcl::filter::PDFArrayElement*>(aPages[0]->Lookup("Annots")); + CPPUNIT_ASSERT(pAnnots); + CPPUNIT_ASSERT_EQUAL_MESSAGE("# of radio buttons",static_cast<size_t>(8), pAnnots->GetElements().size()); + + sal_uInt32 nRadioGroups = 0; + 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() == "Btn" ) + { + auto pKids = dynamic_cast<vcl::filter::PDFArrayElement*>(pObject->Lookup("Kids")); + if ( pKids ) + { + size_t expectedSize = 2; + ++nRadioGroups; + if ( nRadioGroups == 2 ) + expectedSize = 5; + CPPUNIT_ASSERT_EQUAL(expectedSize, pKids->GetElements().size()); + } + } + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("# of radio groups", sal_uInt32(2), nRadioGroups); +} + #if HAVE_MORE_FONTS // This requires Carlito font, if it is missing the test will most likely // fail. |