22#include <com/sun/star/awt/Gradient2.hpp>
26#include <rtl/ustrbuf.hxx>
27#include <rtl/ustring.hxx>
62 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
66 OUString aDisplayName;
68 awt::Gradient2 aGradient;
69 aGradient.XOffset = 0;
70 aGradient.YOffset = 0;
71 aGradient.StartIntensity = 100;
72 aGradient.EndIntensity = 100;
80 switch( aIter.getToken() )
84 rStrName = aIter.toString();
89 aDisplayName = aIter.toString();
99 aGradient.XOffset = sal::static_int_cast< sal_Int16 >(nTmpValue);
103 aGradient.YOffset = sal::static_int_cast< sal_Int16 >(nTmpValue);
107 sal_Int32 aStartTransparency;
110 sal_uInt8 n = sal::static_int_cast< sal_uInt8 >(
111 ( (100 - aStartTransparency) * 255 ) / 100 );
114 aGradient.StartColor =
static_cast<sal_Int32
>( aColor );
119 sal_Int32 aEndTransparency;
122 sal_uInt8 n = sal::static_int_cast< sal_uInt8 >(
123 ( (100 - aEndTransparency) * 255 ) / 100 );
126 aGradient.EndColor =
static_cast<sal_Int32
>( aColor );
132 bool const bSuccess =
135 (cmp12 < 0) || (cmp12 == 0
136 && (
rImport.isGeneratorVersionOlderThan(SvXMLImport::AOO_4x, SvXMLImport::LO_7x)
138 ||
rImport.getGeneratorVersion() == SvXMLImport::AOO_4x)));
139 SAL_INFO_IF(!bSuccess,
"xmloff.style",
"failed to import draw:angle");
144 aGradient.Border = sal::static_int_cast< sal_Int16 >(nTmpValue);
152 rValue <<= aGradient;
154 if( !aDisplayName.isEmpty() )
158 rStrName = aDisplayName;
170 const OUString& rStrName,
176 if( rStrName.isEmpty() )
178 if (!rValue.has<css::awt::Gradient2>() && !rValue.has<css::awt::Gradient>())
196 bool bEncoded =
false;
204 aStrValue = aOut.makeStringAndClear();
212 aStrValue = aOut.makeStringAndClear();
216 aStrValue = aOut.makeStringAndClear();
222 double fOpacityStartPerc = 100.0;
223 double fOpacityEndPerc = 100.0;
227 = (1.0 - aGradient.
GetColorStops().front().getStopColor().getRed()) * 100.0;
228 fOpacityEndPerc = (1.0 - aGradient.
GetColorStops().back().getStopColor().getRed()) * 100.0;
233 aStrValue = aOut.makeStringAndClear();
238 aStrValue = aOut.makeStringAndClear();
246 aStrValue = aOut.makeStringAndClear();
252 aStrValue = aOut.makeStringAndClear();
265 double fPreviousOffset = 0.0;
269 double fOffset = std::clamp<double>(aCandidate.getStopOffset(), 0.0, 1.0);
270 if (fOffset < fPreviousOffset)
271 fOffset = fPreviousOffset;
273 fPreviousOffset = fOffset;
276 double fOpacity = std::clamp<double>(1.0 - aCandidate.getStopColor().getRed(), 0.0, 1.0);
SvXMLEnumMapEntry< awt::GradientStyle > const pXML_GradientStyle_Enum[]
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
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...
void exportXML(const OUString &rStrName, const css::uno::Any &rValue)
XMLTransGradientStyleExport(SvXMLExport &rExport)
void importXML(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Any &rValue, OUString &rStrName)
XMLTransGradientStyleImport(SvXMLImport &rImport)
void tryToRecreateBorder(basegfx::BColorStops *pAssociatedTransparencyStops=nullptr)
sal_uInt16 GetBorder() const
sal_uInt16 GetXOffset() const
const basegfx::BColorStops & GetColorStops() const
void tryToConvertToAxial()
Degree10 GetAngle() const
css::awt::GradientStyle GetGradientStyle() const
sal_uInt16 GetYOffset() const
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
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
UNDERLYING_TYPE get() const
#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