Loading...
Searching...
No Matches
OdsColorScale Class Reference

`#include <odscolorscale.h>`

## Public Member Functions

| OdsColorScale (const QString &cell_start_position, const QString &cell_stop_position)
| OdsColorScale (const OdsColorScale &other)
virtual | ~OdsColorScale ()
void | setCellRange (const QString &cell_start_position, const QString &cell_stop_position)
| set cell range to apply color scale
void | setMinimumColor (const QColor &minimum_color)
| set minimum color of the color scale
void | setMaximumColor (const QColor &maximum_color)
| set maximum color of the color scale

## Protected Member Functions

bool | isInSheet (const QString &sheet_name)
void | writeConditionalFormat (QXmlStreamWriter *p_writer)

## Private Member Functions

std::tuple< QString, QString > | parseCellRange (const QString &cell_position)

## Private Attributes

friend | ContentXml
QString | _sheet_name
QString | _cell_start_position
QString | _cell_stop_position
QColor | _minimum_color = QColor("#0000ff")
QColor | _maximum_color = QColor("#ff0000")
QColor | _percentile_color = QColor("#ffffff")

## Detailed Description

Definition at line 43 of file odscolorscale.h.

## Constructor & Destructor Documentation

## OdsColorScale() [1/2]

OdsColorScale::OdsColorScale | ( | const QString & | cell_start_position,
|  | const QString & | cell_stop_position )

Definition at line 41 of file odscolorscale.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< cell_start_position;
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< cell_stop_position;
setCellRange(cell_start_position, cell_stop_position);
}
OdsColorScale::setCellRange
void setCellRange(const QString &cell_start_position, const QString &cell_stop_position)
set cell range to apply color scale
Definition odscolorscale.cpp:183

References setCellRange().

Referenced by OdsColorScale().

## OdsColorScale() [2/2]

OdsColorScale::OdsColorScale | ( | const OdsColorScale & | other | ) |

Definition at line 52 of file odscolorscale.cpp.

{
_sheet_name = other._sheet_name;
_percentile_color = other._percentile_color;
_minimum_color = other._minimum_color;
_maximum_color = other._maximum_color;
_cell_start_position = other._cell_start_position;
_cell_stop_position = other._cell_stop_position;
}
OdsColorScale::_maximum_color
QColor _maximum_color
Definition odscolorscale.h:83
OdsColorScale::_sheet_name
QString _sheet_name
Definition odscolorscale.h:78
OdsColorScale::_cell_stop_position
QString _cell_stop_position
Definition odscolorscale.h:80
OdsColorScale::_cell_start_position
QString _cell_start_position
Definition odscolorscale.h:79
OdsColorScale::_percentile_color
QColor _percentile_color
Definition odscolorscale.h:84
OdsColorScale::_minimum_color
QColor _minimum_color
Definition odscolorscale.h:82

References OdsColorScale(), _cell_start_position, _cell_stop_position, _maximum_color, _minimum_color, _percentile_color, and _sheet_name.

## ~OdsColorScale()

OdsColorScale::~OdsColorScale | ( |  | ) |

virtual

Definition at line 62 of file odscolorscale.cpp.

{
}

## Member Function Documentation

## isInSheet()

bool OdsColorScale::isInSheet | ( | const QString & | sheet_name | ) |

protected

Definition at line 76 of file odscolorscale.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< sheet_name << " " << _sheet_name;
if(_sheet_name == sheet_name)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " OK";
return true;
}
return false;
}

References _sheet_name.

## parseCellRange()

std::tuple< QString, QString > OdsColorScale::parseCellRange | ( | const QString & | cell_position | ) |

private

Definition at line 154 of file odscolorscale.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
if(cell_position.isEmpty())
{
throw OdsException(
QObject::tr("error parsing cell range :\n empty cell position"));
}
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< cell_position;
QRegularExpression reg_exp("^(.*)\\.([A-Z]+[0-9]+)$");
QRegularExpressionMatch reg_exp_match = reg_exp.match(cell_position);
if(reg_exp_match.hasMatch())
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< cell_position;
return std::make_tuple(reg_exp_match.capturedTexts().at(1),
reg_exp_match.capturedTexts().at(2));
}
else
{
throw OdsException(
QObject::tr("error parsing cell range :\n cell_position %1 does not "
"contains pattern ^(.*).([A-Z]+[0-9]+)$")
.arg(cell_position));
}
}

Referenced by setCellRange().

## setCellRange()

void OdsColorScale::setCellRange | ( | const QString & | cell_start_position,
|  | const QString & | cell_stop_position )

set cell range to apply color scale

Parameters

  cell_start_position | cell position to start (Feuille1.C2)
  cell_stop_position | cell position to stop (Feuille1.D4)

Definition at line 183 of file odscolorscale.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
if(cell_start_position.isEmpty() && cell_stop_position.isEmpty())
return; // this is not an ods doc writer
QString sheet_name;
std::tie(sheet_name, _cell_start_position) =
parseCellRange(cell_start_position);
_sheet_name = sheet_name;
std::tie(sheet_name, _cell_stop_position) =
parseCellRange(cell_stop_position);
//"Feuille1.C2:Feuille1.D4"
if(sheet_name != _sheet_name)
{
throw OdsException(
QObject::tr("error in OdsColorScale::setCellRange :\n start %1 and "
"stop %2 are not on the same sheet")
.arg(cell_start_position)
.arg(cell_stop_position));
}
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
OdsColorScale::parseCellRange
std::tuple< QString, QString > parseCellRange(const QString &cell_position)
Definition odscolorscale.cpp:154

References _cell_start_position, _cell_stop_position, _sheet_name, and parseCellRange().

Referenced by OdsColorScale().

## setMaximumColor()

void OdsColorScale::setMaximumColor | ( | const QColor & | maximum_color | ) |

set maximum color of the color scale

Parameters

  maximum_color | maximum color

Definition at line 213 of file odscolorscale.cpp.

{
_maximum_color = maximum_color;
}

References _maximum_color.

## setMinimumColor()

void OdsColorScale::setMinimumColor | ( | const QColor & | minimum_color | ) |

set minimum color of the color scale

Parameters

  minimum_color | minimum color

Definition at line 208 of file odscolorscale.cpp.

{
_minimum_color = minimum_color;
}

References _minimum_color.

## writeConditionalFormat()

void OdsColorScale::writeConditionalFormat | ( | QXmlStreamWriter * | p_writer | ) |

protected

Definition at line 88 of file odscolorscale.cpp.

{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
QString sheet_name = _sheet_name;
if(sheet_name.contains(" "))
{
sheet_name = QString("&apos;%1&apos;").arg(sheet_name);
}
//<calcext:conditional-format
//calcext:target-range-address="Feuille1.C2:Feuille1.D4">
p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"conditional-format");
p_writer->device()->write(
QString(" calcext:target-range-address=\"%1.%2:%1.%3\" ")
.arg(sheet_name)
.arg(_cell_start_position)
.arg(_cell_stop_position)
.toUtf8());
// p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"),
// "target-range-address",QString("%1:%2").arg(cell_start_position).arg(cell_stop_position));
//<calcext:color-scale>
p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"color-scale");
//<calcext:color-scale-entry calcext:value="0" calcext:type="minimum"
//calcext:color="#ff0000"/>
p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"color-scale-entry");
p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "0");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "type", "minimum");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "color", _minimum_color.name());
p_writer->writeEndElement();
//<calcext:color-scale-entry calcext:value="50" calcext:type="percentile"
//calcext:color="#ffffff"/>
p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"color-scale-entry");
p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "50");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "type", "percentile");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "color", _percentile_color.name());
p_writer->writeEndElement();
//<calcext:color-scale-entry calcext:value="0" calcext:type="maximum"
//calcext:color="#0000ff"/>
p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
"color-scale-entry");
p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "0");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "type", "maximum");
p_writer->writeAttribute(
MetaXml::getNamespaceURI("calcext"), "color", _maximum_color.name());
p_writer->writeEndElement();
//</calcext:color-scale>
p_writer->writeEndElement();
//</calcext:conditional-format>
p_writer->writeEndElement();
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
MetaXml::getNamespaceURI
static const QString & getNamespaceURI(const QString &xml_namespace)
Definition metaxml.cpp:32

References _cell_start_position, _cell_stop_position, _maximum_color, _minimum_color, _percentile_color, _sheet_name, and MetaXml::getNamespaceURI().

## Member Data Documentation

## _cell_start_position

QString OdsColorScale::_cell_start_position

private

Definition at line 79 of file odscolorscale.h.

Referenced by OdsColorScale(), setCellRange(), and writeConditionalFormat().

## _cell_stop_position

QString OdsColorScale::_cell_stop_position

private

Definition at line 80 of file odscolorscale.h.

Referenced by OdsColorScale(), setCellRange(), and writeConditionalFormat().

## _maximum_color

QColor OdsColorScale::_maximum_color = QColor("#ff0000")

private

Definition at line 83 of file odscolorscale.h.

Referenced by OdsColorScale(), setMaximumColor(), and writeConditionalFormat().

## _minimum_color

QColor OdsColorScale::_minimum_color = QColor("#0000ff")

private

Definition at line 82 of file odscolorscale.h.

Referenced by OdsColorScale(), setMinimumColor(), and writeConditionalFormat().

## _percentile_color

QColor OdsColorScale::_percentile_color = QColor("#ffffff")

private

Definition at line 84 of file odscolorscale.h.

Referenced by OdsColorScale(), and writeConditionalFormat().

## _sheet_name

QString OdsColorScale::_sheet_name

private

Definition at line 78 of file odscolorscale.h.

Referenced by OdsColorScale(), isInSheet(), setCellRange(), and writeConditionalFormat().

## ContentXml

friend OdsColorScale::ContentXml

private

Definition at line 45 of file odscolorscale.h.

The documentation for this class was generated from the following files:

- odsstream/writer/options/odscolorscale.h
- odsstream/writer/options/odscolorscale.cpp