Okular

generator.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Piotr Szymanski <niedakh@gmail.com>
3 SPDX-FileCopyrightText: 2008 Albert Astals Cid <aacid@kde.org>
4
5 Work sponsored by the LiMux project of the city of Munich:
6 SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company <info@kdab.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#include "config-okular.h"
12
13#include "generator.h"
14#include "generator_p.h"
15#include "observer.h"
16
17#include <QApplication>
18#include <QEventLoop>
19#include <QPrinter>
20
21#include <KLocalizedString>
22#include <QDebug>
23#include <QIcon>
24#include <QMimeDatabase>
25#include <QTimer>
26
27#if HAVE_KWALLET
28#include <KWallet>
29#endif
30
31#include "document_p.h"
32#include "page.h"
33#include "page_p.h"
34#include "textpage.h"
35#include "utils.h"
36
37using namespace Okular;
38
39GeneratorPrivate::GeneratorPrivate()
40 : m_document(nullptr)
41 , mPixmapGenerationThread(nullptr)
42 , mTextPageGenerationThread(nullptr)
43 , mPixmapReady(true)
44 , mTextPageReady(true)
45 , m_closing(false)
46 , m_closingLoop(nullptr)
47 , m_dpi(72.0, 72.0)
48{
49 qRegisterMetaType<Okular::Page *>();
50}
51
52GeneratorPrivate::~GeneratorPrivate()
53{
54 if (mPixmapGenerationThread) {
55 mPixmapGenerationThread->wait();
56 }
57
58 delete mPixmapGenerationThread;
59
60 if (mTextPageGenerationThread) {
61 mTextPageGenerationThread->wait();
62 }
63
64 delete mTextPageGenerationThread;
65}
66
67PixmapGenerationThread *GeneratorPrivate::pixmapGenerationThread()
68{
69 if (mPixmapGenerationThread) {
70 return mPixmapGenerationThread;
71 }
72
73 Q_Q(Generator);
74 mPixmapGenerationThread = new PixmapGenerationThread(q);
76 mPixmapGenerationThread, &PixmapGenerationThread::finished, q, [this] { pixmapGenerationFinished(); }, Qt::QueuedConnection);
77
78 return mPixmapGenerationThread;
79}
80
81TextPageGenerationThread *GeneratorPrivate::textPageGenerationThread()
82{
83 if (mTextPageGenerationThread) {
84 return mTextPageGenerationThread;
85 }
86
87 Q_Q(Generator);
88 mTextPageGenerationThread = new TextPageGenerationThread(q);
90 mTextPageGenerationThread, &TextPageGenerationThread::finished, q, [this] { textpageGenerationFinished(); }, Qt::QueuedConnection);
91
92 return mTextPageGenerationThread;
93}
94
95void GeneratorPrivate::pixmapGenerationFinished()
96{
97 Q_Q(Generator);
98 PixmapRequest *request = mPixmapGenerationThread->request();
99 const QImage &img = mPixmapGenerationThread->image();
100 mPixmapGenerationThread->endGeneration();
101
102 QMutexLocker locker(threadsLock());
103
104 if (m_closing) {
105 mPixmapReady = true;
106 delete request;
107 if (mTextPageReady) {
108 locker.unlock();
109 m_closingLoop->quit();
110 }
111 return;
112 }
113
114 if (!request->shouldAbortRender()) {
115 request->page()->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(img)), request->normalizedRect());
116 const int pageNumber = request->page()->number();
117
118 if (mPixmapGenerationThread->calcBoundingBox()) {
119 q->updatePageBoundingBox(pageNumber, mPixmapGenerationThread->boundingBox());
120 }
121 } else {
122 // Cancel the text page generation too if it's still running
123 if (mTextPageGenerationThread && mTextPageGenerationThread->isRunning()) {
124 mTextPageGenerationThread->abortExtraction();
125 mTextPageGenerationThread->wait();
126 }
127 }
128
129 mPixmapReady = true;
130 q->signalPixmapRequestDone(request);
131}
132
133void GeneratorPrivate::textpageGenerationFinished()
134{
135 Q_Q(Generator);
136 Page *page = mTextPageGenerationThread->page();
137 mTextPageGenerationThread->endGeneration();
138
139 QMutexLocker locker(threadsLock());
140 mTextPageReady = true;
141
142 if (m_closing) {
143 delete mTextPageGenerationThread->textPage();
144 if (mPixmapReady) {
145 locker.unlock();
146 m_closingLoop->quit();
147 }
148 return;
149 }
150
151 if (mTextPageGenerationThread->textPage()) {
152 TextPage *tp = mTextPageGenerationThread->textPage();
153 page->setTextPage(tp);
154 q->signalTextGenerationDone(page, tp);
155 }
156}
157
158QMutex *GeneratorPrivate::threadsLock()
159{
160 return &m_threadsMutex;
161}
162
163QVariant GeneratorPrivate::metaData(const QString &, const QVariant &) const
164{
165 return QVariant();
166}
167
168QImage GeneratorPrivate::image(PixmapRequest *)
169{
170 return QImage();
171}
172
173Generator::Generator(QObject *parent, const QVariantList &args)
174 : Generator(*new GeneratorPrivate(), parent, args)
175{
176 // the delegated constructor does it all
177}
178
179Generator::Generator(GeneratorPrivate &dd, QObject *parent, const QVariantList &args)
180 : QObject(parent)
181 , d_ptr(&dd)
182{
183 d_ptr->q_ptr = this;
184 Q_UNUSED(args)
185}
186
188{
189 delete d_ptr;
190}
191
192bool Generator::loadDocument(const QString &fileName, QVector<Page *> &pagesVector)
193{
194 Q_UNUSED(fileName);
195 Q_UNUSED(pagesVector);
196
197 return false;
198}
199
201{
202 return false;
203}
204
206{
207 return loadDocument(fileName, pagesVector) ? Document::OpenSuccess : Document::OpenError;
208}
209
211{
212 return loadDocumentFromData(fileData, pagesVector) ? Document::OpenSuccess : Document::OpenError;
213}
214
216{
217 return SwapBackingFileError;
218}
219
221{
222 Q_D(Generator);
223
224 d->m_closing = true;
225
226 d->threadsLock()->lock();
227 if (!(d->mPixmapReady && d->mTextPageReady)) {
228 QEventLoop loop;
229 d->m_closingLoop = &loop;
230
231 d->threadsLock()->unlock();
232
233 loop.exec();
234
235 d->m_closingLoop = nullptr;
236 } else {
237 d->threadsLock()->unlock();
238 }
239
240 bool ret = doCloseDocument();
241
242 d->m_closing = false;
243
244 return ret;
245}
246
248{
249 Q_D(const Generator);
250 return d->mPixmapReady;
251}
252
253bool Generator::canSign() const
254{
255 return false;
256}
257
258bool Generator::sign(const NewSignatureData &, const QString &)
259{
260 return false;
261}
262
263CertificateStore *Generator::certificateStore() const
264{
265 return nullptr;
266}
267
269{
270 Q_D(Generator);
271 d->mPixmapReady = false;
272
273 const bool calcBoundingBox = !request->isTile() && !request->page()->isBoundingBoxKnown();
274
275 if (request->asynchronous() && hasFeature(Threaded)) {
276 if (d->textPageGenerationThread()->isFinished() && !canGenerateTextPage()) {
277 // It can happen that the text generation has already finished but
278 // mTextPageReady is still false because textpageGenerationFinished
279 // didn't have time to run, if so queue ourselves
280 QTimer::singleShot(0, this, [this, request] { generatePixmap(request); });
281 return;
282 }
283
284 /**
285 * We create the text page for every page that is visible to the
286 * user, so he can use the text extraction tools without a delay.
287 */
288 if (hasFeature(TextExtraction) && !request->page()->hasTextPage() && canGenerateTextPage() && !d->m_closing) {
289 d->mTextPageReady = false;
290 d->textPageGenerationThread()->setPage(request->page());
291
292 // dummy is used as a way to make sure the lambda gets disconnected each time it is executed
293 // since not all the times the pixmap generation thread starts we want the text generation thread to also start
294 QObject *dummy = new QObject();
295 connect(d_ptr->pixmapGenerationThread(), &QThread::started, dummy, [this, dummy] {
296 delete dummy;
297 d_ptr->textPageGenerationThread()->startGeneration();
298 });
299 }
300 // pixmap generation thread must be started *after* connect(), else we may miss the start signal and get lock-ups (see bug 396137)
301 d->pixmapGenerationThread()->startGeneration(request, calcBoundingBox);
302
303 return;
304 }
305
306 const QImage &img = image(request);
307 request->page()->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(img)), request->normalizedRect());
308 const int pageNumber = request->page()->number();
309
310 d->mPixmapReady = true;
311
313 if (calcBoundingBox) {
315 }
316}
317
319{
320 Q_D(const Generator);
321 return d->mTextPageReady;
322}
323
325{
326 TextRequest treq(page);
327 TextPage *tp = textPage(&treq);
328 page->setTextPage(tp);
329 signalTextGenerationDone(page, tp);
330}
331
333{
334 Q_D(Generator);
335 return d->image(request);
336}
337
339{
340 return nullptr;
341}
342
344{
345 Q_UNUSED(keys);
346
347 return DocumentInfo();
348}
349
351{
352 return nullptr;
353}
354
359
361{
362 return nullptr;
363}
364
369
371{
372 return true;
373}
374
378
380{
381 return PageSize::List();
382}
383
385{
386}
387
389{
390 return Document::UnknownPrintError;
391}
392
393void Generator::opaqueAction(const BackendOpaqueAction * /*action*/)
394{
395}
396
397void Generator::freeOpaqueActionContents(const BackendOpaqueAction & /*action*/)
398{
399}
400
401QVariant Generator::metaData(const QString &key, const QVariant &option) const
402{
403 Q_D(const Generator);
404 return d->metaData(key, option);
405}
406
411
413{
414 return false;
415}
416
417void Generator::walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const
418{
419#if HAVE_KWALLET
420 *walletKey = fileName.section(QLatin1Char('/'), -1, -1);
421 *walletName = KWallet::Wallet::NetworkWallet();
422 *walletFolder = QStringLiteral("KPdf");
423#endif
424}
425
427{
428 Q_D(const Generator);
429 return d->m_features.contains(feature);
430}
431
433{
434 Q_D(Generator);
435 if (d->m_document) {
436 d->m_document->requestDone(request);
437 } else {
438 delete request;
439 }
440}
441
443{
444 Q_D(Generator);
445 if (d->m_document) {
446 d->m_document->textGenerationDone(page);
447 } else {
448 delete textPage;
449 }
450}
451
453{
454 if (request->shouldAbortRender()) {
455 return;
456 }
457
458 PagePrivate *pagePrivate = PagePrivate::get(request->page());
459 pagePrivate->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(image)), request->normalizedRect(), true /* isPartialPixmap */);
460
461 const int pageNumber = request->page()->number();
463}
464
466{
467 Q_D(const Generator);
468 if (d->m_document) {
469 return d->m_document->m_parent;
470 }
471 return nullptr;
472}
473
475{
476 Q_D(Generator);
477 if (on) {
478 d->m_features.insert(feature);
479 } else {
480 d->m_features.remove(feature);
481 }
482}
483
485{
486 Q_D(const Generator);
487 if (!d->m_document) {
488 return QVariant();
489 }
490
491 return d->m_document->documentMetaData(key, option);
492}
493
495{
496 Q_D(const Generator);
497 return &d->m_mutex;
498}
499
500void Generator::updatePageBoundingBox(int page, const NormalizedRect &boundingBox)
501{
502 Q_D(Generator);
503 if (d->m_document) { // still connected to document?
504 d->m_document->setPageBoundingBox(page, boundingBox);
505 }
506}
507
509{
510 return {};
511}
512
514{
515 Q_D(Generator);
516 d->m_dpi = dpi;
517}
518
520{
521 Q_D(const Generator);
522 return d->m_dpi;
523}
524
526{
527 return nullptr;
528}
529
530TextRequest::TextRequest()
531 : d(new TextRequestPrivate)
532{
533 d->mPage = nullptr;
534 d->mShouldAbortExtraction = 0;
535}
536
537TextRequest::TextRequest(Page *page)
538 : d(new TextRequestPrivate)
539{
540 d->mPage = page;
541 d->mShouldAbortExtraction = 0;
542}
543
545{
546 delete d;
547}
548
550{
551 return d->mPage;
552}
553
555{
556 return d->mShouldAbortExtraction != 0;
557}
558
559TextRequestPrivate *TextRequestPrivate::get(const TextRequest *req)
560{
561 return req->d;
562}
563
564PixmapRequest::PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, qreal dpr, int priority, PixmapRequestFeatures features)
565 : d(new PixmapRequestPrivate)
566{
567 d->mObserver = observer;
568 d->mPageNumber = pageNumber;
569 d->mWidth = ceil(width * dpr);
570 d->mHeight = ceil(height * dpr);
571 d->mPriority = priority;
572 d->mFeatures = features;
573 d->mForce = false;
574 d->mTile = false;
575 d->mNormalizedRect = NormalizedRect();
576 d->mPartialUpdatesWanted = false;
577 d->mShouldAbortRender = 0;
578}
579
581{
582 delete d;
583}
584
586{
587 return d->mObserver;
588}
589
591{
592 return d->mPageNumber;
593}
594
596{
597 return d->mWidth;
598}
599
601{
602 return d->mHeight;
603}
604
606{
607 return d->mPriority;
608}
609
611{
612 return d->mFeatures & Asynchronous;
613}
614
616{
617 return d->mFeatures & Preload;
618}
619
621{
622 return d->mPage;
623}
624
626{
627 d->mTile = tile;
628}
629
631{
632 return d->mTile;
633}
634
636{
637 if (d->mNormalizedRect == rect) {
638 return;
639 }
640
641 d->mNormalizedRect = rect;
642}
643
645{
646 return d->mNormalizedRect;
647}
648
649void PixmapRequest::setPartialUpdatesWanted(bool partialUpdatesWanted)
650{
651 d->mPartialUpdatesWanted = partialUpdatesWanted;
652}
653
655{
656 return d->mPartialUpdatesWanted;
657}
658
660{
661 return d->mShouldAbortRender != 0;
662}
663
664Okular::TilesManager *PixmapRequestPrivate::tilesManager() const
665{
666 return mPage->d->tilesManager(mObserver);
667}
668
669PixmapRequestPrivate *PixmapRequestPrivate::get(const PixmapRequest *req)
670{
671 return req->d;
672}
673
674void PixmapRequestPrivate::swap()
675{
676 std::swap(mWidth, mHeight);
677}
678
679class Okular::ExportFormatPrivate : public QSharedData
680{
681public:
682 ExportFormatPrivate(const QString &description, const QMimeType &mimeType, const QIcon &icon = QIcon())
683 : QSharedData()
684 , mDescription(description)
685 , mMimeType(mimeType)
686 , mIcon(icon)
687 {
688 }
689 ~ExportFormatPrivate()
690 {
691 }
692
693 QString mDescription;
694 QMimeType mMimeType;
695 QIcon mIcon;
696};
697
699 : d(new ExportFormatPrivate(QString(), QMimeType()))
700{
701}
702
703ExportFormat::ExportFormat(const QString &description, const QMimeType &mimeType)
704 : d(new ExportFormatPrivate(description, mimeType))
705{
706}
707
708ExportFormat::ExportFormat(const QIcon &icon, const QString &description, const QMimeType &mimeType)
709 : d(new ExportFormatPrivate(description, mimeType, icon))
710{
711}
712
716
718 : d(other.d)
719{
720}
721
723{
724 if (this == &other) {
725 return *this;
726 }
727
728 d = other.d;
729
730 return *this;
731}
732
734{
735 return d->mDescription;
736}
737
739{
740 return d->mMimeType;
741}
742
744{
745 return d->mIcon;
746}
747
749{
750 return !d->mMimeType.isValid() || d->mDescription.isNull();
751}
752
754{
755 QMimeDatabase db;
756 switch (type) {
757 case PlainText:
758 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-x-generic")), i18n("Plain &Text..."), db.mimeTypeForName(QStringLiteral("text/plain")));
759 break;
760 case PDF:
761 return ExportFormat(QIcon::fromTheme(QStringLiteral("application-pdf")), i18n("PDF"), db.mimeTypeForName(QStringLiteral("application/pdf")));
762 break;
763 case OpenDocumentText:
764 return ExportFormat(
765 QIcon::fromTheme(QStringLiteral("application-vnd.oasis.opendocument.text")), i18nc("This is the document format", "OpenDocument Text"), db.mimeTypeForName(QStringLiteral("application/vnd.oasis.opendocument.text")));
766 break;
767 case HTML:
768 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-html")), i18nc("This is the document format", "HTML"), db.mimeTypeForName(QStringLiteral("text/html")));
769 break;
770 }
771 return ExportFormat();
772}
773
774bool ExportFormat::operator==(const ExportFormat &other) const
775{
776 return d == other.d;
777}
778
779bool ExportFormat::operator!=(const ExportFormat &other) const
780{
781 return d != other.d;
782}
783
785{
786 PixmapRequestPrivate *reqPriv = PixmapRequestPrivate::get(&req);
787
788 str << "PixmapRequest:" << &req;
789 str << "- observer:" << (qulonglong)req.observer();
790 str << "- page:" << req.pageNumber();
791 str << "- width:" << req.width();
792 str << "- height:" << req.height();
793 str << "- priority:" << req.priority();
794 str << "- async:" << (req.asynchronous() ? "true" : "false");
795 str << "- tile:" << (req.isTile() ? "true" : "false");
796 str << "- rect:" << req.normalizedRect();
797 str << "- preload:" << (req.preload() ? "true" : "false");
798 str << "- partialUpdates:" << (req.partialUpdatesWanted() ? "true" : "false");
799 str << "- shouldAbort:" << (req.shouldAbortRender() ? "true" : "false");
800 str << "- force:" << (reqPriv->mForce ? "true" : "false");
801 return str;
802}
803
804/* kate: replace-tabs on; indent-width 4; */
static const QString NetworkWallet()
A helper class to store information about x509 certificate.
The DocumentInfo structure can be filled in by generators to display metadata about the currently ope...
Definition document.h:76
Base class for objects being notified when something changes.
Definition observer.h:29
virtual void notifyPageChanged(int page, int flags)
This method is called whenever the content on page described by the passed flags has been changed.
Definition observer.cpp:29
@ Pixmap
Pixmaps has been changed.
Definition observer.h:45
A DOM tree that describes the Table of Contents.
Definition document.h:1431
The Document.
Definition document.h:192
OpenResult
Describes the result of an open document operation.
Definition document.h:210
Defines an entry for the export menu.
Definition generator.h:79
QMimeType mimeType() const
Returns the mime type of the format.
~ExportFormat()
Destroys the export format.
QString description() const
Returns the description of the format.
ExportFormat()
Creates an empty export format.
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
bool isNull() const
Returns whether the export format is null/valid.
QIcon icon() const
Returns the icon for GUI representations of the format.
ExportFormat & operator=(const ExportFormat &other)
StandardExportFormat
Type of standard export format.
Definition generator.h:148
@ PDF
PDF, aka Portable Document Format.
Definition generator.h:150
@ HTML
OpenDocument Text format.
Definition generator.h:152
@ OpenDocumentText
OpenDocument Text format.
Definition generator.h:151
@ PlainText
Plain text.
Definition generator.h:149
A small class that represents the information of a font.
Definition fontinfo.h:25
[Abstract Class] The information generator.
Definition generator.h:188
virtual void walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const
This method is called to know which wallet data should be used for the given file name.
virtual void freeOpaqueActionContents(const BackendOpaqueAction &action)
Frees the contents of the opaque action (if any);.
virtual void pageSizeChanged(const PageSize &pageSize, const PageSize &oldPageSize)
This method is called when the page size has been changed by the user.
virtual void generatePixmap(PixmapRequest *request)
This method can be called to trigger the generation of a new pixmap as described by request.
virtual void opaqueAction(const BackendOpaqueAction *action)
Calls the backend to execute an BackendOpaqueAction.
void generateTextPage(Page *page)
This method can be called to trigger the generation of a text page for the given page.
virtual const DocumentSynopsis * generateDocumentSynopsis()
Returns the 'table of content' object of the document or 0 if no table of content is available.
Generator(QObject *parent=nullptr, const QVariantList &args=QVariantList())
Creates a new generator.
virtual ExportFormat::List exportFormats() const
Returns the list of additional supported export formats.
virtual QAbstractItemModel * layersModel() const
Returns the 'layers model' object of the document or NULL if layers model is not available.
SwapBackingFileResult
Describes the result of an swap file operation.
Definition generator.h:278
DocumentMetaDataKey
Internal document setting.
Definition generator.h:542
virtual bool loadDocument(const QString &fileName, QVector< Page * > &pagesVector)
Loads the document with the given fileName and fills the pagesVector with the parsed pages.
void signalPartialPixmapRequest(Okular::PixmapRequest *request, const QImage &image)
This method can be called to trigger a partial pixmap update for the given request Make sure you call...
virtual Document::OpenResult loadDocumentWithPassword(const QString &fileName, QVector< Page * > &pagesVector, const QString &password)
Loads the document with the given fileName and password and fills the pagesVector with the parsed pag...
virtual void rotationChanged(Rotation orientation, Rotation oldOrientation)
This method is called when the orientation has been changed by the user.
virtual QVariant metaData(const QString &key, const QVariant &option) const
This method returns the meta data of the given key with the given option of the document.
virtual const QList< EmbeddedFile * > * embeddedFiles() const
Returns the 'list of embedded files' object of the document or 0 if no list of embedded files is avai...
bool hasFeature(GeneratorFeature feature) const
Query for the specified feature.
void signalTextGenerationDone(Page *page, TextPage *textPage)
This method must be called when a text generation has been finished.
bool closeDocument()
This method is called when the document is closed and not used any longer.
QSizeF dpi() const
Returns DPI, previously set via setDPI()
virtual TextPage * textPage(TextRequest *request)
Returns the text page for the given request.
virtual bool isAllowed(Permission action) const
Returns whether the given action is allowed in the document.
virtual FontInfo::List fontsForPage(int page)
Returns the 'list of embedded fonts' object of the specified page of the document.
~Generator() override
Destroys the generator.
GeneratorFeature
Describe the possible optional features that a Generator can provide.
Definition generator.h:201
@ Threaded
Whether the Generator supports asynchronous generation of pictures or text pages.
Definition generator.h:202
@ TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition generator.h:203
virtual Document::OpenResult loadDocumentFromDataWithPassword(const QByteArray &fileData, QVector< Page * > &pagesVector, const QString &password)
Loads the document from the raw data fileData and password and fills the pagesVector with the parsed ...
virtual SwapBackingFileResult swapBackingFile(const QString &newFileName, QVector< Okular::Page * > &newPagesVector)
Changes the path of the file we are reading from.
void setDPI(const QSizeF dpi)
Update DPI of the generator.
virtual DocumentInfo generateDocumentInfo(const QSet< DocumentInfo::Key > &keys) const
Returns the general information object of the document.
virtual PageSizeMetric pagesSizeMetric() const
This method returns the metric of the page size.
virtual bool exportTo(const QString &fileName, const ExportFormat &format)
This method is called to export the document in the given format and save it under the given fileName...
QVariant documentMetaData(const DocumentMetaDataKey key, const QVariant &option=QVariant()) const
Request a meta data of the Document, if available, like an internal setting.
PageSizeMetric
This enum identifies the metric of the page size.
Definition generator.h:367
@ None
The page size is not defined in a physical metric.
Definition generator.h:368
const Document * document() const
Returns a pointer to the document.
virtual bool canGenerateTextPage() const
This method returns whether the generator is ready to handle a new text page request.
void setFeature(GeneratorFeature feature, bool on=true)
Toggle the feature .
void signalPixmapRequestDone(PixmapRequest *request)
This method must be called when the pixmap request triggered by generatePixmap() has been finished.
void updatePageBoundingBox(int page, const NormalizedRect &boundingBox)
Set the bounding box of a page after the page has already been handed to the Document.
virtual Document::PrintError print(QPrinter &printer)
This method is called to print the document to the given printer.
virtual PageSize::List pageSizes() const
Returns the list of supported page sizes.
virtual bool doCloseDocument()=0
This method is called when the document is closed and not used any longer.
virtual bool loadDocumentFromData(const QByteArray &fileData, QVector< Page * > &pagesVector)
Loads the document from the raw data fileData and fills the pagesVector with the parsed pages.
virtual QByteArray requestFontData(const Okular::FontInfo &font)
Gets the font data for the given font.
virtual bool canGeneratePixmap() const
This method returns whether the generator is ready to handle a new pixmap request.
virtual QImage image(PixmapRequest *request)
Returns the image of the page as specified in the passed pixmap request.
QMutex * userMutex() const
Return the pointer to a mutex the generator can use freely.
Data needed to create a new signature.
Definition document.h:1538
A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.
Definition area.h:189
A small class that represents the size of a page.
Definition pagesize.h:24
Collector for all the data belonging to a page.
Definition page.h:48
void setTextPage(TextPage *text)
Sets the text page.
Definition page.cpp:585
int number() const
Returns the number of the page in the document.
Definition page.cpp:160
bool hasTextPage() const
Returns whether the page provides a text page (TextPage).
Definition page.cpp:256
void setPixmap(DocumentObserver *observer, QPixmap *pixmap, const NormalizedRect &rect=NormalizedRect())
Sets the region described by rect with pixmap for the given observer.
Definition page.cpp:547
bool isBoundingBoxKnown() const
Returns whether the bounding box of the page has been computed.
Definition page.cpp:200
Describes a pixmap type request.
Definition generator.h:611
bool preload() const
Returns whether the generation request is for a page that is not important i.e.
void setTile(bool tile)
Sets whether the generator should render only the given normalized rect or the entire page.
bool asynchronous() const
Returns whether the generation should be done synchronous or asynchronous.
bool shouldAbortRender() const
Should the request be aborted if possible?
PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, qreal dpr, int priority, PixmapRequestFeatures features)
Creates a new pixmap request.
~PixmapRequest()
Destroys the pixmap request.
void setPartialUpdatesWanted(bool partialUpdatesWanted)
Sets whether the request should report back updates if possible.
int width() const
Returns the page width of the requested pixmap.
int height() const
Returns the page height of the requested pixmap.
int priority() const
Returns the priority (less it better, 0 is maximum) of the request.
const NormalizedRect & normalizedRect() const
Returns the normalized region of the page to request.
bool partialUpdatesWanted() const
Should the request report back updates if possible?
int pageNumber() const
Returns the page number of the request.
void setNormalizedRect(const NormalizedRect &rect)
Sets the region of the page to request.
Page * page() const
Returns a pointer to the page where the pixmap shall be generated for.
bool isTile() const
Returns whether the generator should render just the region given by normalizedRect() or the entire p...
DocumentObserver * observer() const
Returns the observer of the request.
Represents the textual information of a Page.
Definition textpage.h:102
Describes a text request.
Definition generator.h:747
bool shouldAbortExtraction() const
Should the request be aborted if possible?
Page * page() const
Returns a pointer to the page where the pixmap shall be generated for.
~TextRequest()
Destroys the pixmap request.
static NormalizedRect imageBoundingBox(const QImage *image)
Compute the smallest rectangle that contains all non-white pixels in image), in normalized [0,...
Definition utils.cpp:69
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KCALUTILS_EXPORT QString mimeType()
global.h
Definition action.h:17
Permission
Describes the DRM capabilities.
Definition global.h:24
Rotation
A rotation.
Definition global.h:46
QDebug operator<<(QDebug dbg, const PerceptualColor::LchaDouble &value)
int exec(QEventLoop::ProcessEventsFlags flags)
QIcon fromTheme(const QString &name)
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags)
QString section(QChar sep, int start, int end, QString::SectionFlags flags) const const
QueuedConnection
void started()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:44:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.