1
/* This file is part of the KDE project
2
Copyright (C) 2010 KO GmbH <jos.van.den.oever@kogmbh.com>
3
Copyright (C) 2010 Sven Langkamp <sven.langkamp@gmail.com>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
21
#include <kaboutdata.h>
23
#include <KoPADocument.h>
24
#include <KoPAPageBase.h>
25
#include <KDE/KPluginFactory>
26
#include <KDE/KStandardDirs>
27
#include <KDE/KMimeType>
28
#include <KDE/KParts/ComponentFactory>
29
#include <QtCore/QDebug>
30
#include <OkularOdpGenerator.h>
31
#include <okular/core/page.h>
35
static KAboutData createAboutData()
40
ki18n( "ODP Backend" ),
42
ki18n( "ODP file renderer" ),
43
KAboutData::License_GPL,
44
ki18n( "© 2010 Sven Langkamp" )
47
// fill the about data
51
OKULAR_EXPORT_PLUGIN(OkularOdpGenerator, createAboutData())
53
OkularOdpGenerator::OkularOdpGenerator( QObject *parent, const QVariantList &args )
54
: Okular::Generator( parent, args )
59
OkularOdpGenerator::~OkularOdpGenerator()
63
bool OkularOdpGenerator::loadDocument( const QString &fileName, QVector<Okular::Page*> &pages )
65
KComponentData cd("OkularOdpGenerator", QByteArray(),
66
KComponentData::SkipMainComponentRegistration);
67
KPluginFactory *factory = KPluginLoader("libkpresenterpart", cd).factory();
69
qDebug() << "could not load libkpresenterpart";
72
KoPADocument* doc = factory->create<KoPADocument>();
75
url.setPath(fileName);
76
doc->setCheckAutoSaveFile(false);
77
doc->setAutoErrorHandlingEnabled(false); // show error dialogs
78
if (!doc->openUrl(url)) {
81
doc->setReadWrite(false);
85
int pageCount = m_doc->pageCount();
86
for(int i = 0; i < pageCount; i++) {
87
KoPAPageBase* kprpage = m_doc->pages().value(i);
91
QSize size = kprpage->size().toSize();
93
Okular::Page * page = new Okular::Page( i, size.width(), size.height(), Okular::Rotation0 );
100
bool OkularOdpGenerator::doCloseDocument()
106
bool OkularOdpGenerator::canGeneratePixmap() const
111
void OkularOdpGenerator::generatePixmap( Okular::PixmapRequest *request )
115
pix = new QPixmap(request->width(), request->height());
116
QPainter painter(pix);
117
painter.fillRect(0 ,0 , request->width(), request->height(), Qt::white);
119
KoPAPageBase* page = m_doc->pages().value(request->pageNumber());
120
pix = new QPixmap(page->thumbnail(QSize(request->width(), request->height())));
123
request->page()->setPixmap( request->id(), pix );
125
signalPixmapRequestDone( request );