[Libreoffice-commits] .: Branch 'feature/svg-export' - 3 commits - filter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 29 06:24:46 PDT 2012


 filter/source/svg/presentation_engine.js |  222 ++++++++++++++++++++++---------
 filter/source/svg/svgexport.cxx          |   23 +--
 2 files changed, 176 insertions(+), 69 deletions(-)

New commits:
commit 896ec40ea7543041e23ce2204e08adc1d950cd20
Author: Marco Cecchetti <mrcekets at gmail.com>
Date:   Sun Aug 26 18:48:01 2012 +0200

    Bug Fix: background objects on master pages were not stacked in the correct order

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index a525744..63e8a4c 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -1606,6 +1606,34 @@ function getClassAttribute(  aElem )
     return '';
 }
 
+function createElementGroup( aParentElement, aElementList, nFrom, nCount, sGroupClass, sGroupId )
+{
+    var nTo = nFrom + nCount;
+    if( nCount < 1 || aElementList.length < nTo )
+    {
+        log( 'createElementGroup: not enough elements available.' );
+        return;
+    }
+    var firstElement = aElementList[nFrom];
+    if( !firstElement )
+    {
+        log( 'createElementGroup: element not found.' );
+        return;
+    }
+    var aGroupElement = document.createElementNS( NSS['svg'], 'g' );
+    if( sGroupId )
+        aGroupElement.setAttribute( 'id', sGroupId );
+    if( sGroupClass )
+        aGroupElement.setAttribute( 'class', sGroupClass );
+    aParentElement.insertBefore( aGroupElement, firstElement );
+    var i = nFrom;
+    for( ; i < nTo; ++i )
+    {
+        aParentElement.removeChild( aElementList[i] );
+        aGroupElement.appendChild( aElementList[i] );
+    }
+}
+
 function initVisibilityProperty( aElement )
 {
     var nVisibility = VISIBLE;
@@ -2213,6 +2241,47 @@ function MasterPage( sMasterPageId )
     {
         this.backgroundObjectsId = this.backgroundObjects.getAttribute( 'id' );
         this.backgroundObjectsVisibility = initVisibilityProperty( this.backgroundObjects );
+
+        if( this.backgroundObjectsVisibility != HIDDEN )
+        {
+            var aBackgroundObjectList = getElementChildren( this.backgroundObjects );
+            var nFrom = 0;
+            var nCount = 0;
+            var nSubGroupId = 1;
+            var sClass;
+            var sId = '';
+            this.aBackgroundObjectSubGroupIdList = new Array();
+            var i = 0;
+            for( ; i < aBackgroundObjectList.length; ++i )
+            {
+                sClass = aBackgroundObjectList[i].getAttribute( 'class' );
+                if( !sClass || ( ( sClass !== aDateTimeClassName ) && ( sClass !== aFooterClassName )
+                                     && ( sClass !== aHeaderClassName ) && ( sClass !== aSlideNumberClassName ) ) )
+                {
+                    if( nCount === 0 )
+                    {
+                        nFrom = i;
+                        sId = this.backgroundObjectsId + '.' + nSubGroupId;
+                        ++nSubGroupId;
+                        this.aBackgroundObjectSubGroupIdList.push( sId );
+                    }
+                    ++nCount;
+                }
+                else
+                {
+                    this.aBackgroundObjectSubGroupIdList.push( sClass );
+                    if( nCount !== 0 )
+                    {
+                        createElementGroup( this.backgroundObjects, aBackgroundObjectList, nFrom, nCount, 'BackgroundObjectSubgroup', sId );
+                        nCount = 0;
+                    }
+                }
+            }
+            if( nCount !== 0 )
+            {
+                createElementGroup( this.backgroundObjects, aBackgroundObjectList, nFrom, nCount, 'BackgroundObjectSubgroup', sId );
+            }
+        }
     }
     else
     {
@@ -2355,15 +2424,14 @@ PlaceholderShape.prototype.init = function()
  *  <g class='MasterPageView'>
  *      <use class='Background'>               // reference to master page background element
  *      <g class='BackgroundObjects'>
- *          <g class='BackgroundFields'>
- *              <g class='Slide_Number'>       // a cloned element
+ *          <use class='BackgroundObjectSubGroup'>     // reference to the group of shapes on the master page that are below text fields
+ *          <g class='Slide_Number'>                   // a cloned element
  *                  ...
- *              </g>
- *              <use class='Date/Time'>        // reference to a clone
- *              <use class='Footer'>
- *              <use class='Header'>
  *          </g>
- *          <use class='BackgroundShapes'>     // reference to the group of shapes on the master page
+ *          <use class='Date/Time'>                    // reference to a clone
+ *          <use class='Footer'>
+ *          <use class='Header'>
+ *          <use class='BackgroundObjectSubGroup'>     // reference to the group of shapes on the master page that are above text fields
  *      </g>
  *  </g>
  *
@@ -2458,11 +2526,9 @@ MasterPageView.prototype.createElement = function()
         this.aBackgroundObjectsElement = theDocument.createElementNS( NSS['svg'], 'g' );
         this.aBackgroundObjectsElement.setAttribute( 'class', 'BackgroundObjects' );
 
-        // create background fields group
-        this.aBackgroundFieldsElement = theDocument.createElementNS( NSS['svg'], 'g' );
-        this.aBackgroundFieldsElement.setAttribute( 'class', 'BackgroundFields' );
-
         // clone and initialize text field elements
+        var aBackgroundObjectSubGroupIdList = this.aMasterPage.aBackgroundObjectSubGroupIdList;
+        this.aBackgroundSubGroupElementSet = new Array();
         var aPlaceholderShapeSet = this.aMasterPage.aPlaceholderShapeSet;
         var aTextFieldContentProviderSet = this.aMetaSlide.aTextFieldContentProviderSet;
         // where cloned elements are appended
@@ -2470,58 +2536,76 @@ MasterPageView.prototype.createElement = function()
         var aTextFieldHandlerSet = this.aMetaSlide.theMetaDoc.aTextFieldHandlerSet;
         var sMasterSlideId = this.aMasterPage.id;
 
-        // Slide Number Field
-        // The cloned element is appended directly to the field group element
-        // since there is no slide number field content shared between two slide
-        // (because the slide number of two slide is always different).
-        if( aPlaceholderShapeSet[aSlideNumberClassName] &&
-            aPlaceholderShapeSet[aSlideNumberClassName].isValid() &&
-            this.aMetaSlide.nIsPageNumberVisible &&
-            aTextFieldContentProviderSet[aSlideNumberClassName] )
-        {
-            this.aSlideNumberFieldHandler =
-            new SlideNumberFieldHandler( aPlaceholderShapeSet[aSlideNumberClassName],
-                                         aTextFieldContentProviderSet[aSlideNumberClassName] );
-            this.aSlideNumberFieldHandler.update( this.aMetaSlide.nSlideNumber );
-            this.aSlideNumberFieldHandler.appendTo( this.aBackgroundFieldsElement );
-        }
-
-        // Date/Time field
-        if( this.aMetaSlide.nIsDateTimeVisible )
-        {
-            this.aDateTimeFieldHandler =
-            this.initTextFieldHandler( aDateTimeClassName, aPlaceholderShapeSet,
-                                       aTextFieldContentProviderSet, aDefsElement,
-                                       aTextFieldHandlerSet, sMasterSlideId );
-        }
-
-        // Footer Field
-        if( this.aMetaSlide.nIsFooterVisible )
+        var i = 0;
+        var sId;
+        for( ; i < aBackgroundObjectSubGroupIdList.length; ++i )
         {
-            this.aFooterFieldHandler =
-            this.initTextFieldHandler( aFooterClassName, aPlaceholderShapeSet,
-                                       aTextFieldContentProviderSet, aDefsElement,
-                                       aTextFieldHandlerSet, sMasterSlideId );
-        }
+            sId = aBackgroundObjectSubGroupIdList[i];
+            if( sId === aSlideNumberClassName )
+            {
+                // Slide Number Field
+                // The cloned element is appended directly to the field group element
+                // since there is no slide number field content shared between two slide
+                // (because the slide number of two slide is always different).
+                if( aPlaceholderShapeSet[aSlideNumberClassName] &&
+                    aPlaceholderShapeSet[aSlideNumberClassName].isValid() &&
+                    this.aMetaSlide.nIsPageNumberVisible &&
+                    aTextFieldContentProviderSet[aSlideNumberClassName] )
+                {
+                    this.aSlideNumberFieldHandler =
+                    new SlideNumberFieldHandler( aPlaceholderShapeSet[aSlideNumberClassName],
+                                                 aTextFieldContentProviderSet[aSlideNumberClassName] );
+                    this.aSlideNumberFieldHandler.update( this.aMetaSlide.nSlideNumber );
+                    this.aSlideNumberFieldHandler.appendTo( this.aBackgroundObjectsElement );
+                }
+            }
+            else if( sId === aDateTimeClassName )
+            {
+                // Date/Time field
+                if( this.aMetaSlide.nIsDateTimeVisible )
+                {
+                    this.aDateTimeFieldHandler =
+                    this.initTextFieldHandler( aDateTimeClassName, aPlaceholderShapeSet,
+                                               aTextFieldContentProviderSet, aDefsElement,
+                                               aTextFieldHandlerSet, sMasterSlideId );
+                }
+            }
+            else if( sId === aFooterClassName )
+            {
+                // Footer Field
+                if( this.aMetaSlide.nIsFooterVisible )
+                {
+                    this.aFooterFieldHandler =
+                    this.initTextFieldHandler( aFooterClassName, aPlaceholderShapeSet,
+                                               aTextFieldContentProviderSet, aDefsElement,
+                                               aTextFieldHandlerSet, sMasterSlideId );
+                }
+            }
+            else if( sId === aHeaderClassName )
+            {
+                // Header Field
+                if( this.aMetaSlide.nIsHeaderVisible )
+                {
+                    this.aHeaderFieldHandler =
+                    this.initTextFieldHandler( aHeaderClassName, aPlaceholderShapeSet,
+                                               aTextFieldContentProviderSet, aDefsElement,
+                                               aTextFieldHandlerSet, sMasterSlideId );
+                }
+            }
+            else
+            {
+                // init BackgroundObjectSubGroup elements
+                var aBackgroundSubGroupElement = theDocument.createElementNS( NSS['svg'], 'use' );
+                aBackgroundSubGroupElement.setAttribute( 'class', 'BackgroundObjectSubGroup' );
+                setNSAttribute( 'xlink', aBackgroundSubGroupElement,
+                                'href', '#' + sId );
+                this.aBackgroundSubGroupElementSet.push( aBackgroundSubGroupElement );
+                // node linking
+                this.aBackgroundObjectsElement.appendChild( aBackgroundSubGroupElement );
+            }
 
-        // Header Field
-        if( this.aMetaSlide.nIsHeaderVisible )
-        {
-            this.aHeaderFieldHandler =
-            this.initTextFieldHandler( aHeaderClassName, aPlaceholderShapeSet,
-                                       aTextFieldContentProviderSet, aDefsElement,
-                                       aTextFieldHandlerSet, sMasterSlideId );
         }
-
-        // init BackgroundShapes element
-        this.aBackgroundShapesElement = theDocument.createElementNS( NSS['svg'], 'use' );
-        this.aBackgroundShapesElement.setAttribute( 'class', 'BackgroundShapes' );
-        setNSAttribute( 'xlink', this.aBackgroundShapesElement,
-                        'href', '#' + this.aMasterPage.backgroundObjectsId );
-
         // node linking
-        this.aBackgroundObjectsElement.appendChild( this.aBackgroundFieldsElement );
-        this.aBackgroundObjectsElement.appendChild( this.aBackgroundShapesElement );
         aMasterPageViewElement.appendChild( this.aBackgroundObjectsElement );
     }
 
@@ -2561,7 +2645,7 @@ function( sClassName, aPlaceholderShapeSet, aTextFieldContentProviderSet,
         setNSAttribute( 'xlink', aTextFieldElement,
                         'href', '#' + aTextFieldHandler.sId );
         // node linking
-        this.aBackgroundFieldsElement.appendChild( aTextFieldElement );
+        this.aBackgroundObjectsElement.appendChild( aTextFieldElement );
     }
     return aTextFieldHandler;
 };
commit c0a08eab93861e3c4a0e75a7b3c0deb5843a1123
Author: Marco Cecchetti <mrcekets at gmail.com>
Date:   Sat Aug 25 12:01:24 2012 +0200

    Bug fix: fixed date/time fields were not exported correctly when positioned chars are used.

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 91110b7..a525744 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -2323,6 +2323,24 @@ PlaceholderShape.prototype.init = function()
                 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 )
+            {
+                // Just to be sure it is the element we are looking for.
+                var sFontFamilyAttr = aTextLineGroupElem.getAttribute( 'font-family' );
+                if( sFontFamilyAttr )
+                {
+                    var aChildSet = getElementChildren( aTextLineGroupElem );
+                    if( aChildSet.length > 1  )
+                    var i = 1;
+                    for( ; i < aChildSet.length; ++i )
+                    {
+                        aTextLineGroupElem.removeChild( aChildSet[i] );
+                    }
+                }
+            }
         }
     }
 };
commit 6f13ead35f4b003e03268fc5f2553909ec466dcd
Author: Marco Cecchetti <mrcekets at gmail.com>
Date:   Sat Aug 25 11:27:56 2012 +0200

    IsUsePositionedCharacters() tries to get its value from filter data passed to SVGExport ctor
    
    Now IsUseTinyProfile and IsEmbedFonts methods are depended by
    IsUsePositionedCharacters

diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index cf76b91..f3c8350 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -352,7 +352,7 @@ sal_Bool SVGExport::IsUseTinyProfile() const
 {
     sal_Bool bRet = sal_False;
 
-    if( mrFilterData.getLength() > 0 )
+    if( IsUsePositionedCharacters() && mrFilterData.getLength() > 0 )
         mrFilterData[ 0 ].Value >>= bRet;
 
     return bRet;
@@ -364,7 +364,7 @@ sal_Bool SVGExport::IsEmbedFonts() const
 {
     sal_Bool bRet = sal_False;
 
-    if( mrFilterData.getLength() > 1 )
+    if( IsUsePositionedCharacters() && mrFilterData.getLength() > 1 )
         mrFilterData[ 1 ].Value >>= bRet;
 
     return bRet;
@@ -372,13 +372,6 @@ sal_Bool SVGExport::IsEmbedFonts() const
 
 // -----------------------------------------------------------------------------
 
-sal_Bool SVGExport::IsUsePositionedCharacters() const
-{
-    return false;
-}
-
-// -----------------------------------------------------------------------------
-
 sal_Bool SVGExport::IsUseNativeTextDecoration() const
 {
     sal_Bool bRet = !IsUseTinyProfile();
@@ -401,6 +394,18 @@ sal_Bool SVGExport::IsUseOpacity() const
     return bRet;
 }
 
+// -----------------------------------------------------------------------------
+
+sal_Bool SVGExport::IsUsePositionedCharacters() const
+{
+    sal_Bool bRet = sal_False;
+    if( mrFilterData.getLength() > 6 )
+        mrFilterData[ 6 ].Value >>= bRet;
+
+    return bRet;
+}
+
+
 // ------------------------
 // - ObjectRepresentation -
 // ------------------------


More information about the Libreoffice-commits mailing list