summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-08-09 13:27:49 +0200
committerTomaž Vajngerl <quikee@gmail.com>2023-08-21 09:27:12 +0200
commit242bb3fdda5be165bd00701518df47cc1276438f (patch)
treebc61d6d7fa1b3ee628bfe2ff875c03b89728f59f /svx
parent84b12cd3ea96ee9b02365b5239f391af242f7303 (diff)
move BGradient to awt::Gradient2 UNO conversion into docmodel
This is needed because the module dependencies are an issues if the conversion is done in basegfx. The bigger issue will come when the ComplexColor conversion will be done as basegfx can't depend on docmodel because of circular dependencies. The BGradient is also more suitable for docmodel anyway as the previously it was part of the model and is not a basic (gfx) type - however this doesn't move the whole BGradient into docmodel yet. Change-Id: Id91ce52232f89f00e09b451c13da36e2854ae14b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155674 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx24
-rw-r--r--svx/source/xoutdev/xattr.cxx17
2 files changed, 12 insertions, 29 deletions
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx
index 4d47a1290281..ed3bf9d0a697 100644
--- a/svx/source/unodraw/XPropertyTable.cxx
+++ b/svx/source/unodraw/XPropertyTable.cxx
@@ -37,6 +37,7 @@
#include <svx/unoapi.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <docmodel/uno/UnoGradientTools.hxx>
using namespace com::sun::star;
using namespace ::cppu;
@@ -533,26 +534,9 @@ uno::Reference< container::XNameContainer > SvxUnoXGradientTable_createInstance(
uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const noexcept
{
const basegfx::BGradient& aBGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient();
- awt::Gradient2 aGradient;
- assert(aGradient.ColorStops.get() && "cid#1524745 aGradient.ColorStops._pSequence won't be null here");
-
- // standard values
- aGradient.Style = aBGradient.GetGradientStyle();
- aGradient.Angle = static_cast<short>(aBGradient.GetAngle());
- aGradient.Border = aBGradient.GetBorder();
- aGradient.XOffset = aBGradient.GetXOffset();
- aGradient.YOffset = aBGradient.GetYOffset();
- aGradient.StartIntensity = aBGradient.GetStartIntens();
- aGradient.EndIntensity = aBGradient.GetEndIntens();
- aGradient.StepCount = aBGradient.GetSteps();
- // for compatibility, still set StartColor/EndColor
- const basegfx::BColorStops& rBColorStops(aBGradient.GetColorStops());
- aGradient.StartColor = static_cast<sal_Int32>(Color(rBColorStops.front().getStopColor()));
- aGradient.EndColor = static_cast<sal_Int32>(Color(rBColorStops.back().getStopColor()));
-
- // fill ColorStops to extended Gradient2
- aGradient.ColorStops = rBColorStops.getAsColorStopSequence();
+ awt::Gradient2 aGradient = model::gradient::createUnoGradient2(aBGradient);
+ assert(aGradient.ColorStops.get() && "cid#1524745 aGradient.ColorStops._pSequence won't be null here");
return uno::Any(aGradient);
}
@@ -562,7 +546,7 @@ std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString
if (!rAny.has<css::awt::Gradient>() || !rAny.has<css::awt::Gradient2>())
return std::unique_ptr<XPropertyEntry>();
- const basegfx::BGradient aBGradient(rAny);
+ const basegfx::BGradient aBGradient = model::gradient::getFromAny(rAny);
return std::make_unique<XGradientEntry>(aBGradient, rName);
}
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index a2f34c229f4e..abf72bd6d6d4 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -36,6 +36,7 @@
#include <o3tl/any.hxx>
#include <svl/itempool.hxx>
#include <editeng/memberids.h>
+#include <docmodel/uno/UnoGradientTools.hxx>
#include <docmodel/uno/UnoComplexColor.hxx>
#include <docmodel/color/ComplexColorJSON.hxx>
#include <tools/mapunit.hxx>
@@ -2252,7 +2253,7 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c
case 0:
{
// fill values
- const css::awt::Gradient2 aGradient2(GetGradientValue().getAsGradient2());
+ const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
// create sequence
uno::Sequence< beans::PropertyValue > aPropSeq{
@@ -2266,7 +2267,7 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c
case MID_FILLGRADIENT:
{
// fill values
- const css::awt::Gradient2 aGradient2(GetGradientValue().getAsGradient2());
+ const css::awt::Gradient2 aGradient2 = model::gradient::createUnoGradient2(GetGradientValue());
// create sequence
rVal <<= aGradient2;
@@ -2282,8 +2283,7 @@ bool XFillGradientItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) c
case MID_GRADIENT_COLORSTOPSEQUENCE:
{
// fill values
- const css::awt::ColorStopSequence aColorStopSequence(
- GetGradientValue().GetColorStops().getAsColorStopSequence());
+ const css::awt::ColorStopSequence aColorStopSequence = model::gradient::createColorStopSequence(GetGradientValue().GetColorStops());
// create sequence
rVal <<= aColorStopSequence;
@@ -2334,8 +2334,7 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
if (aGradientAny.hasValue() && (aGradientAny.has<css::awt::Gradient>() || aGradientAny.has<css::awt::Gradient2>()))
{
- const basegfx::BGradient aBGradient(aGradientAny);
- SetGradientValue(aBGradient);
+ SetGradientValue(model::gradient::getFromAny(aGradientAny));
}
return true;
@@ -2357,8 +2356,7 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
{
if (rVal.hasValue() && (rVal.has<css::awt::Gradient>() || rVal.has<css::awt::Gradient2>()))
{
- const basegfx::BGradient aBGradient(rVal);
- SetGradientValue(aBGradient);
+ SetGradientValue(model::gradient::getFromAny(rVal));
}
break;
@@ -2369,7 +2367,8 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
// check if we have a awt::ColorStopSequence
if (rVal.hasValue() && rVal.has<css::awt::ColorStopSequence>())
{
- const basegfx::BColorStops aColorStops(rVal);
+
+ const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromAny(rVal);
if (!aColorStops.empty())
{