[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/tellico/src
From: Robby Stephenson <robby () periapsis ! org>
Date: 2010-08-01 0:05:13
Message-ID: 20100801000513.82E3AAC783 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1157718 by rstephenson:
update CSV exporter to change ID to Id if it's the first exported field, to \
workaround a micrsoft bug
M +1 -0 tests/csvtest.cpp
M +9 -8 translators/csvexporter.cpp
--- trunk/extragear/office/tellico/src/tests/csvtest.cpp #1157717:1157718
@@ -73,4 +73,5 @@
QTest::newRow("tab") << "robby\t\tstephenson" << "\t" << 3 << 0 << "robby" << 1 << \
""; // quotes get swallowed
QTest::newRow("quotes") << "robby,\"stephenson,is,cool\"" << "," << 2 << 0 << \
"robby" << 1 << "stephenson,is,cool"; + QTest::newRow("newline") << \
"robby,\"stephenson\n,is,cool\"" << "," << 2 << 0 << "robby" << 1 << \
"stephenson\n,is,cool"; }
--- trunk/extragear/office/tellico/src/translators/csvexporter.cpp #1157717:1157718
@@ -58,13 +58,13 @@
QString& CSVExporter::escapeText(QString& text_) {
bool quotes = false;
- if(text_.indexOf(QLatin1Char('"')) != -1) {
+ if(text_.contains(QLatin1Char('"'))) {
quotes = true;
// quotation marks will be escaped by using a double pair
text_.replace(QLatin1Char('"'), QLatin1String("\"\""));
}
// if the text contains quotes or the delimiter, it needs to be surrounded by \
quotes
- if(quotes || text_.indexOf(m_delimiter)!= -1) {
+ if(quotes || text_.contains(m_delimiter) || text_.contains(QLatin1Char('\n'))) {
text_.prepend(QLatin1Char('"'));
text_.append(QLatin1Char('"'));
}
@@ -78,11 +78,13 @@
QString text;
- Data::FieldList fields = collection()->fields();
-
if(m_includeTitles) {
- foreach(Data::FieldPtr fIt, fields) {
+ foreach(Data::FieldPtr fIt, collection()->fields()) {
QString title = fIt->title();
+ // because of Microsoft Excel bug, http://support.microsoft.com/kb/323626
+ if(text.isEmpty() && title == QLatin1String("ID")) {
+ title = QLatin1String("Id");
+ }
text += escapeText(title) + m_delimiter;
}
// remove last delimiter
@@ -95,9 +97,8 @@
FieldFormat::AsIsFormat);
QString tmp;
- Data::EntryList entries = this->entries();
- foreach(Data::EntryPtr entryIt, entries) {
- foreach(Data::FieldPtr fIt, fields) {
+ foreach(Data::EntryPtr entryIt, entries()) {
+ foreach(Data::FieldPtr fIt, collection()->fields()) {
tmp = entryIt->formattedField(fIt->name(), format);
text += escapeText(tmp) + m_delimiter;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic