summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/oox/ppt/pptfilterhelpers.hxx2
-rw-r--r--oox/source/ppt/animvariantcontext.cxx30
-rw-r--r--oox/source/ppt/pptfilterhelpers.cxx14
-rw-r--r--oox/source/ppt/timenodelistcontext.cxx50
-rw-r--r--sd/qa/unit/data/pptx/tdf113822underline.pptxbin0 -> 34449 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx16
6 files changed, 63 insertions, 49 deletions
diff --git a/include/oox/ppt/pptfilterhelpers.hxx b/include/oox/ppt/pptfilterhelpers.hxx
index 94ac025cb6c9..7944b03d8d05 100644
--- a/include/oox/ppt/pptfilterhelpers.hxx
+++ b/include/oox/ppt/pptfilterhelpers.hxx
@@ -36,7 +36,7 @@ namespace oox { namespace ppt {
enum class AnimationAttributeEnum
{
PPT_X, PPT_Y, PPT_W, PPT_H, PPT_C, R, XSHEAR, FILLCOLOR, FILLTYPE,
- STROKECOLOR, STROKEON, STYLECOLOR, STYLEROTATION, FONTWEIGHT,
+ FILLON, STROKECOLOR, STROKEON, STYLECOLOR, STYLEROTATION, FONTWEIGHT,
STYLEUNDERLINE, STYLEFONTFAMILY, STYLEFONTSIZE, STYLEFONTSTYLE,
STYLEVISIBILITY, STYLEOPACITY, UNKNOWN
};
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);
}
}
diff --git a/sd/qa/unit/data/pptx/tdf113822underline.pptx b/sd/qa/unit/data/pptx/tdf113822underline.pptx
new file mode 100644
index 000000000000..2d0d076544da
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf113822underline.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 0394b0ab92de..7ac6fc01404d 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -99,6 +99,7 @@ public:
void testTextRotation();
void testTdf115394PPT();
void testBulletsAsImage();
+ void testTdf113822();
CPPUNIT_TEST_SUITE(SdExportTest);
@@ -123,6 +124,7 @@ public:
CPPUNIT_TEST(testTextRotation);
CPPUNIT_TEST(testTdf115394PPT);
CPPUNIT_TEST(testBulletsAsImage);
+ CPPUNIT_TEST(testTdf113822);
CPPUNIT_TEST_SUITE_END();
@@ -1065,6 +1067,20 @@ void SdExportTest::testBulletsAsImage()
}
}
+void SdExportTest::testTdf113822()
+{
+ utl::TempFile tempFile;
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf113822underline.pptx"), PPTX);
+
+ xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
+
+ xmlDocPtr pXmlDoc = parseExport(tempFile, "content.xml");
+ assertXPath(pXmlDoc, "//anim:set[1]", "to", "solid");
+
+ xDocShRef->DoClose();
+}
+
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();