~ubuntu-branches/ubuntu/vivid/kfilemetadata-kf5/vivid-updates

« back to all changes in this revision

Viewing changes to src/extractors/officeextractor.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-10-01 15:44:16 UTC
  • mto: (2.1.1 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141001154416-2im4irvqp092mkj9
Tags: upstream-5.1.0.1
ImportĀ upstreamĀ versionĀ 5.1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <QFile>
25
25
#include <QProcess>
26
 
#include <KService>
27
26
 
28
27
using namespace KFileMetaData;
29
28
 
30
 
OfficeExtractor::OfficeExtractor(QObject* parent, const QVariantList&)
 
29
OfficeExtractor::OfficeExtractor(QObject* parent)
31
30
    : ExtractorPlugin(parent)
32
31
{
33
32
    // Find the executables of catdoc, catppt and xls2csv. If an executable cannot
58
57
    QStringList args;
59
58
    QString contents;
60
59
 
61
 
    args << QLatin1String("-s") << QLatin1String("cp1252"); // FIXME: Store somewhere a map between the user's language and the encoding of the Windows files it may use ?
62
 
    args << QLatin1String("-d") << QLatin1String("utf8");
 
60
    args << QStringLiteral("-s") << QStringLiteral("cp1252"); // FIXME: Store somewhere a map between the user's language and the encoding of the Windows files it may use ?
 
61
    args << QStringLiteral("-d") << QStringLiteral("utf8");
63
62
 
64
63
    const QString fileUrl = result->inputUrl();
65
64
    const QString mimeType = result->inputMimetype();
66
 
    if (mimeType == QLatin1String("application/msword")) {
 
65
    if (mimeType == QStringLiteral("application/msword")) {
67
66
        result->addType(Type::Document);
68
67
 
69
 
        args << QLatin1String("-w");
 
68
        args << QStringLiteral("-w");
70
69
        contents = textFromFile(fileUrl, m_catdoc, args);
71
70
 
72
71
        // Now that we have the plain text content, count words, lines and characters
76
75
 
77
76
        result->add(Property::WordCount, words);
78
77
        result->add(Property::LineCount, lines);
79
 
    } else if (mimeType == QLatin1String("application/vnd.ms-excel")) {
 
78
    } else if (mimeType == QStringLiteral("application/vnd.ms-excel")) {
80
79
        result->addType(Type::Document);
81
80
        result->addType(Type::Spreadsheet);
82
81
 
83
 
        args << QLatin1String("-c") << QLatin1String(" ");
84
 
        args << QLatin1String("-b") << QLatin1String(" ");
85
 
        args << QLatin1String("-q") << QLatin1String("0");
 
82
        args << QStringLiteral("-c") << QStringLiteral(" ");
 
83
        args << QStringLiteral("-b") << QStringLiteral(" ");
 
84
        args << QStringLiteral("-q") << QStringLiteral("0");
86
85
        contents = textFromFile(fileUrl, m_xls2csv, args);
87
 
    } else if (mimeType == QLatin1String("application/vnd.ms-powerpoint")) {
 
86
    } else if (mimeType == QStringLiteral("application/vnd.ms-powerpoint")) {
88
87
        result->addType(Type::Document);
89
88
        result->addType(Type::Presentation);
90
89
 
115
114
    else
116
115
        return QString::fromUtf8(process.readAll());
117
116
}
118
 
 
119
 
K_PLUGIN_FACTORY(factory, registerPlugin<OfficeExtractor>();)
120
 
 
121
 
#include "officeextractor.moc"