summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2022-11-15 10:56:15 +0100
committerAndras Timar <andras.timar@collabora.com>2022-11-16 21:45:37 +0100
commite87d8bb20267b83ba6ef665aabc70a3e26307fd9 (patch)
tree0c4cde40493ec6b6915f20e12601ef3f1b6149d9
parent98ff2f350a79959760b063821000ec6e7a37b090 (diff)
svg export filter: when a text field is too small, its content is wrong
When the text field width is too small, the placeholder text spans several lines. That stopped the js engine to substitute the text field placeholder with the right content. This is a workaround but it should work in the majority of cases. A complete solution needs to support svg text wrapping. Change-Id: Ide52e08acd35b3764b8abc600e4b467acea0a248 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142794 Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--filter/source/svg/presentation_engine.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index cf49ba565192..dbfe2ab0f914 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -5401,6 +5401,29 @@ function getTextFieldType ( elem )
else if (sContent === '<header>')
sFieldType = aHeaderClassName;
}
+
+ if( sFieldType )
+ return sFieldType;
+
+ var aTextPortionElement = getElementByClassName( elem, 'TextPortion' );
+ if( aTextPortionElement )
+ {
+ var sContent = aTextPortionElement.textContent
+ if( sContent.indexOf( '<number>' ) != -1 )
+ sFieldType = aSlideNumberClassName;
+ else if( sContent.indexOf( '<date/time>' ) != -1 )
+ sFieldType = aDateTimeClassName;
+ else if( sContent.indexOf( '<date>' ) != -1 )
+ sFieldType = aDateClassName;
+ else if( sContent.indexOf( '<time>' ) != -1 )
+ sFieldType = aTimeClassName;
+ else if( sContent.indexOf( '<slide-name>' ) != -1 )
+ sFieldType = aSlideNameClassName;
+ else if( sContent.indexOf( '<footer>' ) != -1 )
+ sFieldType = aFooterClassName;
+ else if( sContent.indexOf( '<header>' ) != -1 )
+ sFieldType = aHeaderClassName;
+ }
}
return sFieldType;
}
@@ -5610,6 +5633,20 @@ PlaceholderShape.prototype.init = function()
var aTextElem = getElementByClassName( aTextFieldElement, 'SVGTextShape' );
if( aTextElem )
{
+ var aTextParagraphSet = getElementsByClassName( aTextElem, 'TextParagraph' );
+ // When the text field width is too small, the placeholder text spans several lines.
+ // We remove all text lines but the first one which is used as a placeholder.
+ // This is a workaround but it should work in the majority of cases.
+ // A complete solution needs to support svg text wrapping.
+ if( aTextParagraphSet.length > 1 )
+ {
+ var i = aTextParagraphSet.length;
+ while( i > 1 )
+ {
+ aTextElem.removeChild(aTextParagraphSet[i-1]);
+ --i;
+ }
+ }
var aPlaceholderElement = getElementByClassName(aTextElem, 'PlaceholderText');
if( aPlaceholderElement )
{