Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[calligra] Fix issues with formatting of currency values. Fixes JB#47521
Fix conditional styles begin incorrectly identified as being equal and grouped together. Fix internal currency formatting and spreadsheet defined cell formatting both being applied to a cell leading to duplicate currency symbols. Fix the xlsx style format parsing skipping the number format information if it follows the currency symbol leading to cells only showing the symbol and no numbers.
- Loading branch information
Showing
4 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
From dd5370f0e37bb4a481d433cff915c9e282b0d218 Mon Sep 17 00:00:00 2001 | ||
From: Andrew den Exter <andrew.den.exter@qinetic.com.au> | ||
Date: Mon, 14 Oct 2019 06:54:40 +0000 | ||
Subject: [PATCH 1/3] Fix incorrect conditional styling of spreadsheet cells. | ||
|
||
Include the conditions default style when comparing equality and | ||
calculating the hash to reduce instances of false equivalency. | ||
|
||
Then remove the QMap index cache since sorting on a hash an item may | ||
still produce unstable results in the somewhat unlikely case of a hash | ||
collision and it's going to take a lot of items before building and | ||
searching the map starts to be less expensive than a linear scan. | ||
--- | ||
sheets/Condition.cpp | 4 +++- | ||
sheets/RectStorage.h | 6 +----- | ||
2 files changed, 4 insertions(+), 6 deletions(-) | ||
|
||
diff --git a/sheets/Condition.cpp b/sheets/Condition.cpp | ||
index f01f0e1..c1cf7f5 100644 | ||
--- a/sheets/Condition.cpp | ||
+++ b/sheets/Condition.cpp | ||
@@ -381,6 +381,8 @@ void Conditions::operator=(const Conditions & other) | ||
|
||
bool Conditions::operator==(const Conditions& other) const | ||
{ | ||
+ if (d->defaultStyle != other.d->defaultStyle) | ||
+ return false; | ||
if (d->conditionList.count() != other.d->conditionList.count()) | ||
return false; | ||
QLinkedList<Conditional>::ConstIterator end(d->conditionList.end()); | ||
@@ -399,7 +401,7 @@ bool Conditions::operator==(const Conditions& other) const | ||
|
||
uint Calligra::Sheets::qHash(const Conditions &c) | ||
{ | ||
- uint res = 0; | ||
+ uint res = qHash(c.defaultStyle()); | ||
foreach (const Conditional& co, c.conditionList()) { | ||
res ^= qHash(co); | ||
} | ||
diff --git a/sheets/RectStorage.h b/sheets/RectStorage.h | ||
index c9f77ab..c6f00a2 100644 | ||
--- a/sheets/RectStorage.h | ||
+++ b/sheets/RectStorage.h | ||
@@ -570,19 +570,15 @@ void RectStorageLoader<T>::run() | ||
|
||
QList<QPair<QRegion, T> > treeData; | ||
typedef QPair<QRegion, T> TRegion; | ||
- QMap<T, int> indexCache; | ||
foreach (const TRegion& tr, m_data) { | ||
const QRegion& reg = tr.first; | ||
const T& d = tr.second; | ||
|
||
- typename QMap<T, int>::iterator idx = indexCache.find(d); | ||
- int index = idx != indexCache.end() ? idx.value() : m_storage->m_storedData.indexOf(d); | ||
+ int index = m_storage->m_storedData.indexOf(d); | ||
if (index != -1) { | ||
treeData.append(qMakePair(reg, m_storage->m_storedData[index])); | ||
- if (idx == indexCache.end()) indexCache.insert(d, index); | ||
} else { | ||
treeData.append(tr); | ||
- if (idx == indexCache.end()) indexCache.insert(d, m_storage->m_storedData.size()); | ||
m_storage->m_storedData.append(d); | ||
} | ||
} | ||
-- | ||
1.8.3-rc3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 6951e1e9b2d4439c83f385b354d246bd24e53ce3 Mon Sep 17 00:00:00 2001 | ||
From: Andrew den Exter <andrew.den.exter@qinetic.com.au> | ||
Date: Mon, 14 Oct 2019 08:39:21 +0000 | ||
Subject: [PATCH 2/3] Don't double format spreadsheet currency values with | ||
custom format strings. | ||
|
||
--- | ||
sheets/ValueFormatter.cpp | 6 +++++- | ||
1 file changed, 5 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/sheets/ValueFormatter.cpp b/sheets/ValueFormatter.cpp | ||
index 66914b1..2f2d703 100644 | ||
--- a/sheets/ValueFormatter.cpp | ||
+++ b/sheets/ValueFormatter.cpp | ||
@@ -330,7 +330,11 @@ QString ValueFormatter::createNumberFormat(Number value, int precision, | ||
break; | ||
case Format::Money: | ||
// There is no substitute for this in QLocale (toCurrencyString cannot set precision) :( | ||
- localizedNumber = m_converter->settings()->locale()->formatMoney(val, currencySymbol.isEmpty() ? m_converter->settings()->locale()->currencySymbol() : currencySymbol, p); | ||
+ if (_formatString.isEmpty()) { | ||
+ localizedNumber = m_converter->settings()->locale()->formatMoney(val, currencySymbol, p); | ||
+ } else { | ||
+ localizedNumber = m_converter->settings()->locale()->formatNumber(val, p); | ||
+ } | ||
break; | ||
case Format::Scientific: { | ||
const QString decimalSymbol = m_converter->settings()->locale()->decimalSymbol(); | ||
-- | ||
1.8.3-rc3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From c70d858b620b6f9f21be639933ba923587765816 Mon Sep 17 00:00:00 2001 | ||
From: Andrew den Exter <andrew.den.exter@qinetic.com.au> | ||
Date: Tue, 15 Oct 2019 06:31:51 +0000 | ||
Subject: [PATCH 3/3] Don't drop number styling information from xlsx cell | ||
formats which start with a currency symbol. | ||
|
||
--- | ||
filters/libmso/NumberFormatParser.cpp | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/filters/libmso/NumberFormatParser.cpp b/filters/libmso/NumberFormatParser.cpp | ||
index b8d6734..21b2f80 100644 | ||
--- a/filters/libmso/NumberFormatParser.cpp | ||
+++ b/filters/libmso/NumberFormatParser.cpp | ||
@@ -260,7 +260,8 @@ KoGenStyle NumberFormatParser::parse(const QString& origNumberFormat, KoGenStyle | ||
// do following only if we are really a number and not part of another KoGenStyle like a date or time formatting | ||
if (type == KoGenStyle::NumericNumberStyle | ||
|| type == KoGenStyle::NumericFractionStyle | ||
- || type == KoGenStyle::NumericScientificStyle) | ||
+ || type == KoGenStyle::NumericScientificStyle | ||
+ || type == KoGenStyle::NumericCurrencyStyle) | ||
{ | ||
bool grouping = false; | ||
bool gotDot = false; | ||
-- | ||
1.8.3-rc3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters