diff options
author | Mark Hung <marklh9@gmail.com> | 2023-01-27 22:13:36 +0800 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-28 17:44:37 +0000 |
commit | 0a55335ef3b91bbf573f6e5eaa4241d14a15a4ee (patch) | |
tree | 67c2d4bea305bceec6623c13adff24b1a6b91b61 /sd | |
parent | a434653fd46828d152d0256738c24adb63530330 (diff) |
sd/filter/pptx-anmiation refactor Cond class.
Change-Id: Iffb0eeb1454a858987680d402add3f5122f7b6db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146292
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/Library_sd.mk | 1 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-animations-cond.cxx | 105 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-animations-cond.hxx | 31 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-animations.cxx | 95 |
4 files changed, 138 insertions, 94 deletions
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 86ad12f6a2b9..297c2bc23654 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -187,6 +187,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/filter/eppt/pptx-epptbase \ sd/source/filter/eppt/pptx-epptooxml \ sd/source/filter/eppt/pptx-animations \ + sd/source/filter/eppt/pptx-animations-cond \ sd/source/filter/eppt/pptx-grouptable \ sd/source/filter/eppt/pptx-stylesheet \ sd/source/filter/eppt/pptx-text \ diff --git a/sd/source/filter/eppt/pptx-animations-cond.cxx b/sd/source/filter/eppt/pptx-animations-cond.cxx new file mode 100644 index 000000000000..440d31885dad --- /dev/null +++ b/sd/source/filter/eppt/pptx-animations-cond.cxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <com/sun/star/animations/Timing.hpp> +#include <com/sun/star/animations/Event.hpp> +#include <com/sun/star/animations/EventTrigger.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include "pptx-animations-cond.hxx" + +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::uno; + +namespace +{ +const char* convertEventTrigger(sal_Int16 nTrigger) +{ + const char* pEvent = nullptr; + switch (nTrigger) + { + case EventTrigger::ON_NEXT: + pEvent = "onNext"; + break; + case EventTrigger::ON_PREV: + pEvent = "onPrev"; + break; + case EventTrigger::BEGIN_EVENT: + pEvent = "begin"; + break; + case EventTrigger::END_EVENT: + pEvent = "end"; + break; + case EventTrigger::ON_BEGIN: + pEvent = "onBegin"; + break; + case EventTrigger::ON_END: + pEvent = "onEnd"; + break; + case EventTrigger::ON_CLICK: + pEvent = "onClick"; + break; + case EventTrigger::ON_DBL_CLICK: + pEvent = "onDblClick"; + break; + case EventTrigger::ON_STOP_AUDIO: + pEvent = "onStopAudio"; + break; + case EventTrigger::ON_MOUSE_ENTER: + pEvent = "onMouseOver"; // not exact? + break; + case EventTrigger::ON_MOUSE_LEAVE: + pEvent = "onMouseOut"; + break; + } + return pEvent; +} +} + +namespace oox::core +{ +Cond::Cond(const Any& rAny, bool bIsMainSeqChild) + : mpEvent(nullptr) +{ + bool bHasFDelay = false; + double fDelay = 0; + Timing eTiming; + Event aEvent; + + if (rAny >>= eTiming) + { + if (eTiming == Timing_INDEFINITE) + msDelay = "indefinite"; + } + else if (rAny >>= aEvent) + { + if (aEvent.Trigger == EventTrigger::ON_NEXT && bIsMainSeqChild) + msDelay = "indefinite"; + else + { + mpEvent = convertEventTrigger(aEvent.Trigger); + if (!(aEvent.Source >>= mxShape)) + aEvent.Source >>= mxNode; + + if (aEvent.Offset >>= fDelay) + bHasFDelay = true; + } + } + else if (rAny >>= fDelay) + bHasFDelay = true; + + if (bHasFDelay) + { + sal_Int32 nDelay = static_cast<sal_uInt32>(fDelay * 1000.0); + msDelay = OString::number(nDelay); + } +} +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-animations-cond.hxx b/sd/source/filter/eppt/pptx-animations-cond.hxx new file mode 100644 index 000000000000..ec101c429ef1 --- /dev/null +++ b/sd/source/filter/eppt/pptx-animations-cond.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include <o3tl/any.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> + +namespace oox::core +{ +struct Cond +{ + OString msDelay; + const char* mpEvent; + css::uno::Reference<css::drawing::XShape> mxShape; + css::uno::Reference<css::animations::XAnimationNode> mxNode; + + Cond(const css::uno::Any& rAny, bool bIsMainSeqChild); + + bool isValid() const { return msDelay.getLength() || mpEvent; } + const char* getDelay() const { return msDelay.getLength() ? msDelay.getStr() : nullptr; } +}; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx index 03c8e6cc7b49..77b4ea2282a7 100644 --- a/sd/source/filter/eppt/pptx-animations.cxx +++ b/sd/source/filter/eppt/pptx-animations.cxx @@ -33,8 +33,6 @@ #include <com/sun/star/animations/AnimationTransformType.hpp> #include <com/sun/star/animations/AnimationValueType.hpp> #include <com/sun/star/animations/AnimationColorSpace.hpp> -#include <com/sun/star/animations/Event.hpp> -#include <com/sun/star/animations/EventTrigger.hpp> #include <com/sun/star/animations/Timing.hpp> #include <com/sun/star/animations/ValuePair.hpp> #include <com/sun/star/animations/XAnimateMotion.hpp> @@ -61,6 +59,7 @@ #include "pptexanimations.hxx" #include "pptx-animations.hxx" +#include "pptx-animations-cond.hxx" #include "../ppt/pptanimations.hxx" using namespace ::com::sun::star; @@ -258,48 +257,6 @@ void WriteAnimationCondListForSeq(const FSHelperPtr& pFS, sal_Int32 nToken) pFS->endElementNS(XML_p, nToken); } -const char* convertEventTrigger(sal_Int16 nTrigger) -{ - const char* pEvent = nullptr; - switch (nTrigger) - { - case EventTrigger::ON_NEXT: - pEvent = "onNext"; - break; - case EventTrigger::ON_PREV: - pEvent = "onPrev"; - break; - case EventTrigger::BEGIN_EVENT: - pEvent = "begin"; - break; - case EventTrigger::END_EVENT: - pEvent = "end"; - break; - case EventTrigger::ON_BEGIN: - pEvent = "onBegin"; - break; - case EventTrigger::ON_END: - pEvent = "onEnd"; - break; - case EventTrigger::ON_CLICK: - pEvent = "onClick"; - break; - case EventTrigger::ON_DBL_CLICK: - pEvent = "onDblClick"; - break; - case EventTrigger::ON_STOP_AUDIO: - pEvent = "onStopAudio"; - break; - case EventTrigger::ON_MOUSE_ENTER: - pEvent = "onMouseOver"; // not exact? - break; - case EventTrigger::ON_MOUSE_LEAVE: - pEvent = "onMouseOut"; - break; - } - return pEvent; -} - void WriteAnimationAttributeName(const FSHelperPtr& pFS, const OUString& rAttributeName) { if (rAttributeName.isEmpty()) @@ -575,56 +532,6 @@ public: const Reference<XAnimationNode>& getNodeForCondition() const; }; -struct Cond -{ - OString msDelay; - const char* mpEvent; - Reference<XShape> mxShape; - Reference<XAnimationNode> mxNode; - - Cond(const Any& rAny, bool bIsMainSeqChild); - - bool isValid() const { return msDelay.getLength() || mpEvent; } - const char* getDelay() const { return msDelay.getLength() ? msDelay.getStr() : nullptr; } -}; - -Cond::Cond(const Any& rAny, bool bIsMainSeqChild) - : mpEvent(nullptr) -{ - bool bHasFDelay = false; - double fDelay = 0; - Timing eTiming; - Event aEvent; - - if (rAny >>= eTiming) - { - if (eTiming == Timing_INDEFINITE) - msDelay = "indefinite"; - } - else if (rAny >>= aEvent) - { - if (aEvent.Trigger == EventTrigger::ON_NEXT && bIsMainSeqChild) - msDelay = "indefinite"; - else - { - mpEvent = convertEventTrigger(aEvent.Trigger); - if (!(aEvent.Source >>= mxShape)) - aEvent.Source >>= mxNode; - - if (aEvent.Offset >>= fDelay) - bHasFDelay = true; - } - } - else if (rAny >>= fDelay) - bHasFDelay = true; - - if (bHasFDelay) - { - sal_Int32 nDelay = static_cast<sal_uInt32>(fDelay * 1000.0); - msDelay = OString::number(nDelay); - } -} - class PPTXAnimationExport { void WriteAnimationNode(const NodeContextPtr& pContext); |