• 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
textdocumentgenerator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007 by Tobias Koenig <tokoe@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #include "textdocumentgenerator.h"
11 #include "textdocumentgenerator_p.h"
12 
13 #include <QtCore/QFile>
14 #include <QtCore/QMutex>
15 #include <QtCore/QStack>
16 #include <QtCore/QTextStream>
17 #include <QtCore/QVector>
18 #include <QtGui/QFontDatabase>
19 #include <QtGui/QImage>
20 #include <QtGui/QPainter>
21 #include <QtGui/QPrinter>
22 #if QT_VERSION >= 0x040500
23 #include <QtGui/QTextDocumentWriter>
24 #endif
25 
26 #include "action.h"
27 #include "annotations.h"
28 #include "page.h"
29 #include "textpage.h"
30 
31 #include "document.h"
32 
33 using namespace Okular;
34 
38 TextDocumentConverter::TextDocumentConverter()
39  : QObject( 0 ), d_ptr( new TextDocumentConverterPrivate )
40 {
41 }
42 
43 TextDocumentConverter::~TextDocumentConverter()
44 {
45  delete d_ptr;
46 }
47 
48 DocumentViewport TextDocumentConverter::calculateViewport( QTextDocument *document, const QTextBlock &block )
49 {
50  return TextDocumentUtils::calculateViewport( document, block );
51 }
52 
53 TextDocumentGenerator* TextDocumentConverter::generator() const
54 {
55  return d_ptr->mParent ? d_ptr->mParent->q_func() : 0;
56 }
57 
61 Okular::TextPage* TextDocumentGeneratorPrivate::createTextPage( int pageNumber ) const
62 {
63 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
64  Q_Q( const TextDocumentGenerator );
65 #endif
66 
67  Okular::TextPage *textPage = new Okular::TextPage;
68 
69  int start, end;
70 
71 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
72  q->userMutex()->lock();
73 #endif
74  TextDocumentUtils::calculatePositions( mDocument, pageNumber, start, end );
75 
76  {
77  QTextCursor cursor( mDocument );
78  for ( int i = start; i < end - 1; ++i ) {
79  cursor.setPosition( i );
80  cursor.setPosition( i + 1, QTextCursor::KeepAnchor );
81 
82  QString text = cursor.selectedText();
83  if ( text.length() == 1 ) {
84  QRectF rect;
85  TextDocumentUtils::calculateBoundingRect( mDocument, i, i + 1, rect, pageNumber );
86  if ( pageNumber == -1 )
87  text = "\n";
88 
89  textPage->append( text, new Okular::NormalizedRect( rect.left(), rect.top(), rect.right(), rect.bottom() ) );
90  }
91  }
92  }
93 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
94  q->userMutex()->unlock();
95 #endif
96 
97  return textPage;
98 }
99 
100 void TextDocumentGeneratorPrivate::addAction( Action *action, int cursorBegin, int cursorEnd )
101 {
102  if ( !action )
103  return;
104 
105  LinkPosition position;
106  position.link = action;
107  position.startPosition = cursorBegin;
108  position.endPosition = cursorEnd;
109 
110  mLinkPositions.append( position );
111 }
112 
113 void TextDocumentGeneratorPrivate::addAnnotation( Annotation *annotation, int cursorBegin, int cursorEnd )
114 {
115  if ( !annotation )
116  return;
117 
118  annotation->setFlags( annotation->flags() | Okular::Annotation::External );
119 
120  AnnotationPosition position;
121  position.annotation = annotation;
122  position.startPosition = cursorBegin;
123  position.endPosition = cursorEnd;
124 
125  mAnnotationPositions.append( position );
126 }
127 
128 void TextDocumentGeneratorPrivate::addTitle( int level, const QString &title, const QTextBlock &block )
129 {
130  TitlePosition position;
131  position.level = level;
132  position.title = title;
133  position.block = block;
134 
135  mTitlePositions.append( position );
136 }
137 
138 void TextDocumentGeneratorPrivate::addMetaData( const QString &key, const QString &value, const QString &title )
139 {
140  mDocumentInfo.set( key, value, title );
141 }
142 
143 void TextDocumentGeneratorPrivate::addMetaData( DocumentInfo::Key key, const QString &value )
144 {
145  mDocumentInfo.set( key, value );
146 }
147 
148 void TextDocumentGeneratorPrivate::generateLinkInfos()
149 {
150  for ( int i = 0; i < mLinkPositions.count(); ++i ) {
151  const LinkPosition &linkPosition = mLinkPositions[ i ];
152 
153  LinkInfo info;
154  info.link = linkPosition.link;
155 
156  TextDocumentUtils::calculateBoundingRect( mDocument, linkPosition.startPosition, linkPosition.endPosition,
157  info.boundingRect, info.page );
158 
159  if ( info.page >= 0 )
160  mLinkInfos.append( info );
161  }
162 }
163 
164 void TextDocumentGeneratorPrivate::generateAnnotationInfos()
165 {
166  for ( int i = 0; i < mAnnotationPositions.count(); ++i ) {
167  const AnnotationPosition &annotationPosition = mAnnotationPositions[ i ];
168 
169  AnnotationInfo info;
170  info.annotation = annotationPosition.annotation;
171 
172  TextDocumentUtils::calculateBoundingRect( mDocument, annotationPosition.startPosition, annotationPosition.endPosition,
173  info.boundingRect, info.page );
174 
175  if ( info.page >= 0 )
176  mAnnotationInfos.append( info );
177  }
178 }
179 
180 void TextDocumentGeneratorPrivate::generateTitleInfos()
181 {
182  QStack< QPair<int,QDomNode> > parentNodeStack;
183 
184  QDomNode parentNode = mDocumentSynopsis;
185 
186  parentNodeStack.push( qMakePair( 0, parentNode ) );
187 
188  for ( int i = 0; i < mTitlePositions.count(); ++i ) {
189  const TitlePosition &position = mTitlePositions[ i ];
190 
191  Okular::DocumentViewport viewport = TextDocumentUtils::calculateViewport( mDocument, position.block );
192 
193  QDomElement item = mDocumentSynopsis.createElement( position.title );
194  item.setAttribute( "Viewport", viewport.toString() );
195 
196  int headingLevel = position.level;
197 
198  // we need a parent, which has to be at a higher heading level than this heading level
199  // so we just work through the stack
200  while ( ! parentNodeStack.isEmpty() ) {
201  int parentLevel = parentNodeStack.top().first;
202  if ( parentLevel < headingLevel ) {
203  // this is OK as a parent
204  parentNode = parentNodeStack.top().second;
205  break;
206  } else {
207  // we'll need to be further into the stack
208  parentNodeStack.pop();
209  }
210  }
211  parentNode.appendChild( item );
212  parentNodeStack.push( qMakePair( headingLevel, QDomNode(item) ) );
213  }
214 }
215 
216 void TextDocumentGeneratorPrivate::initializeGenerator()
217 {
218  Q_Q( TextDocumentGenerator );
219 
220  mConverter->d_ptr->mParent = q->d_func();
221 
222  if ( mGeneralSettings ) {
223  mFont = mGeneralSettings->font();
224  }
225 
226  q->setFeature( Generator::TextExtraction );
227  q->setFeature( Generator::PrintNative );
228  q->setFeature( Generator::PrintToFile );
229 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
230  if ( QFontDatabase::supportsThreadedFontRendering() )
231  q->setFeature( Generator::Threaded );
232 #endif
233 
234  QObject::connect( mConverter, SIGNAL(addAction(Action*,int,int)),
235  q, SLOT(addAction(Action*,int,int)) );
236  QObject::connect( mConverter, SIGNAL(addAnnotation(Annotation*,int,int)),
237  q, SLOT(addAnnotation(Annotation*,int,int)) );
238  QObject::connect( mConverter, SIGNAL(addTitle(int,QString,QTextBlock)),
239  q, SLOT(addTitle(int,QString,QTextBlock)) );
240  QObject::connect( mConverter, SIGNAL(addMetaData(QString,QString,QString)),
241  q, SLOT(addMetaData(QString,QString,QString)) );
242  QObject::connect( mConverter, SIGNAL(addMetaData(DocumentInfo::Key,QString)),
243  q, SLOT(addMetaData(DocumentInfo::Key,QString)) );
244 
245  QObject::connect( mConverter, SIGNAL(error(QString,int)),
246  q, SIGNAL(error(QString,int)) );
247  QObject::connect( mConverter, SIGNAL(warning(QString,int)),
248  q, SIGNAL(warning(QString,int)) );
249  QObject::connect( mConverter, SIGNAL(notice(QString,int)),
250  q, SIGNAL(notice(QString,int)) );
251 }
252 
253 TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, const QString& configName, QObject *parent, const QVariantList &args )
254  : Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
255 {
256  Q_D( TextDocumentGenerator );
257  d->mGeneralSettings = new TextDocumentSettings( configName, this );
258 
259  d->initializeGenerator();
260 }
261 
262 TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, QObject *parent, const QVariantList &args )
263  : Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
264 {
265  Q_D( TextDocumentGenerator );
266 
267  d->initializeGenerator();
268 }
269 
270 TextDocumentGenerator::~TextDocumentGenerator()
271 {
272 }
273 
274 bool TextDocumentGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
275 {
276  Q_D( TextDocumentGenerator );
277  d->mDocument = d->mConverter->convert( fileName );
278 
279  if ( !d->mDocument )
280  {
281  // loading failed, cleanup all the stuff eventually gathered from the converter
282  d->mTitlePositions.clear();
283  Q_FOREACH ( const TextDocumentGeneratorPrivate::LinkPosition &linkPos, d->mLinkPositions )
284  {
285  delete linkPos.link;
286  }
287  d->mLinkPositions.clear();
288  Q_FOREACH ( const TextDocumentGeneratorPrivate::AnnotationPosition &annPos, d->mAnnotationPositions )
289  {
290  delete annPos.annotation;
291  }
292  d->mAnnotationPositions.clear();
293 
294  return false;
295  }
296 
297  d->generateTitleInfos();
298  d->generateLinkInfos();
299  d->generateAnnotationInfos();
300 
301  pagesVector.resize( d->mDocument->pageCount() );
302 
303  const QSize size = d->mDocument->pageSize().toSize();
304 
305  QVector< QLinkedList<Okular::ObjectRect*> > objects( d->mDocument->pageCount() );
306  for ( int i = 0; i < d->mLinkInfos.count(); ++i ) {
307  const TextDocumentGeneratorPrivate::LinkInfo &info = d->mLinkInfos.at( i );
308 
309  // in case that the converter report bogus link info data, do not assert here
310  if ( info.page >= objects.count() )
311  continue;
312 
313  const QRectF rect = info.boundingRect;
314  objects[ info.page ].append( new Okular::ObjectRect( rect.left(), rect.top(), rect.right(), rect.bottom(), false,
315  Okular::ObjectRect::Action, info.link ) );
316  }
317 
318  QVector< QLinkedList<Okular::Annotation*> > annots( d->mDocument->pageCount() );
319  for ( int i = 0; i < d->mAnnotationInfos.count(); ++i ) {
320  const TextDocumentGeneratorPrivate::AnnotationInfo &info = d->mAnnotationInfos[ i ];
321  annots[ info.page ].append( info.annotation );
322  }
323 
324  for ( int i = 0; i < d->mDocument->pageCount(); ++i ) {
325  Okular::Page * page = new Okular::Page( i, size.width(), size.height(), Okular::Rotation0 );
326  pagesVector[ i ] = page;
327 
328  if ( !objects.at( i ).isEmpty() ) {
329  page->setObjectRects( objects.at( i ) );
330  }
331  QLinkedList<Okular::Annotation*>::ConstIterator annIt = annots.at( i ).begin(), annEnd = annots.at( i ).end();
332  for ( ; annIt != annEnd; ++annIt ) {
333  page->addAnnotation( *annIt );
334  }
335  }
336 
337  return true;
338 }
339 
340 bool TextDocumentGenerator::doCloseDocument()
341 {
342  Q_D( TextDocumentGenerator );
343  delete d->mDocument;
344  d->mDocument = 0;
345 
346  d->mTitlePositions.clear();
347  d->mLinkPositions.clear();
348  d->mLinkInfos.clear();
349  d->mAnnotationPositions.clear();
350  d->mAnnotationInfos.clear();
351  // do not use clear() for the following two, otherwise they change type
352  d->mDocumentInfo = Okular::DocumentInfo();
353  d->mDocumentSynopsis = Okular::DocumentSynopsis();
354 
355  return true;
356 }
357 
358 bool TextDocumentGenerator::canGeneratePixmap() const
359 {
360  return Generator::canGeneratePixmap();
361 }
362 
363 void TextDocumentGenerator::generatePixmap( Okular::PixmapRequest * request )
364 {
365  Generator::generatePixmap( request );
366 }
367 
368 QImage TextDocumentGeneratorPrivate::image( PixmapRequest * request )
369 {
370  if ( !mDocument )
371  return QImage();
372 
373 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
374  Q_Q( TextDocumentGenerator );
375 #endif
376 
377  QImage image( request->width(), request->height(), QImage::Format_ARGB32 );
378  image.fill( Qt::white );
379 
380  QPainter p;
381  p.begin( &image );
382 
383  qreal width = request->width();
384  qreal height = request->height();
385 
386  const QSize size = mDocument->pageSize().toSize();
387 
388  p.scale( width / (qreal)size.width(), height / (qreal)size.height() );
389 
390  QRect rect;
391  rect = QRect( 0, request->pageNumber() * size.height(), size.width(), size.height() );
392  p.translate( QPoint( 0, request->pageNumber() * size.height() * -1 ) );
393 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
394  q->userMutex()->lock();
395 #endif
396  mDocument->setDefaultFont( mFont );
397  mDocument->drawContents( &p, rect );
398 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
399  q->userMutex()->unlock();
400 #endif
401  p.end();
402 
403  return image;
404 }
405 
406 Okular::TextPage* TextDocumentGenerator::textPage( Okular::Page * page )
407 {
408  Q_D( TextDocumentGenerator );
409  return d->createTextPage( page->number() );
410 }
411 
412 bool TextDocumentGenerator::print( QPrinter& printer )
413 {
414  Q_D( TextDocumentGenerator );
415  if ( !d->mDocument )
416  return false;
417 
418  d->mDocument->print( &printer );
419 
420  return true;
421 }
422 
423 const Okular::DocumentInfo* TextDocumentGenerator::generateDocumentInfo()
424 {
425  Q_D( TextDocumentGenerator );
426  return &d->mDocumentInfo;
427 }
428 
429 const Okular::DocumentSynopsis* TextDocumentGenerator::generateDocumentSynopsis()
430 {
431  Q_D( TextDocumentGenerator );
432  if ( !d->mDocumentSynopsis.hasChildNodes() )
433  return 0;
434  else
435  return &d->mDocumentSynopsis;
436 }
437 
438 QVariant TextDocumentGeneratorPrivate::metaData( const QString &key, const QVariant &option ) const
439 {
440  Q_UNUSED( option )
441  if ( key == "DocumentTitle" )
442  {
443  return mDocumentInfo.get( "title" );
444  }
445  return QVariant();
446 }
447 
448 Okular::ExportFormat::List TextDocumentGenerator::exportFormats( ) const
449 {
450  static Okular::ExportFormat::List formats;
451  if ( formats.isEmpty() ) {
452  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ) );
453  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PDF ) );
454 #if QT_VERSION >= 0x040500
455  if ( QTextDocumentWriter::supportedDocumentFormats().contains( "ODF" ) ) {
456  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::OpenDocumentText ) );
457  }
458  if ( QTextDocumentWriter::supportedDocumentFormats().contains( "HTML" ) ) {
459  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::HTML ) );
460  }
461 #endif
462  }
463 
464  return formats;
465 }
466 
467 bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::ExportFormat &format )
468 {
469  Q_D( TextDocumentGenerator );
470  if ( !d->mDocument )
471  return false;
472 
473  if ( format.mimeType()->name() == QLatin1String( "application/pdf" ) ) {
474  QFile file( fileName );
475  if ( !file.open( QIODevice::WriteOnly ) )
476  return false;
477 
478  QPrinter printer( QPrinter::HighResolution );
479  printer.setOutputFormat( QPrinter::PdfFormat );
480  printer.setOutputFileName( fileName );
481  d->mDocument->print( &printer );
482 
483  return true;
484  } else if ( format.mimeType()->name() == QLatin1String( "text/plain" ) ) {
485  QFile file( fileName );
486  if ( !file.open( QIODevice::WriteOnly ) )
487  return false;
488 
489  QTextStream out( &file );
490  out << d->mDocument->toPlainText();
491 
492  return true;
493 #if QT_VERSION >= 0x040500
494  } else if ( format.mimeType()->name() == QLatin1String( "application/vnd.oasis.opendocument.text" ) ) {
495  QTextDocumentWriter odfWriter( fileName, "odf" );
496 
497  return odfWriter.write( d->mDocument );
498  } else if ( format.mimeType()->name() == QLatin1String( "text/html" ) ) {
499  QTextDocumentWriter odfWriter( fileName, "html" );
500 
501  return odfWriter.write( d->mDocument );
502 #endif
503  }
504  return false;
505 }
506 
507 bool TextDocumentGenerator::reparseConfig()
508 {
509  Q_D( TextDocumentGenerator );
510  const QFont newFont = d->mGeneralSettings->font();
511 
512  if ( newFont != d->mFont ) {
513  d->mFont = newFont;
514  return true;
515  }
516 
517  return false;
518 }
519 
520 void TextDocumentGenerator::addPages( KConfigDialog* /*dlg*/ )
521 {
522  kWarning() << "You forgot to reimplement addPages in your TextDocumentGenerator";
523  return;
524 }
525 
526 TextDocumentSettings* TextDocumentGenerator::generalSettings()
527 {
528  Q_D( TextDocumentGenerator );
529 
530  return d->mGeneralSettings;
531 }
532 
533 #include "textdocumentgenerator.moc"
534 
Okular::TextDocumentSettings::font
QFont font() const
Definition: textdocumentsettings.cpp:73
Okular::TextDocumentGenerator::generateDocumentSynopsis
const Okular::DocumentSynopsis * generateDocumentSynopsis()
Returns the 'table of content' object of the document or 0 if no table of content is available...
Definition: textdocumentgenerator.cpp:429
Okular::TextDocumentUtils::calculateBoundingRect
static void calculateBoundingRect(QTextDocument *document, int startPosition, int endPosition, QRectF &rect, int &page)
Definition: textdocumentgenerator_p.h:26
Okular::Generator::PrintToFile
Whether the Generator supports export to PDF & PS through the Print Dialog.
Definition: generator.h:208
Okular::TextDocumentGeneratorPrivate::createTextPage
Okular::TextPage * createTextPage(int) const
Generic Generator Implementation.
Definition: textdocumentgenerator.cpp:61
Okular::TextDocumentUtils::calculatePositions
static void calculatePositions(QTextDocument *document, int page, int &start, int &end)
Definition: textdocumentgenerator_p.h:69
Okular::TextDocumentGeneratorPrivate::addMetaData
void addMetaData(const QString &key, const QString &value, const QString &title)
Definition: textdocumentgenerator.cpp:138
Okular::TextDocumentGeneratorPrivate::LinkInfo::boundingRect
QRectF boundingRect
Definition: textdocumentgenerator_p.h:173
Okular::PixmapRequest::pageNumber
int pageNumber() const
Returns the page number of the request.
Definition: generator.cpp:449
Okular::TextDocumentGeneratorPrivate::mAnnotationInfos
QList< AnnotationInfo > mAnnotationInfos
Definition: textdocumentgenerator_p.h:192
Okular::TextDocumentGeneratorPrivate::LinkPosition::link
Action * link
Definition: textdocumentgenerator_p.h:166
Okular::TextPage
The TextPage class represents the text of a page by providing.
Definition: textpage.h:90
Okular::TextDocumentGeneratorPrivate::mLinkPositions
QList< LinkPosition > mLinkPositions
Definition: textdocumentgenerator_p.h:168
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::boundingRect
QRectF boundingRect
Definition: textdocumentgenerator_p.h:189
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::ExportFormat::PlainText
Plain text.
Definition: generator.h:147
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::startPosition
int startPosition
Definition: textdocumentgenerator_p.h:180
Okular::Page::number
int number() const
Returns the number of the page in the document.
Definition: page.cpp:160
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::annotation
Annotation * annotation
Definition: textdocumentgenerator_p.h:190
Okular::TextDocumentGeneratorPrivate::addTitle
void addTitle(int level, const QString &title, const QTextBlock &position)
Definition: textdocumentgenerator.cpp:128
Okular::TextDocumentGenerator::doCloseDocument
bool doCloseDocument()
This method is called when the document is closed and not used any longer.
Definition: textdocumentgenerator.cpp:340
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::TextDocumentConverter::TextDocumentConverter
TextDocumentConverter()
Creates a new generic converter.
Definition: textdocumentgenerator.cpp:38
Okular::TextDocumentGeneratorPrivate::mLinkInfos
QList< LinkInfo > mLinkInfos
Definition: textdocumentgenerator_p.h:176
Okular::TextDocumentGeneratorPrivate::addAnnotation
void addAnnotation(Annotation *annotation, int cursorBegin, int cursorEnd)
Definition: textdocumentgenerator.cpp:113
Okular::TextDocumentConverter::calculateViewport
DocumentViewport calculateViewport(QTextDocument *document, const QTextBlock &block)
This method can be used to calculate the viewport for a given text block.
Definition: textdocumentgenerator.cpp:48
textdocumentgenerator_p.h
Okular::TextDocumentGenerator::generalSettings
TextDocumentSettings * generalSettings()
Config skeleton for TextDocumentSettingsWidget.
Definition: textdocumentgenerator.cpp:526
QObject
Okular::Rotation0
Not rotated.
Definition: global.h:46
Okular::TextDocumentGenerator::loadDocument
bool loadDocument(const QString &fileName, QVector< Okular::Page * > &pagesVector)
Definition: textdocumentgenerator.cpp:274
page.h
Okular::TextDocumentConverterPrivate::mParent
TextDocumentGeneratorPrivate * mParent
Definition: textdocumentgenerator_p.h:108
Okular::Annotation::setFlags
void setFlags(int flags)
Sets the flags of the annotation.
Definition: annotations.cpp:587
Okular::DocumentInfo::Key
Key
The list of predefined keys.
Definition: document.h:1079
Okular::PixmapRequest::height
int height() const
Returns the page height of the requested pixmap.
Definition: generator.cpp:459
Okular::TextDocumentConverter::~TextDocumentConverter
~TextDocumentConverter()
Destroys the generic converter.
Definition: textdocumentgenerator.cpp:43
Okular::TextDocumentGeneratorPrivate::metaData
QVariant metaData(const QString &key, const QVariant &option) const
Definition: textdocumentgenerator.cpp:438
Okular::TextDocumentUtils::calculateViewport
static Okular::DocumentViewport calculateViewport(QTextDocument *document, const QTextBlock &block)
Definition: textdocumentgenerator_p.h:82
Okular::ExportFormat::List
QList< ExportFormat > List
Definition: generator.h:78
Okular::Generator::Threaded
Definition: generator.h:201
Okular::TextDocumentGenerator::textPage
Okular::TextPage * textPage(Okular::Page *page)
Returns the text page for the given page.
Definition: textdocumentgenerator.cpp:406
Okular::TextDocumentGeneratorPrivate::LinkInfo::page
int page
Definition: textdocumentgenerator_p.h:172
Okular::TextDocumentGeneratorPrivate::LinkInfo
Definition: textdocumentgenerator_p.h:170
Okular::ExportFormat::standardFormat
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
Definition: generator.cpp:582
Okular::DocumentInfo::get
QString get(const QString &key) const
Returns the value for a given key or an empty string when the key doesn't exist.
Definition: document.cpp:4657
Okular::TextDocumentGenerator::addPages
void addPages(KConfigDialog *dlg)
Does nothing by default. You need to reimplement it in your generator.
Definition: textdocumentgenerator.cpp:520
Okular::Page::setObjectRects
void setObjectRects(const QLinkedList< ObjectRect * > &rects)
Sets the list of object rects of the page.
Definition: page.cpp:564
Okular::ObjectRect
NormalizedRect that contains a reference to an object.
Definition: area.h:337
Okular::PixmapRequest::width
int width() const
Returns the page width of the requested pixmap.
Definition: generator.cpp:454
Okular::TextDocumentGenerator::~TextDocumentGenerator
virtual ~TextDocumentGenerator()
Definition: textdocumentgenerator.cpp:270
Okular::TextDocumentGeneratorPrivate::mDocument
QTextDocument * mDocument
Definition: textdocumentgenerator_p.h:150
action.h
annotations.h
Okular::Annotation::External
Is stored external.
Definition: annotations.h:134
Okular::TextDocumentGeneratorPrivate::mGeneralSettings
TextDocumentSettings * mGeneralSettings
Definition: textdocumentgenerator_p.h:194
Okular::Annotation::flags
int flags() const
Returns the flags of the annotation.
Definition: annotations.cpp:593
Okular::TextDocumentConverter
Definition: textdocumentgenerator.h:29
Okular::ExportFormat::OpenDocumentText
OpenDocument Text format.
Definition: generator.h:149
Okular::TextDocumentGeneratorPrivate
Definition: textdocumentgenerator_p.h:111
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
Okular::TextDocumentGenerator::reparseConfig
bool reparseConfig()
By default checks if the default font has changed or not.
Definition: textdocumentgenerator.cpp:507
document.h
Okular::TextDocumentGeneratorPrivate::mAnnotationPositions
QList< AnnotationPosition > mAnnotationPositions
Definition: textdocumentgenerator_p.h:184
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::annotation
Annotation * annotation
Definition: textdocumentgenerator_p.h:182
textpage.h
Okular::TextDocumentGeneratorPrivate::LinkPosition::endPosition
int endPosition
Definition: textdocumentgenerator_p.h:165
Okular::TextDocumentGeneratorPrivate::generateTitleInfos
void generateTitleInfos()
Definition: textdocumentgenerator.cpp:180
Okular::TextDocumentGeneratorPrivate::AnnotationPosition
Definition: textdocumentgenerator_p.h:178
Okular::ExportFormat::mimeType
KMimeType::Ptr mimeType() const
Returns the mime type of the format.
Definition: generator.cpp:567
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::page
int page
Definition: textdocumentgenerator_p.h:188
Okular::TextDocumentGeneratorPrivate::mDocumentInfo
Okular::DocumentInfo mDocumentInfo
Definition: textdocumentgenerator_p.h:151
Okular::TextDocumentGeneratorPrivate::LinkInfo::link
Action * link
Definition: textdocumentgenerator_p.h:174
Okular::ObjectRect::Action
An action.
Definition: area.h:345
Okular::TextDocumentGeneratorPrivate::TitlePosition::level
int level
Definition: textdocumentgenerator_p.h:156
Okular::TextDocumentGeneratorPrivate::mConverter
TextDocumentConverter * mConverter
Definition: textdocumentgenerator_p.h:148
Okular::Generator::PrintNative
Whether the Generator supports native cross-platform printing (QPainter-based).
Definition: generator.h:206
Okular::Action
Encapsulates data that describes an action.
Definition: action.h:43
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1073
Okular::TextDocumentGenerator
QTextDocument-based Generator.
Definition: textdocumentgenerator.h:136
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:148
Okular::TextDocumentGenerator::TextDocumentGenerator
TextDocumentGenerator(TextDocumentConverter *converter, const QString &configName, QObject *parent, const QVariantList &args)
Creates a new generator that uses the specified converter.
Definition: textdocumentgenerator.cpp:253
Okular::TextDocumentConverterPrivate
Definition: textdocumentgenerator_p.h:100
Okular::TextDocumentGenerator::generateDocumentInfo
const Okular::DocumentInfo * generateDocumentInfo()
Returns the general information object of the document or 0 if no information are available...
Definition: textdocumentgenerator.cpp:423
Okular::TextDocumentGeneratorPrivate::addAction
void addAction(Action *action, int cursorBegin, int cursorEnd)
Definition: textdocumentgenerator.cpp:100
Okular::DocumentInfo::set
void set(const QString &key, const QString &value, const QString &title=QString())
Sets a value for a special key.
Definition: document.cpp:4628
Okular::TextDocumentGeneratorPrivate::mTitlePositions
QList< TitlePosition > mTitlePositions
Definition: textdocumentgenerator_p.h:160
Okular::TextDocumentGeneratorPrivate::generateLinkInfos
void generateLinkInfos()
Definition: textdocumentgenerator.cpp:148
textdocumentgenerator.h
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:75
Okular::Annotation
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:90
Okular::TextDocumentGeneratorPrivate::initializeGenerator
void initializeGenerator()
Definition: textdocumentgenerator.cpp:216
Okular::TextDocumentGeneratorPrivate::generateAnnotationInfos
void generateAnnotationInfos()
Definition: textdocumentgenerator.cpp:164
Okular::ExportFormat::HTML
OpenDocument Text format.
Definition: generator.h:150
Okular::TextDocumentGeneratorPrivate::LinkPosition::startPosition
int startPosition
Definition: textdocumentgenerator_p.h:164
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::TextDocumentGeneratorPrivate::TitlePosition::title
QString title
Definition: textdocumentgenerator_p.h:157
Okular::TextDocumentGeneratorPrivate::AnnotationInfo
Definition: textdocumentgenerator_p.h:186
Okular::TextDocumentGeneratorPrivate::TitlePosition
Definition: textdocumentgenerator_p.h:154
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::endPosition
int endPosition
Definition: textdocumentgenerator_p.h:181
Okular::TextDocumentGenerator::print
bool print(QPrinter &printer)
This method is called to print the document to the given printer.
Definition: textdocumentgenerator.cpp:412
Okular::DocumentViewport
A view on the document.
Definition: document.h:1003
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:202
Okular::TextDocumentGenerator::exportTo
bool exportTo(const QString &fileName, const Okular::ExportFormat &format)
This method is called to export the document in the given format and save it under the given fileName...
Definition: textdocumentgenerator.cpp:467
Okular::TextDocumentGeneratorPrivate::mFont
QFont mFont
Definition: textdocumentgenerator_p.h:196
Okular::Page::addAnnotation
void addAnnotation(Annotation *annotation)
Adds a new annotation to the page.
Definition: page.cpp:641
Okular::DocumentViewport::toString
QString toString() const
Returns the viewport as xml description.
Definition: document.cpp:4560
Okular::TextDocumentGeneratorPrivate::TitlePosition::block
QTextBlock block
Definition: textdocumentgenerator_p.h:158
Okular::TextDocumentGeneratorPrivate::mDocumentSynopsis
Okular::DocumentSynopsis mDocumentSynopsis
Definition: textdocumentgenerator_p.h:152
Okular::TextDocumentSettings
TextDocumentSettings.
Definition: textdocumentsettings.h:106
Okular::TextDocumentGeneratorPrivate::LinkPosition
Definition: textdocumentgenerator_p.h:162
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1154
Okular::TextPage::append
void append(const QString &text, NormalizedRect *area)
Appends the given text with the given area as new TextEntity to the page.
Definition: textpage.cpp:239
Okular::TextDocumentGenerator::exportFormats
Okular::ExportFormat::List exportFormats() const
Returns the list of additional supported export formats.
Definition: textdocumentgenerator.cpp:448
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:522
Okular::TextDocumentGenerator::generatePixmap
void generatePixmap(Okular::PixmapRequest *request)
This method can be called to trigger the generation of a new pixmap as described by request...
Definition: textdocumentgenerator.cpp:363
Okular::TextDocumentConverter::generator
TextDocumentGenerator * generator() const
Returns the generator that owns this converter.
Definition: textdocumentgenerator.cpp:53
Okular::Generator
[Abstract Class] The information generator.
Definition: generator.h:185
Okular::TextDocumentGeneratorPrivate::image
QImage image(PixmapRequest *)
Definition: textdocumentgenerator.cpp:368
Okular::TextDocumentGenerator::canGeneratePixmap
bool canGeneratePixmap() const
This method returns whether the generator is ready to handle a new pixmap request.
Definition: textdocumentgenerator.cpp:358
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:03 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