~verzegnassi-stefano/+junk/pdf-viewer

« back to all changes in this revision

Viewing changes to src/plugin/libreofficetoolkit-qml-plugin/config.h

  • Committer: Stefano Verzegnassi
  • Date: 2016-04-15 10:51:55 UTC
  • Revision ID: stefano92.100@gmail.com-20160415105155-swsdn420t6n85b2i
 * Removed all the not necessary stuff, including the LibreOffice Viewer and the Plain Text Viewer
* 2014 WelcomePage is back again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2015 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 3, as published
6
 
 * by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
10
 
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
 
 * PURPOSE.  See the GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License along
14
 
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 */
17
 
 
18
 
#ifndef CONFIG_H
19
 
#define CONFIG_H
20
 
 
21
 
#define TILE_SIZE 256.0
22
 
 
23
 
// Uncomment it if you want to see tiles boundaries
24
 
//#define DEBUG_SHOW_TILE_BORDER
25
 
 
26
 
// Uncomment for benchmarking tile rendering performance
27
 
//#define DEBUG_TILE_BENCHMARK
28
 
 
29
 
// Uncomment if you want more verbose application output
30
 
//#define DEBUG_VERBOSE
31
 
 
32
 
#include <QDir>
33
 
#include <QStandardPaths>
34
 
#include <QCoreApplication>
35
 
#include <QDebug>
36
 
 
37
 
class Config
38
 
{
39
 
 
40
 
public:
41
 
    static const char* getLibreOfficePath() {
42
 
        QString loPath;
43
 
 
44
 
        // LibreOffice installation path on Debian/Ubuntu
45
 
        QString path = "/usr/lib/libreoffice/program";
46
 
 
47
 
        if (QDir(path).exists()) {
48
 
            loPath = path;
49
 
        }
50
 
 
51
 
        // Check if LibreOffice has been provided through a .click package
52
 
        else {
53
 
            QString libPaths = getenv("LD_LIBRARY_PATH");
54
 
 
55
 
            Q_FOREACH(QString libPath, libPaths.split(":")) {
56
 
                QDir clickDir(libPath);
57
 
 
58
 
                if (clickDir.cd("libreoffice/program")) {
59
 
                    QString clickPath = libPath + "/libreoffice/program";
60
 
 
61
 
                    loPath = clickPath;
62
 
                }
63
 
            }
64
 
        }
65
 
 
66
 
        if (loPath.isEmpty()) {
67
 
            qDebug() << "LibreOffice binaries not found.";
68
 
 
69
 
            return nullptr;
70
 
        }
71
 
 
72
 
        else {
73
 
            char *data = new char[loPath.toLatin1().size() + 1];
74
 
            strcpy(data, loPath.toLatin1().data());
75
 
 
76
 
            qDebug() << "LibreOffice binaries found at:" << loPath;
77
 
 
78
 
            return data;
79
 
        }
80
 
    }
81
 
 
82
 
    static const char* getLibreOfficeProfilePath() {
83
 
        QString configLocation = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
84
 
        QString appPkgName = QCoreApplication::organizationDomain();
85
 
 
86
 
        QString profilePath = "file://" + configLocation + "/" + appPkgName + "/libreoffice/4";
87
 
 
88
 
        qDebug() << "LibreOffice profile path:" << profilePath;
89
 
 
90
 
        char *data = new char[profilePath.toLatin1().size() + 1];
91
 
        strcpy(data, profilePath.toLatin1().data());
92
 
 
93
 
        return data;
94
 
    }
95
 
};
96
 
 
97
 
#endif // CONFIG_H