sd/qa/unit/tiledrendering/data/link_2p.pdf |binary sd/qa/unit/tiledrendering/tiledrendering2.cxx | 34 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
New commits: commit 4fd624c05113135c08e401950c6f11358583c068 Author: Jaume Pujantell <[email protected]> AuthorDate: Wed Jul 16 13:55:29 2025 +0200 Commit: Jaume Pujantell <[email protected]> CommitDate: Mon Nov 3 13:35:08 2025 +0100 lokit pdfium: test link data Unit test for commits 3217f0d4b368a96b30909e2aa7d4afc9a985a88b and 3217f0d4b368a96b30909e2aa7d4afc9a985a88b about sending link data when using PDFium in LOKit. Change-Id: I82a3f2c72f0e1a97300953850349267638717e13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187961 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit deb489f97792066c3294dcbdbb2f7da5d75a2f71) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193263 Reviewed-by: Jaume Pujantell <[email protected]> Tested-by: Jenkins diff --git a/sd/qa/unit/tiledrendering/data/link_2p.pdf b/sd/qa/unit/tiledrendering/data/link_2p.pdf new file mode 100644 index 000000000000..cb737de4f6e0 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/link_2p.pdf differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering2.cxx b/sd/qa/unit/tiledrendering/tiledrendering2.cxx index 9be4886e2a09..2918a332e92b 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering2.cxx @@ -137,6 +137,40 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testNotesViewInvalidations) CPPUNIT_ASSERT_EQUAL(2, aView.editModeOfInvalidation); } +CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPdfiumLinks) +{ + // Given a pdf file with links: + SdXImpressDocument* pDoc = createDoc("link_2p.pdf"); + SdTestViewCallback aView; + + auto get_links_array = [&aView]() -> boost::property_tree::ptree { + auto it = aView.m_aStateChanges.find("PageLinks"); + CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); + boost::property_tree::ptree pTree = it->second; + auto it2 = pTree.find("state"); + CPPUNIT_ASSERT(it2 != pTree.not_found()); + auto it3 = it2->second.find("links"); + CPPUNIT_ASSERT(it3 != pTree.not_found()); + return it3->second; + }; + + // First page has a link + pDoc->setPart(0); + auto links = get_links_array(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), links.size()); + // auto pLinkInfo = links.get_child(""); + auto pLinkInfo = links.begin()->second; + CPPUNIT_ASSERT_EQUAL(std::string("767.28x292.999@(1133.86,2013)"), + pLinkInfo.get_child("rectangle").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("http://cidac.pt/"), + pLinkInfo.get_child("uri").get_value<std::string>()); + + // Second doesn't + pDoc->setPart(1); + links = get_links_array(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), links.size()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
