diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-11-19 17:24:39 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-12-09 09:24:06 +0000 |
commit | c805d85e0346265065a462445d7b255d27ab0872 (patch) | |
tree | 415c84a988af0b45fe7ac95740025e1965b901f5 /filter | |
parent | 3b74c0f8b750cfe89598358fba811f4900287b64 (diff) |
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/20241
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/svg/presentation_engine.js | 47 | ||||
-rw-r--r-- | filter/source/svg/svgexport.cxx | 21 |
2 files changed, 46 insertions, 22 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 892b76a950c5..7eec9b8d547c 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 794c71342091..ce71e255b3a0 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -67,6 +67,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"; @@ -353,7 +354,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); } @@ -935,6 +936,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 */ @@ -1810,6 +1816,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); |