12#include <oox/token/tokens.hxx>
13#include <oox/token/namespaces.hxx>
16#include <document.hxx>
21using ::oox::core::ContextHandlerRef;
28::Color getColor(
const AttributeList& rAttribs, ThemeBuffer
const& rThemeBuffer)
30 if (rAttribs.hasAttribute(XML_rgb))
32 return ::Color(ColorAlpha, rAttribs.getIntegerHex(XML_rgb, sal_Int32(
API_RGB_TRANSPARENT)));
34 else if (rAttribs.hasAttribute(XML_theme))
36 sal_uInt32 nThemeIndex = rAttribs.getUnsigned(XML_theme, 0);
41 else if (nThemeIndex == 1)
43 else if (nThemeIndex == 2)
45 else if (nThemeIndex == 3)
48 ::Color aColor = rThemeBuffer.getColorByIndex(nThemeIndex);
49 double nTint = rAttribs.getDouble(XML_tint, 0.0);
60 const AttributeList& rAttribs, ThemeBuffer& rThemeBuffer)
64 case XLS14_TOKEN(colorSeries):
65 rAttributes.setColorSeries(getColor(rAttribs, rThemeBuffer));
67 case XLS14_TOKEN(colorNegative):
68 rAttributes.setColorNegative(getColor(rAttribs, rThemeBuffer));
70 case XLS14_TOKEN(colorAxis):
71 rAttributes.setColorAxis(getColor(rAttribs, rThemeBuffer));
73 case XLS14_TOKEN(colorMarkers):
74 rAttributes.setColorMarkers(getColor(rAttribs, rThemeBuffer));
76 case XLS14_TOKEN(colorFirst):
77 rAttributes.setColorFirst(getColor(rAttribs, rThemeBuffer));
79 case XLS14_TOKEN(colorLast):
80 rAttributes.setColorLast(getColor(rAttribs, rThemeBuffer));
82 case XLS14_TOKEN(colorHigh):
83 rAttributes.setColorHigh(getColor(rAttribs, rThemeBuffer));
85 case XLS14_TOKEN(colorLow):
86 rAttributes.setColorLow(getColor(rAttribs, rThemeBuffer));
95 if (rString == u
"column")
97 else if (rString == u
"stacked")
104 if (rString == u
"span")
106 else if (rString == u
"gap")
113 if (rString == u
"group")
115 else if (rString == u
"custom")
121 const AttributeList& rAttribs)
123 auto oManualMax = rAttribs.getDouble(XML_manualMax);
124 auto oManualMin = rAttribs.getDouble(XML_manualMin);
126 rSparklineAttributes.
setLineWeight(rAttribs.getDouble(XML_lineWeight, 0.75));
128 OUString
sType = rAttribs.getString(XML_type,
"line");
129 rSparklineAttributes.
setType(parseSparklineType(sType));
131 rSparklineAttributes.
setDateAxis(rAttribs.getBool(XML_dateAxis,
false));
133 OUString sDisplayEmptyCellsAs = rAttribs.getString(XML_displayEmptyCellsAs,
"zero");
136 rSparklineAttributes.
setMarkers(rAttribs.getBool(XML_markers,
false));
137 rSparklineAttributes.
setHigh(rAttribs.getBool(XML_high,
false));
138 rSparklineAttributes.
setLow(rAttribs.getBool(XML_low,
false));
139 rSparklineAttributes.
setFirst(rAttribs.getBool(XML_first,
false));
140 rSparklineAttributes.
setLast(rAttribs.getBool(XML_last,
false));
141 rSparklineAttributes.
setNegative(rAttribs.getBool(XML_negative,
false));
142 rSparklineAttributes.
setDisplayXAxis(rAttribs.getBool(XML_displayXAxis,
false));
143 rSparklineAttributes.
setDisplayHidden(rAttribs.getBool(XML_displayHidden,
false));
145 OUString sMinAxisType = rAttribs.getString(XML_minAxisType,
"individual");
148 OUString sMaxAxisType = rAttribs.getString(XML_maxAxisType,
"individual");
151 rSparklineAttributes.
setRightToLeft(rAttribs.getBool(XML_rightToLeft,
false));
171 case XLS14_TOKEN(sparklineGroup):
174 auto& rSparklineAttributes = rLastGroup.getSparklineGroup()->getAttributes();
175 addAttributesToSparklineAttributes(rSparklineAttributes, rAttribs);
178 rLastGroup.getSparklineGroup()->setID(aGuid);
181 case XLS14_TOKEN(colorSeries):
182 case XLS14_TOKEN(colorNegative):
183 case XLS14_TOKEN(colorAxis):
184 case XLS14_TOKEN(colorMarkers):
185 case XLS14_TOKEN(colorFirst):
186 case XLS14_TOKEN(colorLast):
187 case XLS14_TOKEN(colorHigh):
188 case XLS14_TOKEN(colorLow):
191 auto& rSparklineAttributes = rLastGroup.getSparklineGroup()->getAttributes();
192 addColorsToSparklineAttributes(rSparklineAttributes, nElement, rAttribs,
getTheme());
195 case XLS14_TOKEN(sparklines):
199 case XLS14_TOKEN(sparkline):
202 rLastGroup.getSparklines().emplace_back();
213 if (getCurrentElement() == XM_TOKEN(sqref) || getCurrentElement() == XM_TOKEN(f))
217 auto& rLastSparkline = rLastGroup.getSparklines().back();
224 if (getCurrentElement() == XM_TOKEN(sqref))
226 rLastSparkline.m_aTargetRange = aRange;
231 for (
auto& rRange : rLastSparkline.m_aTargetRange)
237 else if (getCurrentElement() == XM_TOKEN(f))
238 rLastSparkline.m_aInputRange = aRange;
246 if (getCurrentElement() == XLS14_TOKEN(sparklineGroup))
249 for (
Sparkline& rSparkline : rLastGroup.getSparklines())
262 if (rRange.aStart == rRange.aEnd)
265 auto* pCreated = rDocument.CreateSparkline(rRange.aStart, pSparklineGroup);
void ApplyTintOrShade(sal_Int16 n100thPercent)
static bool GetRangeListFromString(ScRangeList &rRangeList, std::u16string_view rRangeListStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator=' ', sal_Unicode cQuote='\'')
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Transitional sparkline group data.
const std::shared_ptr< sc::SparklineGroup > & getSparklineGroup()
void onStartElement(const AttributeList &rAttribs) override
void onEndElement() override
SparklineGroupsContext(WorksheetContextBase &rFragment)
std::vector< SparklineGroup > m_aSparklineGroups
void onCharacters(const OUString &rCharacters) override
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void insertSparkline(SparklineGroup &rSparklineGroup, Sparkline &rSparkline)
Transitional sparkline data.
ScRangeList m_aTargetRange
ScRangeList m_aInputRange
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
Context handler derived from the WorksheetHelper helper class.
ScDocument & getScDocument()
SCTAB getSheetIndex() const
Returns the index of the current sheet.
Common properties for a group of sparklines.
void setType(SparklineType eType)
void setDisplayHidden(bool bValue)
void setManualMax(std::optional< double > aValue)
void setMarkers(bool bValue)
void setMaxAxisType(AxisType eAxisType)
void setNegative(bool bValue)
void setDisplayEmptyCellsAs(DisplayEmptyCellsAs eValue)
AxisType getMaxAxisType() const
void setLast(bool bValue)
void setLineWeight(double nWeight)
void setRightToLeft(bool bValue)
AxisType getMinAxisType() const
void setMinAxisType(AxisType eAxisType)
void setManualMin(std::optional< double > aValue)
void setDisplayXAxis(bool bValue)
void setDateAxis(bool bValue)
void setHigh(bool bValue)
void setFirst(bool bValue)
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
SparklineType
Supported sparkline types.
DisplayEmptyCellsAs
Determines how to display the empty cells.
AxisType
The method of calculating the axis min or max value.