tdf#129459 drawinglayer: fill shapes with solid color brush

EMF+ shapes were not filling when the brush style is a solid color. This
patch fixes this issue.

Change-Id: I6a2b12e514af9a85f50198dceee642fac8df2f1b
Reviewed-on: https://gerrit.libreoffice.org/85343
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
(cherry picked from commit e356b371373ed6d047efac9913bc69cb2bfa0105)
Reviewed-on: https://gerrit.libreoffice.org/85363
Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index 4d7ec51..69f9e33 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -573,6 +573,33 @@ namespace emfplushelper
        }
    }

    void EmfPlusHelperData::EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon& polygon, Color const& color)
    {
        if (color.GetTransparency() < 255)
        {
            if (color.GetTransparency() == 0)
            {
                // not transparent
                mrTargetHolders.Current().append(
                            std::make_unique<drawinglayer::primitive2d::PolyPolygonColorPrimitive2D>(
                                polygon,
                                color.getBColor()));
            }
            else
            {
                const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
                            new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
                                polygon,
                                color.getBColor()));

                mrTargetHolders.Current().append(
                            std::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>(
                                drawinglayer::primitive2d::Primitive2DContainer { aPrimitive },
                                color.GetTransparency() / 255.0));
            }
        }
    }

    void EmfPlusHelperData::EMFPPlusFillPolygon(const ::basegfx::B2DPolyPolygon& polygon, const bool isColor, const sal_uInt32 brushIndexOrColor)
    {
        if (!polygon.count())
@@ -585,29 +612,7 @@ namespace emfplushelper
            // EMF Alpha (1 byte): An 8-bit unsigned integer that specifies the transparency of the background,
            // ranging from 0 for completely transparent to 0xFF for completely opaque.
            const Color color(0xff - (brushIndexOrColor >> 24), (brushIndexOrColor >> 16) & 0xff, (brushIndexOrColor >> 8) & 0xff, brushIndexOrColor & 0xff);
            if (color.GetTransparency() < 255)
            {
                if (color.GetTransparency() == 0)
                {
                    // not transparent
                    mrTargetHolders.Current().append(
                                std::make_unique<drawinglayer::primitive2d::PolyPolygonColorPrimitive2D>(
                                    polygon,
                                    color.getBColor()));
                }
                else
                {
                    const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
                                new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
                                    polygon,
                                    color.getBColor()));

                    mrTargetHolders.Current().append(
                                std::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>(
                                    drawinglayer::primitive2d::Primitive2DContainer { aPrimitive },
                                    color.GetTransparency() / 255.0));
                }
            }
            EMFPPlusFillPolygonSolidColor(polygon, color);

            mrPropertyHolders.Current().setFillColor(color.getBColor());
            mrPropertyHolders.Current().setFillColorActive(true);
@@ -625,7 +630,12 @@ namespace emfplushelper
            mrPropertyHolders.Current().setFillColorActive(false);
            mrPropertyHolders.Current().setLineColorActive(false);

            if (brush->type == BrushTypeHatchFill)
            if (brush->type == BrushTypeSolidColor)
            {
                Color fillColor = brush->solidColor;
                EMFPPlusFillPolygonSolidColor(polygon, fillColor);
            }
            else if (brush->type == BrushTypeHatchFill)
            {
                // EMF+ like hatching is currently not supported. These are just color blends which serve as an approximation for some of them
                // for the others the hatch "background" color (secondColor in brush) is used.
diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx
index 98a6dea..53047b7 100644
--- a/drawinglayer/source/tools/emfphelperdata.hxx
+++ b/drawinglayer/source/tools/emfphelperdata.hxx
@@ -185,6 +185,7 @@ namespace emfplushelper
        // primitive creators
        void EMFPPlusDrawPolygon(const ::basegfx::B2DPolyPolygon& polygon, sal_uInt32 penIndex);
        void EMFPPlusFillPolygon(const ::basegfx::B2DPolyPolygon& polygon, const bool isColor, const sal_uInt32 brushIndexOrColor);
        void EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon& polygon, Color const& color);

        // helper functions
        Color EMFPGetBrushColorOrARGBColor(const sal_uInt16 flags, const sal_uInt32 brushIndexOrColor) const;