summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-03-29 11:04:27 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-04-02 13:19:27 +0200
commitce86e5b4a8d54eb55fdde7756ad6fde6e6967d55 (patch)
tree231633e0df006983a150dd6b4c5830c15107e9ab /basegfx
parent389f338da025aa7bc26556a7167cd272b64b77fd (diff)
MCGR: 1st additions to OOXML MCGR import
This change provides 1st changes to get Gradients with muti color stops imported from MSO in the oox import filter. It supports currently multiple ColorStops and transparency. Also 'border'(s) should work, but -remember- this is work in progress. Since it is work in progress it is currently and temporaily secured by ENV VAR "MCGR_TEST=0", so when not using this the master version will not be touched at all. The number defines various ColorStop tests, 0 for none, but some changes are active, e.g. MSO import. You may try 1 or 16 to see all your Gradients hard replaced by something using that feature. I will take care fo cleaning this up again when the feature progresses/gets complete. Change-Id: I92e10d8cd5150733741a6def20a542abf97bd903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149682 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/tools/gradienttools.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx
index a98eeddf641c..49cf831da262 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -264,6 +264,38 @@ namespace basegfx
namespace utils
{
+ /* Tooling method to check if a ColorStop vector is defined
+ by a single color. It returns true if this is the case.
+ If true is returned, rSingleColor contains that single
+ color for convenience.
+ NOTE: If no ColorStop is defined, a fallback to BColor-default
+ (which is black) and true will be returned
+ */
+ bool isSingleColor(const ColorStops& rColorStops, BColor& rSingleColor)
+ {
+ if (rColorStops.empty())
+ {
+ rSingleColor = BColor();
+ return true;
+ }
+
+ if (1 == rColorStops.size())
+ {
+ rSingleColor = rColorStops.front().getStopColor();
+ return true;
+ }
+
+ rSingleColor = rColorStops.front().getStopColor();
+
+ for (auto const& rCandidate : rColorStops)
+ {
+ if (rCandidate.getStopColor() != rSingleColor)
+ return false;
+ }
+
+ return true;
+ }
+
/* Tooling method to reverse ColorStops, including offsets.
When also mirroring offsets a valid sort keeps valid.
*/