• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.14
  • kdegraphics
  • okular
  • core
generator.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-5 by Enrico Ros <eros.kde@email.it> *
3  * Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
4  * Copyright (C) 2008 by Albert Astals Cid <aacid@kde.org> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  ***************************************************************************/
11 
12 #ifndef _OKULAR_GENERATOR_H_
13 #define _OKULAR_GENERATOR_H_
14 
15 #include "okular_export.h"
16 #include "document.h"
17 #include "fontinfo.h"
18 #include "global.h"
19 #include "pagesize.h"
20 
21 #include <QtCore/QList>
22 #include <QtCore/QObject>
23 #include <QtCore/QSharedDataPointer>
24 #include <QtCore/QSizeF>
25 #include <QtCore/QString>
26 #include <QtCore/QVariant>
27 #include <QtCore/QVector>
28 
29 #include <kmimetype.h>
30 #include <kpluginfactory.h>
31 
32 #define OKULAR_EXPORT_PLUGIN( classname, aboutdata ) \
33  K_PLUGIN_FACTORY( classname ## Factory, registerPlugin< classname >(); ) \
34  K_EXPORT_PLUGIN( classname ## Factory( aboutdata ) )
35 
36 class QByteArray;
37 class QMutex;
38 class QPrinter;
39 class QPrintDialog;
40 class KIcon;
41 
42 namespace Okular {
43 
44 class DocumentFonts;
45 class DocumentInfo;
46 class DocumentObserver;
47 class DocumentSynopsis;
48 class EmbeddedFile;
49 class ExportFormatPrivate;
50 class FontInfo;
51 class GeneratorPrivate;
52 class Page;
53 class PixmapRequest;
54 class PixmapRequestPrivate;
55 class TextPage;
56 class NormalizedRect;
57 class SourceReference;
58 
59 /* Note: on contents generation and asynchronous queries.
60  * Many observers may want to request data syncronously or asynchronously.
61  * - Sync requests. These should be done in-place.
62  * - Async request must be done in real background. That usually means a
63  * thread, such as QThread derived classes.
64  * Once contents are available, they must be immediately stored in the
65  * Page they refer to, and a signal is emitted as soon as storing
66  * (even for sync or async queries) has been done.
67  */
68 
76 class OKULAR_EXPORT ExportFormat
77 {
78  public:
79  typedef QList<ExportFormat> List;
80 
86  ExportFormat();
87 
94  ExportFormat( const QString &description, const KMimeType::Ptr &mimeType );
95 
103  ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType );
104 
108  ~ExportFormat();
109 
113  ExportFormat( const ExportFormat &other );
114 
118  ExportFormat& operator=( const ExportFormat &other );
119 
123  QString description() const;
124 
128  KMimeType::Ptr mimeType() const;
129 
133  KIcon icon() const;
134 
141  bool isNull() const;
142 
146  enum StandardExportFormat
147  {
148  PlainText,
149  PDF,
150  OpenDocumentText,
151  HTML
152  };
153 
157  static ExportFormat standardFormat( StandardExportFormat type );
158 
159  bool operator==( const ExportFormat &other ) const;
160 
161  bool operator!=( const ExportFormat &other ) const;
162 
163  private:
165  friend class ExportFormatPrivate;
167  QSharedDataPointer<ExportFormatPrivate> d;
168 };
169 
186 class OKULAR_EXPORT Generator : public QObject
187 {
189  friend class PixmapGenerationThread;
190  friend class TextPageGenerationThread;
192 
193  Q_OBJECT
194 
195  public:
200  enum GeneratorFeature
201  {
202  Threaded,
203  TextExtraction,
204  ReadRawData,
205  FontInfo,
206  PageSizes,
207  PrintNative,
208  PrintPostscript,
209  PrintToFile,
210  TiledRendering
211  };
212 
216  Generator( QObject *parent, const QVariantList &args );
217 
221  virtual ~Generator();
222 
231  virtual bool loadDocument( const QString & fileName, QVector< Page * > & pagesVector );
232 
243  virtual bool loadDocumentFromData( const QByteArray & fileData, QVector< Page * > & pagesVector );
244 
255  virtual Document::OpenResult loadDocumentWithPassword( const QString & fileName, QVector< Page * > & pagesVector, const QString &password );
256 
269  virtual Document::OpenResult loadDocumentFromDataWithPassword( const QByteArray & fileData, QVector< Page * > & pagesVector, const QString &password );
270 
271 
278  bool closeDocument();
279 
284  virtual bool canGeneratePixmap() const;
285 
290  virtual void generatePixmap( PixmapRequest * request );
291 
296  virtual bool canGenerateTextPage() const;
297 
308  virtual void generateTextPage( Page * page );
309 
314  virtual const DocumentInfo * generateDocumentInfo();
315 
320  virtual const DocumentSynopsis * generateDocumentSynopsis();
321 
329  virtual FontInfo::List fontsForPage( int page );
330 
335  virtual const QList<EmbeddedFile*> * embeddedFiles() const;
336 
340  enum PageSizeMetric
341  {
342  None,
343  Points,
344  Pixels
345  };
346 
350  virtual PageSizeMetric pagesSizeMetric() const;
351 
356  virtual bool isAllowed( Permission action ) const;
357 
361  virtual void rotationChanged( Rotation orientation, Rotation oldOrientation );
362 
366  virtual PageSize::List pageSizes() const;
367 
371  virtual void pageSizeChanged( const PageSize &pageSize, const PageSize &oldPageSize );
372 
376  virtual bool print( QPrinter &printer );
377 
382  enum PrintError
383  {
384  NoPrintError,
385  UnknownPrintError,
386  TemporaryFileOpenPrintError,
387  FileConversionPrintError,
388  PrintingProcessCrashPrintError,
389  PrintingProcessStartPrintError,
390  PrintToFilePrintError,
391  InvalidPrinterStatePrintError,
392  UnableToFindFilePrintError,
393  NoFileToPrintError,
394  NoBinaryToPrintError,
395  InvalidPageSizePrintError
396  };
397 
402  virtual QVariant metaData( const QString &key, const QVariant &option ) const;
403 
407  virtual ExportFormat::List exportFormats() const;
408 
413  virtual bool exportTo( const QString &fileName, const ExportFormat &format );
414 
420  virtual void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
421 
425  bool hasFeature( GeneratorFeature feature ) const;
426 
432  void setDPI(const QSizeF &dpi);
433 
434  Q_SIGNALS:
441  void error( const QString &message, int duration );
442 
449  void warning( const QString &message, int duration );
450 
457  void notice( const QString &message, int duration );
458 
459  protected:
464  void signalPixmapRequestDone( PixmapRequest * request );
465 
469  void signalTextGenerationDone( Page *page, TextPage *textPage );
470 
477  virtual bool doCloseDocument() = 0;
478 
486  virtual QImage image( PixmapRequest *page );
487 
494  virtual TextPage* textPage( Page *page );
495 
499  const Document * document() const;
500 
504  void setFeature( GeneratorFeature feature, bool on = true );
505 
510  QVariant documentMetaData( const QString &key, const QVariant &option = QVariant() ) const;
511 
515  QMutex* userMutex() const;
516 
524  void updatePageBoundingBox( int page, const NormalizedRect & boundingBox );
525 
530  QSizeF dpi() const;
531 
532  protected Q_SLOTS:
538  void requestFontData(const Okular::FontInfo &font, QByteArray *data);
539 
547  const SourceReference * dynamicSourceReference( int pageNr, double absX, double absY );
548 
553  Okular::Generator::PrintError printError() const;
554 
555  protected:
557  Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args );
558  Q_DECLARE_PRIVATE( Generator )
559  GeneratorPrivate *d_ptr;
560 
561  friend class Document;
562  friend class DocumentPrivate;
564 
565  private:
566  Q_DISABLE_COPY( Generator )
567 
568  Q_PRIVATE_SLOT( d_func(), void pixmapGenerationFinished() )
569  Q_PRIVATE_SLOT( d_func(), void textpageGenerationFinished() )
570 };
571 
575 class OKULAR_EXPORT PixmapRequest
576 {
577  friend class Document;
578  friend class DocumentPrivate;
579 
580  public:
581  enum PixmapRequestFeature
582  {
583  NoFeature = 0,
584  Asynchronous = 1,
585  Preload = 2
586  };
587  Q_DECLARE_FLAGS( PixmapRequestFeatures, PixmapRequestFeature )
588 
589 
599  PixmapRequest( DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features );
600 
604  ~PixmapRequest();
605 
609  DocumentObserver *observer() const;
610 
614  int pageNumber() const;
615 
619  int width() const;
620 
624  int height() const;
625 
630  int priority() const;
631 
639  bool asynchronous() const;
640 
645  bool preload() const;
646 
650  Page *page() const;
651 
658  void setTile( bool tile );
659 
666  bool isTile() const;
667 
673  void setNormalizedRect( const NormalizedRect &rect );
674 
680  const NormalizedRect& normalizedRect() const;
681 
682  private:
683  Q_DISABLE_COPY( PixmapRequest )
684 
685  friend class PixmapRequestPrivate;
686  PixmapRequestPrivate* const d;
687 };
688 
689 }
690 
691 Q_DECLARE_METATYPE(Okular::Generator::PrintError)
692 
693 #ifndef QT_NO_DEBUG_STREAM
694 OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::PixmapRequest &req );
695 #endif
696 
697 #endif
698 
699 /* kate: replace-tabs on; indent-width 4; */
Okular::Generator::NoFileToPrintError
Definition: generator.h:393
Okular::Generator::PrintToFile
Whether the Generator supports export to PDF & PS through the Print Dialog.
Definition: generator.h:209
QMutex
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::TextPage
The TextPage class represents the text of a page by providing.
Definition: textpage.h:90
QByteArray
Okular::PixmapRequest::PixmapRequestFeature
PixmapRequestFeature
Definition: generator.h:581
Okular::TextPageGenerationThread
Definition: generator_p.h:120
Okular::Generator::UnknownPrintError
Definition: generator.h:385
QPrinter
fontinfo.h
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:148
Okular::Generator::PageSizeMetric
PageSizeMetric
This enum identifies the metric of the page size.
Definition: generator.h:340
Okular::Generator::ReadRawData
Whether the Generator can read a document directly from its raw data.
Definition: generator.h:204
Okular::NormalizedRect
NormalizedRect is a helper class which stores the coordinates of a normalized rect, which is a rectangle of.
Definition: area.h:105
Okular::Generator::InvalidPrinterStatePrintError
Definition: generator.h:391
Okular::Generator::FontInfo
Whether the Generator can provide information about the fonts used in the document.
Definition: generator.h:205
Okular::PixmapGenerationThread
Definition: generator_p.h:91
Okular::Generator::PrintPostscript
Whether the Generator supports postscript-based file printing.
Definition: generator.h:208
global.h
Okular::Generator::Points
The page size is given in 1/72 inches.
Definition: generator.h:343
okular_export.h
Okular::Document::OpenResult
OpenResult
Describes the result of an open document operation.
Definition: document.h:103
pagesize.h
Okular::ExportFormat::List
QList< ExportFormat > List
Definition: generator.h:79
Okular::Generator::Threaded
Definition: generator.h:202
Okular::FontInfo
A small class that represents the information of a font.
Definition: fontinfo.h:27
QPrintDialog
Okular::Generator::NoPrintError
There was no print error.
Definition: generator.h:384
QObject
Okular::Generator::PrintingProcessCrashPrintError
Definition: generator.h:388
Okular::ExportFormat::OpenDocumentText
OpenDocument Text format.
Definition: generator.h:150
Okular::PixmapRequestPrivate
Definition: generator_p.h:72
Okular::Document
The Document.
Definition: document.h:84
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
document.h
QString
QList< ExportFormat >
Okular::Generator::PageSizes
Whether the Generator can change the size of the document pages.
Definition: generator.h:206
Okular::Asynchronous
Will create the object in an asynchronous way.
Definition: global.h:58
Okular::Generator::TemporaryFileOpenPrintError
Definition: generator.h:386
Okular::ExportFormat::StandardExportFormat
StandardExportFormat
Type of standard export format.
Definition: generator.h:146
Okular::Generator::PrintNative
Whether the Generator supports native cross-platform printing (QPainter-based).
Definition: generator.h:207
Okular::Generator::FileConversionPrintError
Definition: generator.h:387
Okular::DocumentPrivate
Definition: document_p.h:77
QImage
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1086
QDebug
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:149
Okular::SourceReference
Defines a source reference.
Definition: sourcereference.h:25
QVector
Okular::Generator::None
The page size is not defined in a physical metric.
Definition: generator.h:342
QSizeF
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
Okular::Generator::PrintingProcessStartPrintError
Definition: generator.h:389
Okular::PageSize
A small class that represents the size of a page.
Definition: pagesize.h:26
Okular::Generator::PrintToFilePrintError
Definition: generator.h:390
Okular::Generator::PrintError
PrintError
Possible print errors.
Definition: generator.h:382
operator<<
OKULAR_EXPORT QDebug operator<<(QDebug str, const Okular::PixmapRequest &req)
Definition: generator.cpp:657
Okular::DocumentObserver
Base class for objects being notified when something changes.
Definition: observer.h:28
description
static const char description[]
Definition: main.cpp:33
OKULAR_EXPORT
#define OKULAR_EXPORT
Definition: okular_export.h:30
Okular::Generator::NoBinaryToPrintError
Definition: generator.h:394
Okular::Permission
Permission
Describes the DRM capabilities.
Definition: global.h:20
Okular::Generator::UnableToFindFilePrintError
Definition: generator.h:392
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:203
Okular::GeneratorPrivate
Definition: generator_p.h:35
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1167
QSharedDataPointer< ExportFormatPrivate >
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:575
Okular::Generator
[Abstract Class] The information generator.
Definition: generator.h:186
QVariant
Okular::Generator::GeneratorFeature
GeneratorFeature
Describe the possible optional features that a Generator can provide.
Definition: generator.h:200
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal