summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-06-05 17:15:34 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-06-13 23:20:41 +0200
commit9b8c21acd31f08a0c3f8d88ddac57c80ef5997a1 (patch)
tree5361329018ac0b8573a858a6a28426f6f5684008 /include
parente691869486cd4ee4ee1dfb8f7a41440f7f6500fd (diff)
MCGR: tdf#155479 repair gradient SVG export for MCGR
Unfortunately SVG export is based on metafiles and thus there is (in principle) no way to get the BGradient/ColorStop/MCGR data transfered as needed. For that, using UNO API to read the model or using B2DPrimitives would help - as is better for the export respectively. Since there is not the time to re-design SVG export I added this 'compromize' as a fix. It gets the needed data transported over the metafile (that part is the compromize). It then exports the MCGR data to SVG (at least - as was already there - if it's a linear/axial gradient). This happens now with all Gradient Stops when there is a MCGR gradient. That part is/will hopefully be re-usable if SVG export gets redesigned. I also added a handling for StepCount feature, so when used (in LO, others do not have that) 'hard' color stops get generated to make the gradient look identical for SVG export. Had to make adding of that extra-information in metafiles dependent on exporting really to SVG. There are 51 cases which use 'MetaActionType::COMMENT' which would potentially have to be adapted. Also added code to solve the problem for TransparencePrimitive2D at VclMetafileProcessor2D::processTransparencePrimitive2D. This will now - also only for SVG export - directly create the needed MetaFloatTransparentAction and add additional MCGR information. This will be used on SVG export to write a 'Mask' as was done before. This is now capable of creating fill MCGR-Masks in the sense that any number of TransparencyStops will be supported. Change-Id: Ic6d022714eae96b8fbc09e60652851ac5799b757 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152623 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com> (cherry picked from commit a6e72e2b314e64f3199f3eaf1ecf78157446f6dd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152882 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'include')
-rw-r--r--include/basegfx/utils/bgradient.hxx17
-rw-r--r--include/svx/svdxcgv.hxx6
-rw-r--r--include/vcl/gdimtf.hxx7
-rw-r--r--include/vcl/metaact.hxx11
4 files changed, 38 insertions, 3 deletions
diff --git a/include/basegfx/utils/bgradient.hxx b/include/basegfx/utils/bgradient.hxx
index 1f42b23c6321..3e2acf9a4b67 100644
--- a/include/basegfx/utils/bgradient.hxx
+++ b/include/basegfx/utils/bgradient.hxx
@@ -96,6 +96,8 @@ public:
return getStopOffset() == rCandidate.getStopOffset()
&& getStopColor() == rCandidate.getStopColor();
}
+
+ bool operator!=(const BColorStop& rCandidate) const { return !(*this == rCandidate); }
};
/* MCGR: Provide ColorStops definition to the FillGradientAttribute
@@ -276,6 +278,13 @@ public:
// returns true if the color stops are symmetrical in color and offset, otherwise false.
bool isSymmetrical() const;
+ // assume that the color stops represent an Axial gradient
+ // and replace with gradient stops to represent the same
+ // gradient as linear gradient
+ void doApplyAxial();
+
+ // apply Steps as 'hard' color stops
+ void doApplySteps(sal_uInt16 nStepCount);
};
class BASEGFX_DLLPUBLIC BGradient final
@@ -337,7 +346,11 @@ public:
/// Tooling method to fill awt::Gradient2 from data contained in the given basegfx::BGradient
css::awt::Gradient2 getAsGradient2() const;
- /// Tooling to handle border correction/integration and StartStopIntensity
+ // Tooling to handle
+ // - border correction/integration
+ // - apply StartStopIntensity to color stops
+ // - convert type from 'axial' to linear
+ // - apply Steps as 'hard' color stops
void tryToRecreateBorder(basegfx::BColorStops* pAssociatedTransparencyStops = nullptr);
void tryToApplyBorder();
void tryToApplyStartEndIntensity();
@@ -345,6 +358,8 @@ public:
// If a linear gradient is symmetrical it is converted to an axial gradient.
// Does nothing in other cases and for other gradient types.
void tryToConvertToAxial();
+ void tryToApplyAxial();
+ void tryToApplySteps();
};
}
diff --git a/include/svx/svdxcgv.hxx b/include/svx/svdxcgv.hxx
index 11e16b2ebcdb..2d7f04455913 100644
--- a/include/svx/svdxcgv.hxx
+++ b/include/svx/svdxcgv.hxx
@@ -79,10 +79,14 @@ public:
The object (can also be a group object) to retrieve a Graphic
for.
+ @param bSVG
+ tdf#155479 need to know it's SVG export, default is false
+
+
@return a graphical representation of the given object, as it
appears on screen (e.g. with rotation, if any, applied).
*/
- static Graphic GetObjGraphic(const SdrObject& rSdrObject);
+ static Graphic GetObjGraphic(const SdrObject& rSdrObject, bool bSVG = false);
// The new Draw objects are marked for all paste methods.
// If bAddMark is true, the new Draw objects are added to an existing
diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx
index f8637675482d..d62cd899623b 100644
--- a/include/vcl/gdimtf.hxx
+++ b/include/vcl/gdimtf.hxx
@@ -67,6 +67,9 @@ private:
bool m_bRecord;
bool m_bUseCanvas;
+ // tdf#155479 need to know if it's SVG export
+ bool m_bSVG;
+
SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
@@ -186,6 +189,10 @@ public:
void UseCanvas( bool _bUseCanvas );
bool GetUseCanvas() const { return m_bUseCanvas; }
+ // tdf#155479
+ bool getSVG() const { return m_bSVG; }
+ void setSVG(bool bNew) { m_bSVG = bNew; }
+
/// Dumps the meta actions as XML in metafile.xml.
void dumpAsXml(const char* pFileName = nullptr) const;
};
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 06357c74a7eb..3f2e85dff6b4 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -43,6 +43,7 @@
#include <vcl/region.hxx>
#include <vcl/rendercontext/RasterOp.hxx>
#include <vcl/wall.hxx>
+#include <basegfx/utils/bgradient.hxx>
#include <memory>
@@ -1569,7 +1570,7 @@ public:
bool IsTransparent() const override { return true; }
};
-class SAL_DLLPUBLIC_RTTI MetaFloatTransparentAction final : public MetaAction
+class VCL_DLLPUBLIC MetaFloatTransparentAction final : public MetaAction
{
private:
@@ -1578,6 +1579,9 @@ private:
Size maSize;
Gradient maGradient;
+ // tdf#155479 allow holding MCGR infos
+ std::optional<basegfx::BColorStops> maSVGTransparencyColorStops;
+
public:
MetaFloatTransparentAction();
MetaFloatTransparentAction(MetaFloatTransparentAction const &) = default;
@@ -1605,6 +1609,11 @@ public:
void SetSize(const Size& rSize) { maSize = rSize; }
void SetGradient(const Gradient& rGradient) { maGradient = rGradient; }
bool IsTransparent() const override { return true; }
+
+ // tdf#155479 allow holding MCGR infos
+ const basegfx::BColorStops* getSVGTransparencyColorStops() const
+ { return !maSVGTransparencyColorStops ? nullptr : &(*maSVGTransparencyColorStops); }
+ void addSVGTransparencyColorStops(const basegfx::BColorStops& rSVGTransparencyColorStops);
};
class VCL_DLLPUBLIC MetaEPSAction final : public MetaAction