sd/qa/unit/tiledrendering/tiledrendering.cxx | 29 +++++++- sd/source/ui/unoidl/unomodel.cxx | 89 +++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 4 deletions(-)
New commits: commit 7596e810717c2f8f460ca7cc090cbd5b1214e64f Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jun 27 18:00:27 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jun 27 16:30:25 2024 +0200 lok: export transition info to getPresentationInfo JSON structure Added only basic transitions (type + subtype conversion) + added test case Change-Id: Ibebc34005ee0ffe1fdc2d1587c746538f657fbdd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169620 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 89864a53d380..a088baf8c776 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3069,10 +3069,15 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo) 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>()); - + // Check only that these exist CPPUNIT_ASSERT(has_child(rChild, "hash")); CPPUNIT_ASSERT(has_child(rChild, "masterPage")); CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + + // Transitions + CPPUNIT_ASSERT_EQUAL(std::string("BarWipe"), rChild.get_child("transitionType").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TopToBottom"), rChild.get_child("transitionSubtype").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(false, rChild.get_child("transitionDirection").get_value<bool>()); } // Slide Index 1 @@ -3080,10 +3085,16 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo) 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>()); - + // Check only that these exist CPPUNIT_ASSERT(has_child(rChild, "hash")); CPPUNIT_ASSERT(has_child(rChild, "masterPage")); CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + + // Transitions + CPPUNIT_ASSERT_EQUAL(std::string("FanWipe"), rChild.get_child("transitionType").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("CenterTop"), rChild.get_child("transitionSubtype").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, rChild.get_child("transitionDirection").get_value<bool>()); + } // Slide Index 2 @@ -3091,10 +3102,15 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo) 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>()); - + // Check only that these exist CPPUNIT_ASSERT(has_child(rChild, "hash")); CPPUNIT_ASSERT(has_child(rChild, "masterPage")); CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + + // Transitions + CPPUNIT_ASSERT_EQUAL(std::string("BlindWipe"), rChild.get_child("transitionType").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("Vertical"), rChild.get_child("transitionSubtype").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, rChild.get_child("transitionDirection").get_value<bool>()); } // Slide Index 3 - Hidden @@ -3104,10 +3120,15 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPresentationInfo) 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>()); - + // Check only that these exist CPPUNIT_ASSERT(has_child(rChild, "hash")); CPPUNIT_ASSERT(has_child(rChild, "masterPage")); CPPUNIT_ASSERT(has_child(rChild, "masterPageObjectsVisible")); + + // Transitions + CPPUNIT_ASSERT_EQUAL(std::string("Fade"), rChild.get_child("transitionType").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("FadeOverColor"), rChild.get_child("transitionSubtype").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, rChild.get_child("transitionDirection").get_value<bool>()); } } diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 409ebf7803c1..1f4777ed7dfc 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -30,6 +30,8 @@ #include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/util/XTheme.hpp> +#include <com/sun/star/animations/TransitionType.hpp> +#include <com/sun/star/animations/TransitionSubType.hpp> #include <com/sun/star/embed/Aspects.hpp> @@ -141,6 +143,10 @@ #include <svx/ColorSets.hxx> #include <docmodel/theme/Theme.hxx> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> + #include <app.hrc> using namespace ::cppu; @@ -2998,6 +3004,59 @@ void SdXImpressDocument::initializeDocument() } } +namespace +{ + +constexpr auto constTransitionTypeToString = frozen::make_unordered_map<sal_Int16, std::string_view>({ + { animations::TransitionType::BARWIPE, "BarWipe" }, // Wipe + { animations::TransitionType::PINWHEELWIPE, "PineWheelWipe" }, // Wheel + { animations::TransitionType::SLIDEWIPE, "SlideWipe" }, // Cover, Uncover + { animations::TransitionType::RANDOMBARWIPE, "RandomBarWipe" }, // Bars + { animations::TransitionType::CHECKERBOARDWIPE, "CheckerBoardWipe" }, // Checkers + { animations::TransitionType::FOURBOXWIPE, "FourBoxWipe" }, // Shape + { animations::TransitionType::IRISWIPE, "IrisWipe" }, // Box + { animations::TransitionType::FANWIPE, "FanWipe" }, // Wedge + { animations::TransitionType::BLINDSWIPE, "BlindWipe"}, // Venetian + { animations::TransitionType::FADE, "Fade"}, + { animations::TransitionType::DISSOLVE, "Dissolve"}, + { animations::TransitionType::PUSHWIPE, "PushWipe"}, // Comb + { animations::TransitionType::ELLIPSEWIPE, "EllipseWipe"}, // Shape + { animations::TransitionType::BARNDOORWIPE, "BarnDoorWipe"}, // Split + { animations::TransitionType::WATERFALLWIPE, "WaterfallWipe"}, // Diagonal +}); + +constexpr auto constTransitionSubTypeToString = frozen::make_unordered_map<sal_Int16, std::string_view>({ + { animations::TransitionSubType::LEFTTORIGHT, "LeftToRight" }, + { animations::TransitionSubType::TOPTOBOTTOM, "TopToBottom" }, + { animations::TransitionSubType::EIGHTBLADE, "8Blade" }, + { animations::TransitionSubType::FOURBLADE, "4Blade" }, + { animations::TransitionSubType::THREEBLADE, "3Blade" }, + { animations::TransitionSubType::TWOBLADEVERTICAL, "2BladeVertical" }, + { animations::TransitionSubType::ONEBLADE, "1Blade" }, + { animations::TransitionSubType::FROMTOPLEFT, "FromTopLeft" }, + { animations::TransitionSubType::FROMTOPRIGHT, "FromTopRight"}, + { animations::TransitionSubType::FROMBOTTOMLEFT, "FromBottomLeft"}, + { animations::TransitionSubType::FROMBOTTOMRIGHT, "FromBottomRight"}, + { animations::TransitionSubType::VERTICAL, "Vertical"}, + { animations::TransitionSubType::HORIZONTAL, "Horizontal"}, + { animations::TransitionSubType::DOWN, "Down"}, + { animations::TransitionSubType::ACROSS, "Across"}, + { animations::TransitionSubType::CORNERSOUT, "CornersOut"}, + { animations::TransitionSubType::DIAMOND, "Diamond"}, + { animations::TransitionSubType::CIRCLE, "Circle"}, + { animations::TransitionSubType::RECTANGLE, "Rectangle"}, + { animations::TransitionSubType::CENTERTOP, "CenterTop"}, + { animations::TransitionSubType::CROSSFADE, "CrossFade"}, + { animations::TransitionSubType::FADEOVERCOLOR, "FadeOverColor"}, + { animations::TransitionSubType::FROMLEFT, "FromLeft"}, + { animations::TransitionSubType::FROMRIGHT, "FromRight"}, + { animations::TransitionSubType::FROMTOP, "FromTop"}, + { animations::TransitionSubType::HORIZONTALLEFT, "HorizontalLeft"}, + { animations::TransitionSubType::HORIZONTALRIGHT, "HorizontalRight"}, +}); + +} + OString SdXImpressDocument::getPresentationInfo() const { ::tools::JsonWriter aJsonWriter; @@ -3070,6 +3129,36 @@ OString SdXImpressDocument::getPresentationInfo() const } } } + + sal_Int32 nTransitionType = 0; + xPropSet->getPropertyValue("TransitionType") >>= nTransitionType; + + if (nTransitionType != 0) + { + auto iterator = constTransitionTypeToString.find(nTransitionType); + + if (iterator != constTransitionTypeToString.end()) + { + aJsonWriter.put("transitionType", iterator->second); + + sal_Int32 nTransitionSubtype = 0; + xPropSet->getPropertyValue("TransitionSubtype") >>= nTransitionSubtype; + + auto iteratorSubType = constTransitionSubTypeToString.find(nTransitionSubtype); + if (iteratorSubType != constTransitionSubTypeToString.end()) + { + aJsonWriter.put("transitionSubtype", iteratorSubType->second); + } + else + { + SAL_WARN("sd", "Transition sub-type unknown: " << nTransitionSubtype); + } + + bool nTransitionDirection = false; + xPropSet->getPropertyValue("TransitionDirection") >>= nTransitionDirection; + aJsonWriter.put("transitionDirection", nTransitionDirection); + } + } } } }