summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/attribute/fillgradientattribute.cxx33
-rw-r--r--drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx46
-rw-r--r--drawinglayer/source/primitive2d/Tools.cxx2
3 files changed, 81 insertions, 0 deletions
diff --git a/drawinglayer/source/attribute/fillgradientattribute.cxx b/drawinglayer/source/attribute/fillgradientattribute.cxx
index e02fdd4a5dad..54f455f647ef 100644
--- a/drawinglayer/source/attribute/fillgradientattribute.cxx
+++ b/drawinglayer/source/attribute/fillgradientattribute.cxx
@@ -223,6 +223,39 @@ namespace drawinglayer::attribute
return mpFillGradientAttribute->getSteps();
}
+ bool FillGradientAttribute::sameDefinitionThanAlpha(const FillGradientAttribute& rAlpha) const
+ {
+ // entries that are used by all gradient styles
+ if (getStyle() != rAlpha.getStyle()
+ || getBorder() != rAlpha.getBorder()
+ || getSteps() != rAlpha.getSteps())
+ {
+ return false;
+ }
+
+ // check for offsets if not ignored
+ const bool bIgnoreOffset(css::awt::GradientStyle_LINEAR == getStyle() || css::awt::GradientStyle_AXIAL == getStyle());
+ if (!bIgnoreOffset && (getOffsetX() != rAlpha.getOffsetX() || getOffsetY() != rAlpha.getOffsetY()))
+ {
+ return false;
+ }
+
+ // check for angle if not ignored
+ const bool bIgnoreAngle(css::awt::GradientStyle_RADIAL == getStyle());
+ if (!bIgnoreAngle && getAngle() != rAlpha.getAngle())
+ {
+ return false;
+ }
+
+ // check for same count & offsets in the gradients (all except 'colors')
+ if (!getColorStops().sameSizeAndDistances(rAlpha.getColorStops()))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
} // end of namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
index 4fe3321e62f8..2e6b83ab526f 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
@@ -22,6 +22,8 @@
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <rtl/ref.hxx>
#include <utility>
@@ -84,6 +86,50 @@ sal_uInt32 PolyPolygonGradientPrimitive2D::getPrimitive2DID() const
return PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D;
}
+Primitive2DReference PolyPolygonRGBAGradientPrimitive2D::create2DDecomposition(
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ Primitive2DContainer aContent{ new PolyPolygonGradientPrimitive2D(
+ getB2DPolyPolygon(), getDefinitionRange(), getFillGradient()) };
+
+ Primitive2DContainer aAlpha{ new FillGradientPrimitive2D(
+ basegfx::utils::getRange(getB2DPolyPolygon()), getDefinitionRange(),
+ getFillGradientAlpha()) };
+
+ return Primitive2DReference{ new TransparencePrimitive2D(std::move(aContent),
+ std::move(aAlpha)) };
+}
+
+PolyPolygonRGBAGradientPrimitive2D::PolyPolygonRGBAGradientPrimitive2D(
+ basegfx::B2DPolyPolygon aPolyPolygon, const basegfx::B2DRange& rDefinitionRange,
+ attribute::FillGradientAttribute aFillGradient,
+ attribute::FillGradientAttribute aFillGradientAlpha)
+ : PolyPolygonGradientPrimitive2D(aPolyPolygon, rDefinitionRange, aFillGradient)
+ , maFillGradientAlpha(aFillGradientAlpha)
+{
+ // assert when the definition is not allowed, it HAS to fulfil the
+ // requested preconditions
+ assert(aFillGradient.sameDefinitionThanAlpha(aFillGradientAlpha));
+}
+
+bool PolyPolygonRGBAGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ if (PolyPolygonGradientPrimitive2D::operator==(rPrimitive))
+ {
+ const PolyPolygonRGBAGradientPrimitive2D& rCompare
+ = static_cast<const PolyPolygonRGBAGradientPrimitive2D&>(rPrimitive);
+
+ return getFillGradientAlpha() == rCompare.getFillGradientAlpha();
+ }
+
+ return false;
+}
+
+sal_uInt32 PolyPolygonRGBAGradientPrimitive2D::getPrimitive2DID() const
+{
+ return PRIMITIVE2D_ID_POLYPOLYGONRGBAGRADIENTPRIMITIVE2D;
+}
+
} // end drawinglayer::primitive2d namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/primitive2d/Tools.cxx b/drawinglayer/source/primitive2d/Tools.cxx
index bd74a4b5cd00..b13505bc3fd6 100644
--- a/drawinglayer/source/primitive2d/Tools.cxx
+++ b/drawinglayer/source/primitive2d/Tools.cxx
@@ -233,6 +233,8 @@ OUString idToString(sal_uInt32 nId)
return u"SINGLELINEPRIMITIVE"_ustr;
case PRIMITIVE2D_ID_EXCLUSIVEEDITVIEWPRIMITIVE2D:
return u"EXCLUSIVEEDITVIEWPRIMITIVE2D"_ustr;
+ case PRIMITIVE2D_ID_POLYPOLYGONRGBAGRADIENTPRIMITIVE2D:
+ return u"POLYPOLYGONRGBAGRADIENTPRIMITIVE2D"_ustr;
default:
return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF);
}