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 : q_ptr(nullptr)
41 , m_document(nullptr)
42 , mPixmapGenerationThread(nullptr)
43 , mTextPageGenerationThread(nullptr)
44 , mPixmapReady(true)
45 , mTextPageReady(true)
46 , m_closing(false)
47 , m_closingLoop(nullptr)
48 , m_dpi(72.0, 72.0)
49{
50 qRegisterMetaType<Okular::Page *>();
51}
52
53GeneratorPrivate::~GeneratorPrivate()
54{
55 if (mPixmapGenerationThread) {
56 mPixmapGenerationThread->wait();
57 }
58
59 delete mPixmapGenerationThread;
60
61 if (mTextPageGenerationThread) {
62 mTextPageGenerationThread->wait();
63 }
64
65 delete mTextPageGenerationThread;
66}
67
68PixmapGenerationThread *GeneratorPrivate::pixmapGenerationThread()
69{
70 if (mPixmapGenerationThread) {
71 return mPixmapGenerationThread;
72 }
73
74 Q_Q(Generator);
75 mPixmapGenerationThread = new PixmapGenerationThread(q);
77 mPixmapGenerationThread, &PixmapGenerationThread::finished, q, [this] { pixmapGenerationFinished(); }, Qt::QueuedConnection);
78
79 return mPixmapGenerationThread;
80}
81
82TextPageGenerationThread *GeneratorPrivate::textPageGenerationThread()
83{
84 if (mTextPageGenerationThread) {
85 return mTextPageGenerationThread;
86 }
87
88 Q_Q(Generator);
89 mTextPageGenerationThread = new TextPageGenerationThread(q);
91 mTextPageGenerationThread, &TextPageGenerationThread::finished, q, [this] { textpageGenerationFinished(); }, Qt::QueuedConnection);
92
93 return mTextPageGenerationThread;
94}
95
96void GeneratorPrivate::pixmapGenerationFinished()
97{
98 Q_Q(Generator);
99 PixmapRequest *request = mPixmapGenerationThread->request();
100 const QImage &img = mPixmapGenerationThread->image();
101 mPixmapGenerationThread->endGeneration();
102
103 QMutexLocker locker(threadsLock());
104
105 if (m_closing) {
106 mPixmapReady = true;
107 delete request;
108 if (mTextPageReady) {
109 locker.unlock();
110 m_closingLoop->quit();
111 }
112 return;
113 }
114
115 if (!request->shouldAbortRender()) {
116 request->page()->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(img)), request->normalizedRect());
117 const int pageNumber = request->page()->number();
118
119 if (mPixmapGenerationThread->calcBoundingBox()) {
120 q->updatePageBoundingBox(pageNumber, mPixmapGenerationThread->boundingBox());
121 }
122 } else {
123 // Cancel the text page generation too if it's still running
124 if (mTextPageGenerationThread && mTextPageGenerationThread->isRunning()) {
125 mTextPageGenerationThread->abortExtraction();
126 mTextPageGenerationThread->wait();
127 }
128 }
129
130 mPixmapReady = true;
131 q->signalPixmapRequestDone(request);
132}
133
134void GeneratorPrivate::textpageGenerationFinished()
135{
136 Q_Q(Generator);
137 Page *page = mTextPageGenerationThread->page();
138 mTextPageGenerationThread->endGeneration();
139
140 QMutexLocker locker(threadsLock());
141 mTextPageReady = true;
142
143 if (m_closing) {
144 delete mTextPageGenerationThread->textPage();
145 if (mPixmapReady) {
146 locker.unlock();
147 m_closingLoop->quit();
148 }
149 return;
150 }
151
152 if (mTextPageGenerationThread->textPage()) {
153 TextPage *tp = mTextPageGenerationThread->textPage();
154 page->setTextPage(tp);
155 q->signalTextGenerationDone(page, tp);
156 }
157}
158
159QMutex *GeneratorPrivate::threadsLock()
160{
161 return &m_threadsMutex;
162}
163
164QVariant GeneratorPrivate::metaData(const QString &, const QVariant &) const
165{
166 return QVariant();
167}
168
169QImage GeneratorPrivate::image(PixmapRequest *)
170{
171 return QImage();
172}
173
174Generator::Generator(QObject *parent, const QVariantList &args)
175 : Generator(*new GeneratorPrivate(), parent, args)
176{
177 // the delegated constructor does it all
178}
179
180Generator::Generator(GeneratorPrivate &dd, QObject *parent, const QVariantList &args)
181 : QObject(parent)
182 , d_ptr(&dd)
183{
184 d_ptr->q_ptr = this;
185 Q_UNUSED(args)
186}
187
189{
190 delete d_ptr;
191}
192
193bool Generator::loadDocument(const QString &fileName, QVector<Page *> &pagesVector)
194{
195 Q_UNUSED(fileName);
196 Q_UNUSED(pagesVector);
197
198 return false;
199}
200
202{
203 return false;
204}
205
207{
208 return loadDocument(fileName, pagesVector) ? Document::OpenSuccess : Document::OpenError;
209}
210
212{
213 return loadDocumentFromData(fileData, pagesVector) ? Document::OpenSuccess : Document::OpenError;
214}
215
217{
218 return SwapBackingFileError;
219}
220
222{
223 Q_D(Generator);
224
225 d->m_closing = true;
226
227 d->threadsLock()->lock();
228 if (!(d->mPixmapReady && d->mTextPageReady)) {
229 QEventLoop loop;
230 d->m_closingLoop = &loop;
231
232 d->threadsLock()->unlock();
233
234 loop.exec();
235
236 d->m_closingLoop = nullptr;
237 } else {
238 d->threadsLock()->unlock();
239 }
240
241 bool ret = doCloseDocument();
242
243 d->m_closing = false;
244
245 return ret;
246}
247
249{
250 Q_D(const Generator);
251 return d->mPixmapReady;
252}
253
254bool Generator::canSign() const
255{
256 return false;
257}
258
259bool Generator::sign(const NewSignatureData &, const QString &)
260{
261 return false;
262}
263
264CertificateStore *Generator::certificateStore() const
265{
266 return nullptr;
267}
268
270{
271 Q_D(Generator);
272 d->mPixmapReady = false;
273
274 const bool calcBoundingBox = !request->isTile() && !request->page()->isBoundingBoxKnown();
275
276 if (request->asynchronous() && hasFeature(Threaded)) {
277 if (d->textPageGenerationThread()->isFinished() && !canGenerateTextPage()) {
278 // It can happen that the text generation has already finished but
279 // mTextPageReady is still false because textpageGenerationFinished
280 // didn't have time to run, if so queue ourselves
281 QTimer::singleShot(0, this, [this, request] { generatePixmap(request); });
282 return;
283 }
284
285 /**
286 * We create the text page for every page that is visible to the
287 * user, so he can use the text extraction tools without a delay.
288 */
289 if (hasFeature(TextExtraction) && !request->page()->hasTextPage() && canGenerateTextPage() && !d->m_closing) {
290 d->mTextPageReady = false;
291 d->textPageGenerationThread()->setPage(request->page());
292
293 // dummy is used as a way to make sure the lambda gets disconnected each time it is executed
294 // since not all the times the pixmap generation thread starts we want the text generation thread to also start
295 QObject *dummy = new QObject();
296 connect(d_ptr->pixmapGenerationThread(), &QThread::started, dummy, [this, dummy] {
297 delete dummy;
298 d_ptr->textPageGenerationThread()->startGeneration();
299 });
300 }
301 // pixmap generation thread must be started *after* connect(), else we may miss the start signal and get lock-ups (see bug 396137)
302 d->pixmapGenerationThread()->startGeneration(request, calcBoundingBox);
303
304 return;
305 }
306
307 const QImage &img = image(request);
308 request->page()->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(img)), request->normalizedRect());
309 const int pageNumber = request->page()->number();
310
311 d->mPixmapReady = true;
312
314 if (calcBoundingBox) {
316 }
317}
318
320{
321 Q_D(const Generator);
322 return d->mTextPageReady;
323}
324
326{
327 TextRequest treq(page);
328 TextPage *tp = textPage(&treq);
329 page->setTextPage(tp);
330 signalTextGenerationDone(page, tp);
331}
332
334{
335 Q_D(Generator);
336 return d->image(request);
337}
338
340{
341 return nullptr;
342}
343
345{
346 Q_UNUSED(keys);
347
348 return DocumentInfo();
349}
350
352{
353 return nullptr;
354}
355
360
362{
363 return nullptr;
364}
365
370
372{
373 return true;
374}
375
379
381{
382 return PageSize::List();
383}
384
386{
387}
388
390{
391 return Document::UnknownPrintError;
392}
393
394void Generator::opaqueAction(const BackendOpaqueAction * /*action*/)
395{
396}
397
398void Generator::freeOpaqueActionContents(const BackendOpaqueAction & /*action*/)
399{
400}
401
402QVariant Generator::metaData(const QString &key, const QVariant &option) const
403{
404 Q_D(const Generator);
405 return d->metaData(key, option);
406}
407
412
414{
415 return false;
416}
417
418void Generator::walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const
419{
420#if HAVE_KWALLET
421 *walletKey = fileName.section(QLatin1Char('/'), -1, -1);
422 *walletName = KWallet::Wallet::NetworkWallet();
423 *walletFolder = QStringLiteral("KPdf");
424#endif
425}
426
428{
429 Q_D(const Generator);
430 return d->m_features.contains(feature);
431}
432
434{
435 Q_D(Generator);
436 if (d->m_document) {
437 d->m_document->requestDone(request);
438 } else {
439 delete request;
440 }
441}
442
444{
445 Q_D(Generator);
446 if (d->m_document) {
447 d->m_document->textGenerationDone(page);
448 } else {
449 delete textPage;
450 }
451}
452
454{
455 if (request->shouldAbortRender()) {
456 return;
457 }
458
459 PagePrivate *pagePrivate = PagePrivate::get(request->page());
460 pagePrivate->setPixmap(request->observer(), new QPixmap(QPixmap::fromImage(image)), request->normalizedRect(), true /* isPartialPixmap */);
461
462 const int pageNumber = request->page()->number();
464}
465
467{
468 Q_D(const Generator);
469 if (d->m_document) {
470 return d->m_document->m_parent;
471 }
472 return nullptr;
473}
474
476{
477 Q_D(Generator);
478 if (on) {
479 d->m_features.insert(feature);
480 } else {
481 d->m_features.remove(feature);
482 }
483}
484
486{
487 Q_D(const Generator);
488 if (!d->m_document) {
489 return QVariant();
490 }
491
492 return d->m_document->documentMetaData(key, option);
493}
494
496{
497 Q_D(const Generator);
498 return &d->m_mutex;
499}
500
501void Generator::updatePageBoundingBox(int page, const NormalizedRect &boundingBox)
502{
503 Q_D(Generator);
504 if (d->m_document) { // still connected to document?
505 d->m_document->setPageBoundingBox(page, boundingBox);
506 }
507}
508
510{
511 return {};
512}
513
515{
516 Q_D(Generator);
517 d->m_dpi = dpi;
518}
519
521{
522 Q_D(const Generator);
523 return d->m_dpi;
524}
525
527{
528 return nullptr;
529}
530
531TextRequest::TextRequest()
532 : d(new TextRequestPrivate)
533{
534 d->mPage = nullptr;
535 d->mShouldAbortExtraction = 0;
536}
537
538TextRequest::TextRequest(Page *page)
539 : d(new TextRequestPrivate)
540{
541 d->mPage = page;
542 d->mShouldAbortExtraction = 0;
543}
544
546{
547 delete d;
548}
549
551{
552 return d->mPage;
553}
554
556{
557 return d->mShouldAbortExtraction != 0;
558}
559
560TextRequestPrivate *TextRequestPrivate::get(const TextRequest *req)
561{
562 return req->d;
563}
564
565PixmapRequest::PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, qreal dpr, int priority, PixmapRequestFeatures features)
566 : d(new PixmapRequestPrivate)
567{
568 d->mObserver = observer;
569 d->mPageNumber = pageNumber;
570 d->mWidth = ceil(width * dpr);
571 d->mHeight = ceil(height * dpr);
572 d->mPriority = priority;
573 d->mFeatures = features;
574 d->mForce = false;
575 d->mTile = false;
576 d->mNormalizedRect = NormalizedRect();
577 d->mPartialUpdatesWanted = false;
578 d->mShouldAbortRender = 0;
579}
580
582{
583 delete d;
584}
585
587{
588 return d->mObserver;
589}
590
592{
593 return d->mPageNumber;
594}
595
597{
598 return d->mWidth;
599}
600
602{
603 return d->mHeight;
604}
605
607{
608 return d->mPriority;
609}
610
612{
613 return d->mFeatures & Asynchronous;
614}
615
617{
618 return d->mFeatures & Preload;
619}
620
622{
623 return d->mPage;
624}
625
627{
628 d->mTile = tile;
629}
630
632{
633 return d->mTile;
634}
635
637{
638 if (d->mNormalizedRect == rect) {
639 return;
640 }
641
642 d->mNormalizedRect = rect;
643}
644
646{
647 return d->mNormalizedRect;
648}
649
650void PixmapRequest::setPartialUpdatesWanted(bool partialUpdatesWanted)
651{
652 d->mPartialUpdatesWanted = partialUpdatesWanted;
653}
654
656{
657 return d->mPartialUpdatesWanted;
658}
659
661{
662 return d->mShouldAbortRender != 0;
663}
664
665Okular::TilesManager *PixmapRequestPrivate::tilesManager() const
666{
667 return mPage->d->tilesManager(mObserver);
668}
669
670PixmapRequestPrivate *PixmapRequestPrivate::get(const PixmapRequest *req)
671{
672 return req->d;
673}
674
675void PixmapRequestPrivate::swap()
676{
677 std::swap(mWidth, mHeight);
678}
679
680class Okular::ExportFormatPrivate : public QSharedData
681{
682public:
683 ExportFormatPrivate(const QString &description, const QMimeType &mimeType, const QIcon &icon = QIcon())
684 : QSharedData()
685 , mDescription(description)
686 , mMimeType(mimeType)
687 , mIcon(icon)
688 {
689 }
690 ~ExportFormatPrivate()
691 {
692 }
693
694 QString mDescription;
695 QMimeType mMimeType;
696 QIcon mIcon;
697};
698
700 : d(new ExportFormatPrivate(QString(), QMimeType()))
701{
702}
703
704ExportFormat::ExportFormat(const QString &description, const QMimeType &mimeType)
705 : d(new ExportFormatPrivate(description, mimeType))
706{
707}
708
709ExportFormat::ExportFormat(const QIcon &icon, const QString &description, const QMimeType &mimeType)
710 : d(new ExportFormatPrivate(description, mimeType, icon))
711{
712}
713
717
719 : d(other.d)
720{
721}
722
724{
725 if (this == &other) {
726 return *this;
727 }
728
729 d = other.d;
730
731 return *this;
732}
733
735{
736 return d->mDescription;
737}
738
740{
741 return d->mMimeType;
742}
743
745{
746 return d->mIcon;
747}
748
750{
751 return !d->mMimeType.isValid() || d->mDescription.isNull();
752}
753
755{
756 QMimeDatabase db;
757 switch (type) {
758 case PlainText:
759 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-x-generic")), i18n("Plain &Text..."), db.mimeTypeForName(QStringLiteral("text/plain")));
760 break;
761 case PDF:
762 return ExportFormat(QIcon::fromTheme(QStringLiteral("application-pdf")), i18n("PDF"), db.mimeTypeForName(QStringLiteral("application/pdf")));
763 break;
764 case OpenDocumentText:
765 return ExportFormat(
766 QIcon::fromTheme(QStringLiteral("application-vnd.oasis.opendocument.text")), i18nc("This is the document format", "OpenDocument Text"), db.mimeTypeForName(QStringLiteral("application/vnd.oasis.opendocument.text")));
767 break;
768 case HTML:
769 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-html")), i18nc("This is the document format", "HTML"), db.mimeTypeForName(QStringLiteral("text/html")));
770 break;
771 }
772 return ExportFormat();
773}
774
775bool ExportFormat::operator==(const ExportFormat &other) const
776{
777 return d == other.d;
778}
779
780bool ExportFormat::operator!=(const ExportFormat &other) const
781{
782 return d != other.d;
783}
784
786{
787 PixmapRequestPrivate *reqPriv = PixmapRequestPrivate::get(&req);
788
789 str << "PixmapRequest:" << &req;
790 str << "- observer:" << (qulonglong)req.observer();
791 str << "- page:" << req.pageNumber();
792 str << "- width:" << req.width();
793 str << "- height:" << req.height();
794 str << "- priority:" << req.priority();
795 str << "- async:" << (req.asynchronous() ? "true" : "false");
796 str << "- tile:" << (req.isTile() ? "true" : "false");
797 str << "- rect:" << req.normalizedRect();
798 str << "- preload:" << (req.preload() ? "true" : "false");
799 str << "- partialUpdates:" << (req.partialUpdatesWanted() ? "true" : "false");
800 str << "- shouldAbort:" << (req.shouldAbortRender() ? "true" : "false");
801 str << "- force:" << (reqPriv->mForce ? "true" : "false");
802 return str;
803}
804
805/* 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:1484
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:1591
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(ProcessEventsFlags flags)
QIcon fromTheme(const QString &name)
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags)
QString section(QChar sep, qsizetype start, qsizetype end, 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 Fri Jul 12 2024 11:57:22 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.