Windows string fixes

This patch changes multiline QStringLiterals to QString::fromLatin1
as QStringLiterals doesn't understand multiline strings on windows.
Also, strncasecmp is replaced by the portable qstrnicmp function provided
by QByteArray header.

REVIEW: 126379
frameworks
Patrick Spendrin 10 years ago
parent 9689a8eccd
commit d0ecab4736
  1. 21
      generators/dvi/dviRenderer_prescan.cpp
  2. 2
      generators/dvi/psgs.cpp
  3. 28
      generators/dvi/special.cpp
  4. 2
      generators/epub/converter.cpp
  5. 2
      ui/latexrenderer.cpp
  6. 2
      ui/pageview.cpp

@ -22,6 +22,7 @@
#include <kprocess.h> #include <kprocess.h>
#include <QApplication> #include <QApplication>
#include <QByteArray>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QImage> #include <QImage>
@ -44,7 +45,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
#endif #endif
// Encapsulated Postscript File // Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) != 0) if (qstrnicmp(cp, "PSfile=", 7) != 0)
return; return;
QString command(cp+7); QString command(cp+7);
@ -230,7 +231,7 @@ void dviRenderer::prescan_removePageSizeInfo(char *cp, quint8 *beginningOfSpecia
#endif #endif
// Encapsulated Postscript File // Encapsulated Postscript File
if (strncasecmp(cp, "papersize=", 10) != 0) if (qstrnicmp(cp, "papersize=", 10) != 0)
return; return;
for (quint8 *ptr=beginningOfSpecialCommand; ptr<command_pointer; ptr++) for (quint8 *ptr=beginningOfSpecialCommand; ptr<command_pointer; ptr++)
@ -526,25 +527,25 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
// prescan phase, and NOT during rendering. // prescan phase, and NOT during rendering.
// PaperSize special // PaperSize special
if (strncasecmp(cp, "papersize", 9) == 0) { if (qstrnicmp(cp, "papersize", 9) == 0) {
prescan_ParsePapersizeSpecial(special_command.mid(9)); prescan_ParsePapersizeSpecial(special_command.mid(9));
return; return;
} }
// color special for background color // color special for background color
if (strncasecmp(cp, "background", 10) == 0) { if (qstrnicmp(cp, "background", 10) == 0) {
prescan_ParseBackgroundSpecial(special_command.mid(10)); prescan_ParseBackgroundSpecial(special_command.mid(10));
return; return;
} }
// HTML anchor special // HTML anchor special
if (strncasecmp(cp, "html:<A name=", 13) == 0) { if (qstrnicmp(cp, "html:<A name=", 13) == 0) {
prescan_ParseHTMLAnchorSpecial(special_command.mid(14)); prescan_ParseHTMLAnchorSpecial(special_command.mid(14));
return; return;
} }
// Postscript Header File // Postscript Header File
if (strncasecmp(cp, "header=", 7) == 0) { if (qstrnicmp(cp, "header=", 7) == 0) {
prescan_ParsePSHeaderSpecial(special_command.mid(7)); prescan_ParsePSHeaderSpecial(special_command.mid(7));
return; return;
} }
@ -562,19 +563,19 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
} }
// PS-Postscript inclusion // PS-Postscript inclusion
if (strncasecmp(cp, "ps:", 3) == 0) { if (qstrnicmp(cp, "ps:", 3) == 0) {
prescan_ParsePSSpecial(special_command); prescan_ParsePSSpecial(special_command);
return; return;
} }
// Encapsulated Postscript File // Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) == 0) { if (qstrnicmp(cp, "PSfile=", 7) == 0) {
prescan_ParsePSFileSpecial(special_command.mid(7)); prescan_ParsePSFileSpecial(special_command.mid(7));
return; return;
} }
// source special // source special
if (strncasecmp(cp, "src:", 4) == 0) { if (qstrnicmp(cp, "src:", 4) == 0) {
prescan_ParseSourceSpecial(special_command.mid(4)); prescan_ParseSourceSpecial(special_command.mid(4));
return; return;
} }
@ -583,7 +584,7 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
// both during rendering and during the pre-scan phase // both during rendering and during the pre-scan phase
// HTML anchor end // HTML anchor end
if (strncasecmp(cp, "html:</A>", 9) == 0) { if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end(); html_anchor_end();
return; return;
} }

@ -255,7 +255,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
while(proc.canReadLine()) { while(proc.canReadLine()) {
GSoutput = QString::fromLocal8Bit(proc.readLine()); GSoutput = QString::fromLocal8Bit(proc.readLine());
if (GSoutput.contains(QStringLiteral("Unknown device"))) { if (GSoutput.contains(QStringLiteral("Unknown device"))) {
qCDebug(OkularDviDebug) << QStringLiteral("The version of ghostview installed on this computer does not support " qCDebug(OkularDviDebug) << QString::fromLatin1("The version of ghostview installed on this computer does not support "
"the '%1' ghostview device driver.").arg(*gsDevice) << endl; "the '%1' ghostview device driver.").arg(*gsDevice) << endl;
knownDevices.erase(gsDevice); knownDevices.erase(gsDevice);
gsDevice = knownDevices.begin(); gsDevice = knownDevices.begin();

@ -20,13 +20,13 @@
#include <QMimeType> #include <QMimeType>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QByteArray>
#include <QFile> #include <QFile>
#include <QFontDatabase> #include <QFontDatabase>
#include <QImage> #include <QImage>
#include <QPainter> #include <QPainter>
#include "debug_dvi.h" #include "debug_dvi.h"
void dviRenderer::printErrorMsgForSpecials(const QString& msg) void dviRenderer::printErrorMsgForSpecials(const QString& msg)
{ {
if (dviFile->errorCounter < 25) { if (dviFile->errorCounter < 25) {
@ -517,45 +517,45 @@ void dviRenderer::applicationDoSpecial(char *cp)
// and NOT during the prescan phase // and NOT during the prescan phase
// font color specials // font color specials
if (strncasecmp(cp, "color", 5) == 0) { if (qstrnicmp(cp, "color", 5) == 0) {
color_special(special_command.mid(5)); color_special(special_command.mid(5));
return; return;
} }
// HTML reference // HTML reference
if (strncasecmp(cp, "html:<A href=", 13) == 0) { if (qstrnicmp(cp, "html:<A href=", 13) == 0) {
html_href_special(special_command.mid(14)); html_href_special(special_command.mid(14));
return; return;
} }
// HTML anchor end // HTML anchor end
if (strncasecmp(cp, "html:</A>", 9) == 0) { if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end(); html_anchor_end();
return; return;
} }
// TPIC specials // TPIC specials
if (strncasecmp(cp, "pn", 2) == 0) { if (qstrnicmp(cp, "pn", 2) == 0) {
TPIC_setPen_special(special_command.mid(2)); TPIC_setPen_special(special_command.mid(2));
return; return;
} }
if (strncasecmp(cp, "pa ", 3) == 0) { if (qstrnicmp(cp, "pa ", 3) == 0) {
TPIC_addPath_special(special_command.mid(3)); TPIC_addPath_special(special_command.mid(3));
return; return;
} }
if (strncasecmp(cp, "fp", 2) == 0) { if (qstrnicmp(cp, "fp", 2) == 0) {
TPIC_flushPath_special(); TPIC_flushPath_special();
return; return;
} }
// Encapsulated Postscript File // Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) == 0) { if (qstrnicmp(cp, "PSfile=", 7) == 0) {
epsf_special(special_command.mid(7)); epsf_special(special_command.mid(7));
return; return;
} }
// source special // source special
if (strncasecmp(cp, "src:", 4) == 0) { if (qstrnicmp(cp, "src:", 4) == 0) {
source_special(special_command.mid(4)); source_special(special_command.mid(4));
return; return;
} }
@ -694,11 +694,11 @@ void dviRenderer::applicationDoSpecial(char *cp)
// unrecognized special commands. // unrecognized special commands.
if ((cp[0] == '!') || if ((cp[0] == '!') ||
(cp[0] == '"') || (cp[0] == '"') ||
(strncasecmp(cp, "html:<A name=", 13) == 0) || (qstrnicmp(cp, "html:<A name=", 13) == 0) ||
(strncasecmp(cp, "ps:", 3) == 0) || (qstrnicmp(cp, "ps:", 3) == 0) ||
(strncasecmp(cp, "papersize", 9) == 0) || (qstrnicmp(cp, "papersize", 9) == 0) ||
(strncasecmp(cp, "header", 6) == 0) || (qstrnicmp(cp, "header", 6) == 0) ||
(strncasecmp(cp, "background", 10) == 0) ) (qstrnicmp(cp, "background", 10) == 0) )
return; return;
printErrorMsgForSpecials(i18n("The special command '%1' is not implemented.", special_command)); printErrorMsgForSpecials(i18n("The special command '%1' is not implemented.", special_command));

@ -297,7 +297,7 @@ QTextDocument* Converter::convert( const QString &fileName )
QTextBlock before; QTextBlock before;
if(firstPage) { if(firstPage) {
// preHtml & postHtml make it possible to have a margin around the content of the page // preHtml & postHtml make it possible to have a margin around the content of the page
const QString preHtml = QStringLiteral("<html><head></head><body>" const QString preHtml = QString::fromLatin1("<html><head></head><body>"
"<table style=\"-qt-table-type: root; margin-top:%1px; margin-bottom:%1px; margin-left:%1px; margin-right:%1px;\">" "<table style=\"-qt-table-type: root; margin-top:%1px; margin-bottom:%1px; margin-left:%1px; margin-right:%1px;\">"
"<tr>" "<tr>"
"<td style=\"border: none;\">").arg(mTextDocument->padding); "<td style=\"border: none;\">").arg(mTextDocument->padding);

@ -191,7 +191,7 @@ LatexRenderer::Error LatexRenderer::handleLatex( QString& fileName, const QStrin
bool LatexRenderer::securityCheck( const QString &latexFormula ) bool LatexRenderer::securityCheck( const QString &latexFormula )
{ {
return !latexFormula.contains(QRegExp(QStringLiteral("\\\\(def|let|futurelet|newcommand|renewcommand|else|fi|write|input|include" return !latexFormula.contains(QRegExp(QString::fromLatin1("\\\\(def|let|futurelet|newcommand|renewcommand|else|fi|write|input|include"
"|chardef|catcode|makeatletter|noexpand|toksdef|every|errhelp|errorstopmode|scrollmode|nonstopmode|batchmode" "|chardef|catcode|makeatletter|noexpand|toksdef|every|errhelp|errorstopmode|scrollmode|nonstopmode|batchmode"
"|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks" "|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks"
"|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]"))); "|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]")));

@ -2893,7 +2893,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
xs.append(1.0); xs.append(1.0);
ys.prepend(0.0); ys.prepend(0.0);
ys.append(1.0); ys.append(1.0);
selHtml = QStringLiteral("<html><head>" selHtml = QString::fromLatin1("<html><head>"
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\">" "<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\">"
"</head><body><table>"); "</head><body><table>");
for (int r=0; r+1<ys.length(); r++) { for (int r=0; r+1<ys.length(); r++) {

Loading…
Cancel
Save