summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-03-28 11:02:50 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-28 19:42:54 +0100
commit128274d59847288d4c3463fea42b6f57ec089ec0 (patch)
tree3627aa5ee2567b4e67719e94f4c27465142050fc /svgio
parent403abdc86af5f7ec145d14e2315493c510b1b869 (diff)
svgio: simplify code
Change-Id: Ieead2322e74829f187abf84dacbe8b107ea5130e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165450 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgnode.hxx4
-rw-r--r--svgio/inc/svgtools.hxx2
-rw-r--r--svgio/source/svgreader/svgnode.cxx34
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx2
-rw-r--r--svgio/source/svgreader/svgstylenode.cxx31
-rw-r--r--svgio/source/svgreader/svgtools.cxx6
6 files changed, 13 insertions, 66 deletions
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx
index 16c1f50bc3db..073b011c5f6c 100644
--- a/svgio/inc/svgnode.hxx
+++ b/svgio/inc/svgnode.hxx
@@ -21,6 +21,7 @@
#include "SvgNumber.hxx"
#include "svgtoken.hxx"
+#include "svgtools.hxx"
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <memory>
@@ -96,7 +97,7 @@ namespace svgio::svgreader
std::optional<OUString> mpClass;
/// systemLanguage values
- std::vector<OUString> maSystemLanguage;
+ SvgStringVector maSystemLanguage;
/// XmlSpace value
XmlSpace maXmlSpace;
@@ -179,7 +180,6 @@ namespace svgio::svgreader
/// SystemLanguage access
std::vector<OUString> const & getSystemLanguage() const { return maSystemLanguage; }
- void setSystemLanguage(OUString const &);
/// XmlSpace access
XmlSpace getXmlSpace() const;
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx
index 6dc882b6afb2..dfeb12d9ea49 100644
--- a/svgio/inc/svgtools.hxx
+++ b/svgio/inc/svgtools.hxx
@@ -122,7 +122,7 @@ namespace svgio::svgreader
SvgAspectRatio readSvgAspectRatio(std::u16string_view rCandidate);
typedef ::std::vector< OUString > SvgStringVector;
- bool readSvgStringVector(std::u16string_view rCandidate, SvgStringVector& rSvgStringVector);
+ bool readSvgStringVector(std::u16string_view rCandidate, SvgStringVector& rSvgStringVector, sal_Unicode nSeparator);
void readImageLink(const OUString& rCandidate, OUString& rXLink, OUString& rUrl, OUString& rData);
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 20a48de25977..781faaf4b2a7 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -525,9 +525,11 @@ namespace {
}
case SVGToken::SystemLanguage:
{
- if(!aContent.isEmpty())
+ SvgStringVector aSvgStringVector;
+
+ if(readSvgStringVector(aContent, aSvgStringVector, ','))
{
- setSystemLanguage(aContent);
+ maSystemLanguage = aSvgStringVector;
}
break;
}
@@ -755,34 +757,6 @@ namespace {
mrDocument.addSvgNodeToMapper(*mpClass, *this);
}
- void SvgNode::setSystemLanguage(OUString const & rSystemClass)
- {
- const sal_Int32 nLen(rSystemClass.getLength());
- sal_Int32 nPos(0);
- OUStringBuffer aToken;
-
- // split into single tokens (currently only comma separator)
- while(nPos < nLen)
- {
- const sal_Int32 nInitPos(nPos);
- copyToLimiter(rSystemClass, u',', nPos, aToken, nLen);
- skip_char(rSystemClass, u',', nPos, nLen);
- const OUString aLang(o3tl::trim(aToken));
- aToken.setLength(0);
-
- if(!aLang.isEmpty())
- {
- maSystemLanguage.push_back(aLang);
- }
-
- if(nInitPos == nPos)
- {
- OSL_ENSURE(false, "Could not interpret on current position (!)");
- nPos++;
- }
- }
- }
-
XmlSpace SvgNode::getXmlSpace() const
{
if(maXmlSpace != XmlSpace::NotSet)
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 0ae986f010cd..63be6afe270c 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1513,7 +1513,7 @@ namespace svgio::svgreader
{
SvgStringVector aSvgStringVector;
- if(readSvgStringVector(aContent, aSvgStringVector))
+ if(readSvgStringVector(aContent, aSvgStringVector, ','))
{
maFontFamily = aSvgStringVector;
}
diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx
index 88b380cf3b36..cb11e133dc8f 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -75,36 +75,9 @@ namespace svgio::svgreader
{
// aSelectors: CssStyle selectors, any combination, no comma separations, no spaces at start/end
// rNewStyle: the already prepared style to register on that name
- if(aSelectors.empty())
- return;
-
- std::vector< OUString > aSelectorParts;
- const sal_Int32 nLen(aSelectors.size());
- sal_Int32 nPos(0);
- OUStringBuffer aToken;
-
- // split into single tokens (currently only space separator)
- while(nPos < nLen)
- {
- const sal_Int32 nInitPos(nPos);
- copyToLimiter(aSelectors, u' ', nPos, aToken, nLen);
- skip_char(aSelectors, u' ', nPos, nLen);
- const OUString aSelectorPart(o3tl::trim(aToken));
- aToken.setLength(0);
-
- if(!aSelectorPart.isEmpty())
- {
- aSelectorParts.push_back(aSelectorPart);
- }
-
- if(nInitPos == nPos)
- {
- OSL_ENSURE(false, "Could not interpret on current position (!)");
- nPos++;
- }
- }
+ SvgStringVector aSelectorParts;
- if(aSelectorParts.empty())
+ if(!readSvgStringVector(aSelectors, aSelectorParts, ' '))
return;
OUStringBuffer aConcatenatedSelector;
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index 999de3075336..e3a4e7e9f3c3 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -1313,7 +1313,7 @@ namespace svgio::svgreader
return SvgAspectRatio();
}
- bool readSvgStringVector(std::u16string_view rCandidate, SvgStringVector& rSvgStringVector)
+ bool readSvgStringVector(std::u16string_view rCandidate, SvgStringVector& rSvgStringVector, sal_Unicode nSeparator)
{
rSvgStringVector.clear();
const sal_Int32 nLen(rCandidate.size());
@@ -1326,8 +1326,8 @@ namespace svgio::svgreader
while(nPos < nLen)
{
- copyToLimiter(rCandidate, ',', nPos, aTokenValue, nLen);
- skip_char(rCandidate, ',', ' ', nPos, nLen);
+ copyToLimiter(rCandidate, nSeparator, nPos, aTokenValue, nLen);
+ skip_char(rCandidate, nSeparator, nPos, nLen);
const OUString aString = aTokenValue.makeStringAndClear();
if(!aString.isEmpty())