sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 86 ++++++++++++++++ sd/source/ui/unoidl/unomodel.cxx | 5 3 files changed, 89 insertions(+), 2 deletions(-)
New commits: commit 5e18f15d2c5d853b0015d1afbfb65fae8d9963c6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jun 27 13:23:56 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jun 27 15:49:53 2024 +0200 lok: test for getPresentationInfo LOK API function Also fix getting the slides, so we don't rely that a WeakReference is set, as it is not set (yet) when running the test. Change-Id: Icd338e31fbd0bb7c45a06357b955b85081ed38c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169607 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp b/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp new file mode 100644 index 000000000000..77aa85a25356 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/PresentationInfoTest.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 5474a41a5b81..89864a53d380 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3025,6 +3025,92 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarSwitchDeck) CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); } +namespace +{ + +boost::property_tree::ptree const& child_at(boost::property_tree::ptree const& rTree, std::string_view aName, size_t nIndex) +{ + return std::next(rTree.get_child(std::string(aName)).find(""), nIndex)->second; +} + +bool has_child(boost::property_tree::ptree const& rTree, std::string_view aName) +{ + return rTree.count(std::string(aName)) > 0; +} + +} // end anonymous ns + +CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo) +{ + SdXImpressDocument* pXImpressDocument = createDoc("PresentationInfoTest.odp"); + pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + Scheduler::ProcessEventsToIdle(); + + SdPage* pPage = pViewShell->GetActualPage(); + CPPUNIT_ASSERT(pPage); + + OString aString = pXImpressDocument->getPresentationInfo(); + + boost::property_tree::ptree aTree; + std::stringstream aStream((std::string(aString))); + boost::property_tree::read_json(aStream, aTree); + + CPPUNIT_ASSERT_EQUAL(15875, aTree.get_child("docWidth").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(8930, aTree.get_child("docHeight").get_value<int>()); + + CPPUNIT_ASSERT_EQUAL(size_t(4), aTree.get_child("slides").size()); + + // Slide Index 0 + { + const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 0); + CPPUNIT_ASSERT_EQUAL(0, rChild.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>()); + + CPPUNIT_ASSERT(has_child(rChild, "hash")); + CPPUNIT_ASSERT(has_child(rChild, "masterPage")); + CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + } + + // Slide Index 1 + { + const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 1); + CPPUNIT_ASSERT_EQUAL(1, rChild.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>()); + + CPPUNIT_ASSERT(has_child(rChild, "hash")); + CPPUNIT_ASSERT(has_child(rChild, "masterPage")); + CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + } + + // Slide Index 2 + { + const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 2); + CPPUNIT_ASSERT_EQUAL(2, rChild.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>()); + + CPPUNIT_ASSERT(has_child(rChild, "hash")); + CPPUNIT_ASSERT(has_child(rChild, "masterPage")); + CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + } + + // Slide Index 3 - Hidden + + // Slide Index 4 + { + const boost::property_tree::ptree& rChild = child_at(aTree, "slides", 3); + CPPUNIT_ASSERT_EQUAL(4, rChild.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("empty").get_value<bool>()); + + CPPUNIT_ASSERT(has_child(rChild, "hash")); + CPPUNIT_ASSERT(has_child(rChild, "masterPage")); + CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 1bb62e02c832..409ebf7803c1 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3004,7 +3004,8 @@ OString SdXImpressDocument::getPresentationInfo() const try { - uno::Reference<container::XIndexAccess> xSlides(mxDrawPagesAccess.get(), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPages> xDrawPages = const_cast<SdXImpressDocument*>(this)->getDrawPages(); + uno::Reference<container::XIndexAccess> xSlides(xDrawPages, uno::UNO_QUERY_THROW); if (xSlides.is()) { // size in twips @@ -3077,7 +3078,7 @@ OString SdXImpressDocument::getPresentationInfo() const } catch (uno::Exception& ) { - TOOLS_WARN_EXCEPTION( "sd", "SdXImpressDocument::getSlideShowInfo ... maybe some property can't be retrieved" ); + TOOLS_WARN_EXCEPTION("sd", "SdXImpressDocument::getSlideShowInfo ... maybe some property can't be retrieved"); } return aJsonWriter.finishAndGetAsOString(); }