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
479
481{
482 Q_D(Generator);
483 if (on) {
484 d->m_features.insert(feature);
485 } else {
486 d->m_features.remove(feature);
487 }
488}
489
491{
492 Q_D(const Generator);
493 if (!d->m_document) {
494 return QVariant();
495 }
496
497 return d->m_document->documentMetaData(key, option);
498}
499
501{
502 Q_D(const Generator);
503 return &d->m_mutex;
504}
505
506void Generator::updatePageBoundingBox(int page, const NormalizedRect &boundingBox)
507{
508 Q_D(Generator);
509 if (d->m_document) { // still connected to document?
510 d->m_document->setPageBoundingBox(page, boundingBox);
511 }
512}
513
515{
516 return {};
517}
518
520{
521 Q_D(Generator);
522 d->m_dpi = dpi;
523}
524
526{
527 Q_D(const Generator);
528 return d->m_dpi;
529}
530
532{
533 return nullptr;
534}
535
536TextRequest::TextRequest()
537 : d(new TextRequestPrivate)
538{
539 d->mPage = nullptr;
540 d->mShouldAbortExtraction = 0;
541}
542
543TextRequest::TextRequest(Page *page)
544 : d(new TextRequestPrivate)
545{
546 d->mPage = page;
547 d->mShouldAbortExtraction = 0;
548}
549
551{
552 delete d;
553}
554
556{
557 return d->mPage;
558}
559
561{
562 return d->mShouldAbortExtraction != 0;
563}
564
565TextRequestPrivate *TextRequestPrivate::get(const TextRequest *req)
566{
567 return req->d;
568}
569
570PixmapRequest::PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, qreal dpr, int priority, PixmapRequestFeatures features)
571 : d(new PixmapRequestPrivate)
572{
573 d->mObserver = observer;
574 d->mPageNumber = pageNumber;
575 d->mWidth = ceil(width * dpr);
576 d->mHeight = ceil(height * dpr);
577 d->mPriority = priority;
578 d->mFeatures = features;
579 d->mForce = false;
580 d->mTile = false;
581 d->mNormalizedRect = NormalizedRect();
582 d->mPartialUpdatesWanted = false;
583 d->mShouldAbortRender = 0;
584}
585
587{
588 delete d;
589}
590
592{
593 return d->mObserver;
594}
595
597{
598 return d->mPageNumber;
599}
600
602{
603 return d->mWidth;
604}
605
607{
608 return d->mHeight;
609}
610
612{
613 return d->mPriority;
614}
615
617{
618 return d->mFeatures & Asynchronous;
619}
620
622{
623 return d->mFeatures & Preload;
624}
625
627{
628 return d->mPage;
629}
630
632{
633 d->mTile = tile;
634}
635
637{
638 return d->mTile;
639}
640
642{
643 if (d->mNormalizedRect == rect) {
644 return;
645 }
646
647 d->mNormalizedRect = rect;
648}
649
651{
652 return d->mNormalizedRect;
653}
654
655void PixmapRequest::setPartialUpdatesWanted(bool partialUpdatesWanted)
656{
657 d->mPartialUpdatesWanted = partialUpdatesWanted;
658}
659
661{
662 return d->mPartialUpdatesWanted;
663}
664
666{
667 return d->mShouldAbortRender != 0;
668}
669
670Okular::TilesManager *PixmapRequestPrivate::tilesManager() const
671{
672 return mPage->d->tilesManager(mObserver);
673}
674
675PixmapRequestPrivate *PixmapRequestPrivate::get(const PixmapRequest *req)
676{
677 return req->d;
678}
679
680void PixmapRequestPrivate::swap()
681{
682 std::swap(mWidth, mHeight);
683}
684
685class Okular::ExportFormatPrivate : public QSharedData
686{
687public:
688 ExportFormatPrivate(const QString &description, const QMimeType &mimeType, const QIcon &icon = QIcon())
689 : QSharedData()
690 , mDescription(description)
691 , mMimeType(mimeType)
692 , mIcon(icon)
693 {
694 }
695 ~ExportFormatPrivate()
696 {
697 }
698
699 QString mDescription;
700 QMimeType mMimeType;
701 QIcon mIcon;
702};
703
705 : d(new ExportFormatPrivate(QString(), QMimeType()))
706{
707}
708
709ExportFormat::ExportFormat(const QString &description, const QMimeType &mimeType)
710 : d(new ExportFormatPrivate(description, mimeType))
711{
712}
713
714ExportFormat::ExportFormat(const QIcon &icon, const QString &description, const QMimeType &mimeType)
715 : d(new ExportFormatPrivate(description, mimeType, icon))
716{
717}
718
722
724 : d(other.d)
725{
726}
727
729{
730 if (this == &other) {
731 return *this;
732 }
733
734 d = other.d;
735
736 return *this;
737}
738
740{
741 return d->mDescription;
742}
743
745{
746 return d->mMimeType;
747}
748
750{
751 return d->mIcon;
752}
753
755{
756 return !d->mMimeType.isValid() || d->mDescription.isNull();
757}
758
760{
761 QMimeDatabase db;
762 switch (type) {
763 case PlainText:
764 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-x-generic")), i18n("Plain &Text..."), db.mimeTypeForName(QStringLiteral("text/plain")));
765 break;
766 case PDF:
767 return ExportFormat(QIcon::fromTheme(QStringLiteral("application-pdf")), i18n("PDF"), db.mimeTypeForName(QStringLiteral("application/pdf")));
768 break;
769 case OpenDocumentText:
770 return ExportFormat(
771 QIcon::fromTheme(QStringLiteral("application-vnd.oasis.opendocument.text")), i18nc("This is the document format", "OpenDocument Text"), db.mimeTypeForName(QStringLiteral("application/vnd.oasis.opendocument.text")));
772 break;
773 case HTML:
774 return ExportFormat(QIcon::fromTheme(QStringLiteral("text-html")), i18nc("This is the document format", "HTML"), db.mimeTypeForName(QStringLiteral("text/html")));
775 break;
776 }
777 return ExportFormat();
778}
779
780bool ExportFormat::operator==(const ExportFormat &other) const
781{
782 return d == other.d;
783}
784
785bool ExportFormat::operator!=(const ExportFormat &other) const
786{
787 return d != other.d;
788}
789
791{
792 PixmapRequestPrivate *reqPriv = PixmapRequestPrivate::get(&req);
793
794 str << "PixmapRequest:" << &req;
795 str << "- observer:" << (qulonglong)req.observer();
796 str << "- page:" << req.pageNumber();
797 str << "- width:" << req.width();
798 str << "- height:" << req.height();
799 str << "- priority:" << req.priority();
800 str << "- async:" << (req.asynchronous() ? "true" : "false");
801 str << "- tile:" << (req.isTile() ? "true" : "false");
802 str << "- rect:" << req.normalizedRect();
803 str << "- preload:" << (req.preload() ? "true" : "false");
804 str << "- partialUpdates:" << (req.partialUpdatesWanted() ? "true" : "false");
805 str << "- shouldAbort:" << (req.shouldAbortRender() ? "true" : "false");
806 str << "- force:" << (reqPriv->mForce ? "true" : "false");
807 return str;
808}
809
810/* kate: replace-tabs on; indent-width 4; */
static const QString NetworkWallet()
Encapsulates data that describes an action.
Definition action.h:41
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:1504
The Document.
Definition document.h:192
DocumentAdditionalActionType
Describes the additional actions available in the Document.
Definition document.h:760
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:549
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.
virtual Okular::Action * additionalDocumentAction(Document::DocumentAdditionalActionType type)
Retrieves the additional document action for the specified type .
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:1611
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:618
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:754
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()
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
global.h
Definition action.h:17
Permission
Describes the DRM capabilities.
Definition global.h:24
Rotation
A rotation.
Definition global.h:46
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 26 2024 11:51:37 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.