How to add color scales to ODF?

Michael Stahl mstahl at redhat.com
Thu May 10 02:46:49 PDT 2012


On 10/05/12 03:02, Markus Mohrhard wrote:
> Hey,
> 
> I just reached a state where I can think about adding support for
> color scales into ODF. Normally this would not be such a big deal but
> for color scales we face several problems.
> 
> Color scales are a form of conditional formatting but our current
> conditional formatting system is based on styles where color scales (
> and data bars ) don't fit in. The problem is now that conditional
> formatting is part of the styles in ODF and applied to a cell through
> a style. I have the same problem internally but there I was able to
> circumvent that problem till now by implementing a own set of data
> structures for color scales.
> 
> The current structure of a conditional format in ods looks like:
> 
> <style:style style:name="ce1" style:family="table-cell"
> style:parent-style-name="Default">
>   <style:map style:condition="cell-content()=1"
> style:apply-style-name="Untitled1"
> style:base-cell-address="Sheet1.D5"/>
>   <style:map style:condition="cell-content()<0"
> style:apply-style-name="Untitled2"
> style:base-cell-address="Sheet1.D5"/>
>   <style:map style:condition="cell-content-is-between(2,3)"
> style:apply-style-name="Untitled3"
> style:base-cell-address="Sheet1.D5"/>
> </style:style>
> 
> Now we have color scales which are no longer bound to styles because
> they calculate the correct formatting information based on the value
> of the cell. I would not want to add them to the existing style based
> system because they don't fit into there. We will need to add
> different conditions for them and different ways to represent them.
> 
> In OOXML normal conditional formats are represented in the
> [sheetx].xml file and refer to formatting changes in the styles
> section. Color scales however are represented in the same structure
> but contain all their information as sub elements. The structure of
> the attached test file is:
> 
> <conditionalFormatting sqref="C2:D5">
>   <cfRule type="colorScale" priority="1">
>     <colorScale>
>       <cfvo type="num" val="0"/>
>       <cfvo type="num" val="10"/>
>       <color rgb="FF63BE7B"/>
>       <color rgb="FFFFEF9C"/>
>     </colorScale>
>   </cfRule>
> </conditionalFormatting>
> 
> I'm open for suggestions how I can add this sanely to ods. I would
> like to support as much from MSO 2010's color scale feature as
> possible but have no idea yet what I can achieve in the remaining 4
> weeks.

i wonder how exactly this works... some vague ideas:

does it interpolate based on the cell value from the minimum in a range
where the style is applied to a maximum?

<style:style style:name="ce1" style:family="table-cell">
  <style:map style:color-scale-minimum="FFFFFF"/>
  <style:map style:color-scale-maximum="000000"/>
</style:style>

or rather not reuse style:map which wants to map to other styles, how
about this:

<style:style style:name="ce1" style:family="table-cell">
  <style:color-scale style:color-scale-minimum="FFFFFF"
style:color-scale-maximum="000000"/>
</style:style>

or can you set some specific values and it interpolates beyond those as
well?

<style:style style:name="ce1" style:family="table-cell">
  <style:color-scale style:color-scale-minimum="CCCCCC"
style:color-scale-minimum-value="3" style:color-scale-maximum="444444"
style:color-scale-maximum-value="42"/>
</style:style>

but probably i have missed something



More information about the LibreOffice mailing list