comparison src/converter.cpp @ 12:21f11f988115

Make sure strings don't start with = and duplicate text instead of formula
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 22 Mar 2016 17:21:33 +0100
parents a10425e7ef98
children 101ee762f021
comparison
equal deleted inserted replaced
11:79771751d0dc 12:21f11f988115
152 follows immediately behind the last answer we treat it as valid as 152 follows immediately behind the last answer we treat it as valid as
153 otherwise we can't figure out when the next question begins. */ 153 otherwise we can't figure out when the next question begins. */
154 cursor = choiceMatch.capturedEnd(); 154 cursor = choiceMatch.capturedEnd();
155 155
156 /* Write the values */ 156 /* Write the values */
157 xlsx.write(row, 1, choiceMatch.captured(1), mChoiceTextFmt); 157 QString choiceName = choiceMatch.captured(1).trimmed();
158 if (choiceName.startsWith("=")) {
159 choiceName = " " + choiceName;
160 }
161 xlsx.write(row, 1, choiceName, mChoiceTextFmt);
158 bool ok; 162 bool ok;
159 double percent = choiceMatch.captured(3).toDouble(&ok); 163 double percent = choiceMatch.captured(3).toDouble(&ok);
160 if (!ok) { 164 if (!ok) {
161 mErrors << "Unparsable number in string: " + choiceMatch.captured(); 165 mErrors << "Unparsable number in string: " + choiceMatch.captured();
162 } 166 }
203 qDebug() << "Next Question is at: " << nextQuestion.capturedStart(); 207 qDebug() << "Next Question is at: " << nextQuestion.capturedStart();
204 qDebug() << "Text match is: " << textMatch.captured(1).trimmed(); 208 qDebug() << "Text match is: " << textMatch.captured(1).trimmed();
205 qDebug() << "cursor is at: " << cursor; 209 qDebug() << "cursor is at: " << cursor;
206 qDebug() << "text match starts at: " << textMatch.capturedStart(); 210 qDebug() << "text match starts at: " << textMatch.capturedStart();
207 xlsx.write(row - 1, 26, combined, mFreeTextFmt); 211 xlsx.write(row - 1, 26, combined, mFreeTextFmt);
212 xlsx.write(row - 1, 1, combined, mFreeTextFmt);
208 cursor = textMatch.capturedEnd(); 213 cursor = textMatch.capturedEnd();
209 textMatch = freetxtEx.match(input, cursor); 214 textMatch = freetxtEx.match(input, cursor);
210 continue; 215 continue;
211 } 216 }
212 cursor = textMatch.capturedEnd(); 217 cursor = textMatch.capturedEnd();
213 218
214 QString text = textMatch.captured(1).trimmed(); 219 QString text = textMatch.captured(1).trimmed();
215 qDebug() << "Found free text: " << text; 220 qDebug() << "Found free text: " << text;
221 if (text.startsWith("=")) {
222 text = " " + text;
223 }
216 224
217 /* Merge the cells */ 225 /* Merge the cells */
218 xlsx.mergeCells(QString("A%1:C%1").arg(row), mFreeTextFmt); 226 xlsx.mergeCells(QString("A%1:C%1").arg(row), mFreeTextFmt);
219 227
220 /* Merged cells ignore wordwrap the following trick is based on: 228 /* Merged cells ignore wordwrap the following trick is based on:
221 http://excel.tips.net/T003207_Automatic_Row_Height_For_Merged_Cells_with_Text_Wrap.html 229 http://excel.tips.net/T003207_Automatic_Row_Height_For_Merged_Cells_with_Text_Wrap.html
222 */ 230 */
223 /* Write the values */ 231 /* Write the values */
224 xlsx.write(QString("Z%1").arg(row), text, mFreeTextFmt); 232 xlsx.write(QString("Z%1").arg(row), text, mFreeTextFmt);
225 xlsx.write(row, 1, QString("=Z%1").arg(row)); 233 xlsx.write(row, 1, text, mFreeTextFmt);
226 row++; 234 row++;
227 textMatch = freetxtEx.match(input, cursor); 235 textMatch = freetxtEx.match(input, cursor);
228 } 236 }
229 } 237 }
230 /* Insert Empty row. */ 238 /* Insert Empty row. */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)