[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - filter/source
Marco Cecchetti
marco.cecchetti at collabora.com
Wed Dec 9 01:25:20 PST 2015
filter/source/svg/presentation_engine.js | 65 ++++++++++++++++---------------
filter/source/svg/svgexport.cxx | 24 ++++++++++-
2 files changed, 56 insertions(+), 33 deletions(-)
New commits:
commit 3e0f7a0b78f40994a2b0e374f3eba7acefa1ff68
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Sun Nov 22 08:41:43 2015 +0100
svg-export: now animation elements are exported with namespace
For debug build an assertion failed because of presentation, smil and
anim namespaces were not registered before exporting. The JavaScript
engine has been modified in order to handle qualified animation elements
and attributes.
Change-Id: I2415fd59c2d1afddb1c68b708feb62e446ea5252
Reviewed-on: https://gerrit.libreoffice.org/20242
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 7eec9b8..f56621b 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -775,6 +775,9 @@ NSS['rdf']='http://www.w3.org/1999/02/22-rdf-syntax-ns#';
NSS['xlink']='http://www.w3.org/1999/xlink';
NSS['xml']='http://www.w3.org/XML/1998/namespace';
NSS['ooo'] = 'http://xml.openoffice.org/svg/export';
+NSS['presentation'] = 'http://sun.com/xmlns/staroffice/presentation';
+NSS['smil'] = 'http://www.w3.org/2001/SMIL20/';
+NSS['anim'] = 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0';
// Presentation modes.
var SLIDE_MODE = 1;
@@ -5094,13 +5097,13 @@ BaseNode.prototype.parseElement = function()
// begin attribute
this.aBegin = null;
- var sBeginAttr = aAnimElem.getAttribute( 'begin' );
+ var sBeginAttr = aAnimElem.getAttributeNS( NSS['smil'], 'begin' );
this.aBegin = new Timing( this, sBeginAttr );
this.aBegin.parse();
// end attribute
this.aEnd = null;
- var sEndAttr = aAnimElem.getAttribute( 'end' );
+ var sEndAttr = aAnimElem.getAttributeNS( NSS['smil'], 'end' );
if( sEndAttr )
{
this.aEnd = new Timing( this, sEndAttr );
@@ -5109,7 +5112,7 @@ BaseNode.prototype.parseElement = function()
// dur attribute
this.aDuration = null;
- var sDurAttr = aAnimElem.getAttribute( 'dur' );
+ var sDurAttr = aAnimElem.getAttributeNS( NSS['smil'], 'dur' );
this.aDuration = new Duration( sDurAttr );
if( !this.aDuration.isSet() )
{
@@ -5120,21 +5123,21 @@ BaseNode.prototype.parseElement = function()
}
// fill attribute
- var sFillAttr = aAnimElem.getAttribute( 'fill' );
+ var sFillAttr = aAnimElem.getAttributeNS( NSS['smil'], 'fill' );
if( sFillAttr && aFillModeInMap[ sFillAttr ])
this.eFillMode = aFillModeInMap[ sFillAttr ];
else
this.eFillMode = FILL_MODE_DEFAULT;
// restart attribute
- var sRestartAttr = aAnimElem.getAttribute( 'restart' );
+ var sRestartAttr = aAnimElem.getAttributeNS( NSS['smil'], 'restart' );
if( sRestartAttr && aRestartModeInMap[ sRestartAttr ] )
this.eRestartMode = aRestartModeInMap[ sRestartAttr ];
else
this.eRestartMode = RESTART_MODE_DEFAULT;
// repeatCount attribute
- var sRepeatCount = aAnimElem.getAttribute( 'repeatCount' );
+ var sRepeatCount = aAnimElem.getAttributeNS( NSS['smil'], 'repeatCount' );
if( !sRepeatCount )
this.nReapeatCount = 1;
else
@@ -5144,7 +5147,7 @@ BaseNode.prototype.parseElement = function()
// accelerate attribute
this.nAccelerate = 0.0;
- var sAccelerateAttr = aAnimElem.getAttribute( 'accelerate' );
+ var sAccelerateAttr = aAnimElem.getAttributeNS( NSS['smil'], 'accelerate' );
if( sAccelerateAttr )
this.nAccelerate = parseFloat( sAccelerateAttr );
if( this.nAccelerate == NaN )
@@ -5152,7 +5155,7 @@ BaseNode.prototype.parseElement = function()
// decelerate attribute
this.nDecelerate = 0.0;
- var sDecelerateAttr = aAnimElem.getAttribute( 'decelerate' );
+ var sDecelerateAttr = aAnimElem.getAttributeNS( NSS['smil'], 'decelerate' );
if( sDecelerateAttr )
this.nDecelerate = parseFloat( sDecelerateAttr );
if( this.nDecelerate == NaN )
@@ -5160,7 +5163,7 @@ BaseNode.prototype.parseElement = function()
// autoReverse attribute
this.bAutoreverse = false;
- var sAutoReverseAttr = aAnimElem.getAttribute( 'autoReverse' );
+ var sAutoReverseAttr = aAnimElem.getAttributeNS( NSS['smil'], 'autoReverse' );
if( sAutoReverseAttr == 'true' )
this.bAutoreverse = true;
@@ -5618,7 +5621,7 @@ AnimationBaseNode.prototype.parseElement = function()
// targetElement attribute
this.aTargetElement = null;
- var sTargetElementAttr = aAnimElem.getAttribute( 'targetElement' );
+ var sTargetElementAttr = aAnimElem.getAttributeNS( NSS['smil'], 'targetElement' );
if( sTargetElementAttr )
this.aTargetElement = document.getElementById( sTargetElementAttr );
@@ -5629,11 +5632,11 @@ AnimationBaseNode.prototype.parseElement = function()
}
// sub-item attribute for text animated element
- var sSubItemAttr = aAnimElem.getAttribute( 'sub-item' );
+ var sSubItemAttr = aAnimElem.getAttributeNS( NSS['smil'], 'sub-item' );
this.bIsTargetTextElement = ( sSubItemAttr && ( sSubItemAttr === 'text' ) );
// additive attribute
- var sAdditiveAttr = aAnimElem.getAttribute( 'additive' );
+ var sAdditiveAttr = aAnimElem.getAttributeNS( NSS['smil'], 'additive' );
if( sAdditiveAttr && aAddittiveModeInMap[sAdditiveAttr] )
this.eAdditiveMode = aAddittiveModeInMap[sAdditiveAttr];
else
@@ -5652,9 +5655,9 @@ AnimationBaseNode.prototype.parseElement = function()
if( this.aTargetElement )
{
// set up target element initial visibility
- if( aAnimElem.getAttribute( 'attributeName' ) === 'visibility' )
+ if( aAnimElem.getAttributeNS( NSS['smil'], 'attributeName' ) === 'visibility' )
{
- if( aAnimElem.getAttribute( 'to' ) === 'visible' )
+ if( aAnimElem.getAttributeNS( NSS['smil'], 'to' ) === 'visible' )
this.aTargetElement.setAttribute( 'visibility', 'hidden' );
}
@@ -5860,7 +5863,7 @@ AnimationBaseNode2.prototype.parseElement = function()
var aAnimElem = this.aElement;
// attributeName attribute
- this.sAttributeName = aAnimElem.getAttribute( 'attributeName' );
+ this.sAttributeName = aAnimElem.getAttributeNS( NSS['smil'], 'attributeName' );
if( !this.sAttributeName )
{
this.eCurrentState = INVALID_NODE;
@@ -5868,7 +5871,7 @@ AnimationBaseNode2.prototype.parseElement = function()
}
// to attribute
- this.aToValue = aAnimElem.getAttribute( 'to' );
+ this.aToValue = aAnimElem.getAttributeNS( NSS['smil'], 'to' );
return bRet;
};
@@ -5926,25 +5929,25 @@ AnimationBaseNode3.prototype.parseElement = function()
// accumulate attribute
this.eAccumulate = ACCUMULATE_MODE_NONE;
- var sAccumulateAttr = aAnimElem.getAttribute( 'accumulate' );
+ var sAccumulateAttr = aAnimElem.getAttributeNS( NSS['smil'], 'accumulate' );
if( sAccumulateAttr == 'sum' )
this.eAccumulate = ACCUMULATE_MODE_SUM;
// calcMode attribute
this.eCalcMode = CALC_MODE_LINEAR;
- var sCalcModeAttr = aAnimElem.getAttribute( 'calcMode' );
+ var sCalcModeAttr = aAnimElem.getAttributeNS( NSS['smil'], 'calcMode' );
if( sCalcModeAttr && aCalcModeInMap[ sCalcModeAttr ] )
this.eCalcMode = aCalcModeInMap[ sCalcModeAttr ];
// from attribute
- this.aFromValue = aAnimElem.getAttribute( 'from' );
+ this.aFromValue = aAnimElem.getAttributeNS( NSS['smil'], 'from' );
// by attribute
- this.aByValue = aAnimElem.getAttribute( 'by' );
+ this.aByValue = aAnimElem.getAttributeNS( NSS['smil'], 'by' );
// keyTimes attribute
this.aKeyTimes = new Array();
- var sKeyTimesAttr = aAnimElem.getAttribute( 'keyTimes' );
+ var sKeyTimesAttr = aAnimElem.getAttributeNS( NSS['smil'], 'keyTimes' );
sKeyTimesAttr = removeWhiteSpaces( sKeyTimesAttr );
if( sKeyTimesAttr )
{
@@ -5954,7 +5957,7 @@ AnimationBaseNode3.prototype.parseElement = function()
}
// values attribute
- var sValuesAttr = aAnimElem.getAttribute( 'values' );
+ var sValuesAttr = aAnimElem.getAttributeNS( NSS['smil'], 'values' );
if( sValuesAttr )
{
this.aValues = sValuesAttr.split( ';' );
@@ -6059,7 +6062,7 @@ BaseContainerNode.prototype.parseElement= function()
// node-type attribute
this.eImpressNodeType = IMPRESS_DEFAULT_NODE;
- var sNodeTypeAttr = aAnimElem.getAttribute( 'node-type' );
+ var sNodeTypeAttr = aAnimElem.getAttributeNS( NSS['presentation'], 'node-type' );
if( sNodeTypeAttr && aImpressNodeTypeInMap[ sNodeTypeAttr ] )
this.eImpressNodeType = aImpressNodeTypeInMap[ sNodeTypeAttr ];
this.bMainSequenceRootNode = ( this.eImpressNodeType == IMPRESS_MAIN_SEQUENCE_NODE );
@@ -6067,13 +6070,13 @@ BaseContainerNode.prototype.parseElement= function()
// preset-class attribute
this.ePresetClass = undefined;
- var sPresetClassAttr = aAnimElem.getAttribute( 'preset-class' );
+ var sPresetClassAttr = aAnimElem.getAttributeNS( NSS['presentation'], 'preset-class' );
if( sPresetClassAttr && aPresetClassInMap[ sPresetClassAttr ] )
this.ePresetClass = aPresetClassInMap[ sPresetClassAttr ];
// preset-id attribute
this.ePresetId = undefined;
- var sPresetIdAttr = aAnimElem.getAttribute( 'preset-id' );
+ var sPresetIdAttr = aAnimElem.getAttributeNS( NSS['presentation'], 'preset-id' );
if( sPresetIdAttr && aPresetIdInMap[ sPresetIdAttr ] )
this.ePresetId = aPresetIdInMap[ sPresetIdAttr ];
@@ -6775,13 +6778,13 @@ AnimationColorNode.prototype.parseElement = function()
// color-interpolation attribute
this.eColorInterpolation = COLOR_SPACE_RGB;
- var sColorInterpolationAttr = aAnimElem.getAttribute( 'color-interpolation' );
+ var sColorInterpolationAttr = aAnimElem.getAttributeNS( NSS['anim'], 'color-interpolation' );
if( sColorInterpolationAttr && aColorSpaceInMap[ sColorInterpolationAttr ] )
this.eColorInterpolation = aColorSpaceInMap[ sColorInterpolationAttr ];
// color-interpolation-direction attribute
this.eColorInterpolationDirection = CLOCKWISE;
- var sColorInterpolationDirectionAttr = aAnimElem.getAttribute( 'color-interpolation-direction' );
+ var sColorInterpolationDirectionAttr = aAnimElem.getAttributeNS( NSS['anim'], 'color-interpolation-direction' );
if( sColorInterpolationDirectionAttr && aClockDirectionInMap[ sColorInterpolationDirectionAttr ] )
this.eColorInterpolationDirection = aClockDirectionInMap[ sColorInterpolationDirectionAttr ];
@@ -6944,7 +6947,7 @@ AnimationTransitionFilterNode.prototype.parseElement = function()
// type attribute
this.eTransitionType = undefined;
- var sTypeAttr = aAnimElem.getAttribute( 'type' );
+ var sTypeAttr = aAnimElem.getAttributeNS( NSS['smil'], 'type' );
if( sTypeAttr && aTransitionTypeInMap[ sTypeAttr ] )
{
this.eTransitionType = aTransitionTypeInMap[ sTypeAttr ];
@@ -6957,7 +6960,7 @@ AnimationTransitionFilterNode.prototype.parseElement = function()
// subtype attribute
this.eTransitionSubType = undefined;
- var sSubTypeAttr = aAnimElem.getAttribute( 'subtype' );
+ var sSubTypeAttr = aAnimElem.getAttributeNS( NSS['smil'], 'subtype' );
if( sSubTypeAttr && aTransitionSubtypeInMap[ sSubTypeAttr ] )
{
this.eTransitionSubType = aTransitionSubtypeInMap[ sSubTypeAttr ];
@@ -6970,13 +6973,13 @@ AnimationTransitionFilterNode.prototype.parseElement = function()
// direction attribute
this.bReverseDirection = false;
- var sDirectionAttr = aAnimElem.getAttribute( 'direction' );
+ var sDirectionAttr = aAnimElem.getAttributeNS( NSS['smil'], 'direction' );
if( sDirectionAttr == 'reverse' )
this.bReverseDirection = true;
// mode attribute:
this.eTransitionMode = TRANSITION_MODE_IN;
- var sModeAttr = aAnimElem.getAttribute( 'mode' );
+ var sModeAttr = aAnimElem.getAttributeNS( NSS['smil'], 'mode' );
if( sModeAttr === 'out' )
this.eTransitionMode = TRANSITION_MODE_OUT;
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index ce71e25..5201e973 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -43,6 +43,9 @@
#include <i18nlangtag/lang.h>
#include <svl/zforlist.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
#include <xmloff/animationexport.hxx>
#include <boost/preprocessor/repetition/repeat.hpp>
@@ -51,7 +54,7 @@
using namespace ::com::sun::star::graphic;
using namespace ::com::sun::star::geometry;
using namespace ::com::sun::star;
-
+using namespace ::xmloff::token;
// - ooo elements and attributes -
@@ -357,6 +360,21 @@ SVGExport::SVGExport(
// Positioned Characters (The old method)
mbIsUsePositionedCharacters = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_POSITIONED_CHARACTERS, false);
+ // add namespaces
+ _GetNamespaceMap().Add(
+ GetXMLToken(XML_NP_PRESENTATION),
+ GetXMLToken(XML_N_PRESENTATION),
+ XML_NAMESPACE_PRESENTATION);
+
+ _GetNamespaceMap().Add(
+ GetXMLToken(XML_NP_SMIL),
+ GetXMLToken(XML_N_SMIL_COMPAT),
+ XML_NAMESPACE_SMIL);
+
+ _GetNamespaceMap().Add(
+ GetXMLToken(XML_NP_ANIMATION),
+ GetXMLToken(XML_N_ANIMATION),
+ XML_NAMESPACE_ANIMATION);
}
@@ -367,7 +385,6 @@ SVGExport::~SVGExport()
}
-
// - ObjectRepresentation -
@@ -806,6 +823,9 @@ bool SVGFilter::implExportDocument()
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns", constSvgNamespace );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:ooo", "http://xml.openoffice.org/svg/export" );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:presentation", "http://sun.com/xmlns/staroffice/presentation" );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:smil", "http://www.w3.org/2001/SMIL20/" );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0" );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xml:space", "preserve" );
mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", true, true );
More information about the Libreoffice-commits
mailing list