[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice
From: Sebastian Sauer <mail () dipe ! org>
Date: 2010-01-07 17:35:42
Message-ID: 1262885742.574867.19143.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1071179 by sebsauer:
Eval also style:map's that are located in the styles.xml.
M +1 -1 kspread/Cell.cpp
M +36 -53 kspread/Condition.cpp
M +2 -2 kspread/Condition.h
M +10 -2 kspread/Style.cpp
M +1 -1 kspread/Style.h
M +4 -5 kspread/dialogs/ConditionalDialog.cpp
M +1 -1 kspread/dialogs/ConditionalDialog.h
M +1 -1 kspread/ui/CellView.cpp
M +21 -3 libs/odf/KoOdfNumberStyles.cpp
M +1 -0 libs/odf/KoOdfNumberStyles.h
--- trunk/koffice/kspread/Cell.cpp #1071178:1071179
@@ -321,7 +321,7 @@
{
Style style = sheet()->cellStorage()->style(d->column, d->row);
// use conditional formatting attributes
- if (Style* conditialStyle = conditions().testConditions(*this))
+ if (Style* conditialStyle = conditions().testConditions(*this, \
sheet()->map()->styleManager())) style.merge(*conditialStyle);
return style;
}
--- trunk/koffice/kspread/Condition.cpp #1071178:1071179
@@ -52,7 +52,6 @@
, colorcond(0)
, fontcond(0)
, styleName(0)
- , style(0)
, cond(None)
{
}
@@ -75,7 +74,6 @@
colorcond = o.colorcond ? new QColor(*o.colorcond) : 0;
val1 = o.val1;
val2 = o.val2;
- style = o.style;
cond = o.cond;
}
@@ -93,7 +91,6 @@
colorcond = o.colorcond ? new QColor(*o.colorcond) : 0;
val1 = o.val1;
val2 = o.val2;
- style = o.style;
cond = o.cond;
return *this;
@@ -101,18 +98,14 @@
bool Conditional::operator==(const Conditional& other) const
{
- if (cond == other.cond &&
+ return (cond == other.cond &&
val1 == other.val1 &&
val2 == other.val2 &&
(strVal1 && other.strVal1) ? (*strVal1 == *other.strVal1) : (strVal1 == \
other.strVal1) &&
(strVal2 && other.strVal2) ? (*strVal2 == *other.strVal2) : (strVal2 == \
other.strVal2) &&
(colorcond && other.strVal2) ? (*colorcond == *other.colorcond) : \
(colorcond == other.colorcond) &&
(fontcond && other.fontcond) ? (*fontcond == *other.fontcond) : \
(fontcond == other.fontcond) &&
- (styleName && other.styleName) ? (*styleName == *other.styleName) : \
(styleName == other.styleName) &&
- (style && other.style) ? (*style == *other.style) : (style == \
other.style)) {
- return true;
- }
- return false;
+ (styleName && other.styleName) ? (*styleName == *other.styleName) : \
(styleName == other.styleName) ); }
@@ -147,11 +140,11 @@
return d->conditionList.isEmpty();
}
-Style* Conditions::testConditions(const Cell& cell) const
+Style* Conditions::testConditions(const Cell& cell, const StyleManager* \
styleManager) const {
Conditional condition;
- if (currentCondition(cell, condition))
- return condition.style;
+ if (currentCondition(cell, condition) && condition.styleName)
+ return styleManager->style(*condition.styleName);
else
return 0;
}
@@ -168,12 +161,6 @@
for (it = d->conditionList.begin(); it != d->conditionList.end(); ++it) {
condition = *it;
-// if ( (*it).styleName )
-// kDebug()<<"*it :"<< *( ( *it ).styleName );
- //
-// kDebug()<<"*it style :"<<( *it ).style;
-
-
if (condition.strVal1 && cell.value().isNumber())
continue;
@@ -428,32 +415,30 @@
}
}
+void Conditions::loadOdfConditions(const StyleManager* styleManager, const QString \
&conditionValue, const QString &applyStyleName) +{
+ kDebug(36003) << "\tcondition:" << conditionValue;
+ Conditional newCondition;
+ loadOdfConditionValue(conditionValue, newCondition);
+ if (!applyStyleName.isNull()) {
+ kDebug(36003) << "\tstyle:" << applyStyleName;
+ newCondition.styleName = new QString(applyStyleName);
+ }
+ d->conditionList.append(newCondition);
+}
+
void Conditions::loadOdfConditions(const StyleManager* styleManager, const \
KoXmlElement & element) {
kDebug(36003) << "Loading conditional styles";
KoXmlNode node(element);
-
while (!node.isNull()) {
KoXmlElement elementItem = node.toElement();
if (elementItem.tagName() == "map" && elementItem.namespaceURI() == \
KoXmlNS::style) {
- bool ok = true;
- kDebug(36003) << "\tcondition:" << \
elementItem.attributeNS(KoXmlNS::style, "condition", QString());
- Conditional newCondition;
- loadOdfConditionValue(elementItem.attributeNS(KoXmlNS::style, \
"condition", QString()), newCondition);
- if (elementItem.hasAttributeNS(KoXmlNS::style, "apply-style-name")) {
- kDebug(36003) << "\tstyle:" << \
elementItem.attributeNS(KoXmlNS::style, "apply-style-name", \
QString());
- newCondition.styleName = new \
QString(elementItem.attributeNS(KoXmlNS::style, "apply-style-name", \
QString()));
- newCondition.style = styleManager->style(*newCondition.styleName);
- if (!newCondition.style)
- ok = false;
- else
- ok = true;
- }
-
- if (ok)
- d->conditionList.append(newCondition);
- else
- kDebug(36003) << "Error loading condition" << \
elementItem.nodeName(); + QString conditionValue = \
elementItem.attributeNS(KoXmlNS::style, "condition", QString()); + QString \
applyStyleName; + if (elementItem.hasAttributeNS(KoXmlNS::style, \
"apply-style-name")) + applyStyleName = \
elementItem.attributeNS(KoXmlNS::style, "apply-style-name", QString()); + \
loadOdfConditions(styleManager, conditionValue, applyStyleName); }
node = node.nextSibling();
}
@@ -466,6 +451,11 @@
val = val.remove("cell-content()");
loadOdfCondition(val, newCondition);
}
+ else if (val.contains("value()")) {
+ val = val.remove("value()");
+ loadOdfCondition(val, newCondition);
+ }
+
//GetFunction ::= cell-content-is-between(Value, Value) | \
cell-content-is-not-between(Value, Value)
//for the moment we support just int/double value, not text/date/time :(
if (val.contains("cell-content-is-between(")) {
@@ -475,14 +465,13 @@
loadOdfValidationValue(listVal, newCondition);
newCondition.cond = Conditional::Between;
}
- if (val.contains("cell-content-is-not-between(")) {
+ else if (val.contains("cell-content-is-not-between(")) {
val = val.remove("cell-content-is-not-between(");
val = val.remove(')');
QStringList listVal = val.split(',', QString::SkipEmptyParts);
loadOdfValidationValue(listVal, newCondition);
newCondition.cond = Conditional::Different;
}
-
}
void Conditions::loadOdfCondition(QString &valExpression, Conditional &newCondition)
@@ -548,7 +537,6 @@
void Conditions::loadConditions(const StyleManager* styleManager, const KoXmlElement \
& element) {
Conditional newCondition;
- bool ok;
KoXmlElement conditionElement;
forEachElement(conditionElement, element) {
@@ -558,12 +546,14 @@
newCondition.fontcond = 0;
newCondition.colorcond = 0;
- ok = conditionElement.hasAttribute("cond");
+ if (!conditionElement.hasAttribute("cond"))
+ continue;
+
+ bool ok = true;
+ newCondition.cond = (Conditional::Type) \
conditionElement.attribute("cond").toInt(&ok); + if(!ok)
+ continue;
- if (ok)
- newCondition.cond = (Conditional::Type) \
conditionElement.attribute("cond").toInt(&ok);
- else continue;
-
if (conditionElement.hasAttribute("val1")) {
newCondition.val1 = conditionElement.attribute("val1").toDouble(&ok);
@@ -590,16 +580,9 @@
if (conditionElement.hasAttribute("style")) {
newCondition.styleName = new \
QString(conditionElement.attribute("style"));
- newCondition.style = styleManager->style(*newCondition.styleName);
- if (!newCondition.style)
- ok = false;
}
- if (ok) {
- d->conditionList.append(newCondition);
- } else {
- kDebug(36001) << "Error loading condition" << \
conditionElement.nodeName();
- }
+ d->conditionList.append(newCondition);
}
}
--- trunk/koffice/kspread/Condition.h #1071178:1071179
@@ -60,7 +60,6 @@
QColor * colorcond;
QFont * fontcond;
QString * styleName;
- Style * style;
Type cond;
Conditional();
@@ -104,7 +103,7 @@
/**
* \return the style that matches first (or 0 if no condition matches)
*/
- Style* testConditions(const Cell& cell) const;
+ Style* testConditions(const Cell& cell, const StyleManager* styleManager) const;
/**
* Retrieve the current list of conditions we're checking
@@ -135,6 +134,7 @@
* Loads the condtional formattings.
*/
void loadOdfConditions(const StyleManager* styleManager, const KoXmlElement & \
element); + void loadOdfConditions(const StyleManager* styleManager, const QString \
&conditionValue, const QString &applyStyleName);
/**
* \ingroup OpenDocument
--- trunk/koffice/kspread/Style.cpp #1071178:1071179
@@ -216,16 +216,24 @@
conditions.loadOdfConditions(styleManager, e);
}
- loadOdfDataStyle(stylesReader, element);
+ loadOdfDataStyle(stylesReader, element, conditions, styleManager);
}
-void Style::loadOdfDataStyle(KoOdfStylesReader& stylesReader, const KoXmlElement& \
element) +typedef QPair<QString,QString> StringPair;
+
+void Style::loadOdfDataStyle(KoOdfStylesReader& stylesReader, const KoXmlElement& \
element, Conditions& conditions, const StyleManager* styleManager) {
QString str;
if (element.hasAttributeNS(KoXmlNS::style, "data-style-name")) {
const QString styleName = element.attributeNS(KoXmlNS::style, \
"data-style-name", QString()); if (stylesReader.dataFormats().contains(styleName)) {
const KoOdfNumberStyles::NumericStyleFormat dataStyle = \
stylesReader.dataFormats()[styleName]; + QList<QPair<QString,QString> > \
styleMaps = dataStyle.styleMaps; + if(styleMaps.count() > 0) {
+ const KoOdfNumberStyles::NumericStyleFormat ds = dataStyle;
+ foreach(StringPair p, styleMaps)
+ conditions.loadOdfConditions(styleManager, p.first, p.second);
+ }
QString tmp = dataStyle.prefix;
if (!tmp.isEmpty()) {
--- trunk/koffice/kspread/Style.h #1071178:1071179
@@ -233,7 +233,7 @@
void saveOdfStyle(const QSet<Key>& subStyles, KoGenStyle &style,
KoGenStyles &mainStyles, const StyleManager* manager) const;
- void loadOdfDataStyle(KoOdfStylesReader& stylesReader, const KoXmlElement& \
element); + void loadOdfDataStyle(KoOdfStylesReader& stylesReader, const \
KoXmlElement& element, Conditions& conditions, const StyleManager* \
styleManager);
void loadOdfParagraphProperties(KoOdfStylesReader& stylesReader, const \
KoStyleStack& element);
void loadOdfTableCellProperties(KoOdfStylesReader& stylesReader, const \
KoStyleStack& element);
void loadOdfTextProperties(KoOdfStylesReader& stylesReader, const KoStyleStack& \
element);
--- trunk/koffice/kspread/dialogs/ConditionalDialog.cpp #1071178:1071179
@@ -552,7 +552,7 @@
bool ConditionalDialog::getCondition(Conditional & newCondition, const KComboBox * \
cb,
const KLineEdit * edit1, const KLineEdit * \
edit2,
- const KComboBox * sb, Style * style)
+ const KComboBox * sb)
{
if (!cb->isEnabled())
return false;
@@ -588,7 +588,6 @@
newCondition.fontcond = 0;
newCondition.colorcond = 0;
newCondition.styleName = sn;
- newCondition.style = style;
return true;
}
@@ -609,15 +608,15 @@
Conditional newCondition;
if (getCondition(newCondition, m_dlg->m_condition_1, m_dlg->m_firstValue_1,
- m_dlg->m_secondValue_1, m_dlg->m_style_1, \
manager->style(m_dlg->m_style_1->currentText()))) + \
m_dlg->m_secondValue_1, m_dlg->m_style_1)) newList.append(newCondition);
if (getCondition(newCondition, m_dlg->m_condition_2, m_dlg->m_firstValue_2,
- m_dlg->m_secondValue_2, m_dlg->m_style_2, \
manager->style(m_dlg->m_style_2->currentText()))) + \
m_dlg->m_secondValue_2, m_dlg->m_style_2)) newList.append(newCondition);
if (getCondition(newCondition, m_dlg->m_condition_3, m_dlg->m_firstValue_3,
- m_dlg->m_secondValue_3, m_dlg->m_style_3, \
manager->style(m_dlg->m_style_3->currentText()))) + \
m_dlg->m_secondValue_3, m_dlg->m_style_3)) newList.append(newCondition);
kDebug() << "Setting conditional list";
--- trunk/koffice/kspread/dialogs/ConditionalDialog.h #1071178:1071179
@@ -91,7 +91,7 @@
bool checkInputData();
bool getCondition(Conditional & newCondition, const KComboBox * cb,
const KLineEdit * edit1, const KLineEdit * edit2,
- const KComboBox * sb, Style * style);
+ const KComboBox * sb);
};
--- trunk/koffice/kspread/ui/CellView.cpp #1071178:1071179
@@ -171,7 +171,7 @@
// use conditional formatting attributes
Conditions conditions = cell.conditions();
- if (Style* style = conditions.testConditions(cell))
+ if (Style* style = conditions.testConditions(cell, \
sheetView->sheet()->map()->styleManager())) d->style.merge(*style);
}
--- trunk/koffice/libs/odf/KoOdfNumberStyles.cpp #1071178:1071179
@@ -234,10 +234,28 @@
format += '?';
}
}
- // Not needed:
- // <style:map style:condition="value()>=0" \
style:apply-style-name="N106P0"/>
- // we handle painting negative numbers in red differently
+ // stylesmap's are embedded into a style and are pointing to another style \
that + // should be used insteat ot this style if the defined condition is \
true. E.g.; + // <number:number-style style:name="N139P0" \
style:volatile="true"/> + // <number:number-style style:name="N139P1" \
style:volatile="true"/> + // <number:number-style style:name="N139P2" \
style:volatile="true"/> + // <number:text-style style:name="N139">
+ // <style:map style:condition="value()>0" \
style:apply-style-name="N139P0"/> + // <style:map \
style:condition="value()<0" style:apply-style-name="N139P1"/> + // \
<style:map style:condition="value()=0" style:apply-style-name="N139P2"/> + // \
</number:text-style> + for (KoXmlNode node(e); !node.isNull(); node = \
node.nextSibling()) { + KoXmlElement elem = node.toElement();
+ if (elem.namespaceURI() == KoXmlNS::style && elem.localName() == "map") \
{ + QString condition, applyStyleName;
+ if (elem.hasAttributeNS(KoXmlNS::style, "condition"))
+ condition = elem.attributeNS(KoXmlNS::style, "condition");
+ if (elem.hasAttributeNS(KoXmlNS::style, "apply-style-name"))
+ applyStyleName = elem.attributeNS(KoXmlNS::style, \
"apply-style-name"); + dataStyle.styleMaps.append( \
QPair<QString,QString>(condition,applyStyleName) ); + }
+ }
}
const QString styleName = parent.attributeNS(KoXmlNS::style, "name", QString());
--- trunk/koffice/libs/odf/KoOdfNumberStyles.h #1071178:1071179
@@ -56,6 +56,7 @@
Format type;
int precision;
QString currencySymbol;
+ QList<QPair<QString,QString> > styleMaps; // conditional formatting, \
first=condition, second=applyStyleName };
static QPair<QString, NumericStyleFormat> loadOdfNumberStyle(const KoXmlElement& \
parent);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic