diff --git a/Common/3dParty/html/css/src/StyleProperties.cpp b/Common/3dParty/html/css/src/StyleProperties.cpp
index c380779c33..0a1a482cce 100644
--- a/Common/3dParty/html/css/src/StyleProperties.cpp
+++ b/Common/3dParty/html/css/src/StyleProperties.cpp
@@ -254,8 +254,9 @@ namespace NSCSS
bool CDigit::operator==(const CDigit &oDigit) const
{
- return (std::abs(oDigit.m_oValue - m_oValue) <= DBL_EPSILON) &&
- m_enUnitMeasure == oDigit.m_enUnitMeasure;
+ return (Empty() && oDigit.Empty()) ||
+ ((std::abs(oDigit.m_oValue - m_oValue) <= DBL_EPSILON) &&
+ m_enUnitMeasure == oDigit.m_enUnitMeasure);
}
bool CDigit::operator!=(const double &oValue) const
diff --git a/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.cpp b/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.cpp
index 0e3aa5335b..d20b26f5cc 100644
--- a/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.cpp
+++ b/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.cpp
@@ -52,37 +52,21 @@ namespace SVG
bool CGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
{
- if (NULL == pRenderer)
+ if (NULL == pRenderer || m_arObjects.empty())
return false;
- if (m_arObjects.empty())
- {
- if (m_wsXlinkHref.empty() || NULL == pFile)
- return false;
+ std::vector arColors;
+ std::vector arPositions;
- CGradient *pGradiend = dynamic_cast(pFile->GetMarkedObject(m_wsXlinkHref));
-
- if (NULL == pGradiend)
- return false;
-
- pGradiend->Apply(pRenderer, pFile, oObjectBounds);
- }
- else
+ for (const CStopElement* pStopElement : m_arObjects)
{
- std::vector arColors;
- std::vector arPositions;
-
- for (const CStopElement* pStopElement : m_arObjects)
- {
- arColors.push_back(((unsigned int)(pStopElement->GetColor().ToInt() | ((unsigned char)(255. * pStopElement->GetColor().GetOpacity()) << 24))));
- arPositions.push_back(pStopElement->GetOffset().ToDouble());
- }
-
- pRenderer->put_BrushGradientColors(arColors.data(), arPositions.data(), arColors.size());
+ arColors.push_back(((unsigned int)(pStopElement->GetColor().ToInt() | ((unsigned char)(255. * pStopElement->GetColor().GetOpacity()) << 24))));
+ arPositions.push_back(pStopElement->GetOffset().ToDouble());
}
-
+
+ pRenderer->put_BrushGradientColors(arColors.data(), arPositions.data(), arColors.size());
pRenderer->put_BrushTransform(m_oTransform.GetMatrix().GetFinalValue());
-
+
return true;
}
@@ -108,6 +92,31 @@ namespace SVG
pRenderer->BrushBounds(oNewBounds.m_dLeft, oNewBounds.m_dTop, oNewBounds.m_dRight - oNewBounds.m_dLeft, oNewBounds.m_dBottom - oNewBounds.m_dTop);
}
+ CGradient *CGradient::GetRefGradient(const CSvgFile *pFile) const
+ {
+ if (m_wsXlinkHref.empty() || NULL == pFile)
+ return NULL;
+
+ CGradient *pGradiend = dynamic_cast(pFile->GetMarkedObject(m_wsXlinkHref));
+
+ if (NULL == pGradiend)
+ return NULL;
+
+ CGradient *pRefGradient = pGradiend->GetRefGradient(pFile);
+
+ return (NULL != pRefGradient) ? pRefGradient : pGradiend;
+ }
+
+ bool CGradient::ApplyRefGradient(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) const
+ {
+ CGradient *pRefGradient = GetRefGradient(pFile);
+
+ if (NULL == pRefGradient)
+ return false;
+
+ return pRefGradient->Apply(pRenderer, pFile, oObjectBounds);
+ }
+
CLinearGradient::CLinearGradient(XmlUtils::CXmlNode& oNode)
: CGradient(oNode)
{
@@ -120,10 +129,8 @@ namespace SVG
bool CLinearGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
{
if (!CGradient::Apply(pRenderer, pFile, oObjectBounds))
- return false;
+ return ApplyRefGradient(pRenderer, pFile, oObjectBounds);
- pRenderer->put_BrushType(c_BrushTypePathGradient1);
-
if (m_oX1 == m_oX2 && m_oY1 == m_oY2)
{
pRenderer->put_BrushType(c_BrushTypeSolid);
@@ -132,6 +139,8 @@ namespace SVG
return true;
}
+ pRenderer->put_BrushType(c_BrushTypePathGradient1);
+
double dAngle = 0.;
TBounds oNewBounds(oObjectBounds);
@@ -171,8 +180,8 @@ namespace SVG
bool CRadialGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
{
if (!CGradient::Apply(pRenderer, pFile, oObjectBounds) || m_oR.Zero())
- return false;
-
+ return ApplyRefGradient(pRenderer, pFile, oObjectBounds);
+
double dCX = (oObjectBounds.m_dRight + oObjectBounds.m_dLeft) / 2.;
double dCY = (oObjectBounds.m_dBottom + oObjectBounds.m_dTop) / 2.;
double dR = oObjectBounds.m_dBottom - oObjectBounds.m_dTop;
diff --git a/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.h b/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.h
index 0c73ada939..c5b0b6f443 100644
--- a/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.h
+++ b/DesktopEditor/raster/Metafile/svg/SvgObjects/CGradient.h
@@ -47,6 +47,9 @@ namespace SVG
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
void ApplyTransform(IRenderer *pRenderer, const TBounds& oBounds, double& dAngle) const;
private:
+ CGradient* GetRefGradient(const CSvgFile *pFile) const;
+ bool ApplyRefGradient(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) const;
+
std::wstring m_wsXlinkHref;
GradientUnits m_enGradientUnits;
SpreadMethod m_enSpreadMethod;