• 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.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
3  * Copyright (C) 2008 by Albert Astals Cid <aacid@kde.org> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "generator.h"
12 #include "generator_p.h"
13 #include "observer.h"
14 
15 #include <qeventloop.h>
16 #include <QtGui/QPrinter>
17 
18 #include <kdebug.h>
19 #include <kicon.h>
20 #include <klocale.h>
21 
22 #include "document.h"
23 #include "document_p.h"
24 #include "page.h"
25 #include "textpage.h"
26 #include "utils.h"
27 
28 using namespace Okular;
29 
30 GeneratorPrivate::GeneratorPrivate()
31  : m_document( 0 ),
32  mPixmapGenerationThread( 0 ), mTextPageGenerationThread( 0 ),
33  m_mutex( 0 ), m_threadsMutex( 0 ), mPixmapReady( true ), mTextPageReady( true ),
34  m_closing( false ), m_closingLoop( 0 )
35 {
36 }
37 
38 GeneratorPrivate::~GeneratorPrivate()
39 {
40  if ( mPixmapGenerationThread )
41  mPixmapGenerationThread->wait();
42 
43  delete mPixmapGenerationThread;
44 
45  if ( mTextPageGenerationThread )
46  mTextPageGenerationThread->wait();
47 
48  delete mTextPageGenerationThread;
49 
50  delete m_mutex;
51  delete m_threadsMutex;
52 }
53 
54 PixmapGenerationThread* GeneratorPrivate::pixmapGenerationThread()
55 {
56  if ( mPixmapGenerationThread )
57  return mPixmapGenerationThread;
58 
59  Q_Q( Generator );
60  mPixmapGenerationThread = new PixmapGenerationThread( q );
61  QObject::connect( mPixmapGenerationThread, SIGNAL(finished()),
62  q, SLOT(pixmapGenerationFinished()),
63  Qt::QueuedConnection );
64 
65  return mPixmapGenerationThread;
66 }
67 
68 TextPageGenerationThread* GeneratorPrivate::textPageGenerationThread()
69 {
70  if ( mTextPageGenerationThread )
71  return mTextPageGenerationThread;
72 
73  Q_Q( Generator );
74  mTextPageGenerationThread = new TextPageGenerationThread( q );
75  QObject::connect( mTextPageGenerationThread, SIGNAL(finished()),
76  q, SLOT(textpageGenerationFinished()),
77  Qt::QueuedConnection );
78 
79  return mTextPageGenerationThread;
80 }
81 
82 void GeneratorPrivate::pixmapGenerationFinished()
83 {
84  Q_Q( Generator );
85  PixmapRequest *request = mPixmapGenerationThread->request();
86  mPixmapGenerationThread->endGeneration();
87 
88  QMutexLocker locker( threadsLock() );
89  mPixmapReady = true;
90 
91  if ( m_closing )
92  {
93  delete request;
94  if ( mTextPageReady )
95  {
96  locker.unlock();
97  m_closingLoop->quit();
98  }
99  return;
100  }
101 
102  const QImage& img = mPixmapGenerationThread->image();
103  request->page()->setPixmap( request->observer(), new QPixmap( QPixmap::fromImage( img ) ), request->normalizedRect() );
104  const int pageNumber = request->page()->number();
105 
106  if ( mPixmapGenerationThread->calcBoundingBox() )
107  q->updatePageBoundingBox( pageNumber, mPixmapGenerationThread->boundingBox() );
108  q->signalPixmapRequestDone( request );
109 }
110 
111 void GeneratorPrivate::textpageGenerationFinished()
112 {
113  Q_Q( Generator );
114  Page *page = mTextPageGenerationThread->page();
115  mTextPageGenerationThread->endGeneration();
116 
117  QMutexLocker locker( threadsLock() );
118  mTextPageReady = true;
119 
120  if ( m_closing )
121  {
122  delete mTextPageGenerationThread->textPage();
123  if ( mPixmapReady )
124  {
125  locker.unlock();
126  m_closingLoop->quit();
127  }
128  return;
129  }
130 
131  if ( mTextPageGenerationThread->textPage() )
132  {
133  TextPage *tp = mTextPageGenerationThread->textPage();
134  page->setTextPage( tp );
135  q->signalTextGenerationDone( page, tp );
136  }
137 }
138 
139 QMutex* GeneratorPrivate::threadsLock()
140 {
141  if ( !m_threadsMutex )
142  m_threadsMutex = new QMutex();
143  return m_threadsMutex;
144 }
145 
146 QVariant GeneratorPrivate::metaData( const QString &, const QVariant & ) const
147 {
148  return QVariant();
149 }
150 
151 QImage GeneratorPrivate::image( PixmapRequest * )
152 {
153  return QImage();
154 }
155 
156 
157 Generator::Generator( QObject *parent, const QVariantList &args )
158  : QObject( parent ), d_ptr( new GeneratorPrivate() )
159 {
160  d_ptr->q_ptr = this;
161  Q_UNUSED( args )
162 }
163 
164 Generator::Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args )
165  : QObject( parent ), d_ptr( &dd )
166 {
167  d_ptr->q_ptr = this;
168  Q_UNUSED( args )
169 }
170 
171 Generator::~Generator()
172 {
173  delete d_ptr;
174 }
175 
176 bool Generator::loadDocumentFromData( const QByteArray &, QVector< Page * > & )
177 {
178  return false;
179 }
180 
181 bool Generator::closeDocument()
182 {
183  Q_D( Generator );
184 
185  d->m_closing = true;
186 
187  d->threadsLock()->lock();
188  if ( !( d->mPixmapReady && d->mTextPageReady ) )
189  {
190  QEventLoop loop;
191  d->m_closingLoop = &loop;
192 
193  d->threadsLock()->unlock();
194 
195  loop.exec();
196 
197  d->m_closingLoop = 0;
198  }
199  else
200  {
201  d->threadsLock()->unlock();
202  }
203 
204  bool ret = doCloseDocument();
205 
206  d->m_closing = false;
207 
208  return ret;
209 }
210 
211 bool Generator::canGeneratePixmap() const
212 {
213  Q_D( const Generator );
214  return d->mPixmapReady;
215 }
216 
217 void Generator::generatePixmap( PixmapRequest *request )
218 {
219  Q_D( Generator );
220  d->mPixmapReady = false;
221 
222  const bool calcBoundingBox = !request->isTile() && !request->page()->isBoundingBoxKnown();
223 
224  if ( request->asynchronous() && hasFeature( Threaded ) )
225  {
226  d->pixmapGenerationThread()->startGeneration( request, calcBoundingBox );
227 
232  if ( hasFeature( TextExtraction ) && !request->page()->hasTextPage() && canGenerateTextPage() && !d->m_closing ) {
233  d->mTextPageReady = false;
234  d->textPageGenerationThread()->startGeneration( request->page() );
235  }
236 
237  return;
238  }
239 
240  const QImage& img = image( request );
241  request->page()->setPixmap( request->observer(), new QPixmap( QPixmap::fromImage( img ) ), request->normalizedRect() );
242  const int pageNumber = request->page()->number();
243 
244  d->mPixmapReady = true;
245 
246  signalPixmapRequestDone( request );
247  if ( calcBoundingBox )
248  updatePageBoundingBox( pageNumber, Utils::imageBoundingBox( &img ) );
249 }
250 
251 bool Generator::canGenerateTextPage() const
252 {
253  Q_D( const Generator );
254  return d->mTextPageReady;
255 }
256 
257 void Generator::generateTextPage( Page *page )
258 {
259  TextPage *tp = textPage( page );
260  page->setTextPage( tp );
261  signalTextGenerationDone( page, tp );
262 }
263 
264 QImage Generator::image( PixmapRequest *request )
265 {
266  Q_D( Generator );
267  return d->image( request );
268 }
269 
270 TextPage* Generator::textPage( Page* )
271 {
272  return 0;
273 }
274 
275 const DocumentInfo * Generator::generateDocumentInfo()
276 {
277  return 0;
278 }
279 
280 const DocumentSynopsis * Generator::generateDocumentSynopsis()
281 {
282  return 0;
283 }
284 
285 FontInfo::List Generator::fontsForPage( int )
286 {
287  return FontInfo::List();
288 }
289 
290 const QList<EmbeddedFile*> * Generator::embeddedFiles() const
291 {
292  return 0;
293 }
294 
295 Generator::PageSizeMetric Generator::pagesSizeMetric() const
296 {
297  return None;
298 }
299 
300 bool Generator::isAllowed( Permission ) const
301 {
302  return true;
303 }
304 
305 void Generator::rotationChanged( Rotation, Rotation )
306 {
307 }
308 
309 PageSize::List Generator::pageSizes() const
310 {
311  return PageSize::List();
312 }
313 
314 void Generator::pageSizeChanged( const PageSize &, const PageSize & )
315 {
316 }
317 
318 bool Generator::print( QPrinter& )
319 {
320  return false;
321 }
322 
323 Generator::PrintError Generator::printError() const
324 {
325  return UnknownPrintError;
326 }
327 
328 QVariant Generator::metaData( const QString &key, const QVariant &option ) const
329 {
330  Q_D( const Generator );
331  return d->metaData( key, option );
332 }
333 
334 ExportFormat::List Generator::exportFormats() const
335 {
336  return ExportFormat::List();
337 }
338 
339 bool Generator::exportTo( const QString&, const ExportFormat& )
340 {
341  return false;
342 }
343 
344 bool Generator::hasFeature( GeneratorFeature feature ) const
345 {
346  Q_D( const Generator );
347  return d->m_features.contains( feature );
348 }
349 
350 void Generator::signalPixmapRequestDone( PixmapRequest * request )
351 {
352  Q_D( Generator );
353  if ( d->m_document )
354  d->m_document->requestDone( request );
355  else
356  {
357  delete request;
358  }
359 }
360 
361 void Generator::signalTextGenerationDone( Page *page, TextPage *textPage )
362 {
363  Q_D( Generator );
364  if ( d->m_document )
365  d->m_document->textGenerationDone( page );
366  else
367  delete textPage;
368 }
369 
370 const Document * Generator::document() const
371 {
372  Q_D( const Generator );
373  if ( d->m_document )
374  {
375  return d->m_document->m_parent;
376  }
377  return 0;
378 }
379 
380 void Generator::setFeature( GeneratorFeature feature, bool on )
381 {
382  Q_D( Generator );
383  if ( on )
384  d->m_features.insert( feature );
385  else
386  d->m_features.remove( feature );
387 }
388 
389 QVariant Generator::documentMetaData( const QString &key, const QVariant &option ) const
390 {
391  Q_D( const Generator );
392  if ( !d->m_document )
393  return QVariant();
394 
395  return d->m_document->documentMetaData( key, option );
396 }
397 
398 QMutex* Generator::userMutex() const
399 {
400  Q_D( const Generator );
401  if ( !d->m_mutex )
402  {
403  d->m_mutex = new QMutex();
404  }
405  return d->m_mutex;
406 }
407 
408 void Generator::updatePageBoundingBox( int page, const NormalizedRect & boundingBox )
409 {
410  Q_D( Generator );
411  if ( d->m_document ) // still connected to document?
412  d->m_document->setPageBoundingBox( page, boundingBox );
413 }
414 
415 void Generator::requestFontData(const Okular::FontInfo & /*font*/, QByteArray * /*data*/)
416 {
417 
418 }
419 
420 const SourceReference * Generator::dynamicSourceReference( int /*pageNr*/, double /*absX*/, double /*absY*/)
421 {
422  return 0;
423 }
424 
425 PixmapRequest::PixmapRequest( DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features )
426  : d( new PixmapRequestPrivate )
427 {
428  d->mObserver = observer;
429  d->mPageNumber = pageNumber;
430  d->mWidth = width;
431  d->mHeight = height;
432  d->mPriority = priority;
433  d->mFeatures = features;
434  d->mForce = false;
435  d->mTile = false;
436  d->mNormalizedRect = NormalizedRect();
437 }
438 
439 PixmapRequest::~PixmapRequest()
440 {
441  delete d;
442 }
443 
444 DocumentObserver *PixmapRequest::observer() const
445 {
446  return d->mObserver;
447 }
448 
449 int PixmapRequest::pageNumber() const
450 {
451  return d->mPageNumber;
452 }
453 
454 int PixmapRequest::width() const
455 {
456  return d->mWidth;
457 }
458 
459 int PixmapRequest::height() const
460 {
461  return d->mHeight;
462 }
463 
464 int PixmapRequest::priority() const
465 {
466  return d->mPriority;
467 }
468 
469 bool PixmapRequest::asynchronous() const
470 {
471  return d->mFeatures & Asynchronous;
472 }
473 
474 bool PixmapRequest::preload() const
475 {
476  return d->mFeatures & Preload;
477 }
478 
479 Page* PixmapRequest::page() const
480 {
481  return d->mPage;
482 }
483 
484 void PixmapRequest::setTile( bool tile )
485 {
486  d->mTile = tile;
487 }
488 
489 bool PixmapRequest::isTile() const
490 {
491  return d->mTile;
492 }
493 
494 void PixmapRequest::setNormalizedRect( const NormalizedRect &rect )
495 {
496  if ( d->mNormalizedRect == rect )
497  return;
498 
499  d->mNormalizedRect = rect;
500 }
501 
502 const NormalizedRect& PixmapRequest::normalizedRect() const
503 {
504  return d->mNormalizedRect;
505 }
506 
507 void PixmapRequestPrivate::swap()
508 {
509  qSwap( mWidth, mHeight );
510 }
511 
512 class Okular::ExportFormatPrivate : public QSharedData
513 {
514  public:
515  ExportFormatPrivate( const QString &description, const KMimeType::Ptr &mimeType, const KIcon &icon = KIcon() )
516  : QSharedData(), mDescription( description ), mMimeType( mimeType ), mIcon( icon )
517  {
518  }
519  ~ExportFormatPrivate()
520  {
521  }
522 
523  QString mDescription;
524  KMimeType::Ptr mMimeType;
525  KIcon mIcon;
526 };
527 
528 ExportFormat::ExportFormat()
529  : d( new ExportFormatPrivate( QString(), KMimeType::Ptr() ) )
530 {
531 }
532 
533 ExportFormat::ExportFormat( const QString &description, const KMimeType::Ptr &mimeType )
534  : d( new ExportFormatPrivate( description, mimeType ) )
535 {
536 }
537 
538 ExportFormat::ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType )
539  : d( new ExportFormatPrivate( description, mimeType, icon ) )
540 {
541 }
542 
543 ExportFormat::~ExportFormat()
544 {
545 }
546 
547 ExportFormat::ExportFormat( const ExportFormat &other )
548  : d( other.d )
549 {
550 }
551 
552 ExportFormat& ExportFormat::operator=( const ExportFormat &other )
553 {
554  if ( this == &other )
555  return *this;
556 
557  d = other.d;
558 
559  return *this;
560 }
561 
562 QString ExportFormat::description() const
563 {
564  return d->mDescription;
565 }
566 
567 KMimeType::Ptr ExportFormat::mimeType() const
568 {
569  return d->mMimeType;
570 }
571 
572 KIcon ExportFormat::icon() const
573 {
574  return d->mIcon;
575 }
576 
577 bool ExportFormat::isNull() const
578 {
579  return d->mMimeType.isNull() || d->mDescription.isNull();
580 }
581 
582 ExportFormat ExportFormat::standardFormat( StandardExportFormat type )
583 {
584  switch ( type )
585  {
586  case PlainText:
587  return ExportFormat( KIcon( "text-x-generic" ), i18n( "Plain &Text..." ), KMimeType::mimeType( "text/plain" ) );
588  break;
589  case PDF:
590  return ExportFormat( KIcon( "application-pdf" ), i18n( "PDF" ), KMimeType::mimeType( "application/pdf" ) );
591  break;
592  case OpenDocumentText:
593  return ExportFormat(
594  KIcon( "application-vnd.oasis.opendocument.text" ),
595  i18nc( "This is the document format", "OpenDocument Text" ),
596  KMimeType::mimeType( "application/vnd.oasis.opendocument.text" ) );
597  break;
598  case HTML:
599  return ExportFormat( KIcon( "text-html" ), i18nc( "This is the document format", "HTML" ), KMimeType::mimeType( "text/html" ) );
600  break;
601  }
602  return ExportFormat();
603 }
604 
605 bool ExportFormat::operator==( const ExportFormat &other ) const
606 {
607  return d == other.d;
608 }
609 
610 bool ExportFormat::operator!=( const ExportFormat &other ) const
611 {
612  return d != other.d;
613 }
614 
615 QDebug operator<<( QDebug str, const Okular::PixmapRequest &req )
616 {
617  QString s = QString( "PixmapRequest(#%2, %1, %3x%4, page %6, prio %5)" )
618  .arg( QString( req.asynchronous() ? "async" : "sync" ) )
619  .arg( (qulonglong)req.observer() )
620  .arg( req.width() )
621  .arg( req.height() )
622  .arg( req.priority() )
623  .arg( req.pageNumber() );
624  str << qPrintable( s );
625  return str;
626 }
627 
628 #include "generator.moc"
629 
630 /* kate: replace-tabs on; indent-width 4; */
Okular::GeneratorPrivate::mTextPageGenerationThread
TextPageGenerationThread * mTextPageGenerationThread
Definition: generator_p.h:60
Okular::PixmapRequestPrivate::mPageNumber
int mPageNumber
Definition: generator_p.h:76
Okular::TextPageGenerationThread::endGeneration
void endGeneration()
Okular::Generator::signalPixmapRequestDone
void signalPixmapRequestDone(PixmapRequest *request)
This method must be called when the pixmap request triggered by generatePixmap() has been finished...
Definition: generator.cpp:350
Okular::ExportFormat::operator=
ExportFormat & operator=(const ExportFormat &other)
Definition: generator.cpp:552
generator.h
Okular::Generator::exportTo
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...
Definition: generator.cpp:339
Okular::Generator::pageSizes
virtual PageSize::List pageSizes() const
Returns the list of supported page sizes.
Definition: generator.cpp:309
Okular::PixmapRequestPrivate::mFeatures
int mFeatures
Definition: generator_p.h:80
Okular::PageSize::List
QList< PageSize > List
Definition: pagesize.h:29
Okular::Generator::generateTextPage
virtual void generateTextPage(Page *page)
This method can be called to trigger the generation of a text page for the given page.
Definition: generator.cpp:257
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::GeneratorPrivate::m_closingLoop
QEventLoop * m_closingLoop
Definition: generator_p.h:66
Okular::PixmapRequestPrivate::mTile
bool mTile
Definition: generator_p.h:82
Okular::PixmapRequestPrivate::mNormalizedRect
NormalizedRect mNormalizedRect
Definition: generator_p.h:84
Okular::Generator::userMutex
QMutex * userMutex() const
Return the pointer to a mutex the generator can use freely.
Definition: generator.cpp:398
Okular::PixmapRequest::pageNumber
int pageNumber() const
Returns the page number of the request.
Definition: generator.cpp:449
Okular::Generator::documentMetaData
QVariant documentMetaData(const QString &key, const QVariant &option=QVariant()) const
Request a meta data of the Document, if available, like an internal setting.
Definition: generator.cpp:389
Okular::PixmapRequest::page
Page * page() const
Returns a pointer to the page where the pixmap shall be generated for.
Definition: generator.cpp:479
Okular::TextPage
The TextPage class represents the text of a page by providing.
Definition: textpage.h:90
Okular::GeneratorPrivate::mPixmapGenerationThread
PixmapGenerationThread * mPixmapGenerationThread
Definition: generator_p.h:59
Okular::GeneratorPrivate::mTextPageReady
bool mTextPageReady
Definition: generator_p.h:64
Okular::GeneratorPrivate::m_mutex
QMutex * m_mutex
Definition: generator_p.h:61
Okular::ExportFormat::description
QString description() const
Returns the description of the format.
Definition: generator.cpp:562
Okular::Generator::rotationChanged
virtual void rotationChanged(Rotation orientation, Rotation oldOrientation)
This method is called when the orientation has been changed by the user.
Definition: generator.cpp:305
Okular::Generator::textPage
virtual TextPage * textPage(Page *page)
Returns the text page for the given page.
Definition: generator.cpp:270
Okular::PixmapRequestPrivate::mObserver
DocumentObserver * mObserver
Definition: generator_p.h:75
Okular::PixmapRequestPrivate::swap
void swap()
Definition: generator.cpp:507
Okular::TextPageGenerationThread
Definition: generator_p.h:117
Okular::Generator::UnknownPrintError
Definition: generator.h:352
Okular::Generator::embeddedFiles
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...
Definition: generator.cpp:290
Okular::Generator::isAllowed
virtual bool isAllowed(Permission action) const
This method returns whether given action (Permission) is allowed in this document.
Definition: generator.cpp:300
Okular::PixmapRequest::normalizedRect
const NormalizedRect & normalizedRect() const
Returns the normalized region of the page to request.
Definition: generator.cpp:502
Okular::Generator::canGeneratePixmap
virtual bool canGeneratePixmap() const
This method returns whether the generator is ready to handle a new pixmap request.
Definition: generator.cpp:211
Okular::Generator::pagesSizeMetric
virtual PageSizeMetric pagesSizeMetric() const
This method returns the metric of the page size.
Definition: generator.cpp:295
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:147
Okular::GeneratorPrivate::m_threadsMutex
QMutex * m_threadsMutex
Definition: generator_p.h:62
Okular::Generator::~Generator
virtual ~Generator()
Destroys the generator.
Definition: generator.cpp:171
Okular::Generator::PageSizeMetric
PageSizeMetric
This enum identifies the metric of the page size.
Definition: generator.h:308
Okular::Generator::updatePageBoundingBox
void updatePageBoundingBox(int page, const NormalizedRect &boundingBox)
Set the bounding box of a page after the page has already been handed to the Document.
Definition: generator.cpp:408
Okular::Page::number
int number() const
Returns the number of the page in the document.
Definition: page.cpp:160
Okular::Page::isBoundingBoxKnown
bool isBoundingBoxKnown() const
Returns whether the bounding box of the page has been computed.
Definition: page.cpp:200
Okular::NormalizedRect
NormalizedRect is a helper class which stores the coordinates of a normalized rect, which is a rectangle of.
Definition: area.h:105
generator_p.h
Okular::Generator::metaData
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.
Definition: generator.cpp:328
Okular::GeneratorPrivate::textpageGenerationFinished
void textpageGenerationFinished()
Definition: generator.cpp:111
Okular::Generator::fontsForPage
virtual FontInfo::List fontsForPage(int page)
Definition: generator.cpp:285
Okular::PixmapGenerationThread
Definition: generator_p.h:88
Okular::ExportFormat::ExportFormat
ExportFormat()
Creates an empty export format.
Definition: generator.cpp:528
QObject
Okular::Page::hasTextPage
bool hasTextPage() const
Returns whether the page provides a text page (TextPage).
Definition: page.cpp:244
Okular::Generator::dynamicSourceReference
const SourceReference * dynamicSourceReference(int pageNr, double absX, double absY)
Asks the generator to dynamically generate a SourceReference for a given page number and absolute X a...
Definition: generator.cpp:420
Okular::PixmapRequest::Preload
Definition: generator.h:532
page.h
Okular::GeneratorPrivate::~GeneratorPrivate
virtual ~GeneratorPrivate()
Definition: generator.cpp:38
Okular::GeneratorPrivate::metaData
virtual QVariant metaData(const QString &key, const QVariant &option) const
Definition: generator.cpp:146
observer.h
Okular::PixmapRequest::setNormalizedRect
void setNormalizedRect(const NormalizedRect &rect)
Sets the region of the page to request.
Definition: generator.cpp:494
Okular::PixmapRequestPrivate::mPage
Page * mPage
Definition: generator_p.h:83
Okular::PixmapRequest::height
int height() const
Returns the page height of the requested pixmap.
Definition: generator.cpp:459
Okular::Generator::requestFontData
void requestFontData(const Okular::FontInfo &font, QByteArray *data)
Gets the font data for the given font.
Definition: generator.cpp:415
Okular::ExportFormat::operator!=
bool operator!=(const ExportFormat &other) const
Definition: generator.cpp:610
Okular::ExportFormat::List
QList< ExportFormat > List
Definition: generator.h:78
utils.h
Okular::Generator::Threaded
Definition: generator.h:201
Okular::PixmapGenerationThread::endGeneration
void endGeneration()
Okular::ExportFormat::standardFormat
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
Definition: generator.cpp:582
Okular::Generator::Generator
Generator(QObject *parent, const QVariantList &args)
Creates a new generator.
Definition: generator.cpp:157
Okular::PixmapRequestPrivate::mHeight
int mHeight
Definition: generator_p.h:78
Okular::Generator::exportFormats
virtual ExportFormat::List exportFormats() const
Returns the list of additional supported export formats.
Definition: generator.cpp:334
Okular::GeneratorPrivate::threadsLock
QMutex * threadsLock()
Definition: generator.cpp:139
Okular::FontInfo
A small class that represents the information of a font.
Definition: fontinfo.h:27
Okular::GeneratorPrivate::GeneratorPrivate
GeneratorPrivate()
Definition: generator.cpp:30
Okular::TextPageGenerationThread::textPage
TextPage * textPage() const
Okular::Generator::setFeature
void setFeature(GeneratorFeature feature, bool on=true)
Toggle the feature .
Definition: generator.cpp:380
Okular::PixmapRequest::width
int width() const
Returns the page width of the requested pixmap.
Definition: generator.cpp:454
Okular::PixmapRequest::observer
DocumentObserver * observer() const
Returns the observer of the request.
Definition: generator.cpp:444
Okular::Utils::imageBoundingBox
static NormalizedRect imageBoundingBox(const QImage *image)
Compute the smallest rectangle that contains all non-white pixels in image), in normalized [0...
Definition: utils.cpp:194
Okular::ExportFormat::OpenDocumentText
OpenDocument Text format.
Definition: generator.h:149
Okular::GeneratorPrivate::pixmapGenerationThread
PixmapGenerationThread * pixmapGenerationThread()
Definition: generator.cpp:54
Okular::Generator::printError
Okular::Generator::PrintError printError() const
Returns the last print error in case print() failed.
Definition: generator.cpp:323
Okular::PixmapRequestPrivate
Definition: generator_p.h:70
Okular::ExportFormat::icon
KIcon icon() const
Returns the icon for GUI representations of the format.
Definition: generator.cpp:572
Okular::PixmapRequestPrivate::mWidth
int mWidth
Definition: generator_p.h:77
Okular::Document
The Document.
Definition: document.h:84
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
Okular::ExportFormat::~ExportFormat
~ExportFormat()
Destroys the export format.
Definition: generator.cpp:543
document.h
Okular::Page::setPixmap
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:517
Okular::Generator::generateDocumentInfo
virtual const DocumentInfo * generateDocumentInfo()
Returns the general information object of the document or 0 if no information are available...
Definition: generator.cpp:275
textpage.h
Okular::PixmapGenerationThread::image
QImage image() const
Okular::GeneratorPrivate::pixmapGenerationFinished
void pixmapGenerationFinished()
Definition: generator.cpp:82
Okular::ExportFormat::mimeType
KMimeType::Ptr mimeType() const
Returns the mime type of the format.
Definition: generator.cpp:567
operator<<
QDebug operator<<(QDebug str, const Okular::PixmapRequest &req)
Definition: generator.cpp:615
Okular::PixmapRequest::asynchronous
bool asynchronous() const
Returns whether the generation should be done synchronous or asynchronous.
Definition: generator.cpp:469
Okular::ExportFormat::StandardExportFormat
StandardExportFormat
Type of standard export format.
Definition: generator.h:145
Okular::Generator::hasFeature
bool hasFeature(GeneratorFeature feature) const
Query for the specified feature.
Definition: generator.cpp:344
Okular::PixmapRequest::preload
bool preload() const
Returns whether the generation request is for a page that is not important i.e.
Definition: generator.cpp:474
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1073
Okular::PixmapRequest::priority
int priority() const
Returns the priority (less it better, 0 is maximum) of the request.
Definition: generator.cpp:464
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:148
Okular::SourceReference
Defines a source reference.
Definition: sourcereference.h:25
Okular::PixmapGenerationThread::calcBoundingBox
bool calcBoundingBox() const
Okular::GeneratorPrivate::m_closing
bool m_closing
Definition: generator_p.h:65
Okular::Generator::print
virtual bool print(QPrinter &printer)
This method is called to print the document to the given printer.
Definition: generator.cpp:318
Okular::Generator::signalTextGenerationDone
void signalTextGenerationDone(Page *page, TextPage *textPage)
This method must be called when a text generation has been finished.
Definition: generator.cpp:361
Okular::PixmapGenerationThread::request
PixmapRequest * request() const
Okular::Generator::loadDocumentFromData
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...
Definition: generator.cpp:176
document_p.h
Okular::Generator::None
The page size is not defined in a physical metric.
Definition: generator.h:310
Okular::Generator::image
virtual QImage image(PixmapRequest *page)
Returns the image of the page as specified in the passed pixmap request.
Definition: generator.cpp:264
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:75
Okular::PageSize
A small class that represents the size of a page.
Definition: pagesize.h:26
Okular::Generator::pageSizeChanged
virtual void pageSizeChanged(const PageSize &pageSize, const PageSize &oldPageSize)
This method is called when the page size has been changed by the user.
Definition: generator.cpp:314
Okular::Generator::PrintError
PrintError
Possible print errors.
Definition: generator.h:349
Okular::GeneratorPrivate::mPixmapReady
bool mPixmapReady
Definition: generator_p.h:63
Okular::ExportFormat::HTML
OpenDocument Text format.
Definition: generator.h:150
Okular::DocumentObserver
Base class for objects being notified when something changes.
Definition: observer.h:28
Okular::Generator::generatePixmap
virtual void generatePixmap(PixmapRequest *request)
This method can be called to trigger the generation of a new pixmap as described by request...
Definition: generator.cpp:217
Okular::PixmapRequestPrivate::mPriority
int mPriority
Definition: generator_p.h:79
Okular::PixmapRequest::isTile
bool isTile() const
Returns whether the generator should render just the region given by normalizedRect() or the entire p...
Definition: generator.cpp:489
description
static const char description[]
Definition: main.cpp:33
Okular::Permission
Permission
Describes the DRM capabilities.
Definition: global.h:20
Okular::Page::setTextPage
void setTextPage(TextPage *text)
Sets the text page.
Definition: page.cpp:549
Okular::PixmapRequest::PixmapRequest
PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features)
Creates a new pixmap request.
Definition: generator.cpp:425
Okular::GeneratorPrivate::textPageGenerationThread
TextPageGenerationThread * textPageGenerationThread()
Definition: generator.cpp:68
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:202
Okular::PixmapRequestPrivate::mForce
bool mForce
Definition: generator_p.h:81
Okular::Generator::canGenerateTextPage
virtual bool canGenerateTextPage() const
This method returns whether the generator is ready to handle a new text page request.
Definition: generator.cpp:251
Okular::ExportFormat::operator==
bool operator==(const ExportFormat &other) const
Definition: generator.cpp:605
Okular::PixmapGenerationThread::boundingBox
NormalizedRect boundingBox() const
Okular::GeneratorPrivate::image
virtual QImage image(PixmapRequest *)
Definition: generator.cpp:151
Okular::Generator::generateDocumentSynopsis
virtual const DocumentSynopsis * generateDocumentSynopsis()
Returns the 'table of content' object of the document or 0 if no table of content is available...
Definition: generator.cpp:280
Okular::Generator::closeDocument
bool closeDocument()
This method is called when the document is closed and not used any longer.
Definition: generator.cpp:181
Okular::PixmapRequest::Asynchronous
Definition: generator.h:531
Okular::Generator::doCloseDocument
virtual bool doCloseDocument()=0
This method is called when the document is closed and not used any longer.
Okular::Generator::document
const Document * document() const
Returns a pointer to the document.
Definition: generator.cpp:370
Okular::TextPageGenerationThread::page
Page * page() const
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::ExportFormat::isNull
bool isNull() const
Returns whether the export format is null/valid.
Definition: generator.cpp:577
Okular::PixmapRequest::setTile
void setTile(bool tile)
Sets whether the generator should render only the given normalized rect or the entire page...
Definition: generator.cpp:484
Okular::PixmapRequest::~PixmapRequest
~PixmapRequest()
Destroys the pixmap request.
Definition: generator.cpp:439
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