Okular

generator.h
1/*
2 SPDX-FileCopyrightText: 2004-5 Enrico Ros <eros.kde@email.it>
3 SPDX-FileCopyrightText: 2005 Piotr Szymanski <niedakh@gmail.com>
4 SPDX-FileCopyrightText: 2008 Albert Astals Cid <aacid@kde.org>
5
6 Work sponsored by the LiMux project of the city of Munich:
7 SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company <info@kdab.com>
8
9 SPDX-License-Identifier: GPL-2.0-or-later
10*/
11
12#ifndef _OKULAR_GENERATOR_H_
13#define _OKULAR_GENERATOR_H_
14
15#include "action.h"
16#include "document.h"
17#include "fontinfo.h"
18#include "global.h"
19#include "okularcore_export.h"
20#include "pagesize.h"
21#include "signatureutils.h"
22
23#include <QList>
24#include <QObject>
25#include <QSharedDataPointer>
26#include <QSizeF>
27#include <QString>
28#include <QVariant>
29#include <QVector>
30
31#include <KPluginFactory>
32#include <QMimeType>
33
34#define OKULAR_EXPORT_PLUGIN(classname, json) \
35 static_assert(json[0] != '\0', "arg2 must be a string literal"); \
36 K_PLUGIN_CLASS_WITH_JSON(classname, json)
37
38class QByteArray;
39class QMutex;
40class QPrinter;
41class QIcon;
42
43namespace Okular
44{
45class BackendOpaqueAction;
46class DocumentFonts;
47class DocumentInfo;
50class EmbeddedFile;
51class ExportFormatPrivate;
52class FontInfo;
53class GeneratorPrivate;
54class Page;
55class PixmapRequest;
56class PixmapRequestPrivate;
57class TextPage;
58class TextRequest;
59class TextRequestPrivate;
60class NormalizedRect;
61
62/* Note: on contents generation and asynchronous queries.
63 * Many observers may want to request data synchronously or asynchronously.
64 * - Sync requests. These should be done in-place.
65 * - Async request must be done in real background. That usually means a
66 * thread, such as QThread derived classes.
67 * Once contents are available, they must be immediately stored in the
68 * Page they refer to, and a signal is emitted as soon as storing
69 * (even for sync or async queries) has been done.
70 */
71
72/**
73 * @short Defines an entry for the export menu
74 *
75 * This class encapsulates information about an export format.
76 * Every Generator can support 0 or more export formats which can be
77 * queried with @ref Generator::exportFormats().
78 */
79class OKULARCORE_EXPORT ExportFormat
80{
81public:
82 typedef QList<ExportFormat> List;
83
84 /**
85 * Creates an empty export format.
86 *
87 * @see isNull()
88 */
90
91 /**
92 * Creates a new export format.
93 *
94 * @param description The i18n'ed description of the format.
95 * @param mimeType The supported mime type of the format.
96 */
98
99 /**
100 * Creates a new export format.
101 *
102 * @param icon The icon used in the GUI for this format.
103 * @param description The i18n'ed description of the format.
104 * @param mimeType The supported mime type of the format.
105 */
107
108 /**
109 * Destroys the export format.
110 */
112
113 /**
114 * @internal
115 */
116 ExportFormat(const ExportFormat &other);
117
118 /**
119 * @internal
120 */
121 ExportFormat &operator=(const ExportFormat &other);
122
123 /**
124 * Returns the description of the format.
125 */
126 QString description() const;
127
128 /**
129 * Returns the mime type of the format.
130 */
131 QMimeType mimeType() const;
132
133 /**
134 * Returns the icon for GUI representations of the format.
135 */
136 QIcon icon() const;
137
138 /**
139 * Returns whether the export format is null/valid.
140 *
141 * An ExportFormat is null if the mimetype is not valid or the
142 * description is empty, or both.
143 */
144 bool isNull() const;
145
146 /**
147 * Type of standard export format.
148 */
150 PlainText, ///< Plain text
151 PDF, ///< PDF, aka Portable Document Format
152 OpenDocumentText, ///< OpenDocument Text format @since 0.8 (KDE 4.2)
153 HTML ///< OpenDocument Text format @since 0.8 (KDE 4.2)
154 };
155
156 /**
157 * Builds a standard format for the specified @p type .
158 */
159 static ExportFormat standardFormat(StandardExportFormat type);
160
161 bool operator==(const ExportFormat &other) const;
162
163 bool operator!=(const ExportFormat &other) const;
164
165private:
166 /// @cond PRIVATE
167 friend class ExportFormatPrivate;
168 /// @endcond
170};
171
172/**
173 * @short [Abstract Class] The information generator.
174 *
175 * Most of class members are virtuals and some of them pure virtual. The pure
176 * virtuals provide the minimal functionalities for a Generator, that is being
177 * able to generate QPixmap for the Page 's of the Document.
178 *
179 * Implementing the other functions will make the Generator able to provide
180 * more contents and/or functionalities (like text extraction).
181 *
182 * Generation/query is requested by the Document class only, and that
183 * class stores the resulting data into Page s. The data will then be
184 * displayed by the GUI components (PageView, ThumbnailList, etc..).
185 *
186 * @see PrintInterface, ConfigInterface, GuiInterface
187 */
188class OKULARCORE_EXPORT Generator : public QObject
189{
190 /// @cond PRIVATE
191 friend class PixmapGenerationThread;
192 friend class TextPageGenerationThread;
193 /// @endcond
194
196
197public:
198 /**
199 * Describe the possible optional features that a Generator can
200 * provide.
201 */
203 Threaded, ///< Whether the Generator supports asynchronous generation of pictures or text pages
204 TextExtraction, ///< Whether the Generator can extract text from the document in the form of TextPage's
205 ReadRawData, ///< Whether the Generator can read a document directly from its raw data.
206 FontInfo, ///< Whether the Generator can provide information about the fonts used in the document
207 PageSizes, ///< Whether the Generator can change the size of the document pages.
208 PrintNative, ///< Whether the Generator supports native cross-platform printing (QPainter-based).
209 PrintPostscript, ///< Whether the Generator supports postscript-based file printing.
210 PrintToFile, ///< Whether the Generator supports export to PDF & PS through the Print Dialog
211 TiledRendering, ///< Whether the Generator can render tiles @since 0.16 (KDE 4.10)
212 SwapBackingFile, ///< Whether the Generator can hot-swap the file it's reading from @since 1.3
213 SupportsCancelling ///< Whether the Generator can cancel requests @since 1.4
214 };
215
216 /**
217 * Creates a new generator.
218 */
219 explicit Generator(QObject *parent = nullptr, const QVariantList &args = QVariantList());
220
221 /**
222 * Destroys the generator.
223 */
224 ~Generator() override;
225
226 /**
227 * Loads the document with the given @p fileName and fills the
228 * @p pagesVector with the parsed pages.
229 *
230 * @note If you implement the WithPassword variants you don't need to implement this one
231 *
232 * @returns true on success, false otherwise.
233 */
234 virtual bool loadDocument(const QString &fileName, QVector<Page *> &pagesVector);
235
236 /**
237 * Loads the document from the raw data @p fileData and fills the
238 * @p pagesVector with the parsed pages.
239 *
240 * @note If you implement the WithPassword variants you don't need to implement this one
241 *
242 * @note the Generator has to have the feature @ref ReadRawData enabled
243 *
244 * @returns true on success, false otherwise.
245 */
246 virtual bool loadDocumentFromData(const QByteArray &fileData, QVector<Page *> &pagesVector);
247
248 /**
249 * Loads the document with the given @p fileName and @p password and fills the
250 * @p pagesVector with the parsed pages.
251 *
252 * @note Do not implement this if your format doesn't support passwords, it'll cleanly call loadDocument()
253 *
254 * @since 0.20 (KDE 4.14)
255 *
256 * @returns a LoadResult defining the result of the operation
257 */
258 virtual Document::OpenResult loadDocumentWithPassword(const QString &fileName, QVector<Page *> &pagesVector, const QString &password);
259
260 /**
261 * Loads the document from the raw data @p fileData and @p password and fills the
262 * @p pagesVector with the parsed pages.
263 *
264 * @note Do not implement this if your format doesn't support passwords, it'll cleanly call loadDocumentFromData()
265 *
266 * @note the Generator has to have the feature @ref ReadRawData enabled
267 *
268 * @since 0.20 (KDE 4.14)
269 *
270 * @returns a LoadResult defining the result of the operation
271 */
272 virtual Document::OpenResult loadDocumentFromDataWithPassword(const QByteArray &fileData, QVector<Page *> &pagesVector, const QString &password);
273
274 /**
275 * Describes the result of an swap file operation.
276 *
277 * @since 1.3
278 */
280 SwapBackingFileError, //< The document could not be swapped
281 SwapBackingFileNoOp, //< The document was swapped and nothing needs to be done
282 SwapBackingFileReloadInternalData //< The document was swapped and internal data (forms, annotations, etc) needs to be reloaded
283 };
284
285 /**
286 * Changes the path of the file we are reading from. The new path must
287 * point to a copy of the same document.
288 *
289 * @note the Generator has to have the feature @ref SwapBackingFile enabled
290 *
291 * @since 1.3
292 */
293 virtual SwapBackingFileResult swapBackingFile(const QString &newFileName, QVector<Okular::Page *> &newPagesVector);
294
295 /**
296 * This method is called when the document is closed and not used
297 * any longer.
298 *
299 * @returns true on success, false otherwise.
300 */
301 bool closeDocument();
302
303 /**
304 * This method returns whether the generator is ready to
305 * handle a new pixmap request.
306 */
307 virtual bool canGeneratePixmap() const;
308
309 virtual bool canSign() const;
310
311 virtual bool sign(const NewSignatureData &data, const QString &rFilename);
312
313 virtual CertificateStore *certificateStore() const;
314
315 /**
316 * This method can be called to trigger the generation of
317 * a new pixmap as described by @p request.
318 */
319 virtual void generatePixmap(PixmapRequest *request);
320
321 /**
322 * This method returns whether the generator is ready to
323 * handle a new text page request.
324 */
325 virtual bool canGenerateTextPage() const;
326
327 /**
328 * This method can be called to trigger the generation of
329 * a text page for the given @p page.
330 *
331 * The generation is done in the calling thread.
332 *
333 * @see TextPage
334 */
335 void generateTextPage(Page *page);
336
337 /**
338 * Returns the general information object of the document.
339 *
340 * Changed signature in okular version 0.21
341 */
342 virtual DocumentInfo generateDocumentInfo(const QSet<DocumentInfo::Key> &keys) const;
343
344 /**
345 * Returns the 'table of content' object of the document or 0 if
346 * no table of content is available.
347 */
348 virtual const DocumentSynopsis *generateDocumentSynopsis();
349
350 /**
351 * Returns the 'list of embedded fonts' object of the specified \p page
352 * of the document.
353 *
354 * \param page a page of the document, starting from 0 - -1 indicates all
355 * the other fonts
356 */
357 virtual FontInfo::List fontsForPage(int page);
358
359 /**
360 * Returns the 'list of embedded files' object of the document or 0 if
361 * no list of embedded files is available.
362 */
363 virtual const QList<EmbeddedFile *> *embeddedFiles() const;
364
365 /**
366 * This enum identifies default page layouts.
367 *
368 * @since 24.12
369 */
371 NoLayout = -1, ///< Layout not specified
372 SinglePage, ///< Display a single page
373 TwoPageLeft, ///< Display the pages in two columns, with odd-numbered pages on the left
374 TwoPageRight ///< Display the pages in two columns, with odd-numbered pages on the right
375 };
376
377 /**
378 * This method returns the default page layout.
379 *
380 * @since 24.12
381 */
382 virtual PageLayout defaultPageLayout() const;
383
384 /**
385 * This method returns if the default page layout is continuous.
386 *
387 * @since 24.12
388 */
389 virtual bool defaultPageContinuous() const;
390
391 /**
392 * This enum identifies the metric of the page size.
393 */
395 None, ///< The page size is not defined in a physical metric.
396 Points, ///< The page size is given in 1/72 inches.
397 Pixels ///< The page size is given in screen pixels @since 0.19 (KDE 4.13)
398 };
399
400 /**
401 * This method returns the metric of the page size. Default is @ref None.
402 */
403 virtual PageSizeMetric pagesSizeMetric() const;
404
405 /**
406 * Returns whether the given @p action is allowed in the document.
407 * @see @ref Okular::Permission
408 */
409 virtual bool isAllowed(Permission action) const;
410
411 /**
412 * This method is called when the orientation has been changed by the user.
413 */
414 virtual void rotationChanged(Rotation orientation, Rotation oldOrientation);
415
416 /**
417 * Returns the list of supported page sizes.
418 */
419 virtual PageSize::List pageSizes() const;
420
421 /**
422 * This method is called when the page size has been changed by the user.
423 */
424 virtual void pageSizeChanged(const PageSize &pageSize, const PageSize &oldPageSize);
425
426 /**
427 * This method is called to print the document to the given @p printer.
428 */
429 virtual Document::PrintError print(QPrinter &printer);
430
431 /**
432 * This method returns the meta data of the given @p key with the given @p option
433 * of the document.
434 */
435 virtual QVariant metaData(const QString &key, const QVariant &option) const;
436
437 /**
438 * Returns the list of additional supported export formats.
439 */
440 virtual ExportFormat::List exportFormats() const;
441
442 /**
443 * This method is called to export the document in the given @p format and save it
444 * under the given @p fileName. The format must be one of the supported export formats.
445 */
446 virtual bool exportTo(const QString &fileName, const ExportFormat &format);
447
448 /**
449 * This method is called to know which wallet data should be used for the given file name.
450 * Unless you have very special requirements to where wallet data should be stored you
451 * don't need to reimplement this method.
452 */
453 virtual void walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const;
454
455 /**
456 * Query for the specified @p feature.
457 */
458 bool hasFeature(GeneratorFeature feature) const;
459
460 /**
461 * Update DPI of the generator
462 *
463 * @since 0.19 (old signature)
464 * @since 22.04 (new signature)
465 */
466 void setDPI(const QSizeF dpi);
467
468 /**
469 * Returns the 'layers model' object of the document or NULL if
470 * layers model is not available.
471 *
472 * @since 0.24
473 */
474 virtual QAbstractItemModel *layersModel() const;
475
476 /**
477 * Calls the backend to execute a BackendOpaqueAction @p action and returns BackendOpaqueAction result
478 */
479 virtual BackendOpaqueAction::OpaqueActionResult opaqueAction(const BackendOpaqueAction *action);
480
481 /**
482 * Frees the contents of the opaque action (if any);
483 *
484 * @since 22.04
485 */
486 virtual void freeOpaqueActionContents(const BackendOpaqueAction &action);
487
488 /**
489 * Retrieves the additional document action for the specified @p type .
490 *
491 * @since 24.08
492 */
493 virtual Okular::Action *additionalDocumentAction(Document::DocumentAdditionalActionType type);
494
495Q_SIGNALS:
496 /**
497 * This signal should be emitted whenever an error occurred in the generator.
498 *
499 * @param message The message which should be shown to the user.
500 * @param duration The time that the message should be shown to the user.
501 */
502 void error(const QString &message, int duration);
503
504 /**
505 * This signal should be emitted whenever the user should be warned.
506 *
507 * @param message The message which should be shown to the user.
508 * @param duration The time that the message should be shown to the user.
509 */
510 void warning(const QString &message, int duration);
511
512 /**
513 * This signal should be emitted whenever the user should be noticed.
514 *
515 * @param message The message which should be shown to the user.
516 * @param duration The time that the message should be shown to the user.
517 */
518 void notice(const QString &message, int duration);
519
520protected:
521 /**
522 * This method must be called when the pixmap request triggered by generatePixmap()
523 * has been finished.
524 */
526
527 /**
528 * This method must be called when a text generation has been finished.
529 */
531
532 /**
533 * This method is called when the document is closed and not used
534 * any longer.
535 *
536 * @returns true on success, false otherwise.
537 */
538 virtual bool doCloseDocument() = 0;
539
540 /**
541 * Returns the image of the page as specified in
542 * the passed pixmap @p request.
543 *
544 * Must return a null image if the request was cancelled and the generator supports cancelling
545 *
546 * @warning this method may be executed in its own separated thread if the
547 * @ref Threaded is enabled!
548 */
549 virtual QImage image(PixmapRequest *request);
550
551 /**
552 * Returns the text page for the given @p request.
553 *
554 * Must return a null pointer if the request was cancelled and the generator supports cancelling
555 *
556 * @warning this method may be executed in its own separated thread if the
557 * @ref Threaded is enabled!
558 *
559 * @since 1.4
560 */
561 virtual TextPage *textPage(TextRequest *request);
562
563 /**
564 * Returns a pointer to the document.
565 */
566 const Document *document() const;
567
568 /**
569 * Toggle the @p feature .
570 */
571 void setFeature(GeneratorFeature feature, bool on = true);
572
573 /**
574 * Internal document setting
575 */
577 PaperColorMetaData, ///< Returns (QColor) the paper color if set in Settings or the default color (white) if option is true (otherwise returns a non initialized QColor)
578 TextAntialiasMetaData, ///< Returns (bool) text antialias from Settings (option is not used)
579 GraphicsAntialiasMetaData, ///< Returns (bool)graphic antialias from Settings (option is not used)
580 TextHintingMetaData ///< Returns (bool)text hinting from Settings (option is not used)
581 };
582
583 /**
584 * Request a meta data of the Document, if available, like an internal
585 * setting.
586 *
587 * @since 1.1
588 */
589 QVariant documentMetaData(const DocumentMetaDataKey key, const QVariant &option = QVariant()) const;
590
591 /**
592 * Return the pointer to a mutex the generator can use freely.
593 */
594 QMutex *userMutex() const;
595
596 /**
597 * Set the bounding box of a page after the page has already been handed
598 * to the Document. Call this instead of Page::setBoundingBox() to ensure
599 * that all observers are notified.
600 *
601 * @since 0.7 (KDE 4.1)
602 */
603 void updatePageBoundingBox(int page, const NormalizedRect &boundingBox);
604
605 /**
606 * Returns DPI, previously set via setDPI()
607 * @since 0.19 (KDE 4.13)
608 */
609 QSizeF dpi() const;
610
611 /**
612 * Gets the font data for the given font
613 *
614 * @since 0.8 (old signature)
615 * @since 22.04 (new signature)
616 */
617 virtual QByteArray requestFontData(const Okular::FontInfo &font);
618
619protected Q_SLOTS:
620 /**
621 * This method can be called to trigger a partial pixmap update for the given request
622 * Make sure you call it in a way it's executed in the main thread.
623 * @since 1.3
624 */
625 void signalPartialPixmapRequest(Okular::PixmapRequest *request, const QImage &image);
626
627protected:
628 /// @cond PRIVATE
629 Generator(GeneratorPrivate &dd, QObject *parent, const QVariantList &args);
630 Q_DECLARE_PRIVATE(Generator)
631 GeneratorPrivate *d_ptr;
632
633 friend class Document;
634 friend class DocumentPrivate;
635 /// @endcond PRIVATE
636
637private:
638 Q_DISABLE_COPY(Generator)
639};
640
641/**
642 * @short Describes a pixmap type request.
643 */
644class OKULARCORE_EXPORT PixmapRequest
645{
646 friend class Document;
647 friend class DocumentPrivate;
648
649public:
650 enum PixmapRequestFeature { NoFeature = 0, Asynchronous = 1, Preload = 2 };
651 Q_DECLARE_FLAGS(PixmapRequestFeatures, PixmapRequestFeature)
652
653 /**
654 * Creates a new pixmap request.
655 *
656 * @param observer The observer.
657 * @param pageNumber The page number.
658 * @param width The width of the page in logical pixels.
659 * @param height The height of the page in logical pixels.
660 * @param dpr Device pixel ratio of the screen that the pixmap is intended for.
661 * @param priority The priority of the request.
662 * @param features The features of generation.
663 */
664 PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, qreal dpr, int priority, PixmapRequestFeatures features);
665
666 /**
667 * Destroys the pixmap request.
668 */
670
671 /**
672 * Returns the observer of the request.
673 */
674 DocumentObserver *observer() const;
675
676 /**
677 * Returns the page number of the request.
678 */
679 int pageNumber() const;
680
681 /**
682 * Returns the page width of the requested pixmap.
683 */
684 int width() const;
685
686 /**
687 * Returns the page height of the requested pixmap.
688 */
689 int height() const;
690
691 /**
692 * Returns the priority (less it better, 0 is maximum) of the
693 * request.
694 */
695 int priority() const;
696
697 /**
698 * Returns whether the generation should be done synchronous or
699 * asynchronous.
700 *
701 * If asynchronous, the pixmap is created in a thread and the observer
702 * is notified when the job is done.
703 */
704 bool asynchronous() const;
705
706 /**
707 * Returns whether the generation request is for a page that is not important
708 * i.e. it's just for speeding up future rendering
709 */
710 bool preload() const;
711
712 /**
713 * Returns a pointer to the page where the pixmap shall be generated for.
714 */
715 Page *page() const;
716
717 /**
718 * Sets whether the generator should render only the given normalized
719 * rect or the entire page
720 *
721 * @since 0.16 (KDE 4.10)
722 */
723 void setTile(bool tile);
724
725 /**
726 * Returns whether the generator should render just the region given by
727 * normalizedRect() or the entire page.
728 *
729 * @since 0.16 (KDE 4.10)
730 */
731 bool isTile() const;
732
733 /**
734 * Sets the region of the page to request.
735 *
736 * @since 0.16 (KDE 4.10)
737 */
738 void setNormalizedRect(const NormalizedRect &rect);
739
740 /**
741 * Returns the normalized region of the page to request.
742 *
743 * @since 0.16 (KDE 4.10)
744 */
745 const NormalizedRect &normalizedRect() const;
746
747 /**
748 * Sets whether the request should report back updates if possible
749 *
750 * @since 1.3
751 */
753
754 /**
755 * Should the request report back updates if possible?
756 *
757 * @since 1.3
758 */
759 bool partialUpdatesWanted() const;
760
761 /**
762 * Should the request be aborted if possible?
763 *
764 * @since 1.4
765 */
766 bool shouldAbortRender() const;
767
768private:
769 Q_DISABLE_COPY(PixmapRequest)
770
771 friend class PixmapRequestPrivate;
772 PixmapRequestPrivate *const d;
773};
774
775/**
776 * @short Describes a text request.
777 *
778 * @since 1.4
779 */
780class OKULARCORE_EXPORT TextRequest
781{
782public:
783 /**
784 * Creates a new text request.
785 */
786 explicit TextRequest(Page *page);
787
788 TextRequest();
789
790 /**
791 * Destroys the pixmap request.
792 */
793 ~TextRequest();
794
795 /**
796 * Returns a pointer to the page where the pixmap shall be generated for.
797 */
798 Page *page() const;
799
800 /**
801 * Should the request be aborted if possible?
802 */
803 bool shouldAbortExtraction() const;
804
805private:
806 Q_DISABLE_COPY(TextRequest)
807
808 friend TextRequestPrivate;
809 TextRequestPrivate *const d;
810};
811
812}
813
814Q_DECLARE_METATYPE(Okular::PixmapRequest *)
815
816#define OkularGeneratorInterface_iid "org.kde.okular.Generator"
817Q_DECLARE_INTERFACE(Okular::Generator, OkularGeneratorInterface_iid)
818
819#ifndef QT_NO_DEBUG_STREAM
820OKULARCORE_EXPORT QDebug operator<<(QDebug str, const Okular::PixmapRequest &req);
821#endif
822
823#endif
824
825/* kate: replace-tabs on; indent-width 4; */
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
A DOM tree that describes the Table of Contents.
Definition document.h:1531
The Document.
Definition document.h:192
DocumentAdditionalActionType
Describes the additional actions available in the Document.
Definition document.h:775
OpenResult
Describes the result of an open document operation.
Definition document.h:210
An embedded file into the document.
Definition document.h:1555
Defines an entry for the export menu.
Definition generator.h:80
QMimeType mimeType() const
Returns the mime type of the format.
QString description() const
Returns the description of the format.
ExportFormat()
Creates an empty export format.
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:149
@ PDF
PDF, aka Portable Document Format.
Definition generator.h:151
@ HTML
OpenDocument Text format.
Definition generator.h:153
@ OpenDocumentText
OpenDocument Text format.
Definition generator.h:152
@ PlainText
Plain text.
Definition generator.h:150
A small class that represents the information of a font.
Definition fontinfo.h:25
[Abstract Class] The information generator.
Definition generator.h:189
void error(const QString &message, int duration)
This signal should be emitted whenever an error occurred in the generator.
Generator(QObject *parent=nullptr, const QVariantList &args=QVariantList())
Creates a new generator.
SwapBackingFileResult
Describes the result of an swap file operation.
Definition generator.h:279
DocumentMetaDataKey
Internal document setting.
Definition generator.h:576
@ TextHintingMetaData
Returns (bool)text hinting from Settings (option is not used)
Definition generator.h:580
@ GraphicsAntialiasMetaData
Returns (bool)graphic antialias from Settings (option is not used)
Definition generator.h:579
@ TextAntialiasMetaData
Returns (bool) text antialias from Settings (option is not used)
Definition generator.h:578
@ PaperColorMetaData
Returns (QColor) the paper color if set in Settings or the default color (white) if option is true (o...
Definition generator.h:577
void notice(const QString &message, int duration)
This signal should be emitted whenever the user should be noticed.
void signalTextGenerationDone(Page *page, TextPage *textPage)
This method must be called when a text generation has been finished.
virtual TextPage * textPage(TextRequest *request)
Returns the text page for the given request.
GeneratorFeature
Describe the possible optional features that a Generator can provide.
Definition generator.h:202
@ Threaded
Whether the Generator supports asynchronous generation of pictures or text pages.
Definition generator.h:203
@ PrintToFile
Whether the Generator supports export to PDF & PS through the Print Dialog.
Definition generator.h:210
@ ReadRawData
Whether the Generator can read a document directly from its raw data.
Definition generator.h:205
@ TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition generator.h:204
@ TiledRendering
Whether the Generator can render tiles.
Definition generator.h:211
@ SwapBackingFile
Whether the Generator can hot-swap the file it's reading from.
Definition generator.h:212
@ PrintNative
Whether the Generator supports native cross-platform printing (QPainter-based).
Definition generator.h:208
@ FontInfo
Whether the Generator can provide information about the fonts used in the document.
Definition generator.h:206
@ PageSizes
Whether the Generator can change the size of the document pages.
Definition generator.h:207
@ SupportsCancelling
Whether the Generator can cancel requests.
Definition generator.h:213
@ PrintPostscript
Whether the Generator supports postscript-based file printing.
Definition generator.h:209
PageSizeMetric
This enum identifies the metric of the page size.
Definition generator.h:394
@ Points
The page size is given in 1/72 inches.
Definition generator.h:396
@ Pixels
The page size is given in screen pixels.
Definition generator.h:397
@ None
The page size is not defined in a physical metric.
Definition generator.h:395
const Document * document() const
Returns a pointer to the document.
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.
PageLayout
This enum identifies default page layouts.
Definition generator.h:370
@ SinglePage
Display a single page.
Definition generator.h:372
@ NoLayout
Layout not specified.
Definition generator.h:371
@ TwoPageRight
Display the pages in two columns, with odd-numbered pages on the right.
Definition generator.h:374
@ TwoPageLeft
Display the pages in two columns, with odd-numbered pages on the left.
Definition generator.h:373
virtual bool doCloseDocument()=0
This method is called when the document is closed and not used any longer.
virtual QImage image(PixmapRequest *request)
Returns the image of the page as specified in the passed pixmap request.
void warning(const QString &message, int duration)
This signal should be emitted whenever the user should be warned.
Data needed to create a new signature.
Definition document.h:1638
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
Describes a pixmap type request.
Definition generator.h:645
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.
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:781
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(Page *page)
Creates a new text request.
global.h
Definition action.h:17
Permission
Describes the DRM capabilities.
Definition global.h:24
Rotation
A rotation.
Definition global.h:46
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:07:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.