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

okular

  • sources
  • kde-4.12
  • 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 "fontinfo.h"
17 #include "global.h"
18 #include "pagesize.h"
19 
20 #include <QtCore/QList>
21 #include <QtCore/QObject>
22 #include <QtCore/QSharedDataPointer>
23 #include <QtCore/QString>
24 #include <QtCore/QVariant>
25 #include <QtCore/QVector>
26 
27 #include <kmimetype.h>
28 #include <kpluginfactory.h>
29 
30 #define OKULAR_EXPORT_PLUGIN( classname, aboutdata ) \
31  K_PLUGIN_FACTORY( classname ## Factory, registerPlugin< classname >(); ) \
32  K_EXPORT_PLUGIN( classname ## Factory( aboutdata ) )
33 
34 class QByteArray;
35 class QMutex;
36 class QPrinter;
37 class QPrintDialog;
38 class KIcon;
39 
40 namespace Okular {
41 
42 class Document;
43 class DocumentFonts;
44 class DocumentInfo;
45 class DocumentObserver;
46 class DocumentSynopsis;
47 class EmbeddedFile;
48 class ExportFormatPrivate;
49 class FontInfo;
50 class GeneratorPrivate;
51 class Page;
52 class PixmapRequest;
53 class PixmapRequestPrivate;
54 class TextPage;
55 class NormalizedRect;
56 class SourceReference;
57 
58 /* Note: on contents generation and asynchronous queries.
59  * Many observers may want to request data syncronously or asynchronously.
60  * - Sync requests. These should be done in-place.
61  * - Async request must be done in real background. That usually means a
62  * thread, such as QThread derived classes.
63  * Once contents are available, they must be immediately stored in the
64  * Page they refer to, and a signal is emitted as soon as storing
65  * (even for sync or async queries) has been done.
66  */
67 
75 class OKULAR_EXPORT ExportFormat
76 {
77  public:
78  typedef QList<ExportFormat> List;
79 
85  ExportFormat();
86 
93  ExportFormat( const QString &description, const KMimeType::Ptr &mimeType );
94 
102  ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType );
103 
107  ~ExportFormat();
108 
112  ExportFormat( const ExportFormat &other );
113 
117  ExportFormat& operator=( const ExportFormat &other );
118 
122  QString description() const;
123 
127  KMimeType::Ptr mimeType() const;
128 
132  KIcon icon() const;
133 
140  bool isNull() const;
141 
145  enum StandardExportFormat
146  {
147  PlainText,
148  PDF,
149  OpenDocumentText,
150  HTML
151  };
152 
156  static ExportFormat standardFormat( StandardExportFormat type );
157 
158  bool operator==( const ExportFormat &other ) const;
159 
160  bool operator!=( const ExportFormat &other ) const;
161 
162  private:
164  friend class ExportFormatPrivate;
166  QSharedDataPointer<ExportFormatPrivate> d;
167 };
168 
185 class OKULAR_EXPORT Generator : public QObject
186 {
188  friend class PixmapGenerationThread;
189  friend class TextPageGenerationThread;
191 
192  Q_OBJECT
193 
194  public:
199  enum GeneratorFeature
200  {
201  Threaded,
202  TextExtraction,
203  ReadRawData,
204  FontInfo,
205  PageSizes,
206  PrintNative,
207  PrintPostscript,
208  PrintToFile,
209  TiledRendering
210  };
211 
215  Generator( QObject *parent, const QVariantList &args );
216 
220  virtual ~Generator();
221 
228  virtual bool loadDocument( const QString & fileName, QVector< Page * > & pagesVector ) = 0;
229 
238  virtual bool loadDocumentFromData( const QByteArray & fileData, QVector< Page * > & pagesVector );
239 
246  bool closeDocument();
247 
252  virtual bool canGeneratePixmap() const;
253 
258  virtual void generatePixmap( PixmapRequest * request );
259 
264  virtual bool canGenerateTextPage() const;
265 
276  virtual void generateTextPage( Page * page );
277 
282  virtual const DocumentInfo * generateDocumentInfo();
283 
288  virtual const DocumentSynopsis * generateDocumentSynopsis();
289 
297  virtual FontInfo::List fontsForPage( int page );
298 
303  virtual const QList<EmbeddedFile*> * embeddedFiles() const;
304 
308  enum PageSizeMetric
309  {
310  None,
311  Points
312  };
313 
317  virtual PageSizeMetric pagesSizeMetric() const;
318 
323  virtual bool isAllowed( Permission action ) const;
324 
328  virtual void rotationChanged( Rotation orientation, Rotation oldOrientation );
329 
333  virtual PageSize::List pageSizes() const;
334 
338  virtual void pageSizeChanged( const PageSize &pageSize, const PageSize &oldPageSize );
339 
343  virtual bool print( QPrinter &printer );
344 
349  enum PrintError
350  {
351  NoPrintError,
352  UnknownPrintError,
353  TemporaryFileOpenPrintError,
354  FileConversionPrintError,
355  PrintingProcessCrashPrintError,
356  PrintingProcessStartPrintError,
357  PrintToFilePrintError,
358  InvalidPrinterStatePrintError,
359  UnableToFindFilePrintError,
360  NoFileToPrintError,
361  NoBinaryToPrintError,
362  InvalidPageSizePrintError
363  };
364 
369  virtual QVariant metaData( const QString &key, const QVariant &option ) const;
370 
374  virtual ExportFormat::List exportFormats() const;
375 
380  virtual bool exportTo( const QString &fileName, const ExportFormat &format );
381 
385  bool hasFeature( GeneratorFeature feature ) const;
386 
387  Q_SIGNALS:
394  void error( const QString &message, int duration );
395 
402  void warning( const QString &message, int duration );
403 
410  void notice( const QString &message, int duration );
411 
412  protected:
417  void signalPixmapRequestDone( PixmapRequest * request );
418 
422  void signalTextGenerationDone( Page *page, TextPage *textPage );
423 
430  virtual bool doCloseDocument() = 0;
431 
439  virtual QImage image( PixmapRequest *page );
440 
447  virtual TextPage* textPage( Page *page );
448 
452  const Document * document() const;
453 
457  void setFeature( GeneratorFeature feature, bool on = true );
458 
463  QVariant documentMetaData( const QString &key, const QVariant &option = QVariant() ) const;
464 
468  QMutex* userMutex() const;
469 
477  void updatePageBoundingBox( int page, const NormalizedRect & boundingBox );
478 
479  protected Q_SLOTS:
485  void requestFontData(const Okular::FontInfo &font, QByteArray *data);
486 
494  const SourceReference * dynamicSourceReference( int pageNr, double absX, double absY );
495 
500  Okular::Generator::PrintError printError() const;
501 
502  protected:
504  Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args );
505  Q_DECLARE_PRIVATE( Generator )
506  GeneratorPrivate *d_ptr;
507 
508  friend class Document;
509  friend class DocumentPrivate;
511 
512  private:
513  Q_DISABLE_COPY( Generator )
514 
515  Q_PRIVATE_SLOT( d_func(), void pixmapGenerationFinished() )
516  Q_PRIVATE_SLOT( d_func(), void textpageGenerationFinished() )
517 };
518 
522 class OKULAR_EXPORT PixmapRequest
523 {
524  friend class Document;
525  friend class DocumentPrivate;
526 
527  public:
528  enum PixmapRequestFeature
529  {
530  NoFeature = 0,
531  Asynchronous = 1,
532  Preload = 2
533  };
534  Q_DECLARE_FLAGS( PixmapRequestFeatures, PixmapRequestFeature )
535 
536 
546  PixmapRequest( DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features );
547 
551  ~PixmapRequest();
552 
556  DocumentObserver *observer() const;
557 
561  int pageNumber() const;
562 
566  int width() const;
567 
571  int height() const;
572 
577  int priority() const;
578 
586  bool asynchronous() const;
587 
592  bool preload() const;
593 
597  Page *page() const;
598 
605  void setTile( bool tile );
606 
613  bool isTile() const;
614 
620  void setNormalizedRect( const NormalizedRect &rect );
621 
627  const NormalizedRect& normalizedRect() const;
628 
629  private:
630  Q_DISABLE_COPY( PixmapRequest )
631 
632  friend class PixmapRequestPrivate;
633  PixmapRequestPrivate* const d;
634 };
635 
636 }
637 
638 Q_DECLARE_METATYPE(Okular::Generator::PrintError)
639 
640 #ifndef QT_NO_DEBUG_STREAM
641 OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::PixmapRequest &req );
642 #endif
643 
644 #endif
645 
646 /* kate: replace-tabs on; indent-width 4; */
Okular::Generator::NoFileToPrintError
Definition: generator.h:360
Okular::Generator::PrintToFile
Whether the Generator supports export to PDF & PS through the Print Dialog.
Definition: generator.h:208
Okular::PageSize::List
QList< PageSize > List
Definition: pagesize.h:29
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
Okular::PixmapRequest::PixmapRequestFeature
PixmapRequestFeature
Definition: generator.h:528
Okular::TextPageGenerationThread
Definition: generator_p.h:117
Okular::Generator::UnknownPrintError
Definition: generator.h:352
fontinfo.h
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:147
Okular::Generator::PageSizeMetric
PageSizeMetric
This enum identifies the metric of the page size.
Definition: generator.h:308
Okular::Generator::ReadRawData
Whether the Generator can read a document directly from its raw data.
Definition: generator.h:203
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:358
Okular::Generator::FontInfo
Whether the Generator can provide information about the fonts used in the document.
Definition: generator.h:204
Okular::PixmapGenerationThread
Definition: generator_p.h:88
Okular::Generator::PrintPostscript
Whether the Generator supports postscript-based file printing.
Definition: generator.h:207
QObject
global.h
okular_export.h
pagesize.h
Okular::ExportFormat::List
QList< ExportFormat > List
Definition: generator.h:78
Okular::Generator::Threaded
Definition: generator.h:201
Okular::FontInfo
A small class that represents the information of a font.
Definition: fontinfo.h:27
Okular::Generator::NoPrintError
There was no print error.
Definition: generator.h:351
Okular::Generator::PrintingProcessCrashPrintError
Definition: generator.h:355
Okular::ExportFormat::OpenDocumentText
OpenDocument Text format.
Definition: generator.h:149
Okular::PixmapRequestPrivate
Definition: generator_p.h:70
Okular::Document
The Document.
Definition: document.h:84
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
Okular::Generator::PageSizes
Whether the Generator can change the size of the document pages.
Definition: generator.h:205
Okular::Asynchronous
Will create the object in an asynchronous way.
Definition: global.h:58
Okular::Generator::TemporaryFileOpenPrintError
Definition: generator.h:353
Okular::ExportFormat::StandardExportFormat
StandardExportFormat
Type of standard export format.
Definition: generator.h:145
Okular::Generator::PrintNative
Whether the Generator supports native cross-platform printing (QPainter-based).
Definition: generator.h:206
Okular::Generator::FileConversionPrintError
Definition: generator.h:354
Okular::DocumentPrivate
Definition: document_p.h:83
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1073
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:148
Okular::SourceReference
Defines a source reference.
Definition: sourcereference.h:25
Okular::Generator::None
The page size is not defined in a physical metric.
Definition: generator.h:310
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:75
Okular::Generator::PrintingProcessStartPrintError
Definition: generator.h:356
Okular::PageSize
A small class that represents the size of a page.
Definition: pagesize.h:26
Okular::Generator::PrintToFilePrintError
Definition: generator.h:357
Okular::Generator::PrintError
PrintError
Possible print errors.
Definition: generator.h:349
operator<<
OKULAR_EXPORT QDebug operator<<(QDebug str, const Okular::PixmapRequest &req)
Definition: generator.cpp:615
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:361
Okular::Permission
Permission
Describes the DRM capabilities.
Definition: global.h:20
Okular::Generator::UnableToFindFilePrintError
Definition: generator.h:359
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:202
Okular::GeneratorPrivate
Definition: generator_p.h:34
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1154
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:522
Okular::Generator
[Abstract Class] The information generator.
Definition: generator.h:185
Okular::Generator::GeneratorFeature
GeneratorFeature
Describe the possible optional features that a Generator can provide.
Definition: generator.h:199
Okular::FontInfo::List
QList< FontInfo > List
Definition: fontinfo.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 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