comparison src/converter.cpp @ 43:f9a0b2b6832e

Sanitize input and unify Lineendings
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 12 May 2016 17:35:49 +0200
parents f6c53e896008
children aaaf8cdbc85c
comparison
equal deleted inserted replaced
42:8b6cb95d00be 43:f9a0b2b6832e
172 xlsx.write(row++, 1, title, mTitleFmt); 172 xlsx.write(row++, 1, title, mTitleFmt);
173 html << mTitleStyle.arg(title.toHtmlEscaped()); 173 html << mTitleStyle.arg(title.toHtmlEscaped());
174 xlsx.mergeCells("A1:C1"); 174 xlsx.mergeCells("A1:C1");
175 xlsx.setRowHeight(1, TITLE_ROW_HEIGHT); 175 xlsx.setRowHeight(1, TITLE_ROW_HEIGHT);
176 176
177 const QString input = instream.readAll(); 177 QString input = instream.readAll();
178 178
179 QRegularExpression questionEx(QUESTION_PATTERN); 179 QRegularExpression questionEx(QUESTION_PATTERN);
180 QRegularExpression choiceEx(CHOICE_PATTERN); 180 QRegularExpression choiceEx(CHOICE_PATTERN);
181 QRegularExpression choiceAltEx(CHOICE_UNFILLED_PATTERN); 181 QRegularExpression choiceAltEx(CHOICE_UNFILLED_PATTERN);
182 QRegularExpression freetxtEx(FREETXT_PATTERN); 182 QRegularExpression freetxtEx(FREETXT_PATTERN);
183
184 input.replace("\r\n", "\n");
185 input.replace("\n\r", "\n");
186 input.replace("#NAME?\n", "");
183 187
184 QRegularExpressionMatch match = questionEx.match(input); 188 QRegularExpressionMatch match = questionEx.match(input);
185 bool foundSomething = false; 189 bool foundSomething = false;
186 int cursor = match.capturedEnd(); 190 int cursor = match.capturedEnd();
187 while (match.hasMatch() && cursor != -1) { 191 while (match.hasMatch() && cursor != -1) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)