summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-11 19:59:14 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-11 19:59:14 (GMT)
commit2b473fedbdcb04d8cfb8d07a465456cfa2c9089c (patch)
tree7614dfe87c56a616b2cadf430a223ce07f243660
parentb512e668e003a35201c0dac01a06a0d98973186f (diff)
generators: Fix build without implicit cast to/from ascii
See previous commit for details.
-rw-r--r--generators/comicbook/document.cpp2
-rw-r--r--generators/comicbook/qnatsort.cpp2
-rw-r--r--generators/comicbook/unrar.cpp12
-rw-r--r--generators/djvu/kdjvu.cpp2
-rw-r--r--generators/epub/converter.cpp8
-rw-r--r--generators/epub/epubdocument.cpp4
-rw-r--r--generators/fictionbook/converter.cpp6
-rw-r--r--generators/kimgio/tests/kimgiotest.cpp6
-rw-r--r--generators/mobipocket/converter.cpp2
-rw-r--r--generators/mobipocket/generator_mobi.cpp4
-rw-r--r--generators/mobipocket/mobidocument.cpp20
-rw-r--r--generators/ooo/converter.cpp4
-rw-r--r--generators/ooo/generator_ooo.cpp2
-rw-r--r--generators/plucker/unpluck/qunpluck.cpp10
-rw-r--r--generators/poppler/generator_pdf.cpp4
-rw-r--r--generators/xps/generator_xps.cpp142
16 files changed, 115 insertions, 115 deletions
diff --git a/generators/comicbook/document.cpp b/generators/comicbook/document.cpp
index ff54f33..54c4c3c 100644
--- a/generators/comicbook/document.cpp
+++ b/generators/comicbook/document.cpp
@@ -35,7 +35,7 @@ static void imagesInArchive( const QString &prefix, const KArchiveDirectory* dir
Q_FOREACH ( const QString &entry, dir->entries() ) {
const KArchiveEntry *e = dir->entry( entry );
if ( e->isDirectory() ) {
- imagesInArchive( prefix + entry + '/', static_cast<const KArchiveDirectory*>( e ), entries );
+ imagesInArchive( prefix + entry + QLatin1Char('/'), static_cast<const KArchiveDirectory*>( e ), entries );
} else if ( e->isFile() ) {
entries->append( prefix + entry );
}
diff --git a/generators/comicbook/qnatsort.cpp b/generators/comicbook/qnatsort.cpp
index 5ea8ae5..c022c09 100644
--- a/generators/comicbook/qnatsort.cpp
+++ b/generators/comicbook/qnatsort.cpp
@@ -110,7 +110,7 @@ static int natural_order_compare( const QString &leftStr, const QString &rightSt
/* process run of digits */
if ( ca.isDigit() && cb.isDigit() ) {
- fractional = (ca == '0' || cb == '0');
+ fractional = (ca == QLatin1Char('0') || cb == QLatin1Char('0'));
if ( fractional ) {
if ( (result = compare_left( leftStr, ai, rightStr, bi )) != 0 )
diff --git a/generators/comicbook/unrar.cpp b/generators/comicbook/unrar.cpp
index 2feb41d..731ca03 100644
--- a/generators/comicbook/unrar.cpp
+++ b/generators/comicbook/unrar.cpp
@@ -46,7 +46,7 @@ static UnrarFlavour* detectUnrar( const QString &unrarPath, const QString &versi
proc.start( unrarPath, QStringList() << versionCommand );
bool ok = proc.waitForFinished( -1 );
Q_UNUSED( ok )
- const QStringList lines = QString::fromLocal8Bit( proc.readAllStandardOutput() ).split( '\n', QString::SkipEmptyParts );
+ const QStringList lines = QString::fromLocal8Bit( proc.readAllStandardOutput() ).split( QLatin1Char('\n'), QString::SkipEmptyParts );
if ( !lines.isEmpty() )
{
if ( lines.first().startsWith( QLatin1String("UNRAR ") ) )
@@ -118,7 +118,7 @@ bool Unrar::open( const QString &fileName )
mStdOutData.clear();
mStdErrData.clear();
- int ret = startSyncProcess( QStringList() << QStringLiteral("e") << mFileName << mTempDir->path() + '/' );
+ int ret = startSyncProcess( QStringList() << QStringLiteral("e") << mFileName << mTempDir->path() + QLatin1Char('/') );
bool ok = ret == 0;
return ok;
@@ -134,13 +134,13 @@ QStringList Unrar::list()
startSyncProcess( QStringList() << QStringLiteral("lb") << mFileName );
- const QStringList listFiles = helper->kind->processListing( QString::fromLocal8Bit( mStdOutData ).split( '\n', QString::SkipEmptyParts ) );
+ const QStringList listFiles = helper->kind->processListing( QString::fromLocal8Bit( mStdOutData ).split( QLatin1Char('\n'), QString::SkipEmptyParts ) );
QStringList newList;
Q_FOREACH ( const QString &f, listFiles ) {
// Extract all the files to mTempDir regardless of their path inside the archive
// This will break if ever an arvhice with two files with the same name in different subfolders
QFileInfo fi( f );
- if ( QFile::exists( mTempDir->path() + '/' + fi.fileName() ) ) {
+ if ( QFile::exists( mTempDir->path() + QLatin1Char('/') + fi.fileName() ) ) {
newList.append( fi.fileName() );
}
}
@@ -152,7 +152,7 @@ QByteArray Unrar::contentOf( const QString &fileName ) const
if ( !isSuitableVersionAvailable() )
return QByteArray();
- QFile file( mTempDir->path() + '/' + fileName );
+ QFile file( mTempDir->path() + QLatin1Char('/') + fileName );
if ( !file.open( QIODevice::ReadOnly ) )
return QByteArray();
@@ -164,7 +164,7 @@ QIODevice* Unrar::createDevice( const QString &fileName ) const
if ( !isSuitableVersionAvailable() )
return 0;
- std::unique_ptr< QFile> file( new QFile( mTempDir->path() + '/' + fileName ) );
+ std::unique_ptr< QFile> file( new QFile( mTempDir->path() + QLatin1Char('/') + fileName ) );
if ( !file->open( QIODevice::ReadOnly ) )
return 0;
diff --git a/generators/djvu/kdjvu.cpp b/generators/djvu/kdjvu.cpp
index 990fcce..c2e345c 100644
--- a/generators/djvu/kdjvu.cpp
+++ b/generators/djvu/kdjvu.cpp
@@ -1059,7 +1059,7 @@ bool KDjVu::exportAsPostScript( QFile* file, const QList<int>& pageList ) const
pl += QLatin1String( "," );
pl += QString::number( p );
}
- pl.prepend( "-page=" );
+ pl.prepend( QStringLiteral ( "-page=" ) );
// setting the options
static const int optc = 1;
diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp
index 0f563fe..9b28323 100644
--- a/generators/epub/converter.cpp
+++ b/generators/epub/converter.cpp
@@ -85,17 +85,17 @@ void Converter::_handle_anchors(const QTextBlock &start, const QString &name) {
// remove ./ or ../
// making it easier to compare, with links
- while(!hrefString.isNull() && ( hrefString.at(0) == '.' || hrefString.at(0) == '/') ){
+ while(!hrefString.isNull() && ( hrefString.at(0) == QLatin1Char('.') || hrefString.at(0) == QLatin1Char('/')) ){
hrefString.remove(0,1);
}
QUrl href(hrefString);
if (href.isValid() && !href.isEmpty()) {
if (href.isRelative()) { // Inside document link
- if(!hrefString.indexOf('#'))
+ if(!hrefString.indexOf(QLatin1Char('#')))
hrefString = name + hrefString;
else if(QFileInfo(hrefString).path() == QLatin1String(".") && curDir != QLatin1String("."))
- hrefString = curDir + '/' + hrefString;
+ hrefString = curDir + QLatin1Char('/') + hrefString;
// QTextCharFormat sometimes splits a link in two
// if there's no white space between words & the first one is an anchor
@@ -122,7 +122,7 @@ void Converter::_handle_anchors(const QTextBlock &start, const QString &name) {
if (!names.empty()) {
for (QStringList::const_iterator lit = names.constBegin();
lit != names.constEnd(); ++lit) {
- mSectionMap.insert(name + '#' + *lit, bit);
+ mSectionMap.insert(name + QLatin1Char('#') + *lit, bit);
}
}
diff --git a/generators/epub/epubdocument.cpp b/generators/epub/epubdocument.cpp
index ac69b74..c101159 100644
--- a/generators/epub/epubdocument.cpp
+++ b/generators/epub/epubdocument.cpp
@@ -20,7 +20,7 @@ namespace {
QString resourceUrl(const QUrl &baseUrl, const QString &u)
{
- QUrl newUrl(baseUrl.adjusted(QUrl::RemoveFilename).path() + '/' + u);
+ QUrl newUrl(baseUrl.adjusted(QUrl::RemoveFilename).path() + QLatin1Char('/') + u);
QString newDir = newUrl.toLocalFile();
newDir.remove(0, 1);
return newDir;
@@ -56,7 +56,7 @@ struct epub *EpubDocument::getEpub()
void EpubDocument::setCurrentSubDocument(const QString &doc)
{
- mCurrentSubDocument = QUrl::fromLocalFile("/" + doc);
+ mCurrentSubDocument = QUrl::fromLocalFile(QLatin1Char('/') + doc);
}
int EpubDocument::maxContentHeight() const
diff --git a/generators/fictionbook/converter.cpp b/generators/fictionbook/converter.cpp
index 86ea25f..32ccd55 100644
--- a/generators/fictionbook/converter.cpp
+++ b/generators/fictionbook/converter.cpp
@@ -283,7 +283,7 @@ bool Converter::convertTitleInfo( const QDomElement &element )
if ( !convertTextNode( child, keywords ) )
return false;
- mTitleInfo->mKeywords = keywords.split( ' ', QString::SkipEmptyParts );
+ mTitleInfo->mKeywords = keywords.split( QLatin1Char(' '), QString::SkipEmptyParts );
} else if ( child.tagName() == QLatin1String( "date" ) ) {
if ( !convertDate( child, mTitleInfo->mDate ) )
return false;
@@ -606,7 +606,7 @@ bool Converter::convertImage( const QDomElement &element )
{
QString href = element.attributeNS( QStringLiteral("http://www.w3.org/1999/xlink"), QStringLiteral("href") );
- if ( href.startsWith( '#' ) )
+ if ( href.startsWith( QLatin1Char('#') ) )
href = href.mid( 1 );
const QImage img = qVariantValue<QImage>( mTextDocument->resource( QTextDocument::ImageResource, QUrl( href ) ) );
@@ -758,7 +758,7 @@ bool Converter::convertLink( const QDomElement &element )
if ( type == QLatin1String("note") )
mCursor->insertText( QStringLiteral("]") );
- if ( href.startsWith( '#' ) ) { // local link
+ if ( href.startsWith( QLatin1Char('#') ) ) { // local link
mLocalLinks.insert( href.mid( 1 ), QPair<int, int>( startPosition, endPosition ) );
} else {
// external link
diff --git a/generators/kimgio/tests/kimgiotest.cpp b/generators/kimgio/tests/kimgiotest.cpp
index 56f2047..8ed9e16 100644
--- a/generators/kimgio/tests/kimgiotest.cpp
+++ b/generators/kimgio/tests/kimgiotest.cpp
@@ -37,12 +37,12 @@ class KIMGIOTest
void KIMGIOTest::initTestCase()
{
// Make sure we find the okularGenerator_kimgio that we build just now and not the system one
- QFileInfo lib( GENERATOR_PATH );
+ QFileInfo lib( QStringLiteral(GENERATOR_PATH) );
QVERIFY2( lib.exists(), GENERATOR_PATH );
QStringList libPaths = QCoreApplication::libraryPaths();
libPaths.prepend( lib.absolutePath() );
QCoreApplication::setLibraryPaths( libPaths );
- QVERIFY( !KPluginLoader::findPlugin( "okularGenerator_kimgio" ).isEmpty() );
+ QVERIFY( !KPluginLoader::findPlugin( QStringLiteral("okularGenerator_kimgio") ).isEmpty() );
// make sure we didn't break the search path for image formats:
auto availableFormats = QImageReader::supportedImageFormats();
QVERIFY2(availableFormats.contains( "jpeg" ), availableFormats.join( ", " ).data() );
@@ -80,7 +80,7 @@ void KIMGIOTest::testExifOrientation()
QFETCH( QString, imgPath );
QMimeDatabase db;
- Okular::SettingsCore::instance( "kimgiotest" );
+ Okular::SettingsCore::instance( QStringLiteral("kimgiotest") );
Okular::Document *m_document = new Okular::Document( 0 );
const QMimeType mime = db.mimeTypeForFile( imgPath );
diff --git a/generators/mobipocket/converter.cpp b/generators/mobipocket/converter.cpp
index 689ca9b..09ac087 100644
--- a/generators/mobipocket/converter.cpp
+++ b/generators/mobipocket/converter.cpp
@@ -82,7 +82,7 @@ QTextDocument* Converter::convert( const QString &fileName )
if (!format.anchorNames().isEmpty()) {
// link targets
Q_FOREACH(const QString& name, format.anchorNames())
- targets['#'+name]=it;
+ targets[QLatin1Char('#')+name]=it;
}
}
diff --git a/generators/mobipocket/generator_mobi.cpp b/generators/mobipocket/generator_mobi.cpp
index 5afb02e..9ab7248 100644
--- a/generators/mobipocket/generator_mobi.cpp
+++ b/generators/mobipocket/generator_mobi.cpp
@@ -17,7 +17,7 @@
OKULAR_EXPORT_PLUGIN(MobiGenerator, "libokularGenerator_mobi.json")
MobiGenerator::MobiGenerator( QObject *parent, const QVariantList &args )
-: Okular::TextDocumentGenerator( new Mobi::Converter, "okular_mobi_generator_settings", parent, args )
+: Okular::TextDocumentGenerator( new Mobi::Converter, QStringLiteral("okular_mobi_generator_settings"), parent, args )
{
}
@@ -25,7 +25,7 @@ void MobiGenerator::addPages( KConfigDialog* dlg )
{
Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget();
- dlg->addPage( widget, generalSettings(), i18n("Mobipocket"), "application-x-mobipocket-ebook", i18n("Mobipocket Backend Configuration") );
+ dlg->addPage( widget, generalSettings(), i18n("Mobipocket"), QStringLiteral("application-x-mobipocket-ebook"), i18n("Mobipocket Backend Configuration") );
}
#include "generator_mobi.moc"
diff --git a/generators/mobipocket/mobidocument.cpp b/generators/mobipocket/mobidocument.cpp
index 66b5c07..c3b1f81 100644
--- a/generators/mobipocket/mobidocument.cpp
+++ b/generators/mobipocket/mobidocument.cpp
@@ -25,7 +25,7 @@ MobiDocument::MobiDocument(const QString &fileName) : QTextDocument()
if (doc->isValid()) {
QString text=doc->text();
QString header=text.left(1024);
- if (header.contains("<html>") || header.contains("<HTML>")) {
+ if (header.contains(QStringLiteral("<html>")) || header.contains(QStringLiteral("<HTML>"))) {
// HACK BEGIN Get the links without CSS to be blue
// Remove if Qt ever gets fixed and the code in textdocumentgenerator.cpp works
const QPalette orig = qApp->palette();
@@ -53,7 +53,7 @@ MobiDocument::~MobiDocument()
QVariant MobiDocument::loadResource(int type, const QUrl &name)
{
- if (type!=QTextDocument::ImageResource || name.scheme()!=QString("pdbrec")) return QVariant();
+ if (type!=QTextDocument::ImageResource || name.scheme()!=QString(QStringLiteral("pdbrec"))) return QVariant();
bool ok;
quint16 recnum=name.path().mid(1).toUShort(&ok);
if (!ok || recnum>=doc->imageCount()) return QVariant();
@@ -69,8 +69,8 @@ QVariant MobiDocument::loadResource(int type, const QUrl &name)
int outsideTag(const QString& data, int pos)
{
for (int i=pos-1;i>=0;i--) {
- if (data[i]=='>') return pos;
- if (data[i]=='<') return i;
+ if (data[i]==QLatin1Char('>')) return pos;
+ if (data[i]==QLatin1Char('<')) return i;
}
return pos;
}
@@ -79,7 +79,7 @@ QString MobiDocument::fixMobiMarkup(const QString& data)
{
QString ret=data;
QMap<int,QString> anchorPositions;
- static QRegExp anchors("<a(?: href=\"[^\"]*\"){0,1}[\\s]+filepos=['\"]{0,1}([\\d]+)[\"']{0,1}", Qt::CaseInsensitive);
+ static QRegExp anchors(QStringLiteral("<a(?: href=\"[^\"]*\"){0,1}[\\s]+filepos=['\"]{0,1}([\\d]+)[\"']{0,1}"), Qt::CaseInsensitive);
int pos=0;
// find all link destinations
@@ -97,20 +97,20 @@ QString MobiDocument::fixMobiMarkup(const QString& data)
// link pointing outside the document, ignore
if ( (it.key()+offset) >= ret.size()) continue;
int fixedpos=outsideTag(ret, it.key()+offset);
- ret.insert(fixedpos,QString("<a name=\"")+it.value()+QString("\">&nbsp;</a>"));
+ ret.insert(fixedpos,QStringLiteral("<a name=\"")+it.value()+QStringLiteral("\">&nbsp;</a>"));
// inserting anchor shifts all offsets after the anchor
offset+=21+it.value().size();
}
// replace links referencing filepos with normal internal links
- ret.replace(anchors,"<a href=\"#\\1\"");
+ ret.replace(anchors, QStringLiteral("<a href=\"#\\1\""));
// Mobipocket uses strange variang of IMG tags: <img recindex="3232"> where recindex is number of
// record containing image
- static QRegExp imgs("<img.*recindex=\"([\\d]*)\".*>", Qt::CaseInsensitive);
+ static QRegExp imgs(QStringLiteral("<img.*recindex=\"([\\d]*)\".*>"), Qt::CaseInsensitive);
imgs.setMinimal(true);
- ret.replace(imgs,"<img src=\"pdbrec:/\\1\">");
- ret.replace("<mbp:pagebreak/>","<p style=\"page-break-after:always\"></p>");
+ ret.replace(imgs, QStringLiteral("<img src=\"pdbrec:/\\1\">"));
+ ret.replace(QStringLiteral("<mbp:pagebreak/>"), QStringLiteral("<p style=\"page-break-after:always\"></p>"));
return ret;
}
diff --git a/generators/ooo/converter.cpp b/generators/ooo/converter.cpp
index 97de417..b715f57 100644
--- a/generators/ooo/converter.cpp
+++ b/generators/ooo/converter.cpp
@@ -253,7 +253,7 @@ bool Converter::convertHeader( QTextCursor *cursor, const QDomElement &element )
child = child.nextSibling();
}
- emit addTitle( element.attribute( QStringLiteral("outline-level"), 0 ).toInt(), element.text(), cursor->block() );
+ emit addTitle( element.attribute( QStringLiteral("outline-level"), QStringLiteral("0") ).toInt(), element.text(), cursor->block() );
return true;
}
@@ -284,7 +284,7 @@ bool Converter::convertParagraph( QTextCursor *cursor, const QDomElement &elemen
mCursor->insertText( QStringLiteral(" ") );
} else if ( childElement.tagName() == QLatin1String( "s" ) ) {
QString spaces;
- spaces.fill( ' ', childElement.attribute( QStringLiteral("c") ).toInt() );
+ spaces.fill( QLatin1Char(' '), childElement.attribute( QStringLiteral("c") ).toInt() );
mCursor->insertText( spaces );
} else if ( childElement.tagName() == QLatin1String( "frame" ) ) {
if ( !convertFrame( childElement ) )
diff --git a/generators/ooo/generator_ooo.cpp b/generators/ooo/generator_ooo.cpp
index b4f493f..875ebe5 100644
--- a/generators/ooo/generator_ooo.cpp
+++ b/generators/ooo/generator_ooo.cpp
@@ -32,7 +32,7 @@ void KOOOGenerator::addPages( KConfigDialog* dlg )
void KOOOGenerator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
{
- *walletKey = fileName + "/opendocument";
+ *walletKey = fileName + QStringLiteral("/opendocument");
*walletName = KWallet::Wallet::LocalWallet();
*walletFolder = KWallet::Wallet::PasswordFolder();
}
diff --git a/generators/plucker/unpluck/qunpluck.cpp b/generators/plucker/unpluck/qunpluck.cpp
index 3bebce0..37583c3 100644
--- a/generators/plucker/unpluck/qunpluck.cpp
+++ b/generators/plucker/unpluck/qunpluck.cpp
@@ -132,9 +132,9 @@ bool QUnpluck::open( const QString &fileName )
bool status = true;
- mInfo.insert( QStringLiteral("name"), plkr_GetName( mDocument ) );
- mInfo.insert( QStringLiteral("title"), plkr_GetTitle( mDocument ) );
- mInfo.insert( QStringLiteral("author"), plkr_GetAuthor( mDocument ) );
+ mInfo.insert( QStringLiteral("name"), QString::fromLocal8Bit(plkr_GetName( mDocument ) ));
+ mInfo.insert( QStringLiteral("title"), QString::fromLocal8Bit(plkr_GetTitle( mDocument ) ));
+ mInfo.insert( QStringLiteral("author"), QString::fromLocal8Bit(plkr_GetAuthor( mDocument ) ));
mInfo.insert( QStringLiteral("time"), QDateTime::fromTime_t( plkr_GetPublicationTime( mDocument ) ).toString() );
AddRecord( plkr_GetHomeRecordID( mDocument ) );
@@ -380,7 +380,7 @@ void QUnpluck::ParseText
end = ptr + text_len;
while (ptr < end) {
if (ptr[0]) {
- context->cursor->insertText( QString( (char*)ptr ) );
+ context->cursor->insertText( QString::fromLocal8Bit( (char*)ptr ) );
ptr += strlen ((char*)ptr);
}
else {
@@ -974,7 +974,7 @@ bool QUnpluck::TranscribeTextRecord
QTextBlockFormat oldBlockFormat = context->cursor->blockFormat();
QTextBlockFormat blockFormat;
- blockFormat.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, "100%");
+ blockFormat.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, QStringLiteral("100%"));
context->cursor->insertBlock( blockFormat );
context->cursor->insertBlock( oldBlockFormat );
context->cursor->setCharFormat( charFormat );
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 1b4bccb..3b53f41 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -1263,7 +1263,7 @@ bool PDFGenerator::setDocumentRenderHints()
const Poppler::Document::RenderHints oldhints = pdfdoc->renderHints();
#define SET_HINT(hintname, hintdefvalue, hintflag) \
{ \
- bool newhint = documentMetaData(hintname, hintdefvalue).toBool(); \
+ bool newhint = documentMetaData(QStringLiteral(hintname), hintdefvalue).toBool(); \
if (newhint != oldhints.testFlag(hintflag)) \
{ \
pdfdoc->setRenderHint(hintflag, newhint); \
@@ -1379,7 +1379,7 @@ Okular::TextPage * PDFGenerator::abstractTextPage(const QList<Poppler::TextBox*>
if (addChar)
{
QRectF charBBox = word->charBoundingBox(textBoxChar);
- append(ktp, (j==qstringCharCount-1 && !next) ? (s + "\n") : s,
+ append(ktp, (j==qstringCharCount-1 && !next) ? (s + QLatin1Char('\n')) : s,
charBBox.left()/width,
charBBox.bottom()/height,
charBBox.right()/width,
diff --git a/generators/xps/generator_xps.cpp b/generators/xps/generator_xps.cpp
index 7d25c4a..0f8ea12 100644
--- a/generators/xps/generator_xps.cpp
+++ b/generators/xps/generator_xps.cpp
@@ -86,7 +86,7 @@ static QColor hexToRgba(const QByteArray &name)
static QRectF stringToRectF( const QString &data )
{
- QStringList numbers = data.split(',');
+ QStringList numbers = data.split(QLatin1Char(','));
QPointF origin( numbers.at(0).toDouble(), numbers.at(1).toDouble() );
QSizeF size( numbers.at(2).toDouble(), numbers.at(3).toDouble() );
return QRectF( origin, size );
@@ -137,17 +137,17 @@ static bool nextAbbPathToken(AbbPathToken *token)
QChar ch = data.at(*curPos);
- if (ch.isNumber() || (ch == '+') || (ch == '-'))
+ if (ch.isNumber() || (ch == QLatin1Char('+')) || (ch == QLatin1Char('-')))
{
int start = *curPos;
- while ((*curPos < data.length()) && (!data.at(*curPos).isSpace()) && (data.at(*curPos) != ',') && (!data.at(*curPos).isLetter() || data.at(*curPos) == 'e'))
+ while ((*curPos < data.length()) && (!data.at(*curPos).isSpace()) && (data.at(*curPos) != QLatin1Char(',') && (!data.at(*curPos).isLetter() || data.at(*curPos) == QLatin1Char('e'))))
{
(*curPos)++;
}
token->number = data.midRef(start, *curPos - start).toDouble();
token->type = abtNumber;
- } else if (ch == ',')
+ } else if (ch == QLatin1Char(','))
{
token->type = abtComma;
(*curPos)++;
@@ -191,8 +191,8 @@ static QPointF getPointFromString(AbbPathToken *token, bool relative, const QPoi
*/
static QPointF getPointFromString(const QString &string)
{
- const int commaPos = string.indexOf(QLatin1Char(','));
- if (commaPos == -1 || string.indexOf(QLatin1Char(','), commaPos + 1) != -1)
+ const int commaPos = string.indexOf(QLatin1Char(QLatin1Char(',')));
+ if (commaPos == -1 || string.indexOf(QLatin1Char(QLatin1Char(',')), commaPos + 1) != -1)
return QPointF();
QPointF result;
@@ -252,8 +252,8 @@ static QPainterPath parseAbbreviatedPathData( const QString &data)
return path;
}
- char command = QChar(token.command).toLower().cell();
- bool isRelative = QChar(token.command).isLower();
+ char command = QChar::fromLatin1(token.command).toLower().cell();
+ bool isRelative = QChar::fromLatin1(token.command).isLower();
QPointF currPos = path.currentPosition();
nextAbbPathToken(&token);
@@ -377,7 +377,7 @@ static QPainterPath parseAbbreviatedPathData( const QString &data)
*/
static QTransform attsToMatrix( const QString &csv )
{
- QStringList values = csv.split( ',' );
+ QStringList values = csv.split( QLatin1Char(',') );
if ( values.count() != 6 ) {
return QTransform(); // that is an identity matrix - no effect
}
@@ -391,7 +391,7 @@ static QTransform attsToMatrix( const QString &csv )
*/
static QBrush parseRscRefColorForBrush( const QString &data )
{
- if (data[0] == '{') {
+ if (data[0] == QLatin1Char('{')) {
//TODO
qCWarning(OkularXpsDebug) << "Reference" << data;
return QBrush();
@@ -405,7 +405,7 @@ static QBrush parseRscRefColorForBrush( const QString &data )
*/
static QPen parseRscRefColorForPen( const QString &data )
{
- if (data[0] == '{') {
+ if (data[0] == QLatin1Char('{')) {
//TODO
qCWarning(OkularXpsDebug) << "Reference" << data;
return QPen();
@@ -419,7 +419,7 @@ static QPen parseRscRefColorForPen( const QString &data )
*/
static QTransform parseRscRefMatrix( const QString &data )
{
- if (data[0] == '{') {
+ if (data[0] == QLatin1Char('{')) {
//TODO
qCWarning(OkularXpsDebug) << "Reference" << data;
return QTransform();
@@ -433,7 +433,7 @@ static QTransform parseRscRefMatrix( const QString &data )
*/
static QPainterPath parseRscRefPath( const QString &data )
{
- if (data[0] == '{') {
+ if (data[0] == QLatin1Char('{')) {
//TODO
qCWarning(OkularXpsDebug) << "Reference" << data;
return QPainterPath();
@@ -473,7 +473,7 @@ static QString absolutePath( const QString &path, const QString &location )
// already absolute
retPath = location;
} else {
- retPath = QUrl::fromLocalFile(path + '/' + location).toDisplayString(QUrl::PreferLocalFile);
+ retPath = QUrl::fromLocalFile(path + QLatin1Char('/') + location).toDisplayString(QUrl::PreferLocalFile);
}
// it seems paths & file names can also be percent-encoded
// (XPS won't ever finish surprising me)
@@ -541,7 +541,7 @@ static const KArchiveEntry* loadEntry( KZip *archive, const QString &fileName, Q
path = fileName.left( index );
entryName = fileName.mid( index + 1 );
} else {
- path = '/';
+ path = QLatin1Char('/');
entryName = fileName;
}
const KArchiveEntry * newEntry = archive->directory()->entry( path );
@@ -879,10 +879,10 @@ void XpsHandler::processGlyph( XpsRenderNode &node )
att = node.attributes.value( QStringLiteral("Indices") );
QList<qreal> advanceWidths;
if ( ! att.isEmpty() ) {
- QStringList indicesElements = att.split( ';' );
+ QStringList indicesElements = att.split( QLatin1Char(';') );
for( int i = 0; i < indicesElements.size(); ++i ) {
if ( indicesElements.at(i).contains( QStringLiteral(",") ) ) {
- QStringList parts = indicesElements.at(i).split( ',' );
+ QStringList parts = indicesElements.at(i).split( QLatin1Char(',') );
if (parts.size() == 2 ) {
// regular advance case, no offsets
advanceWidths.append( parts.at(1).toDouble() * fontSize / 100.0 );
@@ -1389,7 +1389,7 @@ XpsPage::XpsPage(XpsFile *file, const QString &fileName): m_file( file ),
while ( !xml.atEnd() )
{
xml.readNext();
- if ( xml.isStartElement() && ( xml.name() == "FixedPage" ) )
+ if ( xml.isStartElement() && ( xml.name() == QStringLiteral("FixedPage") ) )
{
QXmlStreamAttributes attributes = xml.attributes();
m_pageSize.setWidth( attributes.value( QStringLiteral("Width") ).toString().toDouble() );
@@ -1601,41 +1601,41 @@ Okular::TextPage* XpsPage::textPage()
while ( ! xml.atEnd() ) {
xml.readNext();
if ( xml.isStartElement() ) {
- if ( xml.name() == "Canvas") {
+ if ( xml.name() == QStringLiteral("Canvas")) {
matrices.push(matrix);
QString att = xml.attributes().value( QStringLiteral("RenderTransform") ).toString();
if (!att.isEmpty()) {
matrix = parseRscRefMatrix( att ) * matrix;
}
- } else if ((xml.name() == "Canvas.RenderTransform") || (xml.name() == "Glyphs.RenderTransform")) {
+ } else if ((xml.name() == QStringLiteral("Canvas.RenderTransform")) || (xml.name() == QStringLiteral("Glyphs.RenderTransform"))) {
useMatrix = true;
- } else if (xml.name() == "MatrixTransform") {
+ } else if (xml.name() == QStringLiteral("MatrixTransform")) {
if (useMatrix) {
matrix = attsToMatrix( xml.attributes().value(QStringLiteral("Matrix")).toString() ) * matrix;
}
- } else if (xml.name() == "Glyphs") {
+ } else if (xml.name() == QStringLiteral("Glyphs")) {
matrices.push( matrix );
glyphsAtts = xml.attributes();
- } else if ( (xml.name() == "Path") || (xml.name() == "Path.Fill") || (xml.name() == "SolidColorBrush")
- || (xml.name() == "ImageBrush") || (xml.name() == "ImageBrush.Transform")
- || (xml.name() == "Path.OpacityMask") || (xml.name() == "Path.Data")
- || (xml.name() == "PathGeometry") || (xml.name() == "PathFigure")
- || (xml.name() == "PolyLineSegment") ) {
+ } else if ( (xml.name() == QStringLiteral("Path")) || (xml.name() == QStringLiteral("Path.Fill")) || (xml.name() == QStringLiteral("SolidColorBrush"))
+ || (xml.name() == QStringLiteral("ImageBrush")) || (xml.name() == QStringLiteral("ImageBrush.Transform"))
+ || (xml.name() == QStringLiteral("Path.OpacityMask")) || (xml.name() == QStringLiteral("Path.Data"))
+ || (xml.name() == QStringLiteral("PathGeometry")) || (xml.name() == QStringLiteral("PathFigure"))
+ || (xml.name() == QStringLiteral("PolyLineSegment")) ) {
// those are only graphical - no use in text handling
- } else if ( (xml.name() == "FixedPage") || (xml.name() == "FixedPage.Resources") ) {
+ } else if ( (xml.name() == QStringLiteral("FixedPage")) || (xml.name() == QStringLiteral("FixedPage.Resources")) ) {
// not useful for text extraction
} else {
qCWarning(OkularXpsDebug) << "Unhandled element in Text Extraction start: " << xml.name().toString();
}
} else if (xml.isEndElement() ) {
- if (xml.name() == "Canvas") {
+ if (xml.name() == QStringLiteral("Canvas")) {
matrix = matrices.pop();
- } else if ((xml.name() == "Canvas.RenderTransform") || (xml.name() == "Glyphs.RenderTransform")) {
+ } else if ((xml.name() == QStringLiteral("Canvas.RenderTransform")) || (xml.name() == QStringLiteral("Glyphs.RenderTransform"))) {
useMatrix = false;
- } else if (xml.name() == "MatrixTransform") {
+ } else if (xml.name() == QStringLiteral("MatrixTransform")) {
// not clear if we need to do anything here yet.
- } else if (xml.name() == "Glyphs") {
+ } else if (xml.name() == QStringLiteral("Glyphs")) {
QString att = glyphsAtts.value( QStringLiteral("RenderTransform") ).toString();
if (!att.isEmpty()) {
matrix = parseRscRefMatrix( att ) * matrix;
@@ -1666,13 +1666,13 @@ Okular::TextPage* XpsPage::textPage()
}
matrix = matrices.pop();
- } else if ( (xml.name() == "Path") || (xml.name() == "Path.Fill") || (xml.name() == "SolidColorBrush")
- || (xml.name() == "ImageBrush") || (xml.name() == "ImageBrush.Transform")
- || (xml.name() == "Path.OpacityMask") || (xml.name() == "Path.Data")
- || (xml.name() == "PathGeometry") || (xml.name() == "PathFigure")
- || (xml.name() == "PolyLineSegment") ) {
+ } else if ( (xml.name() == QStringLiteral("Path")) || (xml.name() == QStringLiteral("Path.Fill")) || (xml.name() == QStringLiteral("SolidColorBrush"))
+ || (xml.name() == QStringLiteral("ImageBrush")) || (xml.name() == QStringLiteral("ImageBrush.Transform"))
+ || (xml.name() == QStringLiteral("Path.OpacityMask")) || (xml.name() == QStringLiteral("Path.Data"))
+ || (xml.name() == QStringLiteral("PathGeometry")) || (xml.name() == QStringLiteral("PathFigure"))
+ || (xml.name() == QStringLiteral("PolyLineSegment")) ) {
// those are only graphical - no use in text handling
- } else if ( (xml.name() == "FixedPage") || (xml.name() == "FixedPage.Resources") ) {
+ } else if ( (xml.name() == QStringLiteral("FixedPage")) || (xml.name() == QStringLiteral("FixedPage.Resources")) ) {
// not useful for text extraction
} else {
qCWarning(OkularXpsDebug) << "Unhandled element in Text Extraction end: " << xml.name().toString();
@@ -1700,14 +1700,14 @@ void XpsDocument::parseDocumentStructure( const QString &documentStructureFileNa
xml.readNext();
if ( xml.isStartElement() ) {
- if ( xml.name() == "DocumentStructure" ) {
+ if ( xml.name() == QStringLiteral("DocumentStructure") ) {
// just a container for optional outline and story elements - nothing to do here
- } else if ( xml.name() == "DocumentStructure.Outline" ) {
+ } else if ( xml.name() == QStringLiteral("DocumentStructure.Outline") ) {
qCWarning(OkularXpsDebug) << "found DocumentStructure.Outline";
- } else if ( xml.name() == "DocumentOutline" ) {
+ } else if ( xml.name() == QStringLiteral("DocumentOutline") ) {
qCWarning(OkularXpsDebug) << "found DocumentOutline";
m_docStructure = new Okular::DocumentSynopsis;
- } else if ( xml.name() == "OutlineEntry" ) {
+ } else if ( xml.name() == QStringLiteral("OutlineEntry") ) {
m_haveDocumentStructure = true;
QXmlStreamAttributes attributes = xml.attributes();
int outlineLevel = attributes.value( QStringLiteral("OutlineLevel")).toString().toInt();
@@ -1715,7 +1715,7 @@ void XpsDocument::parseDocumentStructure( const QString &documentStructureFileNa
QDomElement synopsisElement = m_docStructure->createElement( description );
synopsisElement.setAttribute( QStringLiteral("OutlineLevel"), outlineLevel );
QString target = attributes.value(QStringLiteral("OutlineTarget")).toString();
- int hashPosition = target.lastIndexOf( '#' );
+ int hashPosition = target.lastIndexOf( QLatin1Char('#') );
target = target.mid( hashPosition + 1 );
// qCWarning(OkularXpsDebug) << "target: " << target;
Okular::DocumentViewport viewport;
@@ -1739,11 +1739,11 @@ void XpsDocument::parseDocumentStructure( const QString &documentStructureFileNa
maybeParentNode = maybeParentNode.lastChild();
}
}
- } else if ( xml.name() == "Story" ) {
+ } else if ( xml.name() == QStringLiteral("Story") ) {
// we need to handle Story here, but I have no idea what to do with it.
- } else if ( xml.name() == "StoryFragment" ) {
+ } else if ( xml.name() == QStringLiteral("StoryFragment") ) {
// we need to handle StoryFragment here, but I have no idea what to do with it.
- } else if ( xml.name() == "StoryFragmentReference" ) {
+ } else if ( xml.name() == QStringLiteral("StoryFragmentReference") ) {
// we need to handle StoryFragmentReference here, but I have no idea what to do with it.
} else {
qCWarning(OkularXpsDebug) << "Unhandled entry in DocumentStructure: " << xml.name().toString();
@@ -1775,19 +1775,19 @@ XpsDocument::XpsDocument(XpsFile *file, const QString &fileName): m_file(file),
while( !docXml.atEnd() ) {
docXml.readNext();
if ( docXml.isStartElement() ) {
- if ( docXml.name() == "PageContent" ) {
+ if ( docXml.name() == QStringLiteral("PageContent") ) {
QString pagePath = docXml.attributes().value(QStringLiteral("Source")).toString();
qCWarning(OkularXpsDebug) << "Page Path: " << pagePath;
XpsPage *page = new XpsPage( file, absolutePath( documentFilePath, pagePath ) );
m_pages.append(page);
- } else if ( docXml.name() == "PageContent.LinkTargets" ) {
+ } else if ( docXml.name() == QStringLiteral("PageContent.LinkTargets") ) {
// do nothing - wait for the real LinkTarget elements
- } else if ( docXml.name() == "LinkTarget" ) {
+ } else if ( docXml.name() == QStringLiteral("LinkTarget") ) {
QString targetName = docXml.attributes().value( QStringLiteral("Name") ).toString();
if ( ! targetName.isEmpty() ) {
m_docStructurePageMap[ targetName ] = m_pages.count() - 1;
}
- } else if ( docXml.name() == "FixedDocument" ) {
+ } else if ( docXml.name() == QStringLiteral("FixedDocument") ) {
// we just ignore this - it is just a container
} else {
qCWarning(OkularXpsDebug) << "Unhandled entry in FixedDocument: " << docXml.name().toString();
@@ -1802,8 +1802,8 @@ XpsDocument::XpsDocument(XpsFile *file, const QString &fileName): m_file(file),
// content structure description
// We should be able to find this using a reference from some other part of the document, but I can't see it.
- const int slashPosition = fileName.lastIndexOf( '/' );
- const QString documentRelationshipFile = absolutePath( documentEntryPath, "_rels/" + fileName.mid( slashPosition + 1 ) + ".rels" );
+ const int slashPosition = fileName.lastIndexOf( QLatin1Char('/') );
+ const QString documentRelationshipFile = absolutePath( documentEntryPath, QStringLiteral("_rels/") + fileName.mid( slashPosition + 1 ) + QStringLiteral(".rels") );
const KZipFileEntry* relFile = static_cast<const KZipFileEntry *>(file->xpsArchive()->directory()->entry(documentRelationshipFile));
@@ -1814,7 +1814,7 @@ XpsDocument::XpsDocument(XpsFile *file, const QString &fileName): m_file(file),
while ( !xml.atEnd() )
{
xml.readNext();
- if ( xml.isStartElement() && ( xml.name() == "Relationship" ) ) {
+ if ( xml.isStartElement() && ( xml.name() == QStringLiteral("Relationship") ) ) {
QXmlStreamAttributes attributes = xml.attributes();
if ( attributes.value( QStringLiteral("Type") ).toString() == QLatin1String("http://schemas.microsoft.com/xps/2005/06/documentstructure") ) {
documentStructureFile = attributes.value( QStringLiteral("Target") ).toString();
@@ -1906,22 +1906,22 @@ bool XpsFile::loadDocument(const QString &filename)
{
relXml.readNext();
if ( relXml.isStartElement() ) {
- if ( relXml.name() == "Relationship" ) {
+ if ( relXml.name() == QStringLiteral("Relationship") ) {
QXmlStreamAttributes attributes = relXml.attributes();
QString type = attributes.value( QStringLiteral("Type") ).toString();
QString target = attributes.value( QStringLiteral("Target") ).toString();
- if ( "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" == type ) {
+ if ( QStringLiteral("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail") == type ) {
m_thumbnailFileName = target;
- } else if ( "http://schemas.microsoft.com/xps/2005/06/fixedrepresentation" == type ) {
+ } else if ( QStringLiteral("http://schemas.microsoft.com/xps/2005/06/fixedrepresentation") == type ) {
fixedRepresentationFileName = target;
- } else if ("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" == type) {
+ } else if (QStringLiteral("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties") == type) {
m_corePropertiesFileName = target;
- } else if ("http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin" == type) {
+ } else if (QStringLiteral("http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin") == type) {
m_signatureOrigin = target;
} else {
qCWarning(OkularXpsDebug) << "Unknown relationships element: " << type << " : " << target;
}
- } else if ( relXml.name() == "Relationships" ) {
+ } else if ( relXml.name() == QStringLiteral("Relationships") ) {
// nothing to do here - this is just the container level
} else {
qCWarning(OkularXpsDebug) << "unexpected element in _rels/.rels: " << relXml.name().toString();
@@ -1948,7 +1948,7 @@ bool XpsFile::loadDocument(const QString &filename)
{
fixedRepXml.readNext();
if ( fixedRepXml.isStartElement() ) {
- if ( fixedRepXml.name() == "DocumentReference" ) {
+ if ( fixedRepXml.name() == QStringLiteral("DocumentReference") ) {
const QString source = fixedRepXml.attributes().value(QStringLiteral("Source")).toString();
XpsDocument *doc = new XpsDocument( this, absolutePath( fixedRepresentationFilePath, source ) );
for (int lv = 0; lv < doc->numPages(); ++lv) {
@@ -1956,7 +1956,7 @@ bool XpsFile::loadDocument(const QString &filename)
m_pages.append( doc->page( lv ) );
}
m_documents.append(doc);
- } else if ( fixedRepXml.name() == "FixedDocumentSequence") {
+ } else if ( fixedRepXml.name() == QStringLiteral("FixedDocumentSequence")) {
// we don't do anything here - this is just a container for one or more DocumentReference elements
} else {
qCWarning(OkularXpsDebug) << "Unhandled entry in FixedDocumentSequence: " << fixedRepXml.name().toString();
@@ -1989,25 +1989,25 @@ Okular::DocumentInfo XpsFile::generateDocumentInfo() const
break;
if ( xml.isStartElement() )
{
- if (xml.name() == "title") {
+ if (xml.name() == QStringLiteral("title")) {
docInfo.set( Okular::DocumentInfo::Title, xml.readElementText() );
- } else if (xml.name() == "subject") {
+ } else if (xml.name() == QStringLiteral("subject")) {
docInfo.set( Okular::DocumentInfo::Subject, xml.readElementText() );
- } else if (xml.name() == "description") {
+ } else if (xml.name() == QStringLiteral("description")) {
docInfo.set( Okular::DocumentInfo::Description, xml.readElementText() );
- } else if (xml.name() == "creator") {
+ } else if (xml.name() == QStringLiteral("creator")) {
docInfo.set( Okular::DocumentInfo::Creator, xml.readElementText() );
- } else if (xml.name() == "category") {
+ } else if (xml.name() == QStringLiteral("category")) {
docInfo.set( Okular::DocumentInfo::Category, xml.readElementText() );
- } else if (xml.name() == "created") {
+ } else if (xml.name() == QStringLiteral("created")) {
QDateTime createdDate = QDateTime::fromString( xml.readElementText(), QStringLiteral("yyyy-MM-ddThh:mm:ssZ") );
docInfo.set( Okular::DocumentInfo::CreationDate, QLocale().toString( createdDate, QLocale::LongFormat ) );
- } else if (xml.name() == "modified") {
+ } else if (xml.name() == QStringLiteral("modified")) {
QDateTime modifiedDate = QDateTime::fromString( xml.readElementText(), QStringLiteral("yyyy-MM-ddThh:mm:ssZ") );
docInfo.set( Okular::DocumentInfo::ModificationDate, QLocale().toString( modifiedDate, QLocale::LongFormat ) );
- } else if (xml.name() == "keywords") {
+ } else if (xml.name() == QStringLiteral("keywords")) {
docInfo.set( Okular::DocumentInfo::Keywords, xml.readElementText() );
- } else if (xml.name() == "revision") {
+ } else if (xml.name() == QStringLiteral("revision")) {
docInfo.set( QStringLiteral("revision"), xml.readElementText(), i18n( "Revision" ) );
}
}
@@ -2169,7 +2169,7 @@ bool XpsGenerator::exportTo( const QString &fileName, const Okular::ExportFormat
Okular::TextPage* textPage = m_xpsFile->page(i)->textPage();
QString text = textPage->text();
ts << text;
- ts << QChar('\n');
+ ts << QLatin1Char('\n');
delete textPage;
}
f.close();