summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-04-13 12:13:19 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-04-14 11:56:46 +0200
commit70684ab604c5fb32a16614c708f986671dd2da3c (patch)
tree50b68b1256983c0fffa7d5efdd275d09b8bcc8d8 /include
parent8b8a2844addbd262befb1a2d193dfb590dfa20be (diff)
MCGR: Adaptions to oox export
This is a 1st version and might need more fine-tuning, so it is still 'hidden' behind the MCGR_TEST env var being set (as the import is, too). Still, when used, it can now import a MCGR with transparence and export it again. I will now do extended testing/experimenting, fine-tuning where needed and prepare final change/drive forward. The current state in master should not be changed as long as the mentioned env var is not set, but this will need to be checked, too, due to changes to the export api in oox. Corrected an error in GetAlphaFromTransparenceGradient method(s), css::rendering::RGBColor is [0.0 .. 1.0] Corercted an error in WriteSolidFill where transparence gradient gets checked. This should really check if TrGr is used, but only checks for 'empty/unused' color instead (assuming COL_BLACK is 'unused'). All usages of GetAlphaFromTransparenceGradient should be checked and adapted. Change-Id: If59d7a06b9207e2efe9e71f3f8ddeca4476408f3 Change-Id: If97f8abdd0e1597aa1fd865b7e884e06a22b71f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150391 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include')
-rw-r--r--include/basegfx/utils/gradienttools.hxx49
-rw-r--r--include/oox/export/drawingml.hxx27
2 files changed, 70 insertions, 6 deletions
diff --git a/include/basegfx/utils/gradienttools.hxx b/include/basegfx/utils/gradienttools.hxx
index f438fdf3bd4a..4e78ad2ff960 100644
--- a/include/basegfx/utils/gradienttools.hxx
+++ b/include/basegfx/utils/gradienttools.hxx
@@ -30,6 +30,7 @@
#include <com/sun/star/awt/ColorStopSequence.hdl>
namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
+namespace com { namespace sun { namespace star { namespace awt { struct Gradient2; } } } }
namespace basegfx { class B2DRange; }
namespace basegfx
@@ -213,6 +214,48 @@ namespace basegfx
namespace utils
{
+ /* Tooling method to extract data from given awt::Gradient2
+ to ColorStops, doing some corrections, partitally based
+ on given SingleColor.
+ This will do quite some preparations for the gradient
+ as follows:
+ - It will check for single color (resetting rSingleColor when
+ this is the case) and return with empty ColorStops
+ - It will blend ColorStops to Intensity if StartIntensity/
+ EndIntensity != 100 is set in awt::Gradient2, so applying
+ that value(s) to the gadient directly
+ - It will adapt to Border if Border != 0 is set at the
+ given awt::Gradient2, so applying that value to the gadient
+ directly
+ */
+ BASEGFX_DLLPUBLIC void prepareColorStops(
+ const com::sun::star::awt::Gradient2& rGradient,
+ ColorStops& rColorStops,
+ BColor& rSingleColor);
+
+ /* Tooling method to synchronize the given ColorStops.
+ The intention is that a color GradientStops and an
+ alpha/transparence GradientStops gets synchronized
+ for export.
+ Fo the corrections the single values for color and
+ alpha may be used, e.g. when ColorStops is given
+ and not empty, but AlphaStops is empty, it will get
+ sycronized so that it will have the same number and
+ offsets in AlphaStops as in ColorStops, but with
+ the given SingleAlpha as value.
+ At return it guarantees that both have the same
+ number of entries with the same StopOffsets, so
+ that synchonized pair of ColorStops can e.g. be used
+ to export a Gradient with defined/adapted alpha
+ being 'coupled' indirectly using the
+ 'FillTransparenceGradient' method (at import time).
+ */
+ BASEGFX_DLLPUBLIC void synchronizeColorStops(
+ ColorStops& rColorStops,
+ ColorStops& rAlphaStops,
+ const BColor& rSingleColor,
+ const BColor& rSingleAlpha);
+
/* Tooling method to linearly blend the Colors contained in
a given ColorStop vector against a given Color using the
given intensity values.
@@ -244,6 +287,12 @@ namespace basegfx
/* Tooling method to convert UNO API data to ColorStops.
This will try to extract ColorStop data from the given
+ awt::Gradient2.
+ */
+ BASEGFX_DLLPUBLIC void fillColorStopsFromGradient2(ColorStops& rColorStops, const com::sun::star::awt::Gradient2& rGradient);
+
+ /* Tooling method to convert UNO API data to ColorStops.
+ This will try to extract ColorStop data from the given
Any, so if it's of type awt::Gradient2 that data will be
extracted, converted and copied into the given ColorStops.
*/
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 9179625bd6b7..bfab16f12aff 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -58,7 +58,7 @@ enum class SvxTimeFormat;
namespace com::sun::star {
namespace awt {
struct FontDescriptor;
- struct Gradient;
+ struct Gradient2;
}
namespace beans {
struct PropertyValue;
@@ -107,6 +107,11 @@ namespace core {
namespace drawingml {
+/// Tooling method to fill awt::Gradient2 from data contained in the given Any
+bool fillGradient2FromAny(
+ css::awt::Gradient2& rGradient,
+ const css::uno::Any& rVal);
+
class OOX_DLLPUBLIC URLTransformer
{
public:
@@ -198,7 +203,7 @@ protected:
const char* GetComponentDir() const;
const char* GetRelationCompPrefix() const;
- static bool EqualGradients( css::awt::Gradient aGradient1, css::awt::Gradient aGradient2 );
+ static bool EqualGradients( const css::awt::Gradient2& rGradient1, const css::awt::Gradient2& rGradient2 );
bool IsFontworkShape(const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
void WriteGlowEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
@@ -244,10 +249,20 @@ public:
void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
- void WriteGradientFill( css::awt::Gradient rGradient, css::awt::Gradient rTransparenceGradient,
- const css::uno::Reference<css::beans::XPropertySet>& rXPropSet = css::uno::Reference<css::beans::XPropertySet>());
-
- void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, css::awt::Gradient rGradient);
+ /* New API for WriteGradientFill:
+ If a awt::Gradient2 is given, it will be used. Else, the 'Fix' entry will be used for
+ Color or Transparency. That way, less Pseudo(Color|Transparency)Gradients have to be
+ created at caller side.
+ NOTE: Giving no Gradient at all (both nullptr) is an error.
+ */
+ void WriteGradientFill(
+ const css::awt::Gradient2* pColorGradient, sal_Int32 nFixColor,
+ const css::awt::Gradient2* pTransparenceGradient, sal_Int32 nFixTransparence);
+ void WriteGradientFill2(
+ const css::awt::Gradient2* pColorGradient, sal_Int32 nFixColor,
+ const css::awt::Gradient2* pTransparenceGradient, sal_Int32 nFixTransparence);
+
+ void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, const css::awt::Gradient2& rGradient);
void WriteBlipOrNormalFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
const OUString& rURLPropName, const css::awt::Size& rSize = {});