Kaydet (Commit) 64e4f3c7 authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Andras Timar

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/20234Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 50506421
...@@ -741,6 +741,7 @@ var aOOOAttrNumberOfSlides = 'number-of-slides'; ...@@ -741,6 +741,7 @@ var aOOOAttrNumberOfSlides = 'number-of-slides';
var aOOOAttrStartSlideNumber= 'start-slide-number'; var aOOOAttrStartSlideNumber= 'start-slide-number';
var aOOOAttrNumberingType = 'page-numbering-type'; var aOOOAttrNumberingType = 'page-numbering-type';
var aOOOAttrListItemNumberingType= 'numbering-type'; var aOOOAttrListItemNumberingType= 'numbering-type';
var aOOOAttrUsePositionedChars = 'use-positioned-chars';
var aOOOAttrSlide = 'slide'; var aOOOAttrSlide = 'slide';
var aOOOAttrMaster = 'master'; var aOOOAttrMaster = 'master';
...@@ -1185,6 +1186,8 @@ function MetaDocument() ...@@ -1185,6 +1186,8 @@ function MetaDocument()
this.nStartSlideNumber = parseInt( aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrStartSlideNumber ) ) || 0; this.nStartSlideNumber = parseInt( aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrStartSlideNumber ) ) || 0;
// - the numbering type used in the presentation, default type is arabic. // - the numbering type used in the presentation, default type is arabic.
this.sPageNumberingType = aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrNumberingType ) || '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>. // The <defs> element used for wrapping <clipPath>.
this.aClipPathGroup = getElementByClassName( ROOT_NODE, aClipPathGroupClassName ); this.aClipPathGroup = getElementByClassName( ROOT_NODE, aClipPathGroupClassName );
...@@ -1434,7 +1437,7 @@ initMasterPage : function() ...@@ -1434,7 +1437,7 @@ initMasterPage : function()
// created by an other slide that target the same master page. // created by an other slide that target the same master page.
if( !this.theMetaDoc.aMasterPageSet.hasOwnProperty( sMasterPageId ) ) 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 // We initialize aTextFieldHandlerSet[ sMasterPageId ] to an empty
// collection. // collection.
...@@ -1623,9 +1626,10 @@ getSlideAnimationsRoot : function() ...@@ -1623,9 +1626,10 @@ getSlideAnimationsRoot : function()
* A string representing the value of the id attribute of the master page * A string representing the value of the id attribute of the master page
* element to be handled. * element to be handled.
*/ */
function MasterPage( sMasterPageId ) function MasterPage( sMasterPageId, aMetaSlide )
{ {
this.id = sMasterPageId; this.id = sMasterPageId;
this.metaSlide = aMetaSlide;
// The master page element to be handled. // The master page element to be handled.
this.element = document.getElementById( this.id ); this.element = document.getElementById( this.id );
...@@ -1771,12 +1775,10 @@ PlaceholderShape.prototype.init = function() ...@@ -1771,12 +1775,10 @@ PlaceholderShape.prototype.init = function()
// We exploit such a feature and the exported text adjust attribute // We exploit such a feature and the exported text adjust attribute
// value in order to set up correctly the position and text // value in order to set up correctly the position and text
// adjustment for the placeholder element. // adjustment for the placeholder element.
var aSVGRectElemSet = aTextFieldElement.getElementsByTagName( 'rect' ); var aSVGRectElem = getElementByClassName( aTextFieldElement, 'BoundingBox' );
// As far as text field element exporting is implemented it should if( aSVGRectElem )
// be only one <rect> element!
if( aSVGRectElemSet.length === 1)
{ {
var aRect = new Rectangle( aSVGRectElemSet[0] ); var aRect = new Rectangle( aSVGRectElem );
var sTextAdjust = getOOOAttribute( aTextFieldElement, aOOOAttrTextAdjust ) || 'left'; var sTextAdjust = getOOOAttribute( aTextFieldElement, aOOOAttrTextAdjust ) || 'left';
var sTextAnchor, sX; var sTextAnchor, sX;
if( sTextAdjust == 'left' ) if( sTextAdjust == 'left' )
...@@ -1801,26 +1803,29 @@ PlaceholderShape.prototype.init = function() ...@@ -1801,26 +1803,29 @@ PlaceholderShape.prototype.init = function()
aPlaceholderElement.setAttribute( 'x', sX ); aPlaceholderElement.setAttribute( 'x', sX );
} }
this.element = aTextFieldElement; // date/time fields were not exported correctly when positioned chars are used
this.textElement = aPlaceholderElement; if( this.masterPage.metaSlide.theMetaDoc.bIsUsePositionedChars )
// 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. // We remove all text lines but the first one used as placeholder.
var sFontFamilyAttr = aTextLineGroupElem.getAttribute( 'font-family' ); var aTextLineGroupElem = aPlaceholderElement.parentNode.parentNode;
if( sFontFamilyAttr ) if( aTextLineGroupElem )
{ {
var aChildSet = getElementChildren( aTextLineGroupElem ); // Just to be sure it is the element we are looking for.
if( aChildSet.length > 1 ) var sFontFamilyAttr = aTextLineGroupElem.getAttribute( 'font-family' );
var i = 1; if( sFontFamilyAttr )
for( ; i < aChildSet.length; ++i )
{ {
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;
} }
} }
}; };
......
...@@ -68,6 +68,7 @@ static const char aOOOElemTextField[] = NSPREFIX "text_field"; ...@@ -68,6 +68,7 @@ static const char aOOOElemTextField[] = NSPREFIX "text_field";
static const char aOOOAttrNumberOfSlides[] = NSPREFIX "number-of-slides"; static const char aOOOAttrNumberOfSlides[] = NSPREFIX "number-of-slides";
static const char aOOOAttrStartSlideNumber[] = NSPREFIX "start-slide-number"; static const char aOOOAttrStartSlideNumber[] = NSPREFIX "start-slide-number";
static const char aOOOAttrNumberingType[] = NSPREFIX "page-numbering-type"; static const char aOOOAttrNumberingType[] = NSPREFIX "page-numbering-type";
static const char aOOOAttrUsePositionedChars[] = NSPREFIX "use-positioned-chars";
// ooo xml attributes for meta_slide // ooo xml attributes for meta_slide
static const char aOOOAttrSlide[] = NSPREFIX "slide"; static const char aOOOAttrSlide[] = NSPREFIX "slide";
...@@ -354,7 +355,7 @@ SVGExport::SVGExport( ...@@ -354,7 +355,7 @@ SVGExport::SVGExport(
// Tiny Opacity (supported from SVG Tiny 1.2) // Tiny Opacity (supported from SVG Tiny 1.2)
mbIsUseOpacity = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_OPACITY, true); 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); mbIsUsePositionedCharacters = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_POSITIONED_CHARACTERS, false);
} }
...@@ -937,6 +938,11 @@ bool SVGFilter::implGenerateMetaData() ...@@ -937,6 +938,11 @@ bool SVGFilter::implGenerateMetaData()
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrNumberOfSlides, OUString::number( nCount ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrNumberOfSlides, OUString::number( nCount ) );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrStartSlideNumber, OUString::number( mnVisiblePage ) ); 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 * Add a (global) Page Numbering Type attribute for the document
*/ */
...@@ -1811,6 +1817,19 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape, ...@@ -1811,6 +1817,19 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
} }
SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); 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() ) if( !aBookmark.isEmpty() )
{ {
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xlink:href", aBookmark); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xlink:href", aBookmark);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment