Mercurial > clickerconvert
comparison src/converter.cpp @ 70:3438f5cce8cc
Force text codec for html to use UTF-8
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 29 Sep 2016 14:41:48 +0200 |
parents | dab9c19252bd |
children | 7e195eacb0da |
comparison
equal
deleted
inserted
replaced
69:dab9c19252bd | 70:3438f5cce8cc |
---|---|
159 { | 159 { |
160 Document xlsx; | 160 Document xlsx; |
161 QTextDocument doc; | 161 QTextDocument doc; |
162 QString htmlString; | 162 QString htmlString; |
163 QTextStream html (&htmlString); | 163 QTextStream html (&htmlString); |
164 html.setCodec("UTF-8"); | |
164 | 165 |
165 ConditionalFormatting bars; | 166 ConditionalFormatting bars; |
166 | 167 |
167 bars.addDataBarRule(QColor(0xFF, 0x99, 0x33), ConditionalFormatting::VOT_Num, | 168 bars.addDataBarRule(QColor(0xFF, 0x99, 0x33), ConditionalFormatting::VOT_Num, |
168 "0", ConditionalFormatting::VOT_Num, "100", false); | 169 "0", ConditionalFormatting::VOT_Num, "100", false); |
178 /* For the merged cell wordwrap trick. */ | 179 /* For the merged cell wordwrap trick. */ |
179 xlsx.setColumnWidth(26, sum + 1); | 180 xlsx.setColumnWidth(26, sum + 1); |
180 xlsx.setColumnHidden(26, true); | 181 xlsx.setColumnHidden(26, true); |
181 | 182 |
182 int row = 1; | 183 int row = 1; |
183 html << "<html><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">" | 184 html << "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>" |
184 "<body><table border=\"0\" width:\"100%\">"; | 185 "</head><body><table border=\"0\" width:\"100%\">"; |
185 html << QStringLiteral("<tr><th width=\"%1%\"></th>").arg(HTML_COL1_PERCENT); | 186 html << QStringLiteral("<tr><th width=\"%1%\"></th>").arg(HTML_COL1_PERCENT); |
186 html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL2_PERCENT); | 187 html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL2_PERCENT); |
187 html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL3_PERCENT); | 188 html << QStringLiteral("<th width=\"%1%\"></th>").arg(HTML_COL3_PERCENT); |
188 | 189 |
189 const QString title = mTitle.isEmpty() ? DEFAULT_TITLE : mTitle; | 190 const QString title = mTitle.isEmpty() ? DEFAULT_TITLE : mTitle; |
284 additionalFound = true; | 285 additionalFound = true; |
285 QString choice = choiceMatch.captured(1); | 286 QString choice = choiceMatch.captured(1); |
286 cursor = choiceMatch.capturedEnd(); | 287 cursor = choiceMatch.capturedEnd(); |
287 /* Alternative answer that is just a list of strings */ | 288 /* Alternative answer that is just a list of strings */ |
288 unescapeString(choice); | 289 unescapeString(choice); |
289 qDebug() << "Caputured unfilled choice: " << choice; | 290 qDebug() << "Captured unfilled choice: " << choice; |
290 html << mChoiceTextStyle.arg(choice.toHtmlEscaped()); | 291 html << mChoiceTextStyle.arg(choice.toHtmlEscaped()); |
291 makeBar(html, 0, doc); | 292 makeBar(html, 0, doc); |
292 xlsx.write(row, 2, QVariant()); | 293 xlsx.write(row, 2, QVariant()); |
293 const QString numVotesString = QStringLiteral("Keine eingegangenen Antworten"); | 294 const QString numVotesString = QStringLiteral("Keine eingegangenen Antworten"); |
294 html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); | 295 html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); |
398 | 399 |
399 foreach (QFile *output, outputs) { | 400 foreach (QFile *output, outputs) { |
400 const QString fName = output->fileName().toLower(); | 401 const QString fName = output->fileName().toLower(); |
401 if (fName.endsWith(".html")) { | 402 if (fName.endsWith(".html")) { |
402 QTextStream outstream(output); | 403 QTextStream outstream(output); |
404 outstream.setCodec("UTF-8"); | |
403 outstream << htmlString; | 405 outstream << htmlString; |
404 output->close(); | 406 output->close(); |
405 } else if (fName.endsWith(".pdf")) { | 407 } else if (fName.endsWith(".pdf")) { |
406 output->close(); | 408 output->close(); |
407 QPrinter printer(QPrinter::PrinterResolution); | 409 QPrinter printer(QPrinter::PrinterResolution); |