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>
This commit is contained in:
@@ -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 \
|
||||
|
||||
@@ -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: */
|
||||
@@ -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: */
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user