[Libreoffice-commits] core.git: filter/source

Marco Cecchetti marco.cecchetti at collabora.com
Sat Nov 28 15:13:18 PST 2015


 filter/source/svg/presentation_engine.js |   47 +++++++++++++++++--------------
 filter/source/svg/svgexport.cxx          |   21 +++++++++++++
 2 files changed, 46 insertions(+), 22 deletions(-)

New commits:
commit 64e4f3c70e131d41938ce65ad8089819a11c0e2a
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
    Reviewed-on: https://gerrit.libreoffice.org/20234
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-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 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 0400609..46b89865 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);
 
 }
@@ -937,6 +938,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