[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 5 commits - filter/source

Marco Cecchetti marco.cecchetti at collabora.com
Sun Nov 29 01:51:14 PST 2015


 filter/source/svg/presentation_engine.js |  181 +++++++++++++++++--------------
 filter/source/svg/svgexport.cxx          |   45 +++++++
 2 files changed, 142 insertions(+), 84 deletions(-)

New commits:
commit 761afa1b2e4e21b62065a39818c3acd7200e68b1
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Tue Nov 24 14:44:19 2015 +0100

    svg-export: text animation didn't work - fixed
    
    That was due to 2 problems:
    - The namespace for an animation attribute was wrong
    - For debug build the bullet placeholder is not the first child
    
    Change-Id: If10c362f6fcffd4a05164cc5ca3ff6cacf5c28c1
    Reviewed-on: https://gerrit.libreoffice.org/20238
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit 1b26e2ef0a97ded5cc812664ef8455251468e847)

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 50908af..569a562 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -5638,7 +5638,7 @@ AnimationBaseNode.prototype.parseElement = function()
     }
 
     // sub-item attribute for text animated element
-    var sSubItemAttr = aAnimElem.getAttributeNS( NSS['smil'], 'sub-item' );
+    var sSubItemAttr = aAnimElem.getAttributeNS( NSS['anim'], 'sub-item' );
     this.bIsTargetTextElement = ( sSubItemAttr && ( sSubItemAttr === 'text' ) );
 
     // additive attribute
@@ -9185,7 +9185,7 @@ function AnimatedTextElement( aElement, aEventMultiplexer )
         var aBulletCharGroupElem = getElementByClassName( aTextShapeGroup, 'BulletChars' );
         if( aBulletCharGroupElem )
         {
-            var aBulletPlaceholderElem = getElementByClassName( aElement.firstElementChild, 'BulletPlaceholder' );
+            var aBulletPlaceholderElem = getElementByClassName( aElement, 'BulletPlaceholder' );
             if( aBulletPlaceholderElem )
             {
                 var sId = aBulletPlaceholderElem.getAttribute( 'id' );
commit ca282c75eee5f8328813e9bdf2843678234022a3
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Nov 22 21:59:54 2015 +0100

    svg-export: slide transition did not work - fixed
    
    Slide transition didn't work anymore since the attribute parsing did not
    take into account the smil namespace prefix.
    
    Change-Id: I779f6408b1eac964f934019d219dc4111debe592
    Reviewed-on: https://gerrit.libreoffice.org/20237
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit 23f5c03d964c3a069eb692c7a2b1d586c124cfd1)

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index f6426dc..50908af 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -9445,7 +9445,7 @@ function SlideTransition( aAnimationsRootElement, aSlideId )
     if( aAnimationsRootElement )
     {
         if( aAnimationsRootElement.firstElementChild &&
-            ( aAnimationsRootElement.firstElementChild.getAttribute( 'begin' ) === (this.sSlideId + '.begin') ) )
+            ( aAnimationsRootElement.firstElementChild.getAttributeNS( NSS['smil'], 'begin' ) === (this.sSlideId + '.begin') ) )
         {
             var aTransitionFilterElement = aAnimationsRootElement.firstElementChild.firstElementChild;
             if( aTransitionFilterElement && ( aTransitionFilterElement.localName === 'transitionFilter' ) )
@@ -9583,7 +9583,7 @@ SlideTransition.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 ];
@@ -9595,7 +9595,7 @@ SlideTransition.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 ];
@@ -9608,7 +9608,7 @@ SlideTransition.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;
 
@@ -9619,7 +9619,7 @@ SlideTransition.prototype.parseElement = function()
           this.eTransitionSubType == FADEOVERCOLOR_TRANS_SUBTYPE ||
           this.eTransitionSubType == FADETOCOLOR_TRANS_SUBTYPE ) )
     {
-        var sColorAttr = aAnimElem.getAttribute( 'fadeColor' );
+        var sColorAttr = aAnimElem.getAttributeNS( NSS['smil'], 'fadeColor' );
         if( sColorAttr )
             this.sFadeColor = sColorAttr;
         else
@@ -9629,7 +9629,7 @@ SlideTransition.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() )
     {
commit 2b7dad60efbbbe0fcbfc699131cbe882b1e94680
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Sun Nov 22 18:51:11 2015 +0100

    svg-export: animation sequence was wrong
    
    Animation sequence was wrong due to the priority queue and related
    compare functions implementation.
    
    Change-Id: I359abd087e922ffa0aa4f7770fcc0c9bdb029843
    Reviewed-on: https://gerrit.libreoffice.org/20236
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit 1ed6d1423c7cffa5403dad69a9946ec790a374f2)

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index e4fe52e..f6426dc 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -3776,7 +3776,6 @@ function PriorityQueue( aCompareFunc )
 {
     this.aSequence = new Array();
     this.aCompareFunc = aCompareFunc;
-    this.bSorted = true;
 }
 
 PriorityQueue.prototype.clone = function()
@@ -3793,18 +3792,11 @@ PriorityQueue.prototype.clone = function()
         }
     }
     aCopy.aSequence = dest;
-    aCopy.bSorted = this.bSorted;
-
     return aCopy;
 };
 
 PriorityQueue.prototype.top = function()
 {
-    if( !this.bSorted )
-    {
-        this.aSequence.sort(this.aCompareFunc)
-        this.bSorted = true;
-    }
     return this.aSequence[this.aSequence.length - 1];
 };
 
@@ -3815,28 +3807,23 @@ PriorityQueue.prototype.isEmpty = function()
 
 PriorityQueue.prototype.push = function( aValue )
 {
-    this.bSorted = false;
-    this.aSequence.push( aValue );
+    this.aSequence.unshift( aValue );
+    this.aSequence.sort(this.aCompareFunc);
 };
 
 PriorityQueue.prototype.clear = function()
 {
-    this.bSorted = true;
     this.aSequence = new Array();
 };
 
 PriorityQueue.prototype.pop = function()
 {
-    if( !this.bSorted )
-    {
-        this.aSequence.sort(this.aCompareFunc)
-        this.bSorted = true;
-    }
-
     return this.aSequence.pop();
 };
 
 
+
+
 /**********************************************************************************************
  *      AnimationNode Class Hierarchy
  **********************************************************************************************/
@@ -10353,17 +10340,30 @@ function PriorityEntry( aValue, nPriority )
  *      An instance of type PriorityEntry.
  *  @param aRhsEntry
  *      An instance of type PriorityEntry.
- *  @return {Boolean}
- *      True if the first entry has higher priority of the second entry,
- *      false otherwise.
+ *  @return {Integer}
+ *      -1 if the left entry has lower priority of the right entry,
+ *       1 if the left entry has higher priority of the right entry,
+ *       0 if the two entry have the same priority
  */
 PriorityEntry.compare = function( aLhsEntry, aRhsEntry )
 {
-    return ( aLhsEntry.nPriority < aRhsEntry.nPriority );
+    if ( aLhsEntry.nPriority < aRhsEntry.nPriority )
+    {
+        return -1;
+    }
+    else if (aLhsEntry.nPriority > aRhsEntry.nPriority)
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
 };
 
 
 
+
 function EventMultiplexer( aTimerEventQueue )
 {
     this.nId = EventMultiplexer.getUniqueId();
@@ -12907,7 +12907,18 @@ function EventEntry( aEvent, nTime )
 
 EventEntry.compare = function( aLhsEventEntry, aRhsEventEntry )
 {
-    return ( aLhsEventEntry.nActivationTime > aRhsEventEntry.nActivationTime );
+    if ( aLhsEventEntry.nActivationTime > aRhsEventEntry.nActivationTime )
+    {
+        return -1;
+    }
+    else if ( aLhsEventEntry.nActivationTime < aRhsEventEntry.nActivationTime )
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
 };
 
 
commit e6db50ab6c184d043dcfda96e323dc8f362d3c60
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

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 1cba7b2..e4fe52e 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;
@@ -5113,13 +5116,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 );
@@ -5128,7 +5131,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() )
     {
@@ -5139,21 +5142,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
@@ -5163,7 +5166,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 )
@@ -5171,7 +5174,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 )
@@ -5179,7 +5182,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;
 
@@ -5637,7 +5640,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 );
 
@@ -5648,11 +5651,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
@@ -5671,9 +5674,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' );
         }
 
@@ -5879,7 +5882,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;
@@ -5887,7 +5890,7 @@ AnimationBaseNode2.prototype.parseElement = function()
     }
 
     // to attribute
-    this.aToValue = aAnimElem.getAttribute( 'to' );
+    this.aToValue = aAnimElem.getAttributeNS( NSS['smil'], 'to' );
 
     return bRet;
 };
@@ -5945,25 +5948,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 )
     {
@@ -5973,7 +5976,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( ';' );
@@ -6078,7 +6081,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 );
@@ -6086,13 +6089,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 ];
 
@@ -6794,13 +6797,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 ];
 
@@ -6963,7 +6966,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 ];
@@ -6976,7 +6979,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 ];
@@ -6989,13 +6992,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 68800ea..c0e29fe 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -44,6 +44,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>
@@ -52,7 +55,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 -
 
@@ -358,6 +361,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);
 }
 
 
@@ -368,7 +386,6 @@ SVGExport::~SVGExport()
 }
 
 
-
 // - ObjectRepresentation -
 
 
@@ -807,6 +824,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 );
commit 69fcd7ac235d1261ac816c52f6ab8ef05b4d58ad
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Nov 19 17:24:39 2015 +0100

    svg export: fixed issue about text fields and shape bounding box
    
    - issue: text fields were not displayed; this happened for debug build
    only: the problem was due to 2 facts: 1) the last fix for text
    decoration which changes the order in which tspan and desc elements are
    exported; 2) a workaround implemented for fixing the fact that date/time
    fields were not exported correctly when positioned chars are used (see
    commit c0a08eab).
    
        - issue: text fields were no more aligned correctly: this was due to
    the fact that the rect element representing the bounding box of the
    exported shape is not exported any more: I suspect that the rectangle
    was present in the generated GDIMetaFile representation of the exported
    shape.
    
    Change-Id: I3cd7b0d3a7f2bde8bfd8b933297cbdd7b90e6567

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index a98ca70..1cba7b2 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -741,6 +741,7 @@ var aOOOAttrNumberOfSlides = 'number-of-slides';
 var aOOOAttrStartSlideNumber= 'start-slide-number';
 var aOOOAttrNumberingType = 'page-numbering-type';
 var aOOOAttrListItemNumberingType= 'numbering-type';
+var aOOOAttrUsePositionedChars = 'use-positioned-chars';
 
 var aOOOAttrSlide = 'slide';
 var aOOOAttrMaster = 'master';
@@ -1185,6 +1186,8 @@ function MetaDocument()
     this.nStartSlideNumber = parseInt( aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrStartSlideNumber ) ) || 0;
     // - the numbering type used in the presentation, default type is arabic.
     this.sPageNumberingType = aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrNumberingType ) || 'arabic';
+    // - the way text is exported
+    this.bIsUsePositionedChars = ( aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrUsePositionedChars ) === 'true' );
 
     // The <defs> element used for wrapping <clipPath>.
     this.aClipPathGroup = getElementByClassName( ROOT_NODE, aClipPathGroupClassName );
@@ -1434,7 +1437,7 @@ initMasterPage : function()
     // created by an other slide that target the same master page.
     if( !this.theMetaDoc.aMasterPageSet.hasOwnProperty( sMasterPageId ) )
     {
-        this.theMetaDoc.aMasterPageSet[ sMasterPageId ] = new MasterPage( sMasterPageId );
+        this.theMetaDoc.aMasterPageSet[ sMasterPageId ] = new MasterPage( sMasterPageId, this );
 
         // We initialize aTextFieldHandlerSet[ sMasterPageId ] to an empty
         // collection.
@@ -1623,9 +1626,10 @@ getSlideAnimationsRoot : function()
  *      A string representing the value of the id attribute of the master page
  *      element to be handled.
  */
-function MasterPage( sMasterPageId )
+function MasterPage( sMasterPageId, aMetaSlide )
 {
     this.id = sMasterPageId;
+    this.metaSlide = aMetaSlide;
 
     // The master page element to be handled.
     this.element = document.getElementById( this.id );
@@ -1771,12 +1775,10 @@ PlaceholderShape.prototype.init = function()
             // We exploit such a feature and the exported text adjust attribute
             // value in order to set up correctly the position and text
             // adjustment for the placeholder element.
-            var aSVGRectElemSet = aTextFieldElement.getElementsByTagName( 'rect' );
-            // As far as text field element exporting is implemented it should
-            // be only one <rect> element!
-            if( aSVGRectElemSet.length === 1)
+            var aSVGRectElem = getElementByClassName( aTextFieldElement, 'BoundingBox' );
+            if( aSVGRectElem )
             {
-                var aRect = new Rectangle( aSVGRectElemSet[0] );
+                var aRect = new Rectangle( aSVGRectElem );
                 var sTextAdjust = getOOOAttribute( aTextFieldElement, aOOOAttrTextAdjust ) || 'left';
                 var sTextAnchor, sX;
                 if( sTextAdjust == 'left' )
@@ -1801,26 +1803,29 @@ PlaceholderShape.prototype.init = function()
                     aPlaceholderElement.setAttribute( 'x', sX );
             }
 
-            this.element = aTextFieldElement;
-            this.textElement = aPlaceholderElement;
-
-            // We remove all text lines but the first one used as placeholder.
-            var aTextLineGroupElem = this.textElement.parentNode.parentNode;
-            if( aTextLineGroupElem )
+            // date/time fields were not exported correctly when positioned chars are used
+            if( this.masterPage.metaSlide.theMetaDoc.bIsUsePositionedChars )
             {
-                // Just to be sure it is the element we are looking for.
-                var sFontFamilyAttr = aTextLineGroupElem.getAttribute( 'font-family' );
-                if( sFontFamilyAttr )
+                // We remove all text lines but the first one used as placeholder.
+                var aTextLineGroupElem = aPlaceholderElement.parentNode.parentNode;
+                if( aTextLineGroupElem )
                 {
-                    var aChildSet = getElementChildren( aTextLineGroupElem );
-                    if( aChildSet.length > 1  )
-                        var i = 1;
-                    for( ; i < aChildSet.length; ++i )
+                    // Just to be sure it is the element we are looking for.
+                    var sFontFamilyAttr = aTextLineGroupElem.getAttribute( 'font-family' );
+                    if( sFontFamilyAttr )
                     {
-                        aTextLineGroupElem.removeChild( aChildSet[i] );
+                        var aChildSet = getElementChildren( aTextLineGroupElem );
+                        if( aChildSet.length > 1  )
+                            var i = 1;
+                        for( ; i < aChildSet.length; ++i )
+                        {
+                            aTextLineGroupElem.removeChild( aChildSet[i] );
+                        }
                     }
                 }
             }
+            this.element = aTextFieldElement;
+            this.textElement = aPlaceholderElement;
         }
     }
 };
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 64218db..68800ea 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -68,6 +68,7 @@ static const char    aOOOElemTextField[] = NSPREFIX "text_field";
 static const char    aOOOAttrNumberOfSlides[] = NSPREFIX "number-of-slides";
 static const char    aOOOAttrStartSlideNumber[] = NSPREFIX "start-slide-number";
 static const char    aOOOAttrNumberingType[] = NSPREFIX "page-numbering-type";
+static const char    aOOOAttrUsePositionedChars[] = NSPREFIX "use-positioned-chars";
 
 // ooo xml attributes for meta_slide
 static const char    aOOOAttrSlide[] = NSPREFIX "slide";
@@ -354,7 +355,7 @@ SVGExport::SVGExport(
     // Tiny Opacity (supported from SVG Tiny 1.2)
     mbIsUseOpacity = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_OPACITY, true);
 
-    // Positioned Characters    (Seems to be experimental, as it was always initialized with false)
+    // Positioned Characters    (The old method)
     mbIsUsePositionedCharacters = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_POSITIONED_CHARACTERS, false);
 
 }
@@ -936,6 +937,11 @@ bool SVGFilter::implGenerateMetaData()
         mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrNumberOfSlides, OUString::number( nCount ) );
         mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrStartSlideNumber, OUString::number( mnVisiblePage ) );
 
+        if( mpSVGExport->IsUsePositionedCharacters() )
+        {
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrUsePositionedChars, "true" );
+        }
+
         /*
          *  Add a (global) Page Numbering Type attribute for the document
          */
@@ -1811,6 +1817,19 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
                         }
 
                         SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+
+                        // export the shape bounding box
+                        {
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "BoundingBox" );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke", "none" );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "fill", "none" );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "x", OUString::number( aBoundRect.X ) );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "y", OUString::number( aBoundRect.Y ) );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", OUString::number( aBoundRect.Width ) );
+                            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", OUString::number( aBoundRect.Height ) );
+                            SvXMLElementExport aBB( *mpSVGExport, XML_NAMESPACE_NONE, "rect", true, true );
+                        }
+
                         if( !aBookmark.isEmpty() )
                         {
                             mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xlink:href", aBookmark);


More information about the Libreoffice-commits mailing list