summaryrefslogtreecommitdiff
path: root/svgio/source
diff options
context:
space:
mode:
Diffstat (limited to 'svgio/source')
-rw-r--r--svgio/source/svgreader/svgcharacternode.cxx8
-rw-r--r--svgio/source/svgreader/svgdocumenthandler.cxx22
2 files changed, 23 insertions, 7 deletions
diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx
index 2b88944aa8d0..9ba70ffb3ef5 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -79,7 +79,7 @@ namespace svgio::svgreader
OUString aText)
: SvgNode(SVGToken::Character, rDocument, pParent),
maText(std::move(aText)),
- mpTextParent(nullptr)
+ mpParentLine(nullptr)
{
}
@@ -251,7 +251,7 @@ namespace svgio::svgreader
}
// Use the whole text line to calculate the align position
- double fWholeTextLineWidth(aTextLayouterDevice.getTextWidth(mpTextParent->getTextLine(), 0, mpTextParent->getTextLine().getLength()));
+ double fWholeTextLineWidth(aTextLayouterDevice.getTextWidth(mpParentLine->getTextLine(), 0, mpParentLine->getTextLine().getLength()));
// apply TextAlign
switch(aTextAlign)
{
@@ -482,6 +482,10 @@ namespace svgio::svgreader
if(pPreviousCharacterNode->maTextBeforeSpaceHandling[nLastLength - 1] != ' ' && maTextBeforeSpaceHandling[0] != ' ')
bAddGap = false;
+ // Do not add a gap if this node and last node are in different lines
+ if(pPreviousCharacterNode->mpParentLine != mpParentLine)
+ bAddGap = false;
+
// With this option a baseline shift between two char parts ('words')
// will not add a space 'gap' to the end of the (non-last) word. This
// seems to be the standard behaviour, see last bugdoc attached #122524#
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx
index 16f100e0b01e..ea70f3c5cbd6 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -62,7 +62,7 @@ namespace svgio::svgreader
namespace
{
- svgio::svgreader::SvgCharacterNode* whiteSpaceHandling(svgio::svgreader::SvgNode const * pNode, svgio::svgreader::SvgTextNode* pText, svgio::svgreader::SvgCharacterNode* pLast)
+ svgio::svgreader::SvgCharacterNode* whiteSpaceHandling(svgio::svgreader::SvgNode const * pNode, svgio::svgreader::SvgTspanNode* pParentLine, svgio::svgreader::SvgCharacterNode* pLast)
{
if(pNode)
{
@@ -82,19 +82,31 @@ namespace
// clean whitespace in text span
svgio::svgreader::SvgCharacterNode* pCharNode = static_cast< svgio::svgreader::SvgCharacterNode* >(pCandidate);
+ pCharNode->setParentLine(pParentLine);
+
pCharNode->whiteSpaceHandling();
pLast = pCharNode->addGap(pLast);
- pCharNode->setTextParent(pText);
- pText->concatenateTextLine(pCharNode->getText());
+ pParentLine->concatenateTextLine(pCharNode->getText());
break;
}
case SVGToken::Tspan:
+ {
+ svgio::svgreader::SvgTspanNode* pTspanNode = static_cast< svgio::svgreader::SvgTspanNode* >(pCandidate);
+
+ // If x or y exist it means it's a new line of text
+ if(!pTspanNode->getX().empty() || !pTspanNode->getY().empty())
+ pParentLine = pTspanNode;
+
+ // recursively clean whitespaces in subhierarchy
+ pLast = whiteSpaceHandling(pCandidate, pParentLine, pLast);
+ break;
+ }
case SVGToken::TextPath:
case SVGToken::Tref:
{
// recursively clean whitespaces in subhierarchy
- pLast = whiteSpaceHandling(pCandidate, pText, pLast);
+ pLast = whiteSpaceHandling(pCandidate, pParentLine, pLast);
break;
}
default:
@@ -480,7 +492,7 @@ namespace
if(pTextNode)
{
// cleanup read strings
- whiteSpaceHandling(pTextNode, static_cast< SvgTextNode*>(pTextNode), nullptr);
+ whiteSpaceHandling(pTextNode, static_cast< SvgTspanNode*>(pTextNode), nullptr);
}
}