# HG changeset patch # User Andre Heinecke # Date 1470729556 -7200 # Node ID 5410f9f279eac4bb49306df6a67975640d672e23 # Parent aaaf8cdbc85c79018d8cd9ff01d8df19385721db Redefine question pattern to be more robust We now assume that a question begins after two empty lines. diff -r aaaf8cdbc85c -r 5410f9f279ea src/constants.h --- a/src/constants.h Wed Jul 20 16:57:52 2016 +0200 +++ b/src/constants.h Tue Aug 09 09:59:16 2016 +0200 @@ -55,7 +55,9 @@ * A new question is the first unquoted string after the position * that is followed after a newline by the word "Answer" */ -#define QUESTION_PATTERN "([^\"]+)^(Answer.*$)", QRegularExpression::MultilineOption +#define QUESTION_PATTERN "\n\n(.*)\n+(Answer.*$)", QRegularExpression::MultilineOption + +#define FIRST_QUESTION_PATTERN "(.*)\n+(Answer.*$)", QRegularExpression::MultilineOption /** * @brief Identifiying line that shows a question is a choice question. */ @@ -71,7 +73,7 @@ /** * @brief The pattern used to match a free text answer. */ -#define FREETXT_PATTERN "\"([^\"]*)\"", QRegularExpression::MultilineOption +#define FREETXT_PATTERN "\"([^\"]*)\"?", QRegularExpression::MultilineOption #define TITLE_ROW_HEIGHT 30 diff -r aaaf8cdbc85c -r 5410f9f279ea src/converter.cpp --- a/src/converter.cpp Wed Jul 20 16:57:52 2016 +0200 +++ b/src/converter.cpp Tue Aug 09 09:59:16 2016 +0200 @@ -180,12 +180,13 @@ QRegularExpression choiceEx(CHOICE_PATTERN); QRegularExpression choiceAltEx(CHOICE_UNFILLED_PATTERN); QRegularExpression freetxtEx(FREETXT_PATTERN); + QRegularExpression firstQuestionEx(FIRST_QUESTION_PATTERN); input.replace("\r\n", "\n"); input.replace("\n\r", "\n"); input.replace("#NAME?\n", ""); - QRegularExpressionMatch match = questionEx.match(input); + QRegularExpressionMatch match = firstQuestionEx.match(input); bool foundSomething = false; int cursor = match.capturedEnd(); while (match.hasMatch() && cursor != -1) { @@ -227,7 +228,7 @@ html << mChoiceTextStyle.arg(choiceName.toHtmlEscaped()); qDebug() << "Captured for choice: " << choiceMatch.captured(0); bool ok; - const QString percentStr = choiceMatch.captured("percent"); + QString percentStr = choiceMatch.captured("percent"); double percent; if (percentStr.isNull()) { percent = 0; diff -r aaaf8cdbc85c -r 5410f9f279ea src/l10n/main_de_DE.ts --- a/src/l10n/main_de_DE.ts Wed Jul 20 16:57:52 2016 +0200 +++ b/src/l10n/main_de_DE.ts Tue Aug 09 09:59:16 2016 +0200 @@ -31,12 +31,12 @@ Die Datei "%1" konnte nicht geƶffnet werden. - + Failed to parse input document. Fehler bei der verarbeitung des Eingabedokuments. - + Saving the XLSX document failed. Das erstellen des XLSX Dokuments ist fehlgeschlagen.