• 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.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 #include <kwallet.h>
22 
23 #include "document.h"
24 #include "document_p.h"
25 #include "page.h"
26 #include "page_p.h"
27 #include "textpage.h"
28 #include "utils.h"
29 
30 using namespace Okular;
31 
32 GeneratorPrivate::GeneratorPrivate()
33  : m_document( 0 ),
34  mPixmapGenerationThread( 0 ), mTextPageGenerationThread( 0 ),
35  m_mutex( 0 ), m_threadsMutex( 0 ), mPixmapReady( true ), mTextPageReady( true ),
36  m_closing( false ), m_closingLoop( 0 ),
37  m_dpi(72.0, 72.0)
38 {
39 }
40 
41 GeneratorPrivate::~GeneratorPrivate()
42 {
43  if ( mPixmapGenerationThread )
44  mPixmapGenerationThread->wait();
45 
46  delete mPixmapGenerationThread;
47 
48  if ( mTextPageGenerationThread )
49  mTextPageGenerationThread->wait();
50 
51  delete mTextPageGenerationThread;
52 
53  delete m_mutex;
54  delete m_threadsMutex;
55 }
56 
57 PixmapGenerationThread* GeneratorPrivate::pixmapGenerationThread()
58 {
59  if ( mPixmapGenerationThread )
60  return mPixmapGenerationThread;
61 
62  Q_Q( Generator );
63  mPixmapGenerationThread = new PixmapGenerationThread( q );
64  QObject::connect( mPixmapGenerationThread, SIGNAL(finished()),
65  q, SLOT(pixmapGenerationFinished()),
66  Qt::QueuedConnection );
67 
68  return mPixmapGenerationThread;
69 }
70 
71 TextPageGenerationThread* GeneratorPrivate::textPageGenerationThread()
72 {
73  if ( mTextPageGenerationThread )
74  return mTextPageGenerationThread;
75 
76  Q_Q( Generator );
77  mTextPageGenerationThread = new TextPageGenerationThread( q );
78  QObject::connect( mTextPageGenerationThread, SIGNAL(finished()),
79  q, SLOT(textpageGenerationFinished()),
80  Qt::QueuedConnection );
81 
82  return mTextPageGenerationThread;
83 }
84 
85 void GeneratorPrivate::pixmapGenerationFinished()
86 {
87  Q_Q( Generator );
88  PixmapRequest *request = mPixmapGenerationThread->request();
89  mPixmapGenerationThread->endGeneration();
90 
91  QMutexLocker locker( threadsLock() );
92  mPixmapReady = true;
93 
94  if ( m_closing )
95  {
96  delete request;
97  if ( mTextPageReady )
98  {
99  locker.unlock();
100  m_closingLoop->quit();
101  }
102  return;
103  }
104 
105  const QImage& img = mPixmapGenerationThread->image();
106  request->page()->setPixmap( request->observer(), new QPixmap( QPixmap::fromImage( img ) ), request->normalizedRect() );
107  const int pageNumber = request->page()->number();
108 
109  if ( mPixmapGenerationThread->calcBoundingBox() )
110  q->updatePageBoundingBox( pageNumber, mPixmapGenerationThread->boundingBox() );
111  q->signalPixmapRequestDone( request );
112 }
113 
114 void GeneratorPrivate::textpageGenerationFinished()
115 {
116  Q_Q( Generator );
117  Page *page = mTextPageGenerationThread->page();
118  mTextPageGenerationThread->endGeneration();
119 
120  QMutexLocker locker( threadsLock() );
121  mTextPageReady = true;
122 
123  if ( m_closing )
124  {
125  delete mTextPageGenerationThread->textPage();
126  if ( mPixmapReady )
127  {
128  locker.unlock();
129  m_closingLoop->quit();
130  }
131  return;
132  }
133 
134  if ( mTextPageGenerationThread->textPage() )
135  {
136  TextPage *tp = mTextPageGenerationThread->textPage();
137  page->setTextPage( tp );
138  q->signalTextGenerationDone( page, tp );
139  }
140 }
141 
142 QMutex* GeneratorPrivate::threadsLock()
143 {
144  if ( !m_threadsMutex )
145  m_threadsMutex = new QMutex();
146  return m_threadsMutex;
147 }
148 
149 QVariant GeneratorPrivate::metaData( const QString &, const QVariant & ) const
150 {
151  return QVariant();
152 }
153 
154 QImage GeneratorPrivate::image( PixmapRequest * )
155 {
156  return QImage();
157 }
158 
159 
160 Generator::Generator( QObject *parent, const QVariantList &args )
161  : QObject( parent ), d_ptr( new GeneratorPrivate() )
162 {
163  d_ptr->q_ptr = this;
164  Q_UNUSED( args )
165 }
166 
167 Generator::Generator( GeneratorPrivate &dd, QObject *parent, const QVariantList &args )
168  : QObject( parent ), d_ptr( &dd )
169 {
170  d_ptr->q_ptr = this;
171  Q_UNUSED( args )
172 }
173 
174 Generator::~Generator()
175 {
176  delete d_ptr;
177 }
178 
179 bool Generator::loadDocument( const QString & fileName, QVector< Page * > & pagesVector )
180 {
181  return false;
182 }
183 
184 bool Generator::loadDocumentFromData( const QByteArray &, QVector< Page * > & )
185 {
186  return false;
187 }
188 
189 Document::OpenResult Generator::loadDocumentWithPassword( const QString & fileName, QVector< Page * > & pagesVector, const QString & )
190 {
191  return loadDocument( fileName, pagesVector ) ? Document::OpenSuccess : Document::OpenError;
192 }
193 
194 Document::OpenResult Generator::loadDocumentFromDataWithPassword( const QByteArray & fileData, QVector< Page * > & pagesVector, const QString & )
195 {
196  return loadDocumentFromData( fileData, pagesVector ) ? Document::OpenSuccess : Document::OpenError;
197 }
198 
199 bool Generator::closeDocument()
200 {
201  Q_D( Generator );
202 
203  d->m_closing = true;
204 
205  d->threadsLock()->lock();
206  if ( !( d->mPixmapReady && d->mTextPageReady ) )
207  {
208  QEventLoop loop;
209  d->m_closingLoop = &loop;
210 
211  d->threadsLock()->unlock();
212 
213  loop.exec();
214 
215  d->m_closingLoop = 0;
216  }
217  else
218  {
219  d->threadsLock()->unlock();
220  }
221 
222  bool ret = doCloseDocument();
223 
224  d->m_closing = false;
225 
226  return ret;
227 }
228 
229 bool Generator::canGeneratePixmap() const
230 {
231  Q_D( const Generator );
232  return d->mPixmapReady;
233 }
234 
235 void Generator::generatePixmap( PixmapRequest *request )
236 {
237  Q_D( Generator );
238  d->mPixmapReady = false;
239 
240  const bool calcBoundingBox = !request->isTile() && !request->page()->isBoundingBoxKnown();
241 
242  if ( request->asynchronous() && hasFeature( Threaded ) )
243  {
244  d->pixmapGenerationThread()->startGeneration( request, calcBoundingBox );
245 
250  if ( hasFeature( TextExtraction ) && !request->page()->hasTextPage() && canGenerateTextPage() && !d->m_closing ) {
251  d->mTextPageReady = false;
252  d->textPageGenerationThread()->startGeneration( request->page() );
253  }
254 
255  return;
256  }
257 
258  const QImage& img = image( request );
259  request->page()->setPixmap( request->observer(), new QPixmap( QPixmap::fromImage( img ) ), request->normalizedRect() );
260  const int pageNumber = request->page()->number();
261 
262  d->mPixmapReady = true;
263 
264  signalPixmapRequestDone( request );
265  if ( calcBoundingBox )
266  updatePageBoundingBox( pageNumber, Utils::imageBoundingBox( &img ) );
267 }
268 
269 bool Generator::canGenerateTextPage() const
270 {
271  Q_D( const Generator );
272  return d->mTextPageReady;
273 }
274 
275 void Generator::generateTextPage( Page *page )
276 {
277  TextPage *tp = textPage( page );
278  page->setTextPage( tp );
279  signalTextGenerationDone( page, tp );
280 }
281 
282 QImage Generator::image( PixmapRequest *request )
283 {
284  Q_D( Generator );
285  return d->image( request );
286 }
287 
288 TextPage* Generator::textPage( Page* )
289 {
290  return 0;
291 }
292 
293 const DocumentInfo * Generator::generateDocumentInfo()
294 {
295  return 0;
296 }
297 
298 const DocumentSynopsis * Generator::generateDocumentSynopsis()
299 {
300  return 0;
301 }
302 
303 FontInfo::List Generator::fontsForPage( int )
304 {
305  return FontInfo::List();
306 }
307 
308 const QList<EmbeddedFile*> * Generator::embeddedFiles() const
309 {
310  return 0;
311 }
312 
313 Generator::PageSizeMetric Generator::pagesSizeMetric() const
314 {
315  return None;
316 }
317 
318 bool Generator::isAllowed( Permission ) const
319 {
320  return true;
321 }
322 
323 void Generator::rotationChanged( Rotation, Rotation )
324 {
325 }
326 
327 PageSize::List Generator::pageSizes() const
328 {
329  return PageSize::List();
330 }
331 
332 void Generator::pageSizeChanged( const PageSize &, const PageSize & )
333 {
334 }
335 
336 bool Generator::print( QPrinter& )
337 {
338  return false;
339 }
340 
341 Generator::PrintError Generator::printError() const
342 {
343  return UnknownPrintError;
344 }
345 
346 QVariant Generator::metaData( const QString &key, const QVariant &option ) const
347 {
348  Q_D( const Generator );
349  return d->metaData( key, option );
350 }
351 
352 ExportFormat::List Generator::exportFormats() const
353 {
354  return ExportFormat::List();
355 }
356 
357 bool Generator::exportTo( const QString&, const ExportFormat& )
358 {
359  return false;
360 }
361 
362 void Generator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
363 {
364  *walletKey = fileName.section('/', -1, -1);
365  *walletName = KWallet::Wallet::NetworkWallet();
366  *walletFolder = "KPdf";
367 }
368 
369 bool Generator::hasFeature( GeneratorFeature feature ) const
370 {
371  Q_D( const Generator );
372  return d->m_features.contains( feature );
373 }
374 
375 void Generator::signalPixmapRequestDone( PixmapRequest * request )
376 {
377  Q_D( Generator );
378  if ( d->m_document )
379  d->m_document->requestDone( request );
380  else
381  {
382  delete request;
383  }
384 }
385 
386 void Generator::signalTextGenerationDone( Page *page, TextPage *textPage )
387 {
388  Q_D( Generator );
389  if ( d->m_document )
390  d->m_document->textGenerationDone( page );
391  else
392  delete textPage;
393 }
394 
395 const Document * Generator::document() const
396 {
397  Q_D( const Generator );
398  if ( d->m_document )
399  {
400  return d->m_document->m_parent;
401  }
402  return 0;
403 }
404 
405 void Generator::setFeature( GeneratorFeature feature, bool on )
406 {
407  Q_D( Generator );
408  if ( on )
409  d->m_features.insert( feature );
410  else
411  d->m_features.remove( feature );
412 }
413 
414 QVariant Generator::documentMetaData( const QString &key, const QVariant &option ) const
415 {
416  Q_D( const Generator );
417  if ( !d->m_document )
418  return QVariant();
419 
420  return d->m_document->documentMetaData( key, option );
421 }
422 
423 QMutex* Generator::userMutex() const
424 {
425  Q_D( const Generator );
426  if ( !d->m_mutex )
427  {
428  d->m_mutex = new QMutex();
429  }
430  return d->m_mutex;
431 }
432 
433 void Generator::updatePageBoundingBox( int page, const NormalizedRect & boundingBox )
434 {
435  Q_D( Generator );
436  if ( d->m_document ) // still connected to document?
437  d->m_document->setPageBoundingBox( page, boundingBox );
438 }
439 
440 void Generator::requestFontData(const Okular::FontInfo & /*font*/, QByteArray * /*data*/)
441 {
442 
443 }
444 
445 const SourceReference * Generator::dynamicSourceReference( int /*pageNr*/, double /*absX*/, double /*absY*/)
446 {
447  return 0;
448 }
449 
450 void Generator::setDPI(const QSizeF & dpi)
451 {
452  Q_D( Generator );
453  d->m_dpi = dpi;
454 }
455 
456 QSizeF Generator::dpi() const
457 {
458  Q_D( const Generator );
459  return d->m_dpi;
460 }
461 
462 PixmapRequest::PixmapRequest( DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features )
463  : d( new PixmapRequestPrivate )
464 {
465  d->mObserver = observer;
466  d->mPageNumber = pageNumber;
467  d->mWidth = width;
468  d->mHeight = height;
469  d->mPriority = priority;
470  d->mFeatures = features;
471  d->mForce = false;
472  d->mTile = false;
473  d->mNormalizedRect = NormalizedRect();
474 }
475 
476 PixmapRequest::~PixmapRequest()
477 {
478  delete d;
479 }
480 
481 DocumentObserver *PixmapRequest::observer() const
482 {
483  return d->mObserver;
484 }
485 
486 int PixmapRequest::pageNumber() const
487 {
488  return d->mPageNumber;
489 }
490 
491 int PixmapRequest::width() const
492 {
493  return d->mWidth;
494 }
495 
496 int PixmapRequest::height() const
497 {
498  return d->mHeight;
499 }
500 
501 int PixmapRequest::priority() const
502 {
503  return d->mPriority;
504 }
505 
506 bool PixmapRequest::asynchronous() const
507 {
508  return d->mFeatures & Asynchronous;
509 }
510 
511 bool PixmapRequest::preload() const
512 {
513  return d->mFeatures & Preload;
514 }
515 
516 Page* PixmapRequest::page() const
517 {
518  return d->mPage;
519 }
520 
521 void PixmapRequest::setTile( bool tile )
522 {
523  d->mTile = tile;
524 }
525 
526 bool PixmapRequest::isTile() const
527 {
528  return d->mTile;
529 }
530 
531 void PixmapRequest::setNormalizedRect( const NormalizedRect &rect )
532 {
533  if ( d->mNormalizedRect == rect )
534  return;
535 
536  d->mNormalizedRect = rect;
537 }
538 
539 const NormalizedRect& PixmapRequest::normalizedRect() const
540 {
541  return d->mNormalizedRect;
542 }
543 
544 Okular::TilesManager* PixmapRequestPrivate::tilesManager() const
545 {
546  return mPage->d->tilesManager(mObserver);
547 }
548 
549 void PixmapRequestPrivate::swap()
550 {
551  qSwap( mWidth, mHeight );
552 }
553 
554 class Okular::ExportFormatPrivate : public QSharedData
555 {
556  public:
557  ExportFormatPrivate( const QString &description, const KMimeType::Ptr &mimeType, const KIcon &icon = KIcon() )
558  : QSharedData(), mDescription( description ), mMimeType( mimeType ), mIcon( icon )
559  {
560  }
561  ~ExportFormatPrivate()
562  {
563  }
564 
565  QString mDescription;
566  KMimeType::Ptr mMimeType;
567  KIcon mIcon;
568 };
569 
570 ExportFormat::ExportFormat()
571  : d( new ExportFormatPrivate( QString(), KMimeType::Ptr() ) )
572 {
573 }
574 
575 ExportFormat::ExportFormat( const QString &description, const KMimeType::Ptr &mimeType )
576  : d( new ExportFormatPrivate( description, mimeType ) )
577 {
578 }
579 
580 ExportFormat::ExportFormat( const KIcon &icon, const QString &description, const KMimeType::Ptr &mimeType )
581  : d( new ExportFormatPrivate( description, mimeType, icon ) )
582 {
583 }
584 
585 ExportFormat::~ExportFormat()
586 {
587 }
588 
589 ExportFormat::ExportFormat( const ExportFormat &other )
590  : d( other.d )
591 {
592 }
593 
594 ExportFormat& ExportFormat::operator=( const ExportFormat &other )
595 {
596  if ( this == &other )
597  return *this;
598 
599  d = other.d;
600 
601  return *this;
602 }
603 
604 QString ExportFormat::description() const
605 {
606  return d->mDescription;
607 }
608 
609 KMimeType::Ptr ExportFormat::mimeType() const
610 {
611  return d->mMimeType;
612 }
613 
614 KIcon ExportFormat::icon() const
615 {
616  return d->mIcon;
617 }
618 
619 bool ExportFormat::isNull() const
620 {
621  return d->mMimeType.isNull() || d->mDescription.isNull();
622 }
623 
624 ExportFormat ExportFormat::standardFormat( StandardExportFormat type )
625 {
626  switch ( type )
627  {
628  case PlainText:
629  return ExportFormat( KIcon( "text-x-generic" ), i18n( "Plain &Text..." ), KMimeType::mimeType( "text/plain" ) );
630  break;
631  case PDF:
632  return ExportFormat( KIcon( "application-pdf" ), i18n( "PDF" ), KMimeType::mimeType( "application/pdf" ) );
633  break;
634  case OpenDocumentText:
635  return ExportFormat(
636  KIcon( "application-vnd.oasis.opendocument.text" ),
637  i18nc( "This is the document format", "OpenDocument Text" ),
638  KMimeType::mimeType( "application/vnd.oasis.opendocument.text" ) );
639  break;
640  case HTML:
641  return ExportFormat( KIcon( "text-html" ), i18nc( "This is the document format", "HTML" ), KMimeType::mimeType( "text/html" ) );
642  break;
643  }
644  return ExportFormat();
645 }
646 
647 bool ExportFormat::operator==( const ExportFormat &other ) const
648 {
649  return d == other.d;
650 }
651 
652 bool ExportFormat::operator!=( const ExportFormat &other ) const
653 {
654  return d != other.d;
655 }
656 
657 QDebug operator<<( QDebug str, const Okular::PixmapRequest &req )
658 {
659  QString s = QString( "PixmapRequest(#%2, %1, %3x%4, page %6, prio %5)" )
660  .arg( QString( req.asynchronous() ? "async" : "sync" ) )
661  .arg( (qulonglong)req.observer() )
662  .arg( req.width() )
663  .arg( req.height() )
664  .arg( req.priority() )
665  .arg( req.pageNumber() );
666  str << qPrintable( s );
667  return str;
668 }
669 
670 #include "generator.moc"
671 
672 /* kate: replace-tabs on; indent-width 4; */
QMutexLocker::unlock
void unlock()
Okular::GeneratorPrivate::mTextPageGenerationThread
TextPageGenerationThread * mTextPageGenerationThread
Definition: generator_p.h:61
Okular::PixmapRequestPrivate::mPageNumber
int mPageNumber
Definition: generator_p.h:79
Okular::Generator::loadDocument
virtual bool loadDocument(const QString &fileName, QVector< Page * > &pagesVector)
Loads the document with the given fileName and fills the pagesVector with the parsed pages...
Definition: generator.cpp:179
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:375
Okular::ExportFormat::operator=
ExportFormat & operator=(const ExportFormat &other)
Definition: generator.cpp:594
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:357
Okular::Generator::pageSizes
virtual PageSize::List pageSizes() const
Returns the list of supported page sizes.
Definition: generator.cpp:327
Okular::PixmapRequestPrivate::mFeatures
int mFeatures
Definition: generator_p.h:83
QMutex
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:275
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::GeneratorPrivate::m_closingLoop
QEventLoop * m_closingLoop
Definition: generator_p.h:67
Okular::PixmapRequestPrivate::mTile
bool mTile
Definition: generator_p.h:85
QEventLoop::quit
void quit()
Okular::PixmapRequestPrivate::mNormalizedRect
NormalizedRect mNormalizedRect
Definition: generator_p.h:87
Okular::Generator::userMutex
QMutex * userMutex() const
Return the pointer to a mutex the generator can use freely.
Definition: generator.cpp:423
Okular::PixmapRequest::pageNumber
int pageNumber() const
Returns the page number of the request.
Definition: generator.cpp:486
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:414
QEventLoop
Okular::PixmapRequest::page
Page * page() const
Returns a pointer to the page where the pixmap shall be generated for.
Definition: generator.cpp:516
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:60
Okular::GeneratorPrivate::mTextPageReady
bool mTextPageReady
Definition: generator_p.h:65
Okular::GeneratorPrivate::m_mutex
QMutex * m_mutex
Definition: generator_p.h:62
Okular::ExportFormat::description
QString description() const
Returns the description of the format.
Definition: generator.cpp:604
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:323
Okular::Generator::textPage
virtual TextPage * textPage(Page *page)
Returns the text page for the given page.
Definition: generator.cpp:288
Okular::PixmapRequestPrivate::mObserver
DocumentObserver * mObserver
Definition: generator_p.h:78
QByteArray
Okular::PixmapRequestPrivate::swap
void swap()
Definition: generator.cpp:549
Okular::TextPageGenerationThread
Definition: generator_p.h:120
Okular::Generator::UnknownPrintError
Definition: generator.h:385
QPrinter
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:308
Okular::Generator::isAllowed
virtual bool isAllowed(Permission action) const
This method returns whether given action (Permission) is allowed in this document.
Definition: generator.cpp:318
Okular::PixmapRequest::normalizedRect
const NormalizedRect & normalizedRect() const
Returns the normalized region of the page to request.
Definition: generator.cpp:539
Okular::Generator::dpi
QSizeF dpi() const
Returns DPI, previously set via setDPI()
Definition: generator.cpp:456
Okular::Generator::canGeneratePixmap
virtual bool canGeneratePixmap() const
This method returns whether the generator is ready to handle a new pixmap request.
Definition: generator.cpp:229
Okular::Generator::pagesSizeMetric
virtual PageSizeMetric pagesSizeMetric() const
This method returns the metric of the page size.
Definition: generator.cpp:313
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:148
Okular::GeneratorPrivate::m_threadsMutex
QMutex * m_threadsMutex
Definition: generator_p.h:63
Okular::Generator::~Generator
virtual ~Generator()
Destroys the generator.
Definition: generator.cpp:174
Okular::Generator::PageSizeMetric
PageSizeMetric
This enum identifies the metric of the page size.
Definition: generator.h:340
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:433
Okular::Page::number
int number() const
Returns the number of the page in the document.
Definition: page.cpp:144
Okular::Page::isBoundingBoxKnown
bool isBoundingBoxKnown() const
Returns whether the bounding box of the page has been computed.
Definition: page.cpp:184
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
QPixmap::fromImage
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
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:346
Okular::GeneratorPrivate::textpageGenerationFinished
void textpageGenerationFinished()
Definition: generator.cpp:114
Okular::Generator::fontsForPage
virtual FontInfo::List fontsForPage(int page)
Definition: generator.cpp:303
page_p.h
Okular::PixmapGenerationThread
Definition: generator_p.h:91
Okular::ExportFormat::ExportFormat
ExportFormat()
Creates an empty export format.
Definition: generator.cpp:570
Okular::Page::hasTextPage
bool hasTextPage() const
Returns whether the page provides a text page (TextPage).
Definition: page.cpp:228
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:445
Okular::PixmapRequest::Preload
Definition: generator.h:585
page.h
Okular::GeneratorPrivate::~GeneratorPrivate
virtual ~GeneratorPrivate()
Definition: generator.cpp:41
Okular::GeneratorPrivate::metaData
virtual QVariant metaData(const QString &key, const QVariant &option) const
Definition: generator.cpp:149
observer.h
Okular::PixmapRequest::setNormalizedRect
void setNormalizedRect(const NormalizedRect &rect)
Sets the region of the page to request.
Definition: generator.cpp:531
Okular::PixmapRequestPrivate::mPage
Page * mPage
Definition: generator_p.h:86
Okular::PixmapRequest::height
int height() const
Returns the page height of the requested pixmap.
Definition: generator.cpp:496
Okular::Document::OpenResult
OpenResult
Describes the result of an open document operation.
Definition: document.h:103
Okular::Generator::requestFontData
void requestFontData(const Okular::FontInfo &font, QByteArray *data)
Gets the font data for the given font.
Definition: generator.cpp:440
Okular::ExportFormat::operator!=
bool operator!=(const ExportFormat &other) const
Definition: generator.cpp:652
Okular::ExportFormat::List
QList< ExportFormat > List
Definition: generator.h:79
utils.h
Okular::Generator::Threaded
Definition: generator.h:202
Okular::PixmapGenerationThread::endGeneration
void endGeneration()
Okular::ExportFormat::standardFormat
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
Definition: generator.cpp:624
QSharedData
Okular::Generator::Generator
Generator(QObject *parent, const QVariantList &args)
Creates a new generator.
Definition: generator.cpp:160
Okular::PixmapRequestPrivate::mHeight
int mHeight
Definition: generator_p.h:81
Okular::Generator::exportFormats
virtual ExportFormat::List exportFormats() const
Returns the list of additional supported export formats.
Definition: generator.cpp:352
Okular::GeneratorPrivate::threadsLock
QMutex * threadsLock()
Definition: generator.cpp:142
Okular::FontInfo
A small class that represents the information of a font.
Definition: fontinfo.h:27
Okular::GeneratorPrivate::GeneratorPrivate
GeneratorPrivate()
Definition: generator.cpp:32
Okular::TextPageGenerationThread::textPage
TextPage * textPage() const
QEventLoop::exec
int exec(QFlags< QEventLoop::ProcessEventsFlag > flags)
Okular::Generator::setFeature
void setFeature(GeneratorFeature feature, bool on=true)
Toggle the feature .
Definition: generator.cpp:405
Okular::PixmapRequest::width
int width() const
Returns the page width of the requested pixmap.
Definition: generator.cpp:491
QObject
Okular::TilesManager
Tiles management.
Definition: tilesmanager_p.h:98
Okular::PixmapRequest::observer
DocumentObserver * observer() const
Returns the observer of the request.
Definition: generator.cpp:481
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:311
Okular::Generator::loadDocumentWithPassword
virtual Document::OpenResult loadDocumentWithPassword(const QString &fileName, QVector< Page * > &pagesVector, const QString &password)
Loads the document with the given fileName and password and fills the pagesVector with the parsed pag...
Definition: generator.cpp:189
Okular::ExportFormat::OpenDocumentText
OpenDocument Text format.
Definition: generator.h:150
Okular::Document::OpenError
Definition: document.h:106
Okular::GeneratorPrivate::pixmapGenerationThread
PixmapGenerationThread * pixmapGenerationThread()
Definition: generator.cpp:57
Okular::Generator::printError
Okular::Generator::PrintError printError() const
Returns the last print error in case print() failed.
Definition: generator.cpp:341
Okular::PixmapRequestPrivate
Definition: generator_p.h:72
Okular::ExportFormat::icon
KIcon icon() const
Returns the icon for GUI representations of the format.
Definition: generator.cpp:614
Okular::PixmapRequestPrivate::mWidth
int mWidth
Definition: generator_p.h:80
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:585
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:507
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:293
QString
QList
textpage.h
Okular::PixmapGenerationThread::image
QImage image() const
Okular::Generator::setDPI
void setDPI(const QSizeF &dpi)
Update DPI of the generator.
Definition: generator.cpp:450
Okular::GeneratorPrivate::pixmapGenerationFinished
void pixmapGenerationFinished()
Definition: generator.cpp:85
Okular::PixmapRequestPrivate::tilesManager
TilesManager * tilesManager() const
Definition: generator.cpp:544
QPixmap
Okular::ExportFormat::mimeType
KMimeType::Ptr mimeType() const
Returns the mime type of the format.
Definition: generator.cpp:609
operator<<
QDebug operator<<(QDebug str, const Okular::PixmapRequest &req)
Definition: generator.cpp:657
Okular::PixmapRequest::asynchronous
bool asynchronous() const
Returns whether the generation should be done synchronous or asynchronous.
Definition: generator.cpp:506
Okular::ExportFormat::StandardExportFormat
StandardExportFormat
Type of standard export format.
Definition: generator.h:146
Okular::Generator::hasFeature
bool hasFeature(GeneratorFeature feature) const
Query for the specified feature.
Definition: generator.cpp:369
QImage
Okular::PixmapRequest::preload
bool preload() const
Returns whether the generation request is for a page that is not important i.e.
Definition: generator.cpp:511
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1086
QDebug
Okular::PixmapRequest::priority
int priority() const
Returns the priority (less it better, 0 is maximum) of the request.
Definition: generator.cpp:501
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:149
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:66
Okular::Generator::print
virtual bool print(QPrinter &printer)
This method is called to print the document to the given printer.
Definition: generator.cpp:336
Okular::Generator::signalTextGenerationDone
void signalTextGenerationDone(Page *page, TextPage *textPage)
This method must be called when a text generation has been finished.
Definition: generator.cpp:386
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:184
document_p.h
QVector
Okular::Generator::None
The page size is not defined in a physical metric.
Definition: generator.h:342
QSizeF
QThread::wait
bool wait(unsigned long time)
Okular::Generator::image
virtual QImage image(PixmapRequest *page)
Returns the image of the page as specified in the passed pixmap request.
Definition: generator.cpp:282
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
QMutexLocker
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:332
Okular::Generator::PrintError
PrintError
Possible print errors.
Definition: generator.h:382
Okular::GeneratorPrivate::mPixmapReady
bool mPixmapReady
Definition: generator_p.h:64
Okular::ExportFormat::HTML
OpenDocument Text format.
Definition: generator.h:151
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:235
Okular::PixmapRequestPrivate::mPriority
int mPriority
Definition: generator_p.h:82
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:526
QString::section
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
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:539
Okular::Generator::walletDataForFile
virtual void walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const
This method is called to know which wallet data should be used for the given file name...
Definition: generator.cpp:362
Okular::PixmapRequest::PixmapRequest
PixmapRequest(DocumentObserver *observer, int pageNumber, int width, int height, int priority, PixmapRequestFeatures features)
Creates a new pixmap request.
Definition: generator.cpp:462
Okular::GeneratorPrivate::textPageGenerationThread
TextPageGenerationThread * textPageGenerationThread()
Definition: generator.cpp:71
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:203
Okular::PixmapRequestPrivate::mForce
bool mForce
Definition: generator_p.h:84
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:269
Okular::ExportFormat::operator==
bool operator==(const ExportFormat &other) const
Definition: generator.cpp:647
Okular::PixmapGenerationThread::boundingBox
NormalizedRect boundingBox() const
Okular::GeneratorPrivate::image
virtual QImage image(PixmapRequest *)
Definition: generator.cpp:154
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Okular::Document::OpenSuccess
Definition: document.h:105
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:298
Okular::Generator::closeDocument
bool closeDocument()
This method is called when the document is closed and not used any longer.
Definition: generator.cpp:199
Okular::PixmapRequest::Asynchronous
Definition: generator.h:584
Okular::Generator::doCloseDocument
virtual bool doCloseDocument()=0
This method is called when the document is closed and not used any longer.
Okular::PagePrivate::tilesManager
TilesManager * tilesManager(const DocumentObserver *observer) const
Get the tiles manager for the tiled .
Definition: page.cpp:1007
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Okular::Generator::document
const Document * document() const
Returns a pointer to the document.
Definition: generator.cpp:395
Okular::TextPageGenerationThread::page
Page * page() const
Okular::GeneratorPrivate
Definition: generator_p.h:35
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1167
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:575
Okular::ExportFormat::isNull
bool isNull() const
Returns whether the export format is null/valid.
Definition: generator.cpp:619
Okular::Generator::loadDocumentFromDataWithPassword
virtual Document::OpenResult loadDocumentFromDataWithPassword(const QByteArray &fileData, QVector< Page * > &pagesVector, const QString &password)
Loads the document from the raw data fileData and password and fills the pagesVector with the parsed ...
Definition: generator.cpp:194
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:521
Okular::PixmapRequest::~PixmapRequest
~PixmapRequest()
Destroys the pixmap request.
Definition: generator.cpp:476
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
Okular::FontInfo::List
QList< FontInfo > List
Definition: fontinfo.h:30
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