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>
This commit is contained in:
parent
84b12cd3ea
commit
242bb3fdda
32 changed files with 329 additions and 262 deletions
|
@ -68,41 +68,6 @@ basegfx::BGradient lcl_buildGradientFromStringMap(StringMap& rMap)
|
|||
|
||||
namespace basegfx
|
||||
{
|
||||
void BColorStops::setColorStopSequence(const css::awt::ColorStopSequence& rColorStops)
|
||||
{
|
||||
const sal_Int32 nLen(rColorStops.getLength());
|
||||
|
||||
if (0 != nLen)
|
||||
{
|
||||
// we have ColorStops
|
||||
reserve(nLen);
|
||||
const css::awt::ColorStop* pSourceColorStop(rColorStops.getConstArray());
|
||||
|
||||
for (sal_Int32 a(0); a < nLen; a++, pSourceColorStop++)
|
||||
{
|
||||
emplace_back(pSourceColorStop->StopOffset,
|
||||
BColor(pSourceColorStop->StopColor.Red, pSourceColorStop->StopColor.Green,
|
||||
pSourceColorStop->StopColor.Blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BColorStops::BColorStops(const css::awt::ColorStopSequence& rColorStops)
|
||||
{
|
||||
setColorStopSequence(rColorStops);
|
||||
}
|
||||
|
||||
BColorStops::BColorStops(const css::uno::Any& rVal)
|
||||
{
|
||||
if (rVal.has<css::awt::ColorStopSequence>())
|
||||
{
|
||||
// we can use awt::ColorStopSequence
|
||||
css::awt::ColorStopSequence aColorStopSequence;
|
||||
rVal >>= aColorStopSequence;
|
||||
setColorStopSequence(aColorStopSequence);
|
||||
}
|
||||
}
|
||||
|
||||
// constructor with two colors to explicitly create a
|
||||
// BColorStops for a single StartColor @0.0 & EndColor @1.0
|
||||
BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd)
|
||||
|
@ -498,28 +463,6 @@ bool BColorStops::checkPenultimate() const
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Tooling method to fill a awt::ColorStopSequence with
|
||||
the data from the given ColorStops. This is used in
|
||||
UNO API implementations.
|
||||
*/
|
||||
css::awt::ColorStopSequence BColorStops::getAsColorStopSequence() const
|
||||
{
|
||||
css::awt::ColorStopSequence aRetval(size());
|
||||
// rColorStopSequence.realloc(rColorStops.size());
|
||||
css::awt::ColorStop* pTargetColorStop(aRetval.getArray());
|
||||
|
||||
for (const auto& candidate : *this)
|
||||
{
|
||||
pTargetColorStop->StopOffset = candidate.getStopOffset();
|
||||
pTargetColorStop->StopColor = css::rendering::RGBColor(candidate.getStopColor().getRed(),
|
||||
candidate.getStopColor().getGreen(),
|
||||
candidate.getStopColor().getBlue());
|
||||
pTargetColorStop++;
|
||||
}
|
||||
|
||||
return aRetval;
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
@ -856,72 +799,6 @@ BGradient::BGradient(const basegfx::BColorStops& rColorStops, css::awt::Gradient
|
|||
SetColorStops(aColorStops);
|
||||
}
|
||||
|
||||
void BGradient::setGradient2(const css::awt::Gradient2& rGradient2)
|
||||
{
|
||||
// set values
|
||||
SetGradientStyle(rGradient2.Style);
|
||||
SetAngle(Degree10(rGradient2.Angle));
|
||||
SetBorder(rGradient2.Border);
|
||||
SetXOffset(rGradient2.XOffset);
|
||||
SetYOffset(rGradient2.YOffset);
|
||||
SetStartIntens(rGradient2.StartIntensity);
|
||||
SetEndIntens(rGradient2.EndIntensity);
|
||||
SetSteps(rGradient2.StepCount);
|
||||
|
||||
// set ColorStops
|
||||
if (rGradient2.ColorStops.hasElements())
|
||||
{
|
||||
// if we have a awt::ColorStopSequence, use it
|
||||
aColorStops = BColorStops(rGradient2.ColorStops);
|
||||
aColorStops.sortAndCorrect();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if not, for compatibility, use StartColor/EndColor
|
||||
aColorStops = BColorStops{
|
||||
BColorStop(0.0, ColorToBColorConverter(rGradient2.StartColor).getBColor()),
|
||||
BColorStop(1.0, ColorToBColorConverter(rGradient2.EndColor).getBColor())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
BGradient::BGradient(const css::awt::Gradient2& rGradient2) { setGradient2(rGradient2); }
|
||||
|
||||
BGradient::BGradient(const css::uno::Any& rVal)
|
||||
: BGradient()
|
||||
{
|
||||
if (rVal.has<css::awt::Gradient2>())
|
||||
{
|
||||
// we can use awt::Gradient2 directly
|
||||
css::awt::Gradient2 aGradient2;
|
||||
rVal >>= aGradient2;
|
||||
|
||||
setGradient2(aGradient2);
|
||||
}
|
||||
else if (rVal.has<css::awt::Gradient>())
|
||||
{
|
||||
// use awt::Gradient
|
||||
css::awt::Gradient aGradient;
|
||||
rVal >>= aGradient;
|
||||
|
||||
// set values
|
||||
SetGradientStyle(aGradient.Style);
|
||||
SetAngle(Degree10(aGradient.Angle));
|
||||
SetBorder(aGradient.Border);
|
||||
SetXOffset(aGradient.XOffset);
|
||||
SetYOffset(aGradient.YOffset);
|
||||
SetStartIntens(aGradient.StartIntensity);
|
||||
SetEndIntens(aGradient.EndIntensity);
|
||||
SetSteps(aGradient.StepCount);
|
||||
|
||||
// complete data by creating ColorStops from fixed Start/EndColor
|
||||
aColorStops = BColorStops{
|
||||
BColorStop(0.0, ColorToBColorConverter(aGradient.StartColor).getBColor()),
|
||||
BColorStop(1.0, ColorToBColorConverter(aGradient.EndColor).getBColor())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
bool BGradient::operator==(const BGradient& rGradient) const
|
||||
{
|
||||
return (eStyle == rGradient.eStyle && aColorStops == rGradient.aColorStops
|
||||
|
@ -969,50 +846,6 @@ boost::property_tree::ptree BGradient::dumpAsJSON() const
|
|||
return aTree;
|
||||
}
|
||||
|
||||
css::awt::Gradient2 BGradient::getAsGradient2() const
|
||||
{
|
||||
css::awt::Gradient2 aRetval;
|
||||
|
||||
// standard values
|
||||
aRetval.Style = GetGradientStyle();
|
||||
aRetval.Angle = static_cast<short>(GetAngle());
|
||||
aRetval.Border = GetBorder();
|
||||
aRetval.XOffset = GetXOffset();
|
||||
aRetval.YOffset = GetYOffset();
|
||||
aRetval.StartIntensity = GetStartIntens();
|
||||
aRetval.EndIntensity = GetEndIntens();
|
||||
aRetval.StepCount = GetSteps();
|
||||
|
||||
// for compatibility, still set StartColor/EndColor
|
||||
// NOTE: All code after adapting to multi color gradients works
|
||||
// using the ColorSteps, so in principle Start/EndColor might
|
||||
// be either
|
||||
// (a) ignored consequently everywhere or
|
||||
// (b) be set/added consequently everywhere
|
||||
// since this is - in principle - redundant data.
|
||||
// Be aware that e.g. cases like DrawingML::EqualGradients
|
||||
// and others would have to be identified and adapted (!)
|
||||
// Since awt::Gradient2 is UNO API data there might
|
||||
// be cases where just awt::Gradient is transferred, so (b)
|
||||
// is far better backwards compatible and thus more safe, so
|
||||
// all changes will make use of additionally using/setting
|
||||
// these additionally, but will only make use of the given
|
||||
// ColorSteps if these are not empty, assuming that these
|
||||
// already contain Start/EndColor.
|
||||
// In principle that redundancy and that it is conflict-free
|
||||
// could even be checked and asserted, but consequently using
|
||||
// (b) methodically should be safe.
|
||||
aRetval.StartColor
|
||||
= static_cast<sal_Int32>(ColorToBColorConverter(aColorStops.front().getStopColor()));
|
||||
aRetval.EndColor
|
||||
= static_cast<sal_Int32>(ColorToBColorConverter(aColorStops.back().getStopColor()));
|
||||
|
||||
// fill ColorStops to extended Gradient2
|
||||
aRetval.ColorStops = aColorStops.getAsColorStopSequence();
|
||||
|
||||
return aRetval;
|
||||
}
|
||||
|
||||
void BGradient::tryToRecreateBorder(basegfx::BColorStops* pAssociatedTransparencyStops)
|
||||
{
|
||||
// border already set, do not try to recreate
|
||||
|
|
|
@ -33,10 +33,11 @@ $(eval $(call gb_Library_use_libraries,chartcontroller,\
|
|||
cppu \
|
||||
cppuhelper \
|
||||
drawinglayer \
|
||||
docmodel \
|
||||
editeng \
|
||||
sal \
|
||||
salhelper \
|
||||
i18nlangtag \
|
||||
i18nlangtag \
|
||||
sfx \
|
||||
sot \
|
||||
svl \
|
||||
|
|
|
@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,chart2_import$(1), \
|
|||
cppu \
|
||||
cppuhelper \
|
||||
drawinglayer \
|
||||
docmodel \
|
||||
editeng \
|
||||
for \
|
||||
forui \
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <com/sun/star/awt/Gradient2.hpp>
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
class Chart2ImportTest : public ChartTest
|
||||
{
|
||||
|
@ -628,7 +629,7 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc889755)
|
|||
uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(4), uno::UNO_QUERY_THROW);
|
||||
awt::Gradient2 aTransparence;
|
||||
xShapeProps->getPropertyValue("FillTransparenceGradient") >>= aTransparence;
|
||||
const basegfx::BColorStops aColorStops(aTransparence.ColorStops);
|
||||
const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aTransparence.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -671,7 +672,7 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTransparencyGradientValue)
|
|||
uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
|
||||
uno::Any rTransparenceValue = xTransparenceGradient->getByName(sTranspGradientName);
|
||||
CPPUNIT_ASSERT(rTransparenceValue >>= aTransparenceGradient);
|
||||
const basegfx::BColorStops aColorStops(aTransparenceGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops);
|
||||
|
||||
// MCGR: Use the whole completely imported transparency gradient to check for correctness
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <ObjectNameProvider.hxx>
|
||||
#include <unonames.hxx>
|
||||
|
||||
#include <com/sun/star/awt/Gradient.hpp>
|
||||
#include <com/sun/star/chart2/DataPointLabel.hpp>
|
||||
#include <com/sun/star/beans/XPropertyState.hpp>
|
||||
#include <com/sun/star/graphic/XGraphic.hpp>
|
||||
|
@ -55,6 +56,7 @@
|
|||
#include <com/sun/star/chart/ErrorBarStyle.hpp>
|
||||
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
|
||||
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <editeng/editview.hxx>
|
||||
#include <editeng/outliner.hxx>
|
||||
#include <svx/ActionDescriptionProvider.hxx>
|
||||
|
@ -957,7 +959,7 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor)
|
|||
void ChartController::executeDispatch_FillGradient(std::u16string_view sJSONGradient)
|
||||
{
|
||||
basegfx::BGradient aBGradient = basegfx::BGradient::fromJSON(sJSONGradient);
|
||||
css::awt::Gradient aGradient = aBGradient.getAsGradient2();
|
||||
css::awt::Gradient aGradient = model::gradient::createUnoGradient2(aBGradient);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ $(eval $(call gb_Library_Library,docmodel))
|
|||
|
||||
$(eval $(call gb_Library_add_exception_objects,docmodel,\
|
||||
docmodel/source/uno/UnoComplexColor \
|
||||
docmodel/source/uno/UnoGradientTools \
|
||||
docmodel/source/uno/UnoTheme \
|
||||
docmodel/source/theme/ColorSet \
|
||||
docmodel/source/theme/Theme \
|
||||
|
@ -36,6 +37,7 @@ $(eval $(call gb_Library_set_precompiled_header,docmodel,docmodel/inc/pch/precom
|
|||
$(eval $(call gb_Library_use_sdk_api,docmodel))
|
||||
|
||||
$(eval $(call gb_Library_use_libraries,docmodel,\
|
||||
basegfx \
|
||||
comphelper \
|
||||
cppuhelper \
|
||||
cppu \
|
||||
|
|
200
docmodel/source/uno/UnoGradientTools.cxx
Normal file
200
docmodel/source/uno/UnoGradientTools.cxx
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <com/sun/star/awt/Gradient.hpp>
|
||||
#include <com/sun/star/awt/Gradient2.hpp>
|
||||
#include <com/sun/star/rendering/RGBColor.hpp>
|
||||
#include <basegfx/utils/bgradient.hxx>
|
||||
#include <tools/color.hxx>
|
||||
|
||||
using namespace css;
|
||||
|
||||
namespace model::gradient
|
||||
{
|
||||
css::awt::ColorStopSequence createColorStopSequence(basegfx::BColorStops const& rColorStops)
|
||||
{
|
||||
// Fill color stops
|
||||
css::awt::ColorStopSequence aSequence(rColorStops.size());
|
||||
css::awt::ColorStop* pSequence(aSequence.getArray());
|
||||
|
||||
for (const auto& rStop : rColorStops)
|
||||
{
|
||||
auto rBColor = rStop.getStopColor();
|
||||
pSequence->StopOffset = rStop.getStopOffset();
|
||||
pSequence->StopColor
|
||||
= css::rendering::RGBColor(rBColor.getRed(), rBColor.getGreen(), rBColor.getBlue());
|
||||
pSequence++;
|
||||
}
|
||||
|
||||
return aSequence;
|
||||
}
|
||||
|
||||
css::awt::Gradient2 createUnoGradient2(basegfx::BGradient const& rGradient)
|
||||
{
|
||||
css::awt::Gradient2 aGradient2;
|
||||
|
||||
// standard values
|
||||
aGradient2.Style = rGradient.GetGradientStyle();
|
||||
aGradient2.Angle = static_cast<short>(rGradient.GetAngle());
|
||||
aGradient2.Border = rGradient.GetBorder();
|
||||
aGradient2.XOffset = rGradient.GetXOffset();
|
||||
aGradient2.YOffset = rGradient.GetYOffset();
|
||||
aGradient2.StartIntensity = rGradient.GetStartIntens();
|
||||
aGradient2.EndIntensity = rGradient.GetEndIntens();
|
||||
aGradient2.StepCount = rGradient.GetSteps();
|
||||
|
||||
// for compatibility, still set StartColor/EndColor
|
||||
// NOTE: All code after adapting to multi color gradients works
|
||||
// using the ColorSteps, so in principle Start/EndColor might
|
||||
// be either
|
||||
// (a) ignored consequently everywhere or
|
||||
// (b) be set/added consequently everywhere
|
||||
// since this is - in principle - redundant data.
|
||||
// Be aware that e.g. cases like DrawingML::EqualGradients
|
||||
// and others would have to be identified and adapted (!)
|
||||
// Since awt::Gradient2 is UNO API data there might
|
||||
// be cases where just awt::Gradient is transferred, so (b)
|
||||
// is far better backwards compatible and thus more safe, so
|
||||
// all changes will make use of additionally using/setting
|
||||
// these additionally, but will only make use of the given
|
||||
// ColorSteps if these are not empty, assuming that these
|
||||
// already contain Start/EndColor.
|
||||
// In principle that redundancy and that it is conflict-free
|
||||
// could even be checked and asserted, but consequently using
|
||||
// (b) methodically should be safe.
|
||||
const basegfx::BColorStops& rColorStops = rGradient.GetColorStops();
|
||||
aGradient2.StartColor = static_cast<sal_Int32>(::Color(rColorStops.front().getStopColor()));
|
||||
aGradient2.EndColor = static_cast<sal_Int32>(::Color(rColorStops.back().getStopColor()));
|
||||
|
||||
aGradient2.ColorStops = createColorStopSequence(rColorStops);
|
||||
|
||||
return aGradient2;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void fillFromColorStopSequence(basegfx::BColorStops& rColorStops,
|
||||
css::awt::ColorStopSequence const& rUnoColorStopSequence)
|
||||
{
|
||||
const auto nLength = rUnoColorStopSequence.getLength();
|
||||
if (0 != nLength)
|
||||
{
|
||||
rColorStops.clear();
|
||||
rColorStops.reserve(nLength);
|
||||
|
||||
for (css::awt::ColorStop const& rSourceStop : rUnoColorStopSequence)
|
||||
{
|
||||
rColorStops.emplace_back(rSourceStop.StopOffset,
|
||||
basegfx::BColor(rSourceStop.StopColor.Red,
|
||||
rSourceStop.StopColor.Green,
|
||||
rSourceStop.StopColor.Blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fillFromGradient2(basegfx::BGradient& rBGradient, css::awt::Gradient2 const& rGradient2)
|
||||
{
|
||||
rBGradient.SetGradientStyle(rGradient2.Style);
|
||||
rBGradient.SetAngle(Degree10(rGradient2.Angle));
|
||||
rBGradient.SetBorder(rGradient2.Border);
|
||||
rBGradient.SetXOffset(rGradient2.XOffset);
|
||||
rBGradient.SetYOffset(rGradient2.YOffset);
|
||||
rBGradient.SetStartIntens(rGradient2.StartIntensity);
|
||||
rBGradient.SetEndIntens(rGradient2.EndIntensity);
|
||||
rBGradient.SetSteps(rGradient2.StepCount);
|
||||
|
||||
// set ColorStops
|
||||
if (rGradient2.ColorStops.hasElements())
|
||||
{
|
||||
basegfx::BColorStops aColorStops;
|
||||
fillFromColorStopSequence(aColorStops, rGradient2.ColorStops);
|
||||
rBGradient.SetColorStops(aColorStops);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if not, for compatibility, use StartColor/EndColor
|
||||
basegfx::BColorStops aColorStops{
|
||||
basegfx::BColorStop(0.0, ::Color(ColorTransparency, rGradient2.StartColor).getBColor()),
|
||||
basegfx::BColorStop(1.0, ::Color(ColorTransparency, rGradient2.EndColor).getBColor())
|
||||
};
|
||||
rBGradient.SetColorStops(aColorStops);
|
||||
}
|
||||
}
|
||||
|
||||
} // end anonymous
|
||||
|
||||
basegfx::BColorStops getColorStopsFromUno(css::awt::ColorStopSequence const& rColorStopSequence)
|
||||
{
|
||||
basegfx::BColorStops aColorStops;
|
||||
fillFromColorStopSequence(aColorStops, rColorStopSequence);
|
||||
return aColorStops;
|
||||
}
|
||||
|
||||
basegfx::BColorStops getColorStopsFromAny(css::uno::Any const& rAny)
|
||||
{
|
||||
basegfx::BColorStops aColorStops;
|
||||
if (!rAny.has<css::awt::ColorStopSequence>())
|
||||
return aColorStops;
|
||||
|
||||
auto aSequence = rAny.get<css::awt::ColorStopSequence>();
|
||||
fillFromColorStopSequence(aColorStops, aSequence);
|
||||
return aColorStops;
|
||||
}
|
||||
|
||||
basegfx::BGradient getFromUnoGradient2(css::awt::Gradient2 const& rGradient2)
|
||||
{
|
||||
basegfx::BGradient aBGradient;
|
||||
fillFromGradient2(aBGradient, rGradient2);
|
||||
return aBGradient;
|
||||
}
|
||||
|
||||
basegfx::BGradient getFromAny(css::uno::Any const& rAny)
|
||||
{
|
||||
basegfx::BGradient aBGradient;
|
||||
|
||||
if (rAny.has<css::awt::Gradient2>())
|
||||
{
|
||||
// we can use awt::Gradient2 directly
|
||||
css::awt::Gradient2 aGradient2;
|
||||
rAny >>= aGradient2;
|
||||
|
||||
fillFromGradient2(aBGradient, aGradient2);
|
||||
}
|
||||
else if (rAny.has<css::awt::Gradient>())
|
||||
{
|
||||
// use awt::Gradient
|
||||
css::awt::Gradient aGradient;
|
||||
rAny >>= aGradient;
|
||||
|
||||
// set values
|
||||
aBGradient.SetGradientStyle(aGradient.Style);
|
||||
aBGradient.SetAngle(Degree10(aGradient.Angle));
|
||||
aBGradient.SetBorder(aGradient.Border);
|
||||
aBGradient.SetXOffset(aGradient.XOffset);
|
||||
aBGradient.SetYOffset(aGradient.YOffset);
|
||||
aBGradient.SetStartIntens(aGradient.StartIntensity);
|
||||
aBGradient.SetEndIntens(aGradient.EndIntensity);
|
||||
aBGradient.SetSteps(aGradient.StepCount);
|
||||
|
||||
basegfx::BColorStops aColorStops{
|
||||
basegfx::BColorStop(0.0, ::Color(ColorTransparency, aGradient.StartColor).getBColor()),
|
||||
basegfx::BColorStop(1.0, ::Color(ColorTransparency, aGradient.EndColor).getBColor())
|
||||
};
|
||||
|
||||
aBGradient.SetColorStops(aColorStops);
|
||||
}
|
||||
|
||||
return aBGradient;
|
||||
}
|
||||
|
||||
} // end model::gradient
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -13,7 +13,6 @@
|
|||
#include <basegfx/color/bcolor.hxx>
|
||||
#include <basegfx/basegfxdllapi.h>
|
||||
#include <vector>
|
||||
#include <com/sun/star/awt/Gradient2.hpp>
|
||||
#include <com/sun/star/awt/GradientStyle.hpp>
|
||||
#include <tools/degree.hxx>
|
||||
#include <boost/property_tree/ptree_fwd.hpp>
|
||||
|
@ -109,9 +108,6 @@ public:
|
|||
*/
|
||||
class BASEGFX_DLLPUBLIC BColorStops final : public std::vector<BColorStop>
|
||||
{
|
||||
private:
|
||||
void setColorStopSequence(const css::awt::ColorStopSequence& rColorStops);
|
||||
|
||||
public:
|
||||
explicit BColorStops()
|
||||
: vector()
|
||||
|
@ -133,10 +129,6 @@ public:
|
|||
: vector(first, last)
|
||||
{
|
||||
}
|
||||
BColorStops(const css::awt::ColorStopSequence& rColorStops);
|
||||
|
||||
// needs true == rVal.has<css::awt::ColorStopSequence>()
|
||||
BColorStops(const css::uno::Any& rVal);
|
||||
|
||||
// constructor with two colors to explicitly create a
|
||||
// BColorStops for StartColor @0.0 & EndColor @1.0
|
||||
|
@ -243,12 +235,6 @@ public:
|
|||
// tessellation for gradients does have to create an extra ending/closing entry
|
||||
bool checkPenultimate() const;
|
||||
|
||||
/* Tooling method to fill a awt::ColorStopSequence with
|
||||
the data from the given ColorStops. This is used in
|
||||
UNO API implementations.
|
||||
*/
|
||||
css::awt::ColorStopSequence getAsColorStopSequence() const;
|
||||
|
||||
/* 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
|
||||
|
@ -304,7 +290,6 @@ private:
|
|||
sal_uInt16 nStepCount;
|
||||
|
||||
static std::string GradientStyleToString(css::awt::GradientStyle eStyle);
|
||||
void setGradient2(const css::awt::Gradient2& rGradient2);
|
||||
|
||||
public:
|
||||
BGradient();
|
||||
|
@ -313,10 +298,6 @@ public:
|
|||
Degree10 nAngle = 0_deg10, sal_uInt16 nXOfs = 50, sal_uInt16 nYOfs = 50,
|
||||
sal_uInt16 nBorder = 0, sal_uInt16 nStartIntens = 100, sal_uInt16 nEndIntens = 100,
|
||||
sal_uInt16 nSteps = 0);
|
||||
BGradient(const css::awt::Gradient2& rGradient2);
|
||||
|
||||
// needs true == (rVal.has<css::awt::Gradient>() || rVal.has<css::awt::Gradient2>())
|
||||
BGradient(const css::uno::Any& rVal);
|
||||
|
||||
bool operator==(const BGradient& rGradient) const;
|
||||
|
||||
|
@ -343,9 +324,6 @@ public:
|
|||
boost::property_tree::ptree dumpAsJSON() const;
|
||||
static BGradient fromJSON(std::u16string_view rJSON);
|
||||
|
||||
/// 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
|
||||
// - apply StartStopIntensity to color stops
|
||||
|
|
33
include/docmodel/uno/UnoGradientTools.hxx
Normal file
33
include/docmodel/uno/UnoGradientTools.hxx
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <docmodel/dllapi.h>
|
||||
#include <basegfx/utils/bgradient.hxx>
|
||||
#include <com/sun/star/awt/Gradient2.hpp>
|
||||
#include <com/sun/star/awt/ColorStopSequence.hpp>
|
||||
#include <com/sun/star/uno/Any.hxx>
|
||||
|
||||
namespace model::gradient
|
||||
{
|
||||
DOCMODEL_DLLPUBLIC css::awt::Gradient2 createUnoGradient2(basegfx::BGradient const& rGradient);
|
||||
|
||||
DOCMODEL_DLLPUBLIC basegfx::BGradient getFromUnoGradient2(css::awt::Gradient2 const& rGradient2);
|
||||
DOCMODEL_DLLPUBLIC basegfx::BGradient getFromAny(css::uno::Any const& rAny);
|
||||
|
||||
DOCMODEL_DLLPUBLIC css::awt::ColorStopSequence
|
||||
createColorStopSequence(basegfx::BColorStops const& rColorStops);
|
||||
|
||||
DOCMODEL_DLLPUBLIC basegfx::BColorStops
|
||||
getColorStopsFromUno(css::awt::ColorStopSequence const& rColorStopSequence);
|
||||
DOCMODEL_DLLPUBLIC basegfx::BColorStops getColorStopsFromAny(css::uno::Any const& rAny);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -30,6 +30,7 @@
|
|||
#include <com/sun/star/table/XCellRange.hpp>
|
||||
#include <com/sun/star/util/XTheme.hpp>
|
||||
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <docmodel/uno/UnoComplexColor.hxx>
|
||||
#include <docmodel/uno/UnoTheme.hxx>
|
||||
#include <docmodel/theme/Theme.hxx>
|
||||
|
@ -191,7 +192,8 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency)
|
|||
// i.e. the end transparency was not 100%, but was 21%, leading to an unexpected visible line on
|
||||
// the right of this shape.
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aTransparence.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aTransparence.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(5), aColorStops.size());
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, aColorStops[0].getStopOffset(), 1E-3);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <svx/svdoashp.hxx>
|
||||
#include <tools/color.hxx>
|
||||
#include <docmodel/uno/UnoComplexColor.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
@ -471,7 +472,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -494,7 +496,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.40000000000000002));
|
||||
|
@ -517,7 +520,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -632,7 +636,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -663,7 +668,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -677,7 +683,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
|
|||
|
||||
xShapeProps->getPropertyValue(u"FillTransparenceGradient") >>= aGradient;
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
aColorStops = basegfx::BColorStops(aGradient.ColorStops);
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
// Transparency is encoded in gray color.
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
|
@ -714,7 +720,8 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
|
|||
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops;
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -728,7 +735,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
|
|||
|
||||
xShapeProps->getPropertyValue(u"FillTransparenceGradient") >>= aGradient;
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
aColorStops = basegfx::BColorStops(aGradient.ColorStops);
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
// Transparency is encoded in gray color.
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <vcl/BitmapFilter.hxx>
|
||||
#include <vcl/BitmapMonochromeFilter.hxx>
|
||||
#include <docmodel/uno/UnoComplexColor.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
|
@ -547,7 +548,7 @@ void FillProperties::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelp
|
|||
}
|
||||
|
||||
// push gradient or named gradient to property map
|
||||
if (rPropMap.setProperty(ShapeProperty::FillGradient, aGradient.getAsGradient2()))
|
||||
if (rPropMap.setProperty(ShapeProperty::FillGradient, model::gradient::createUnoGradient2(aGradient)))
|
||||
{
|
||||
eFillStyle = FillStyle_GRADIENT;
|
||||
}
|
||||
|
@ -556,7 +557,7 @@ void FillProperties::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelp
|
|||
if (!aTransparencyStops.empty())
|
||||
{
|
||||
aGradient.SetColorStops(aTransparencyStops);
|
||||
rPropMap.setProperty(ShapeProperty::GradientTransparency, aGradient.getAsGradient2());
|
||||
rPropMap.setProperty(ShapeProperty::GradientTransparency, model::gradient::createUnoGradient2(aGradient));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <comphelper/sequence.hxx>
|
||||
#include <comphelper/sequenceashashmap.hxx>
|
||||
#include <docmodel/uno/UnoComplexColor.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <drawingml/customshapeproperties.hxx>
|
||||
#include <drawingml/presetgeometrynames.hxx>
|
||||
#include <oox/drawingml/drawingmltypes.hxx>
|
||||
|
@ -1170,7 +1171,7 @@ ColorMapType lcl_createColorMapFromShapeProps(
|
|||
basegfx::BColorStops aColorStops;
|
||||
if (rbHasColorGradient)
|
||||
{
|
||||
aColorBGradient = basegfx::BGradient(rColorGradient);
|
||||
aColorBGradient = model::gradient::getFromUnoGradient2(rColorGradient);
|
||||
aColorBGradient.tryToApplyStartEndIntensity();
|
||||
aColorBGradient.tryToApplyBorder();
|
||||
aColorBGradient.tryToApplyAxial();
|
||||
|
@ -1193,7 +1194,7 @@ ColorMapType lcl_createColorMapFromShapeProps(
|
|||
basegfx::BColorStops aTransStops;
|
||||
if (rbHasTransparenceGradient)
|
||||
{
|
||||
aTransBGradient = basegfx::BGradient(rTransparenceGradient);
|
||||
aTransBGradient = model::gradient::getFromUnoGradient2(rTransparenceGradient);
|
||||
aTransBGradient.tryToApplyStartEndIntensity(); // usually 100%, but might be set by macro
|
||||
aTransBGradient.tryToApplyBorder();
|
||||
aTransBGradient.tryToApplyAxial();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <oox/export/utils.hxx>
|
||||
#include <drawingml/chart/typegroupconverter.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
|
@ -1913,9 +1914,9 @@ void ChartExport::exportSolidFill(const Reference< XPropertySet >& xPropSet)
|
|||
{
|
||||
uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
|
||||
uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
|
||||
const uno::Any rTransparenceValue = xTransparenceGradient->getByName(sFillTransparenceGradientName);
|
||||
const uno::Any rTransparenceAny = xTransparenceGradient->getByName(sFillTransparenceGradientName);
|
||||
|
||||
aTransparenceGradient = basegfx::BGradient(rTransparenceValue);
|
||||
aTransparenceGradient = model::gradient::getFromAny(rTransparenceAny);
|
||||
basegfx::BColor aSingleColor;
|
||||
bNeedGradientFill = !aTransparenceGradient.GetColorStops().isSingleColor(aSingleColor);
|
||||
|
||||
|
@ -2001,8 +2002,8 @@ void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet
|
|||
try
|
||||
{
|
||||
uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
|
||||
const uno::Any rGradientValue(xGradient->getByName( sFillGradientName ));
|
||||
const basegfx::BGradient aGradient(rGradientValue);
|
||||
const uno::Any rGradientAny(xGradient->getByName( sFillGradientName ));
|
||||
const basegfx::BGradient aGradient = model::gradient::getFromAny(rGradientAny);
|
||||
basegfx::BColor aSingleColor;
|
||||
|
||||
if (!aGradient.GetColorStops().isSingleColor(aSingleColor))
|
||||
|
@ -2014,9 +2015,9 @@ void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet
|
|||
if( (xPropSet->getPropertyValue("FillTransparenceGradientName") >>= sFillTransparenceGradientName) && !sFillTransparenceGradientName.isEmpty())
|
||||
{
|
||||
uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
|
||||
const uno::Any rTransparenceValue(xTransparenceGradient->getByName(sFillTransparenceGradientName));
|
||||
const uno::Any rTransparenceAny(xTransparenceGradient->getByName(sFillTransparenceGradientName));
|
||||
|
||||
aTransparenceGradient = basegfx::BGradient(rTransparenceValue);
|
||||
aTransparenceGradient = model::gradient::getFromAny(rTransparenceAny);
|
||||
|
||||
WriteGradientFill(&aGradient, 0, &aTransparenceGradient);
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
#include <svx/unoshape.hxx>
|
||||
#include <svx/EnhancedCustomShape2d.hxx>
|
||||
#include <drawingml/presetgeometrynames.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
using namespace ::css;
|
||||
using namespace ::css::beans;
|
||||
|
@ -481,7 +482,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
|
|||
&& !sFillTransparenceGradientName.isEmpty()
|
||||
&& GetProperty(rXPropSet, "FillTransparenceGradient"))
|
||||
{
|
||||
aTransparenceGradient = basegfx::BGradient(mAny);
|
||||
aTransparenceGradient = model::gradient::getFromAny(mAny);
|
||||
basegfx::BColor aSingleColor;
|
||||
bNeedGradientFill = !aTransparenceGradient.GetColorStops().isSingleColor(aSingleColor);
|
||||
|
||||
|
@ -605,7 +606,7 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
|
|||
return;
|
||||
|
||||
// use BGradient constructor directly, it will take care of Gradient/Gradient2
|
||||
basegfx::BGradient aGradient(mAny);
|
||||
basegfx::BGradient aGradient = model::gradient::getFromAny(mAny);
|
||||
|
||||
// get InteropGrabBag and search the relevant attributes
|
||||
basegfx::BGradient aOriginalGradient;
|
||||
|
@ -618,8 +619,7 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
|
|||
if( rProp.Name == "GradFillDefinition" )
|
||||
rProp.Value >>= aGradientStops;
|
||||
else if( rProp.Name == "OriginalGradFill" )
|
||||
// use BGradient constructor directly, it will take care of Gradient/Gradient2
|
||||
aOriginalGradient = basegfx::BGradient(rProp.Value);
|
||||
aOriginalGradient = model::gradient::getFromAny(rProp.Value);
|
||||
}
|
||||
|
||||
// check if an ooxml gradient had been imported and if the user has modified it
|
||||
|
@ -650,7 +650,7 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
|
|||
&& GetProperty(rXPropSet, "FillTransparenceGradient"))
|
||||
{
|
||||
// TransparenceGradient is only used when name is not empty
|
||||
aTransparenceGradient = basegfx::BGradient(mAny);
|
||||
aTransparenceGradient = model::gradient::getFromAny(mAny);
|
||||
pTransparenceGradient = &aTransparenceGradient;
|
||||
}
|
||||
else if (GetProperty(rXPropSet, "FillTransparence"))
|
||||
|
@ -5310,7 +5310,7 @@ void DrawingML::WriteFill(const Reference<XPropertySet>& xPropSet, const awt::Si
|
|||
{
|
||||
// check if a fully transparent TransparenceGradient is used
|
||||
// use BGradient constructor & tooling here now
|
||||
const basegfx::BGradient aTransparenceGradient(mAny);
|
||||
const basegfx::BGradient aTransparenceGradient = model::gradient::getFromAny(mAny);
|
||||
basegfx::BColor aSingleColor;
|
||||
const bool bSingleColor(aTransparenceGradient.GetColorStops().isSingleColor(aSingleColor));
|
||||
const bool bCompletelyTransparent(bSingleColor && basegfx::fTools::equal(aSingleColor.luminance(), 1.0));
|
||||
|
|
|
@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_misc_tests, \
|
|||
cppu \
|
||||
cppuhelper \
|
||||
drawinglayer \
|
||||
docmodel \
|
||||
editeng \
|
||||
for \
|
||||
forui \
|
||||
|
|
|
@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_export_tests$(1), \
|
|||
cppu \
|
||||
cppuhelper \
|
||||
drawinglayer \
|
||||
docmodel \
|
||||
editeng \
|
||||
for \
|
||||
forui \
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <com/sun/star/table/BorderLine2.hpp>
|
||||
#include <com/sun/star/table/XMergeableCell.hpp>
|
||||
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <svx/svdotable.hxx>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <rtl/uri.hxx>
|
||||
|
@ -1226,7 +1227,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf94238)
|
|||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), aGradient.Border);
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
// Without the accompanying fix in place, this test would have failed with
|
||||
// 'Expected: 0, Actual : 10592673', i.e. the start color of the gradient
|
||||
|
@ -1485,7 +1487,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf128345GradientAxial)
|
|||
xShapePropSet->getPropertyValue("FillTransparenceGradient") >>= aTransparenceGradient;
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aTransparenceGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <svx/svdomedia.hxx>
|
||||
#include <svx/svdotable.hxx>
|
||||
#include <svx/svdpage.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
#include <com/sun/star/animations/TransitionType.hpp>
|
||||
#include <com/sun/star/animations/TransitionSubType.hpp>
|
||||
|
@ -1011,7 +1012,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf105739)
|
|||
aXBackgroundPropSet->getPropertyValue("FillGradient") >>= aFillGradient;
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aFillGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aFillGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <editeng/editobj.hxx>
|
||||
#include <editeng/numitem.hxx>
|
||||
#include <editeng/unoprnms.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
#include <svx/xlineit0.hxx>
|
||||
#include <svx/xlndsit.hxx>
|
||||
|
@ -1249,7 +1250,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127372)
|
|||
xShape->getPropertyValue("FillTransparenceGradient") >>= aTransparenceGradient;
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aTransparenceGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -1281,7 +1283,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127379)
|
|||
CPPUNIT_ASSERT(aXBackgroundPropSet->getPropertyValue("FillGradient") >>= aGradient);
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <animations/animationnodehelper.hxx>
|
||||
#include <sax/tools/converter.hxx>
|
||||
|
||||
#include <com/sun/star/awt/Gradient.hpp>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/document/XEventsSupplier.hpp>
|
||||
#include <com/sun/star/presentation/ClickAction.hpp>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <animations/animationnodehelper.hxx>
|
||||
|
||||
#include <com/sun/star/awt/XBitmap.hpp>
|
||||
#include <com/sun/star/awt/Gradient.hpp>
|
||||
#include <com/sun/star/document/XEventsSupplier.hpp>
|
||||
#include <com/sun/star/presentation/ClickAction.hpp>
|
||||
#include <com/sun/star/presentation/XPresentationPage.hpp>
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
#include <editeng/adjustitem.hxx>
|
||||
#include <editeng/outlobj.hxx>
|
||||
#include <editeng/editobj.hxx>
|
||||
#include <comphelper/base64.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
#include <undo/undomanager.hxx>
|
||||
#include <GraphicViewShell.hxx>
|
||||
#include <sdpage.hxx>
|
||||
#include <comphelper/base64.hxx>
|
||||
#include <LayerTabBar.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
#include <vcl/keycodes.hxx>
|
||||
|
@ -286,7 +287,8 @@ void SdMiscTest::testFillGradient()
|
|||
CPPUNIT_ASSERT(xPropSet2->getPropertyValue("FillGradient") >>= aGradient2);
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
const basegfx::BColorStops aColorStops(aGradient2.ColorStops);
|
||||
const basegfx::BColorStops aColorStops
|
||||
= model::gradient::getColorStopsFromUno(aGradient2.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -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,27 +534,10 @@ 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;
|
||||
|
||||
awt::Gradient2 aGradient = model::gradient::createUnoGradient2(aBGradient);
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_odfexport, \
|
|||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
docmodel \
|
||||
sal \
|
||||
sfx \
|
||||
subsequenttest \
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <vcl/filter/PDFiumLibrary.hxx>
|
||||
#include <comphelper/scopeguard.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
#include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call
|
||||
#include <unoprnms.hxx>
|
||||
|
@ -790,7 +791,7 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
|
|||
awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient");
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -804,7 +805,7 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
|
|||
aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient");
|
||||
|
||||
// MCGR: Use the completely imported gradient to check for correctness
|
||||
aColorStops = basegfx::BColorStops(aGradient.ColorStops);
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <oox/drawingml/drawingmltypes.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
class Test : public SwModelTestBase
|
||||
{
|
||||
|
@ -571,7 +572,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
|
|||
awt::Gradient2 aGradient(getProperty<awt::Gradient2>(xFrame, "FillGradient"));
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
@ -587,7 +588,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
|
|||
aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient");
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
aColorStops = basegfx::BColorStops(aGradient.ColorStops);
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <tools/UnitConversion.hxx>
|
||||
#include <basegfx/utils/gradienttools.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
using namespace css;
|
||||
|
||||
|
@ -622,7 +623,7 @@ DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
|
|||
const Color aColD(0x000000);
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
basegfx::BColorStops aColorStops(aGradient.ColorStops);
|
||||
basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
|
||||
|
@ -639,7 +640,7 @@ DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
|
|||
aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient");
|
||||
|
||||
// MCGR: Use the completely imported transparency gradient to check for correctness
|
||||
aColorStops = basegfx::BColorStops(aGradient.ColorStops);
|
||||
aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
|
||||
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
|
||||
|
|
|
@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport$(1), \
|
|||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
docmodel \
|
||||
i18nlangtag \
|
||||
sal \
|
||||
sfx \
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <xmloff/xmltoken.hxx>
|
||||
#include <xmloff/xmluconv.hxx>
|
||||
#include <basegfx/utils/bgradient.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::xmloff::token;
|
||||
|
@ -226,7 +227,7 @@ void XMLGradientStyleExport::exportXML(
|
|||
if (!rValue.has<css::awt::Gradient2>() && !rValue.has<css::awt::Gradient>())
|
||||
return;
|
||||
|
||||
basegfx::BGradient aGradient(rValue);
|
||||
basegfx::BGradient aGradient = model::gradient::getFromAny(rValue);
|
||||
|
||||
// Export of axial gradient to OOXML produces a symmetrical linear multi-color gradient. Import
|
||||
// does not regenerate it as 'axial' because that is not needed for MCGR. For export to ODF we
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <xmloff/xmlnamespace.hxx>
|
||||
#include <xmloff/xmltkmap.hxx>
|
||||
#include <xmloff/xmluconv.hxx>
|
||||
#include <docmodel/uno/UnoGradientTools.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
|
@ -178,7 +179,7 @@ void XMLTransGradientStyleExport::exportXML(
|
|||
if (!rValue.has<css::awt::Gradient2>() && !rValue.has<css::awt::Gradient>())
|
||||
return;
|
||||
|
||||
basegfx::BGradient aGradient(rValue);
|
||||
basegfx::BGradient aGradient = model::gradient::getFromAny(rValue);
|
||||
|
||||
aGradient.tryToConvertToAxial();
|
||||
|
||||
|
|
Loading…
Reference in a new issue