generators: Fix build without implicit cast to/from ascii

See previous commit for details.
frameworks
Martin T. H. Sandsmark 10 years ago
parent b512e668e0
commit 2b473fedbd
  1. 2
      generators/comicbook/document.cpp
  2. 2
      generators/comicbook/qnatsort.cpp
  3. 12
      generators/comicbook/unrar.cpp
  4. 2
      generators/djvu/kdjvu.cpp
  5. 8
      generators/epub/converter.cpp
  6. 4
      generators/epub/epubdocument.cpp
  7. 6
      generators/fictionbook/converter.cpp
  8. 6
      generators/kimgio/tests/kimgiotest.cpp
  9. 2
      generators/mobipocket/converter.cpp
  10. 4
      generators/mobipocket/generator_mobi.cpp
  11. 20
      generators/mobipocket/mobidocument.cpp
  12. 4
      generators/ooo/converter.cpp
  13. 2
      generators/ooo/generator_ooo.cpp
  14. 10
      generators/plucker/unpluck/qunpluck.cpp
  15. 4
      generators/poppler/generator_pdf.cpp
  16. 142
      generators/xps/generator_xps.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 );
}

@ -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 )

@ -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;

@ -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;

@ -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);
}
}

@ -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

@ -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

@ -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 );

@ -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;
}
}

@ -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"

@ -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;
}

@ -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 ) )

@ -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();
}

@ -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 );

@ -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,

@ -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();

Loading…
Cancel
Save