[Libreoffice-commits] core.git: Branch 'aoo/trunk' - svgio/inc svgio/source

Armin Le Grand alg at apache.org
Wed Oct 8 11:07:51 PDT 2014


 svgio/inc/svgio/svgreader/svgstyleattributes.hxx |    8 +
 svgio/inc/svgio/svgreader/svgtoken.hxx           |    2 
 svgio/inc/svgio/svgreader/svgtools.hxx           |   16 +++
 svgio/source/svgreader/svgcirclenode.cxx         |    2 
 svgio/source/svgreader/svgclippathnode.cxx       |    2 
 svgio/source/svgreader/svgdocumenthandler.cxx    |    4 
 svgio/source/svgreader/svgellipsenode.cxx        |    2 
 svgio/source/svgreader/svggnode.cxx              |    2 
 svgio/source/svgreader/svggradientnode.cxx       |    2 
 svgio/source/svgreader/svggradientstopnode.cxx   |    2 
 svgio/source/svgreader/svgimagenode.cxx          |    2 
 svgio/source/svgreader/svglinenode.cxx           |    2 
 svgio/source/svgreader/svgmarkernode.cxx         |    2 
 svgio/source/svgreader/svgmasknode.cxx           |    2 
 svgio/source/svgreader/svgnode.cxx               |    4 
 svgio/source/svgreader/svgpathnode.cxx           |    2 
 svgio/source/svgreader/svgpatternnode.cxx        |    2 
 svgio/source/svgreader/svgpolynode.cxx           |    2 
 svgio/source/svgreader/svgrectnode.cxx           |    2 
 svgio/source/svgreader/svgstyleattributes.cxx    |   95 +++++++++++++----------
 svgio/source/svgreader/svgstylenode.cxx          |    2 
 svgio/source/svgreader/svgsvgnode.cxx            |    2 
 svgio/source/svgreader/svgsymbolnode.cxx         |    2 
 svgio/source/svgreader/svgtextnode.cxx           |    2 
 svgio/source/svgreader/svgtextpathnode.cxx       |    2 
 svgio/source/svgreader/svgtoken.cxx              |   29 ++++++-
 svgio/source/svgreader/svgtools.cxx              |   30 +++++--
 svgio/source/svgreader/svgtrefnode.cxx           |    2 
 svgio/source/svgreader/svgtspannode.cxx          |    2 
 svgio/source/svgreader/svgusenode.cxx            |    2 
 30 files changed, 151 insertions(+), 81 deletions(-)

New commits:
commit 2b179313ac95f4ae9dc2cf8f6b6d577ea893c7a8
Author: Armin Le Grand <alg at apache.org>
Date:   Wed Oct 8 16:36:47 2014 +0000

    i125332 made css style stuff aware that it is case independent

diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
index 36e60ac..3911e6b 100644
--- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
+++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
@@ -259,7 +259,11 @@ namespace svgio
 
         public:
             /// local attribute scanner
-            void parseStyleAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
+            void parseStyleAttribute(
+                const rtl::OUString& rTokenName,
+                SVGToken aSVGToken,
+                const rtl::OUString& aContent,
+                bool bCaseIndependent);
 
             /// helper which does the necessary with a given path
             void add_text(
@@ -279,7 +283,7 @@ namespace svgio
             const SvgStyleAttributes* getCssStyleParent() const { return mpCssStyleParent; }
 
             /// scan helpers
-            void readStyle(const rtl::OUString& rCandidate);
+            void readCssStyle(const rtl::OUString& rCandidate);
             const SvgStyleAttributes* getParentStyle() const;
 
             SvgStyleAttributes(SvgNode& rOwner);
diff --git a/svgio/inc/svgio/svgreader/svgtoken.hxx b/svgio/inc/svgio/svgreader/svgtoken.hxx
index 19c5653..a20ae26 100644
--- a/svgio/inc/svgio/svgreader/svgtoken.hxx
+++ b/svgio/inc/svgio/svgreader/svgtoken.hxx
@@ -186,7 +186,7 @@ namespace svgio
             SVGTokenLast
         };
 
-        SVGToken StrToSVGToken(const rtl::OUString& rStr);
+        SVGToken StrToSVGToken(const rtl::OUString& rStr, bool bCaseIndependent);
 
         const rtl::OUString& getStrTitle();
         const rtl::OUString& getStrDesc();
diff --git a/svgio/inc/svgio/svgreader/svgtools.hxx b/svgio/inc/svgio/svgreader/svgtools.hxx
index c7b0dca..a138d83 100644
--- a/svgio/inc/svgio/svgreader/svgtools.hxx
+++ b/svgio/inc/svgio/svgreader/svgtools.hxx
@@ -203,13 +203,23 @@ namespace svgio
         bool readNumberAndUnit(const rtl::OUString& rCandidate, sal_Int32& nPos, SvgNumber& aNum, const sal_Int32 nLen);
         bool readAngle(const rtl::OUString& rCandidate, sal_Int32& nPos, double& fAngle, const sal_Int32 nLen);
         sal_Int32 read_hex(const sal_Unicode& rChar);
-        bool match_colorKeyword(basegfx::BColor& rColor, const rtl::OUString& rName);
-        bool read_color(const rtl::OUString& rCandidate, basegfx::BColor& rColor);
+        bool match_colorKeyword(
+            basegfx::BColor& rColor,
+            const rtl::OUString& rName,
+            bool bCaseIndependent);
+        bool read_color(
+            const rtl::OUString& rCandidate,
+            basegfx::BColor& rColor,
+            bool bCaseIndependent);
         basegfx::B2DRange readViewBox(const rtl::OUString& rCandidate, InfoProvider& rInfoProvider);
         basegfx::B2DHomMatrix readTransform(const rtl::OUString& rCandidate, InfoProvider& rInfoProvider);
         bool readSingleNumber(const rtl::OUString& rCandidate, SvgNumber& aNum);
         bool readLocalUrl(const rtl::OUString& rCandidate, rtl::OUString& rURL);
-        bool readSvgPaint(const rtl::OUString& rCandidate, SvgPaint& rSvgPaint, rtl::OUString& rURL);
+        bool readSvgPaint(
+            const rtl::OUString& rCandidate,
+            SvgPaint& rSvgPaint,
+            rtl::OUString& rURL,
+            bool bCaseIndependent);
 
         bool readSvgNumberVector(const rtl::OUString& rCandidate, SvgNumberVector& rSvgNumberVector);
         ::std::vector< double > solveSvgNumberVector(const SvgNumberVector& rInput, const InfoProvider& rInfoProvider, NumberType aNumberType = length);
diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx
index 714d10b..8fbaf20 100644
--- a/svgio/source/svgreader/svgcirclenode.cxx
+++ b/svgio/source/svgreader/svgcirclenode.cxx
@@ -62,7 +62,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgclippathnode.cxx b/svgio/source/svgreader/svgclippathnode.cxx
index 82003ed..6fef47a 100644
--- a/svgio/source/svgreader/svgclippathnode.cxx
+++ b/svgio/source/svgreader/svgclippathnode.cxx
@@ -63,7 +63,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx b/svgio/source/svgreader/svgdocumenthandler.cxx
index f28921d..3e7e5ca 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -179,7 +179,7 @@ namespace svgio
         {
             if(aName.getLength())
             {
-                const SVGToken aSVGToken(StrToSVGToken(aName));
+                const SVGToken aSVGToken(StrToSVGToken(aName, false));
 
                 switch(aSVGToken)
                 {
@@ -393,7 +393,7 @@ namespace svgio
         {
             if(aName.getLength())
             {
-                const SVGToken aSVGToken(StrToSVGToken(aName));
+                const SVGToken aSVGToken(StrToSVGToken(aName, false));
                 SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
                 SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0);
                 SvgTitleDescNode* pSvgTitleDescNode(SVGTokenTitle == aSVGToken || SVGTokenDesc == aSVGToken ? static_cast< SvgTitleDescNode* >(mpTarget) : 0);
diff --git a/svgio/source/svgreader/svgellipsenode.cxx b/svgio/source/svgreader/svgellipsenode.cxx
index afe650c..cb3bb09 100644
--- a/svgio/source/svgreader/svgellipsenode.cxx
+++ b/svgio/source/svgreader/svgellipsenode.cxx
@@ -63,7 +63,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx
index 97ace93..b33f2c0 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -70,7 +70,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 48c5ea2..7623c7a 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -86,7 +86,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svggradientstopnode.cxx b/svgio/source/svgreader/svggradientstopnode.cxx
index 51cc5cf..f309fc5 100644
--- a/svgio/source/svgreader/svggradientstopnode.cxx
+++ b/svgio/source/svgreader/svggradientstopnode.cxx
@@ -56,7 +56,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index a96e60b..4014766 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -80,7 +80,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svglinenode.cxx b/svgio/source/svgreader/svglinenode.cxx
index ac6577c..d67dab8 100644
--- a/svgio/source/svgreader/svglinenode.cxx
+++ b/svgio/source/svgreader/svglinenode.cxx
@@ -63,7 +63,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx
index 134898e..b9b218c 100644
--- a/svgio/source/svgreader/svgmarkernode.cxx
+++ b/svgio/source/svgreader/svgmarkernode.cxx
@@ -66,7 +66,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgmasknode.cxx b/svgio/source/svgreader/svgmasknode.cxx
index 231e4ed..99fe962 100644
--- a/svgio/source/svgreader/svgmasknode.cxx
+++ b/svgio/source/svgreader/svgmasknode.cxx
@@ -69,7 +69,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index a631312..5f4afdf 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -331,7 +331,7 @@ namespace svgio
             if(mpLocalCssStyle)
             {
                 // parse and set values to it
-                mpLocalCssStyle->readStyle(aContent);
+                mpLocalCssStyle->readCssStyle(aContent);
             }
             else
             {
@@ -349,7 +349,7 @@ namespace svgio
             for(sal_uInt32 a(0); a < nAttributes; a++)
             {
                 const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(a));
-                const SVGToken aSVGToken(StrToSVGToken(aTokenName));
+                const SVGToken aSVGToken(StrToSVGToken(aTokenName, false));
 
                 parseAttribute(aTokenName, aSVGToken, xAttribs->getValueByIndex(a));
             }
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index 2dd5088..3466153 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -61,7 +61,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx
index 4610649..a633b8b 100644
--- a/svgio/source/svgreader/svgpatternnode.cxx
+++ b/svgio/source/svgreader/svgpatternnode.cxx
@@ -80,7 +80,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index a738f80..bf9f6d5 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -65,7 +65,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgrectnode.cxx b/svgio/source/svgreader/svgrectnode.cxx
index ae096d1..7b4c2b4 100644
--- a/svgio/source/svgreader/svgrectnode.cxx
+++ b/svgio/source/svgreader/svgrectnode.cxx
@@ -65,7 +65,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index b0bf2b0..0fa54d1 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -180,61 +180,70 @@ namespace svgio
             return nRetval;
         }
 
-        void SvgStyleAttributes::readStyle(const rtl::OUString& rCandidate)
+        void SvgStyleAttributes::readCssStyle(const rtl::OUString& rCandidate)
         {
             const sal_Int32 nLen(rCandidate.getLength());
             sal_Int32 nPos(0);
 
             while(nPos < nLen)
             {
-                const sal_Int32 nInitPos(nPos);
-                skip_char(rCandidate, sal_Unicode(' '), nPos, nLen);
+                // get TokenName
                 rtl::OUStringBuffer aTokenName;
+                skip_char(rCandidate, sal_Unicode(' '), nPos, nLen);
                 copyString(rCandidate, nPos, aTokenName, nLen);
 
-                if(aTokenName.getLength())
+                if(!aTokenName.getLength())
                 {
-                    skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
-                    rtl::OUStringBuffer aTokenValue;
-                    copyToLimiter(rCandidate, sal_Unicode(';'), nPos, aTokenValue, nLen);
-                    skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
-                    const rtl::OUString aOUTokenName(aTokenName.makeStringAndClear());
-                    rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+                    // if no TokenName advance one by force to avoid death loop, continue
+                    OSL_ENSURE(false, "Could not interpret on current position, advancing one byte (!)");
+                    nPos++;
+                    continue;
+                }
 
-                    // check for '!important' CssStyle mark, currently not supported
-                    // but neds to be extracted for correct parsing
-                    static rtl::OUString aTokenImportant(RTL_CONSTASCII_USTRINGPARAM("!important"));
-                    const sal_Int32 nIndexTokenImportant(aOUTokenValue.indexOf(aTokenImportant));
+                // get TokenValue
+                rtl::OUStringBuffer aTokenValue;
+                skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
+                copyToLimiter(rCandidate, sal_Unicode(';'), nPos, aTokenValue, nLen);
+                skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
 
-                    if(-1 != nIndexTokenImportant)
-                    {
-                        // if there currently just remove it and remove spaces to have the value only
-                        rtl::OUString aNewOUTokenValue;
+                if(!aTokenValue.getLength())
+                {
+                    // no value - continue
+                    continue;
+                }
 
-                        if(nIndexTokenImportant > 0)
-                        {
-                            // copy content before token
-                            aNewOUTokenValue += aOUTokenValue.copy(0, nIndexTokenImportant);
-                        }
+                // generate OUStrings
+                const rtl::OUString aOUTokenName(aTokenName.makeStringAndClear());
+                rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
 
-                        if(aOUTokenValue.getLength() > nIndexTokenImportant + aTokenImportant.getLength())
-                        {
-                            // copy content after token
-                            aNewOUTokenValue += aOUTokenValue.copy(nIndexTokenImportant + aTokenImportant.getLength());
-                        }
+                // check for '!important' CssStyle mark, currently not supported
+                // but needs to be extracted for correct parsing
+                static rtl::OUString aTokenImportant(RTL_CONSTASCII_USTRINGPARAM("!important"));
+                const sal_Int32 nIndexTokenImportant(aOUTokenValue.indexOf(aTokenImportant));
+
+                if(-1 != nIndexTokenImportant)
+                {
+                    // if there currently just remove it and remove spaces to have the value only
+                    rtl::OUString aNewOUTokenValue;
 
-                        // remove spaces
-                        aOUTokenValue = aNewOUTokenValue.trim();
+                    if(nIndexTokenImportant > 0)
+                    {
+                        // copy content before token
+                        aNewOUTokenValue += aOUTokenValue.copy(0, nIndexTokenImportant);
                     }
 
-                    parseStyleAttribute(aOUTokenName, StrToSVGToken(aOUTokenName), aOUTokenValue);
-                }
+                    if(aOUTokenValue.getLength() > nIndexTokenImportant + aTokenImportant.getLength())
+                    {
+                        // copy content after token
+                        aNewOUTokenValue += aOUTokenValue.copy(nIndexTokenImportant + aTokenImportant.getLength());
+                    }
 
-                if(nInitPos == nPos)
-                {
-                    OSL_ENSURE(false, "Could not interpret on current position (!)");
-                    nPos++;
+                    // remove spaces
+                    aOUTokenValue = aNewOUTokenValue.trim();
                 }
+
+                // valid token-value pair, parse it
+                parseStyleAttribute(aOUTokenName, StrToSVGToken(aOUTokenName, true), aOUTokenValue, true);
             }
         }
 
@@ -1246,7 +1255,11 @@ namespace svgio
         {
         }
 
-        void SvgStyleAttributes::parseStyleAttribute(const rtl::OUString& /* rTokenName */, SVGToken aSVGToken, const rtl::OUString& aContent)
+        void SvgStyleAttributes::parseStyleAttribute(
+            const rtl::OUString& /* rTokenName */,
+            SVGToken aSVGToken,
+            const rtl::OUString& aContent,
+            bool bCaseIndependent)
         {
             switch(aSVGToken)
             {
@@ -1255,7 +1268,7 @@ namespace svgio
                     SvgPaint aSvgPaint;
                     rtl::OUString aURL;
 
-                    if(readSvgPaint(aContent, aSvgPaint, aURL))
+                    if(readSvgPaint(aContent, aSvgPaint, aURL, bCaseIndependent))
                     {
                         setFill(aSvgPaint);
                     }
@@ -1310,7 +1323,7 @@ namespace svgio
                     SvgPaint aSvgPaint;
                     rtl::OUString aURL;
 
-                    if(readSvgPaint(aContent, aSvgPaint, aURL))
+                    if(readSvgPaint(aContent, aSvgPaint, aURL, bCaseIndependent))
                     {
                         setStroke(aSvgPaint);
                     }
@@ -1457,7 +1470,7 @@ namespace svgio
                     SvgPaint aSvgPaint;
                     rtl::OUString aURL;
 
-                    if(readSvgPaint(aContent, aSvgPaint, aURL))
+                    if(readSvgPaint(aContent, aSvgPaint, aURL, bCaseIndependent))
                     {
                         setStopColor(aSvgPaint);
                     }
@@ -1778,7 +1791,7 @@ namespace svgio
                     SvgPaint aSvgPaint;
                     rtl::OUString aURL;
 
-                    if(readSvgPaint(aContent, aSvgPaint, aURL))
+                    if(readSvgPaint(aContent, aSvgPaint, aURL, bCaseIndependent))
                     {
                         setColor(aSvgPaint);
                     }
diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx
index 48482d1..d9317fc7 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -163,7 +163,7 @@ namespace svgio
                 maSvgStyleAttributes.push_back(pNewStyle);
 
                 // fill with content
-                pNewStyle->readStyle(aContent);
+                pNewStyle->readCssStyle(aContent);
 
                 // comma-separated split (Css abbreviation for same style for multiple selectors)
                 const sal_Int32 nLen(aSelectors.getLength());
diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx
index 0a16069..7bc5de1 100644
--- a/svgio/source/svgreader/svgsvgnode.cxx
+++ b/svgio/source/svgreader/svgsvgnode.cxx
@@ -130,7 +130,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgsymbolnode.cxx b/svgio/source/svgreader/svgsymbolnode.cxx
index e799b2e..773b5cfd 100644
--- a/svgio/source/svgreader/svgsymbolnode.cxx
+++ b/svgio/source/svgreader/svgsymbolnode.cxx
@@ -58,7 +58,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgtextnode.cxx b/svgio/source/svgreader/svgtextnode.cxx
index e40a0af..c76754d 100644
--- a/svgio/source/svgreader/svgtextnode.cxx
+++ b/svgio/source/svgreader/svgtextnode.cxx
@@ -65,7 +65,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // read text position attributes
             maSvgTextPositions.parseTextPositionAttributes(rTokenName, aSVGToken, aContent);
diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx
index 7c0d874..fcc4cb3 100644
--- a/svgio/source/svgreader/svgtextpathnode.cxx
+++ b/svgio/source/svgreader/svgtextpathnode.cxx
@@ -299,7 +299,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx
index 20e8bd2..15eb5dc 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -167,7 +167,7 @@ namespace svgio
         static rtl::OUString aSVGStrText(rtl::OUString::createFromAscii("text"));
         static rtl::OUString aSVGStrBaselineShift(rtl::OUString::createFromAscii("baseline-shift"));
 
-        SVGToken StrToSVGToken(const rtl::OUString& rStr)
+        SVGToken StrToSVGToken(const rtl::OUString& rStr, bool bCaseIndependent)
         {
             typedef std::hash_map< rtl::OUString, SVGToken, rtl::OUStringHash > SVGTokenMapper;
             typedef std::pair< rtl::OUString, SVGToken > SVGTokenValueType;
@@ -315,6 +315,33 @@ namespace svgio
 
             if(aResult == aSVGTokenMapperList.end())
             {
+                if(bCaseIndependent)
+                {
+                    static SVGTokenMapper aCaseLindependentSVGTokenMapperList;
+
+                    if(aCaseLindependentSVGTokenMapperList.empty())
+                    {
+                        for(SVGTokenMapper::const_iterator aCurrent(aSVGTokenMapperList.begin()); aCurrent != aSVGTokenMapperList.end(); aCurrent++)
+                        {
+                            aCaseLindependentSVGTokenMapperList.insert(
+                                SVGTokenValueType(
+                                    aCurrent->first.toAsciiLowerCase(),
+                                    aCurrent->second));
+                        }
+                    }
+
+                    const SVGTokenMapper::const_iterator aResult2(aCaseLindependentSVGTokenMapperList.find(rStr.toAsciiLowerCase()));
+
+                    if(aResult2 == aCaseLindependentSVGTokenMapperList.end())
+                    {
+                        return SVGTokenUnknown;
+                    }
+                    else
+                    {
+                        return aResult2->second;
+                    }
+                }
+
                 return SVGTokenUnknown;
             }
             else
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index ed35eed..ee0da7f 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -646,7 +646,10 @@ namespace svgio
             }
         }
 
-        bool match_colorKeyword(basegfx::BColor& rColor, const rtl::OUString& rName)
+        bool match_colorKeyword(
+            basegfx::BColor& rColor,
+            const rtl::OUString& rName,
+            bool bCaseIndependent)
         {
             typedef std::hash_map< rtl::OUString, Color, rtl::OUStringHash > ColorTokenMapper;
             typedef std::pair< rtl::OUString, Color > ColorTokenValueType;
@@ -803,7 +806,13 @@ namespace svgio
                 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("yellowgreen"), Color(154, 205, 50)));
             }
 
-            const ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName));
+            ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName));
+
+            if(bCaseIndependent && aResult == aColorTokenMapperList.end())
+            {
+                // also try case independent match (e.g. for Css styles)
+                aResult = aColorTokenMapperList.find(rName.toAsciiLowerCase());
+            }
 
             if(aResult == aColorTokenMapperList.end())
             {
@@ -816,7 +825,10 @@ namespace svgio
             }
         }
 
-        bool read_color(const rtl::OUString& rCandidate, basegfx::BColor& rColor)
+        bool read_color(
+            const rtl::OUString& rCandidate,
+            basegfx::BColor& rColor,
+            bool bCaseIndependent)
         {
             const sal_Int32 nLen(rCandidate.getLength());
 
@@ -924,7 +936,7 @@ namespace svgio
                     else
                     {
                         // color keyword
-                        if(match_colorKeyword(rColor, rCandidate))
+                        if(match_colorKeyword(rColor, rCandidate, bCaseIndependent))
                         {
                             return true;
                         }
@@ -1209,7 +1221,11 @@ namespace svgio
             return false;
         }
 
-        bool readSvgPaint(const rtl::OUString& rCandidate, SvgPaint& rSvgPaint, rtl::OUString& rURL)
+        bool readSvgPaint(
+            const rtl::OUString& rCandidate,
+            SvgPaint& rSvgPaint,
+            rtl::OUString& rURL,
+            bool bCaseIndependent)
         {
             const sal_Int32 nLen(rCandidate.getLength());
 
@@ -1217,7 +1233,7 @@ namespace svgio
             {
                 basegfx::BColor aColor;
 
-                if(read_color(rCandidate, aColor))
+                if(read_color(rCandidate, aColor, bCaseIndependent))
                 {
                     rSvgPaint = SvgPaint(aColor, true, true);
                     return true;
@@ -1292,7 +1308,7 @@ namespace svgio
 
                     if(aTokenName.getLength())
                     {
-                        switch(StrToSVGToken(aTokenName.makeStringAndClear()))
+                        switch(StrToSVGToken(aTokenName.makeStringAndClear(), false))
                         {
                             case SVGTokenDefer:
                             {
diff --git a/svgio/source/svgreader/svgtrefnode.cxx b/svgio/source/svgreader/svgtrefnode.cxx
index c6f0746..f15ead8 100644
--- a/svgio/source/svgreader/svgtrefnode.cxx
+++ b/svgio/source/svgreader/svgtrefnode.cxx
@@ -55,7 +55,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)
diff --git a/svgio/source/svgreader/svgtspannode.cxx b/svgio/source/svgreader/svgtspannode.cxx
index 3f280df..920e947 100644
--- a/svgio/source/svgreader/svgtspannode.cxx
+++ b/svgio/source/svgreader/svgtspannode.cxx
@@ -57,7 +57,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // read text position attributes
             maSvgTextPositions.parseTextPositionAttributes(rTokenName, aSVGToken, aContent);
diff --git a/svgio/source/svgreader/svgusenode.cxx b/svgio/source/svgreader/svgusenode.cxx
index 123dffd..9c586ec 100644
--- a/svgio/source/svgreader/svgusenode.cxx
+++ b/svgio/source/svgreader/svgusenode.cxx
@@ -64,7 +64,7 @@ namespace svgio
             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
 
             // read style attributes
-            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
+            maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
 
             // parse own
             switch(aSVGToken)


More information about the Libreoffice-commits mailing list