diff options
Diffstat (limited to 'svgio/source/svgreader/svgtools.cxx')
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index ff74d63061aa..a4e4233a805d 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -814,7 +814,7 @@ namespace svgio } } - bool read_color(const OUString& rCandidate, basegfx::BColor& rColor, bool bCaseIndependent) + bool read_color(const OUString& rCandidate, basegfx::BColor& rColor, bool bCaseIndependent, SvgNumber& rOpacity) { const sal_Int32 nLen(rCandidate.getLength()); @@ -866,8 +866,17 @@ namespace svgio if(rCandidate.matchIgnoreAsciiCase(aStrRgb, 0)) { - // rgb definition + // rgb/rgba definition sal_Int32 nPos(strlen(aStrRgb)); + bool bIsRGBA = false; + + if('a' == rCandidate[nPos]) + { + //Delete the 'a' from 'rbga' + skip_char(rCandidate, 'a', nPos, nPos + 1); + bIsRGBA = true; + } + skip_char(rCandidate, ' ', '(', nPos, nLen); double fR(0.0); @@ -901,17 +910,39 @@ namespace svgio if(readNumber(rCandidate, nPos, fB, nLen)) { - const double fFac(bIsPercent ? 0.01 : fFactor); - - rColor.setRed(fR * fFac); - rColor.setGreen(fG * fFac); - rColor.setBlue(fB * fFac); + double fA(1.0); if(bIsPercent) { skip_char(rCandidate, '%', nPos, nLen); } + skip_char(rCandidate, ' ', ',', nPos, nLen); + + if(readNumber(rCandidate, nPos, fA, nLen)) + { + if(bIsRGBA) + { + const double fFac(bIsPercent ? 0.01 : 1); + rOpacity = SvgNumber(fA * fFac); + + if(bIsPercent) + { + skip_char(rCandidate, '%', nPos, nLen); + } + } + else + { + return false; + } + } + + const double fFac(bIsPercent ? 0.01 : fFactor); + + rColor.setRed(fR * fFac); + rColor.setGreen(fG * fFac); + rColor.setBlue(fB * fFac); + skip_char(rCandidate, ' ', ')', nPos, nLen); return true; } @@ -1207,13 +1238,14 @@ namespace svgio return false; } - bool readSvgPaint(const OUString& rCandidate, SvgPaint& rSvgPaint, OUString& rURL, bool bCaseIndependent) + bool readSvgPaint(const OUString& rCandidate, SvgPaint& rSvgPaint, + OUString& rURL, bool bCaseIndependent, SvgNumber& rOpacity) { if( !rCandidate.isEmpty() ) { basegfx::BColor aColor; - if(read_color(rCandidate, aColor, bCaseIndependent)) + if(read_color(rCandidate, aColor, bCaseIndependent, rOpacity)) { rSvgPaint = SvgPaint(aColor, true, true); return true; |