summaryrefslogtreecommitdiff
path: root/filter
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-22 12:15:24 +0100
commitbbe4161818e2ec6652ec443a67951b318c9f0e21 (patch)
tree57d5b3cf18b8317375af01962ce98370a04ad027 /filter
parent0abbef139f3147a9728fb22133bc2350d28b555e (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/+/142760 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ash@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143050 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'filter')
-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 160f5515caf4..c7cef8edd87f 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 )
{