bool TTSImplWindows::speak(QString text, DWORD options) { preprocessText(text); wchar_t* array = new wchar_t[text.size() + 1]; text.toWCharArray(array); array[text.size()] = 0; bool success = m_Voice->Speak(array, options, NULL); delete[] array; getSpeechLog().append(text); return success; }
QString TemplateEngine::processText(MacroExpander *expander, const QString &input, QString *errorMessage) { if (errorMessage) errorMessage->clear(); if (input.isEmpty()) return input; // Recursively expand macros: QString in = input; QString oldIn; for (int i = 0; i < 5 && in != oldIn; ++i) { oldIn = in; in = expander->expand(oldIn); } QString out; if (!preprocessText(in, &out, errorMessage)) return QString(); // Expand \n, \t and handle line continuation: QString result; result.reserve(out.count()); bool isEscaped = false; for (int i = 0; i < out.count(); ++i) { const QChar c = out.at(i); if (isEscaped) { if (c == QLatin1Char('n')) result.append(QLatin1Char('\n')); else if (c == QLatin1Char('t')) result.append(QLatin1Char('\t')); else if (c != QLatin1Char('\n')) result.append(c); isEscaped = false; } else { if (c == QLatin1Char('\\')) isEscaped = true; else result.append(c); } } return result; }