summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-07-14 10:01:08 +0800
committerMark Hung <marklh9@gmail.com>2018-07-18 02:26:34 +0200
commitdaafe79c55cd53decbeac2367f298d79371dcf3d (patch)
tree501c3f34ff1e5135efa9b934ca1eea4617bd8496 /oox
parent7ba295853669f7c333ba22e8284e9732091c67fa (diff)
tdf#113822 convert animation value in SetTimeNodeContext.
Convert 'to' value of SetTimeNodeContext based on attribute name and move conversion code in its destructor to convertAnimationValue. Value conversion in AnimVariantContext is also included in convertAnimationValue and is removed together. Change-Id: I5dc693a1bbc7df57f7506e7704f9cd4693bf2056 Reviewed-on: https://gerrit.libreoffice.org/57412 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ppt/animvariantcontext.cxx30
-rw-r--r--oox/source/ppt/pptfilterhelpers.cxx14
-rw-r--r--oox/source/ppt/timenodelistcontext.cxx50
3 files changed, 46 insertions, 48 deletions
diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx
index 6cf91351bf30..81a70acfe26e 100644
--- a/oox/source/ppt/animvariantcontext.cxx
+++ b/oox/source/ppt/animvariantcontext.cxx
@@ -38,23 +38,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
namespace oox { namespace ppt {
-
- bool convertFillStyle( const OUString& rString, css::drawing::FillStyle& rValue )
- {
- if( rString == "solid" )
- {
- rValue = css::drawing::FillStyle::FillStyle_SOLID;
- return true;
- }
- else if( rString == "none" )
- {
- rValue = css::drawing::FillStyle::FillStyle_NONE;
- return true;
- }
- else
- return false;
- }
-
AnimVariantContext::AnimVariantContext( FragmentHandler2 const & rParent, sal_Int32 aElement, Any & aValue )
: FragmentHandler2( rParent )
, mnElement( aElement )
@@ -102,18 +85,7 @@ namespace oox { namespace ppt {
case PPT_TOKEN( strVal ):
{
OUString val = rAttribs.getString( XML_val, OUString() );
- if( convertMeasure( val ) )
- {
- maValue <<= val;
- }
- else
- {
- css::drawing::FillStyle eFillStyle;
- if( convertFillStyle( val, eFillStyle ) )
- maValue <<= eFillStyle;
- else
- maValue <<= val;
- }
+ maValue <<= val;
return this;
}
default:
diff --git a/oox/source/ppt/pptfilterhelpers.cxx b/oox/source/ppt/pptfilterhelpers.cxx
index a083cc29756e..3c1ab92fc06d 100644
--- a/oox/source/ppt/pptfilterhelpers.cxx
+++ b/oox/source/ppt/pptfilterhelpers.cxx
@@ -60,7 +60,7 @@ namespace oox { namespace ppt {
{ AnimationAttributeEnum::FILLCOLOR, "fillColor", "FillColor" },
{ AnimationAttributeEnum::FILLCOLOR, "fillcolor", "FillColor" },
{ AnimationAttributeEnum::FILLTYPE, "fill.type", "FillStyle" },
- { AnimationAttributeEnum::FILLTYPE, "fill.on", "FillOn" },
+ { AnimationAttributeEnum::FILLON, "fill.on", "FillOn" },
{ AnimationAttributeEnum::STROKECOLOR, "stroke.color", "LineColor" },
{ AnimationAttributeEnum::STROKEON, "stroke.on", "LineStyle" },
{ AnimationAttributeEnum::STYLECOLOR, "style.color", "CharColor" },
@@ -313,6 +313,18 @@ namespace oox { namespace ppt {
}
}
break;
+ case AnimationAttributeEnum::FILLON:
+ {
+ // Slideshow doesn't support FillOn, but we need to convert the value type
+ // so it can be written out again.
+ OUString aString;
+ if (rValue >>= aString)
+ {
+ rValue <<= aString == "true";
+ bRet = true;
+ }
+ }
+ break;
case AnimationAttributeEnum::FILLTYPE:
{
diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx
index 0d4df9b464a4..625036a25a2f 100644
--- a/oox/source/ppt/timenodelistcontext.cxx
+++ b/oox/source/ppt/timenodelistcontext.cxx
@@ -55,6 +55,35 @@ using namespace ::com::sun::star::presentation;
using namespace ::com::sun::star::xml::sax;
using ::com::sun::star::beans::NamedValue;
+namespace {
+
+ oox::ppt::AnimationAttributeEnum getAttributeEnumByAPIName(const OUString &rAPIName)
+ {
+ oox::ppt::AnimationAttributeEnum eResult = oox::ppt::AnimationAttributeEnum::UNKNOWN;
+ const oox::ppt::ImplAttributeNameConversion *attrConv = oox::ppt::getAttributeConversionList();
+ while(attrConv->mpAPIName != nullptr)
+ {
+ if(rAPIName.equalsAscii(attrConv->mpAPIName))
+ {
+ eResult = attrConv->meAttribute;
+ break;
+ }
+ attrConv++;
+ }
+ return eResult;
+ }
+
+ bool convertAnimationValueWithTimeNode(const oox::ppt::TimeNodePtr& pNode, css::uno::Any &rAny)
+ {
+ css::uno::Any aAny = pNode->getNodeProperties()[oox::ppt::NP_ATTRIBUTENAME];
+ OUString aNameList;
+ aAny >>= aNameList;
+
+ // only get first token.
+ return oox::ppt::convertAnimationValue(getAttributeEnumByAPIName(aNameList.getToken(0, ';')), rAny);
+ }
+}
+
namespace oox { namespace ppt {
struct AnimColor
@@ -172,25 +201,10 @@ namespace oox { namespace ppt {
virtual ~SetTimeNodeContext() throw () override
{
- if( maTo.hasValue() )
+ if(maTo.hasValue())
{
- // TODO
- // HACK !!! discard and refactor
- OUString aString;
- if( maTo >>= aString )
- {
- if( aString == "visible" || aString == "true" )
- maTo <<= true;
- else if( aString == "false" )
- maTo <<= false;
-
- if (!maTo.has<bool>())
- {
- SAL_WARN("oox.ppt", "conversion failed");
- maTo <<= false;
- }
- }
- mpNode->setTo( maTo );
+ convertAnimationValueWithTimeNode(mpNode, maTo);
+ mpNode->setTo(maTo);
}
}