22#include <com/sun/star/awt/Gradient2.hpp>
25#include <rtl/ustrbuf.hxx>
26#include <rtl/ustring.hxx>
61 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
65 OUString aDisplayName;
67 awt::Gradient2 aGradient;
68 aGradient.Style = css::awt::GradientStyle_LINEAR;
69 aGradient.StartColor = 0;
70 aGradient.EndColor = 0;
73 aGradient.XOffset = 0;
74 aGradient.YOffset = 0;
75 aGradient.StartIntensity = 100;
76 aGradient.EndIntensity = 100;
77 aGradient.StepCount = 0;
81 sal_Int32 nTmpValue(0);
83 switch( aIter.getToken() )
86 rStrName = aIter.toString();
89 aDisplayName = aIter.toString();
96 aGradient.XOffset =
static_cast< sal_Int16
>( nTmpValue );
100 aGradient.YOffset =
static_cast< sal_Int16
>( nTmpValue );
110 aGradient.StartIntensity =
static_cast< sal_Int16
>( nTmpValue );
114 aGradient.EndIntensity =
static_cast< sal_Int16
>( nTmpValue );
119 bool const bSuccess =
122 (cmp12 < 0) || (cmp12 == 0
123 && (
m_rImport.isGeneratorVersionOlderThan(SvXMLImport::AOO_4x, SvXMLImport::LO_7x)
125 ||
m_rImport.getGeneratorVersion() == SvXMLImport::AOO_4x)));
126 SAL_INFO_IF(!bSuccess,
"xmloff.style",
"failed to import draw:angle");
131 aGradient.Border =
static_cast< sal_Int16
>( nTmpValue );
139 rValue <<= aGradient;
141 if( !aDisplayName.isEmpty() )
145 rStrName = aDisplayName;
150 SvXMLImport& rImport, sal_Int32 nElement,
151 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
152 std::vector<awt::ColorStop>& rColorStopVec)
158 double fOffset = -1.0;
160 OUString sColorValue;
164 switch(aIter.getToken())
172 sColorValue = aIter.toString();
173 if (sColorValue.isEmpty())
177 sColorType = aIter.toString();
178 if (sColorType.isEmpty())
187 if (sColorType !=
u"rgb")
196 css::rendering::RGBColor aRGBColor;
197 aRGBColor.Red = aColor.
GetRed() / 255.0;
198 aRGBColor.Green = aColor.
GetGreen() / 255.0;
199 aRGBColor.Blue = aColor.
GetBlue() / 255.0;
201 awt::ColorStop aColorStop;
202 aColorStop.StopOffset = fOffset;
203 aColorStop.StopColor = aRGBColor;
204 rColorStopVec.push_back(aColorStop);
220 const OUString& rStrName,
223 if( rStrName.isEmpty() )
226 if (!rValue.has<css::awt::Gradient2>() && !rValue.has<css::awt::Gradient>())
255 bool bEncoded =
false;
263 aStrValue = aOut.makeStringAndClear();
271 aStrValue = aOut.makeStringAndClear();
274 aStrValue = aOut.makeStringAndClear();
284 aStartColor = aGradient.
GetColorStops().front().getStopColor();
290 aStrValue = aOut.makeStringAndClear();
295 aStrValue = aOut.makeStringAndClear();
300 aStrValue = aOut.makeStringAndClear();
305 aStrValue = aOut.makeStringAndClear();
312 aStrValue = aOut.makeStringAndClear();
318 aStrValue = aOut.makeStringAndClear();
333 double fPreviousOffset = 0.0;
337 double fOffset = std::clamp<double>(aCandidate.getStopOffset(), 0.0, 1.0);
338 if (fOffset < fPreviousOffset)
339 fOffset = fPreviousOffset;
341 fPreviousOffset = fOffset;
348 ::Color aToolsColor(std::clamp<sal_uInt8>(std::round(aDecimalColor.
getRed() * 255.0), 0, 255),
349 std::clamp<sal_uInt8>(std::round(aDecimalColor.
getGreen() * 255.0), 0, 255),
350 std::clamp<sal_uInt8>(std::round(aDecimalColor.
getBlue() * 255.0), 0, 255));
SvXMLEnumMapEntry< awt::GradientStyle > const pXML_GradientStyle_Enum[]
const SvXMLImport & m_rImport
sal_uInt8 GetBlue() const
OUString AsRGBHexString() const
sal_uInt8 GetGreen() const
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
This class deliberately does not support XWeak, to improve performance when loading large documents.
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
virtual ~XMLGradientStopContext() override
XMLGradientStopContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, std::vector< css::awt::ColorStop > &rColorStopVec)
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
XMLGradientStyleExport(SvXMLExport &rExport)
XMLGradientStyleImport(SvXMLImport &rImport)
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
void tryToRecreateBorder(basegfx::BColorStops *pAssociatedTransparencyStops=nullptr)
sal_uInt16 GetBorder() const
sal_uInt16 GetStartIntens() const
sal_uInt16 GetXOffset() const
const basegfx::BColorStops & GetColorStops() const
sal_uInt16 GetEndIntens() const
void tryToConvertToAxial()
Degree10 GetAngle() const
css::awt::GradientStyle GetGradientStyle() const
sal_uInt16 GetYOffset() const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
static void convertAngle(OUStringBuffer &rBuffer, sal_Int16 nAngle, SvtSaveOptions::ODFSaneDefaultVersion nVersion)
constexpr OUStringLiteral ODFVER_012_TEXT
#define SAL_INFO_IF(condition, area, stream)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_GRADIENTSTYLE_ELLIPSOID
@ XML_GRADIENTSTYLE_AXIAL
@ XML_GRADIENTSTYLE_SQUARE
@ XML_GRADIENTSTYLE_RECTANGULAR
@ XML_GRADIENTSTYLE_RADIAL
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT