summaryrefslogtreecommitdiff
path: root/svgio/source
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-09-22 10:59:29 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-09-22 13:43:59 +0200
commitddf695db44bcb23dc2f1459fd439f93c0b6d5f2a (patch)
tree6aab04eba98b423b424db3ca878ab8bc9d2839a7 /svgio/source
parentcde237f7612cc34b1a7e46b83507877754b8e921 (diff)
tdf#151118: svg: fix handling of xml:space="preserve"
This allows the code to be simplified a bit Change-Id: If42dd9d3ebd7860ece9ff78cb090ff1b07e1b432 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140404 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/source')
-rw-r--r--svgio/source/svgreader/svgcharacternode.cxx4
-rw-r--r--svgio/source/svgreader/svgtools.cxx36
2 files changed, 12 insertions, 28 deletions
diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx
index 31376ee179a8..456a3abc8013 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -541,11 +541,11 @@ namespace svgio::svgreader
{
if (XmlSpace::Default == getXmlSpace())
{
- maText = whiteSpaceHandlingDefault(maText);
+ maText = xmlSpaceHandling(maText, true);
}
else
{
- maText = whiteSpaceHandlingPreserve(maText);
+ maText = xmlSpaceHandling(maText, false);
}
}
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index 5e56ee83b19e..92b2ecab3fb3 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1375,7 +1375,7 @@ namespace svgio::svgreader
}
}
- OUString convert(const OUString& rCandidate, sal_Unicode nPattern, sal_Unicode nNew, bool bRemove)
+ OUString convert(const OUString& rCandidate, sal_Unicode nPattern, sal_Unicode nNew)
{
const sal_Int32 nLen(rCandidate.getLength());
@@ -1392,11 +1392,7 @@ namespace svgio::svgreader
if(nPattern == aChar)
{
bChanged = true;
-
- if(!bRemove)
- {
- aBuffer.append(nNew);
- }
+ aBuffer.append(nNew);
}
else
{
@@ -1513,42 +1509,30 @@ namespace svgio::svgreader
return rCandidate;
}
- OUString whiteSpaceHandlingDefault(const OUString& rCandidate)
+ OUString xmlSpaceHandling(const OUString& rCandidate, bool bIsDefault)
{
const sal_Unicode aNewline('\n');
const sal_Unicode aTab('\t');
const sal_Unicode aSpace(' ');
// remove all newline characters
- OUString aRetval(convert(rCandidate, aNewline, aNewline, true));
+ OUString aRetval(convert(rCandidate, aNewline, aSpace));
// convert tab to space
- aRetval = convert(aRetval, aTab, aSpace, false);
+ aRetval = convert(aRetval, aTab, aSpace);
// strip of all leading and trailing spaces
aRetval = aRetval.trim();
- // consolidate contiguous space
- aRetval = consolidateContiguousSpace(aRetval);
+ if(bIsDefault)
+ {
+ // consolidate contiguous space
+ aRetval = consolidateContiguousSpace(aRetval);
+ }
return aRetval;
}
- OUString whiteSpaceHandlingPreserve(const OUString& rCandidate)
- {
- const sal_Unicode aNewline('\n');
- const sal_Unicode aTab('\t');
- const sal_Unicode aSpace(' ');
-
- // convert newline to space
- convert(rCandidate, aNewline, aSpace, false);
-
- // convert tab to space
- convert(rCandidate, aTab, aSpace, false);
-
- return rCandidate;
- }
-
::std::vector< double > solveSvgNumberVector(const SvgNumberVector& rInput, const InfoProvider& rInfoProvider)
{
::std::vector< double > aRetval;