Commit d0ecab47 authored by Patrick Spendrin's avatar Patrick Spendrin
Browse files

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
parent 9689a8ec
......@@ -22,6 +22,7 @@
#include <kprocess.h>
#include <QApplication>
#include <QByteArray>
#include <QDir>
#include <QFileInfo>
#include <QImage>
......@@ -44,7 +45,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
#endif
// Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) != 0)
if (qstrnicmp(cp, "PSfile=", 7) != 0)
return;
QString command(cp+7);
......@@ -230,7 +231,7 @@ void dviRenderer::prescan_removePageSizeInfo(char *cp, quint8 *beginningOfSpecia
#endif
// Encapsulated Postscript File
if (strncasecmp(cp, "papersize=", 10) != 0)
if (qstrnicmp(cp, "papersize=", 10) != 0)
return;
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.
// PaperSize special
if (strncasecmp(cp, "papersize", 9) == 0) {
if (qstrnicmp(cp, "papersize", 9) == 0) {
prescan_ParsePapersizeSpecial(special_command.mid(9));
return;
}
// color special for background color
if (strncasecmp(cp, "background", 10) == 0) {
if (qstrnicmp(cp, "background", 10) == 0) {
prescan_ParseBackgroundSpecial(special_command.mid(10));
return;
}
// 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));
return;
}
// Postscript Header File
if (strncasecmp(cp, "header=", 7) == 0) {
if (qstrnicmp(cp, "header=", 7) == 0) {
prescan_ParsePSHeaderSpecial(special_command.mid(7));
return;
}
......@@ -562,19 +563,19 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
}
// PS-Postscript inclusion
if (strncasecmp(cp, "ps:", 3) == 0) {
if (qstrnicmp(cp, "ps:", 3) == 0) {
prescan_ParsePSSpecial(special_command);
return;
}
// Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) == 0) {
if (qstrnicmp(cp, "PSfile=", 7) == 0) {
prescan_ParsePSFileSpecial(special_command.mid(7));
return;
}
// source special
if (strncasecmp(cp, "src:", 4) == 0) {
if (qstrnicmp(cp, "src:", 4) == 0) {
prescan_ParseSourceSpecial(special_command.mid(4));
return;
}
......@@ -583,7 +584,7 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
// both during rendering and during the pre-scan phase
// HTML anchor end
if (strncasecmp(cp, "html:</A>", 9) == 0) {
if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end();
return;
}
......
......@@ -255,7 +255,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
while(proc.canReadLine()) {
GSoutput = QString::fromLocal8Bit(proc.readLine());
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;
knownDevices.erase(gsDevice);
gsDevice = knownDevices.begin();
......
......@@ -20,13 +20,13 @@
#include <QMimeType>
#include <QMimeDatabase>
#include <QByteArray>
#include <QFile>
#include <QFontDatabase>
#include <QImage>
#include <QPainter>
#include "debug_dvi.h"
void dviRenderer::printErrorMsgForSpecials(const QString& msg)
{
if (dviFile->errorCounter < 25) {
......@@ -517,45 +517,45 @@ void dviRenderer::applicationDoSpecial(char *cp)
// and NOT during the prescan phase
// font color specials
if (strncasecmp(cp, "color", 5) == 0) {
if (qstrnicmp(cp, "color", 5) == 0) {
color_special(special_command.mid(5));
return;
}
// 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));
return;
}
// HTML anchor end
if (strncasecmp(cp, "html:</A>", 9) == 0) {
if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end();
return;
}
// TPIC specials
if (strncasecmp(cp, "pn", 2) == 0) {
if (qstrnicmp(cp, "pn", 2) == 0) {
TPIC_setPen_special(special_command.mid(2));
return;
}
if (strncasecmp(cp, "pa ", 3) == 0) {
if (qstrnicmp(cp, "pa ", 3) == 0) {
TPIC_addPath_special(special_command.mid(3));
return;
}
if (strncasecmp(cp, "fp", 2) == 0) {
if (qstrnicmp(cp, "fp", 2) == 0) {
TPIC_flushPath_special();
return;
}
// Encapsulated Postscript File
if (strncasecmp(cp, "PSfile=", 7) == 0) {
if (qstrnicmp(cp, "PSfile=", 7) == 0) {
epsf_special(special_command.mid(7));
return;
}
// source special
if (strncasecmp(cp, "src:", 4) == 0) {
if (qstrnicmp(cp, "src:", 4) == 0) {
source_special(special_command.mid(4));
return;
}
......@@ -694,11 +694,11 @@ void dviRenderer::applicationDoSpecial(char *cp)
// unrecognized special commands.
if ((cp[0] == '!') ||
(cp[0] == '"') ||
(strncasecmp(cp, "html:<A name=", 13) == 0) ||
(strncasecmp(cp, "ps:", 3) == 0) ||
(strncasecmp(cp, "papersize", 9) == 0) ||
(strncasecmp(cp, "header", 6) == 0) ||
(strncasecmp(cp, "background", 10) == 0) )
(qstrnicmp(cp, "html:<A name=", 13) == 0) ||
(qstrnicmp(cp, "ps:", 3) == 0) ||
(qstrnicmp(cp, "papersize", 9) == 0) ||
(qstrnicmp(cp, "header", 6) == 0) ||
(qstrnicmp(cp, "background", 10) == 0) )
return;
printErrorMsgForSpecials(i18n("The special command '%1' is not implemented.", special_command));
......
......@@ -297,7 +297,7 @@ QTextDocument* Converter::convert( const QString &fileName )
QTextBlock before;
if(firstPage) {
// 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;\">"
"<tr>"
"<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 )
{
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"
"|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks"
"|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]")));
......
......@@ -2893,7 +2893,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
xs.append(1.0);
ys.prepend(0.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\">"
"</head><body><table>");
for (int r=0; r+1<ys.length(); r++) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment