You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2011/12/08 12:27:31 UTC
svn commit: r1211840 - in
/incubator/ooo/branches/alg/svgreplacement/main/svgio: inc/svgio/svgreader/
source/svgreader/
Author: alg
Date: Thu Dec 8 11:27:30 2011
New Revision: 1211840
URL: http://svn.apache.org/viewvc?rev=1211840&view=rev
Log:
svg: Added support for 'color' Svg attribute; corrected an erro rin ColorStop percent handling
Modified:
incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpaint.hxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx
incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpaint.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpaint.hxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpaint.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgpaint.hxx Thu Dec 8 11:27:30 2011
@@ -39,18 +39,21 @@ namespace svgio
/// bitfield
bool mbSet : 1;
bool mbOn : 1;
+ bool mbCurrent : 1;
public:
- SvgPaint(const basegfx::BColor& rColor = basegfx::BColor(0.0, 0.0, 0.0), bool bSet = false, bool bOn = false)
+ SvgPaint(const basegfx::BColor& rColor = basegfx::BColor(0.0, 0.0, 0.0), bool bSet = false, bool bOn = false, bool bCurrent = false)
: maColor(rColor),
mbSet(bSet),
- mbOn(bOn)
+ mbOn(bOn),
+ mbCurrent(bCurrent)
{
}
const basegfx::BColor& getBColor() const { return maColor; }
bool isSet() const { return mbSet; }
bool isOn() const { return mbOn; }
+ bool isCurrent() const { return mbCurrent; }
};
} // end of namespace svgreader
} // end of namespace svgio
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx Thu Dec 8 11:27:30 2011
@@ -164,6 +164,7 @@ namespace svgio
TextAlign maTextAlign;
TextDecoration maTextDecoration;
TextAnchor maTextAnchor;
+ SvgPaint maColor;
/// bitfield
bool maFillRule : 1; // true: NonZero, false: EvenOdd
@@ -216,7 +217,7 @@ namespace svgio
void setStroke(const SvgPaint& rStroke) { maStroke = rStroke; }
/// stop color content
- const basegfx::BColor& getStopColor() const { return maStopColor.getBColor(); }
+ const basegfx::BColor& getStopColor() const;
void setStopColor(const SvgPaint& rStopColor) { maStopColor = rStopColor; }
/// stroke-width content
@@ -304,6 +305,10 @@ namespace svgio
const TextAnchor getTextAnchor() const;
void setTextAnchor(const TextAnchor aTextAnchor = TextAnchor_notset) { maTextAnchor = aTextAnchor; }
+ /// Color content
+ const basegfx::BColor* getColor() const;
+ void setColor(const SvgPaint& rColor) { maColor = rColor; }
+
};
} // end of namespace svgreader
} // end of namespace svgio
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/inc/svgio/svgreader/svgtoken.hxx Thu Dec 8 11:27:30 2011
@@ -83,6 +83,7 @@ namespace svgio
SVGTokenClass,
SVGTokenTextAnchor,
SVGTokenXmlSpace,
+ SVGTokenColor,
// AspectRatio and params
SVGTokenPreserveAspectRatio,
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svggradientnode.cxx Thu Dec 8 11:27:30 2011
@@ -273,7 +273,18 @@ namespace svgio
if(pStyle)
{
- double fOffset(pCandidate->getOffset().solve(*this));
+ const SvgNumber aOffset(pCandidate->getOffset());
+ double fOffset(0.0);
+
+ if(Unit_percent == aOffset.getUnit())
+ {
+ // percent is not relative to distances in ColorStop context, solve locally
+ fOffset = aOffset.getNumber() * 0.01;
+ }
+ else
+ {
+ fOffset = aOffset.solve(*this);
+ }
if(fOffset < 0.0)
{
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgstyleattributes.cxx Thu Dec 8 11:27:30 2011
@@ -665,6 +665,7 @@ namespace svgio
maTextAlign(TextAlign_notset),
maTextDecoration(TextDecoration_notset),
maTextAnchor(TextAnchor_notset),
+ maColor(),
maFillRule(true),
maFillRuleSet(false)
@@ -683,6 +684,7 @@ namespace svgio
{
SvgPaint aSvgPaint;
rtl::OUString aURL;
+ bool bUseCurrent(false);
if(readSvgPaint(aContent, aSvgPaint, aURL))
{
@@ -1190,6 +1192,17 @@ namespace svgio
}
break;
}
+ case SVGTokenColor:
+ {
+ SvgPaint aSvgPaint;
+ rtl::OUString aURL;
+
+ if(readSvgPaint(aContent, aSvgPaint, aURL))
+ {
+ setColor(aSvgPaint);
+ }
+ break;
+ }
}
}
@@ -1197,7 +1210,11 @@ namespace svgio
{
if(maFill.isSet())
{
- if(maFill.isOn())
+ if(maFill.isCurrent())
+ {
+ return getColor();
+ }
+ else if(maFill.isOn())
{
return &maFill.getBColor();
}
@@ -1219,7 +1236,11 @@ namespace svgio
{
if(maStroke.isSet())
{
- if(maStroke.isOn())
+ if(maStroke.isCurrent())
+ {
+ return getColor();
+ }
+ else if(maStroke.isOn())
{
return &maStroke.getBColor();
}
@@ -1237,6 +1258,18 @@ namespace svgio
return 0;
}
+ const basegfx::BColor& SvgStyleAttributes::getStopColor() const
+ {
+ if(maStopColor.isCurrent())
+ {
+ return *getColor();
+ }
+ else
+ {
+ return maStopColor.getBColor();
+ }
+ }
+
const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeFill() const
{
if(mpSvgGradientNodeFill)
@@ -1648,6 +1681,33 @@ namespace svgio
return TextAnchor_start;
}
+ const basegfx::BColor* SvgStyleAttributes::getColor() const
+ {
+ if(maColor.isSet())
+ {
+ if(maColor.isCurrent())
+ {
+ OSL_ENSURE(false, "Svg error: current color uses current color (!)");
+ return 0;
+ }
+ else if(maColor.isOn())
+ {
+ return &maColor.getBColor();
+ }
+ }
+ else
+ {
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+ if(pSvgStyleAttributes)
+ {
+ return pSvgStyleAttributes->getColor();
+ }
+ }
+
+ return 0;
+ }
+
} // end of namespace svgreader
} // end of namespace svgio
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtoken.cxx Thu Dec 8 11:27:30 2011
@@ -74,6 +74,7 @@ namespace svgio
static rtl::OUString aSVGStrClass(rtl::OUString::createFromAscii("class"));
static rtl::OUString aSVGStrTextAnchor(rtl::OUString::createFromAscii("text-anchor"));
static rtl::OUString aSVGStrXmlSpace(rtl::OUString::createFromAscii("xml:space"));
+ static rtl::OUString aSVGStrColor(rtl::OUString::createFromAscii("color"));
static rtl::OUString aSVGStrPreserveAspectRatio(rtl::OUString::createFromAscii("preserveAspectRatio"));
static rtl::OUString aSVGStrDefer(rtl::OUString::createFromAscii("defer"));
@@ -190,6 +191,7 @@ namespace svgio
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrClass, SVGTokenClass));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrTextAnchor, SVGTokenTextAnchor));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrXmlSpace, SVGTokenXmlSpace));
+ aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrColor, SVGTokenColor));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrPreserveAspectRatio, SVGTokenPreserveAspectRatio));
aSVGTokenMapperList.insert(SVGTokenValueType(aSVGStrDefer, SVGTokenDefer));
Modified: incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx?rev=1211840&r1=1211839&r2=1211840&view=diff
==============================================================================
--- incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx (original)
+++ incubator/ooo/branches/alg/svgreplacement/main/svgio/source/svgreader/svgtools.cxx Thu Dec 8 11:27:30 2011
@@ -1155,10 +1155,11 @@ namespace svgio
{
static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
static rtl::OUString aStrUrl(rtl::OUString::createFromAscii("url"));
+ static rtl::OUString aStrCurrentColor(rtl::OUString::createFromAscii("currentColor"));
if(rCandidate.match(aStrNone, 0))
{
- rSvgPaint = SvgPaint(aColor, true, false);
+ rSvgPaint = SvgPaint(aColor, true, false, false);
return true;
}
else if(rCandidate.match(aStrUrl, 0))
@@ -1173,6 +1174,11 @@ namespace svgio
rURL = aTokenValue.makeStringAndClear();
return false;
}
+ else if(rCandidate.match(aStrCurrentColor, 0))
+ {
+ rSvgPaint = SvgPaint(aColor, true, true, true);
+ return true;
+ }
}
}