• 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
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 QTextDocument *TextDocumentConverter::convert( const QString & )
49 {
50  return 0;
51 }
52 
53 Document::OpenResult TextDocumentConverter::convertWithPassword( const QString &fileName, const QString & )
54 {
55  QTextDocument *doc = convert( fileName );
56  setDocument( doc );
57  return doc != 0 ? Document::OpenSuccess : Document::OpenError;
58 }
59 
60 QTextDocument *TextDocumentConverter::document()
61 {
62  return d_ptr->mDocument;
63 }
64 
65 void TextDocumentConverter::setDocument( QTextDocument *document )
66 {
67  d_ptr->mDocument = document;
68 }
69 
70 DocumentViewport TextDocumentConverter::calculateViewport( QTextDocument *document, const QTextBlock &block )
71 {
72  return TextDocumentUtils::calculateViewport( document, block );
73 }
74 
75 TextDocumentGenerator* TextDocumentConverter::generator() const
76 {
77  return d_ptr->mParent ? d_ptr->mParent->q_func() : 0;
78 }
79 
83 Okular::TextPage* TextDocumentGeneratorPrivate::createTextPage( int pageNumber ) const
84 {
85 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
86  Q_Q( const TextDocumentGenerator );
87 #endif
88 
89  Okular::TextPage *textPage = new Okular::TextPage;
90 
91  int start, end;
92 
93 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
94  q->userMutex()->lock();
95 #endif
96  TextDocumentUtils::calculatePositions( mDocument, pageNumber, start, end );
97 
98  {
99  QTextCursor cursor( mDocument );
100  for ( int i = start; i < end - 1; ++i ) {
101  cursor.setPosition( i );
102  cursor.setPosition( i + 1, QTextCursor::KeepAnchor );
103 
104  QString text = cursor.selectedText();
105  if ( text.length() == 1 ) {
106  QRectF rect;
107  TextDocumentUtils::calculateBoundingRect( mDocument, i, i + 1, rect, pageNumber );
108  if ( pageNumber == -1 )
109  text = "\n";
110 
111  textPage->append( text, new Okular::NormalizedRect( rect.left(), rect.top(), rect.right(), rect.bottom() ) );
112  }
113  }
114  }
115 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
116  q->userMutex()->unlock();
117 #endif
118 
119  return textPage;
120 }
121 
122 void TextDocumentGeneratorPrivate::addAction( Action *action, int cursorBegin, int cursorEnd )
123 {
124  if ( !action )
125  return;
126 
127  LinkPosition position;
128  position.link = action;
129  position.startPosition = cursorBegin;
130  position.endPosition = cursorEnd;
131 
132  mLinkPositions.append( position );
133 }
134 
135 void TextDocumentGeneratorPrivate::addAnnotation( Annotation *annotation, int cursorBegin, int cursorEnd )
136 {
137  if ( !annotation )
138  return;
139 
140  annotation->setFlags( annotation->flags() | Okular::Annotation::External );
141 
142  AnnotationPosition position;
143  position.annotation = annotation;
144  position.startPosition = cursorBegin;
145  position.endPosition = cursorEnd;
146 
147  mAnnotationPositions.append( position );
148 }
149 
150 void TextDocumentGeneratorPrivate::addTitle( int level, const QString &title, const QTextBlock &block )
151 {
152  TitlePosition position;
153  position.level = level;
154  position.title = title;
155  position.block = block;
156 
157  mTitlePositions.append( position );
158 }
159 
160 void TextDocumentGeneratorPrivate::addMetaData( const QString &key, const QString &value, const QString &title )
161 {
162  mDocumentInfo.set( key, value, title );
163 }
164 
165 void TextDocumentGeneratorPrivate::addMetaData( DocumentInfo::Key key, const QString &value )
166 {
167  mDocumentInfo.set( key, value );
168 }
169 
170 void TextDocumentGeneratorPrivate::generateLinkInfos()
171 {
172  for ( int i = 0; i < mLinkPositions.count(); ++i ) {
173  const LinkPosition &linkPosition = mLinkPositions[ i ];
174 
175  LinkInfo info;
176  info.link = linkPosition.link;
177 
178  TextDocumentUtils::calculateBoundingRect( mDocument, linkPosition.startPosition, linkPosition.endPosition,
179  info.boundingRect, info.page );
180 
181  if ( info.page >= 0 )
182  mLinkInfos.append( info );
183  }
184 }
185 
186 void TextDocumentGeneratorPrivate::generateAnnotationInfos()
187 {
188  for ( int i = 0; i < mAnnotationPositions.count(); ++i ) {
189  const AnnotationPosition &annotationPosition = mAnnotationPositions[ i ];
190 
191  AnnotationInfo info;
192  info.annotation = annotationPosition.annotation;
193 
194  TextDocumentUtils::calculateBoundingRect( mDocument, annotationPosition.startPosition, annotationPosition.endPosition,
195  info.boundingRect, info.page );
196 
197  if ( info.page >= 0 )
198  mAnnotationInfos.append( info );
199  }
200 }
201 
202 void TextDocumentGeneratorPrivate::generateTitleInfos()
203 {
204  QStack< QPair<int,QDomNode> > parentNodeStack;
205 
206  QDomNode parentNode = mDocumentSynopsis;
207 
208  parentNodeStack.push( qMakePair( 0, parentNode ) );
209 
210  for ( int i = 0; i < mTitlePositions.count(); ++i ) {
211  const TitlePosition &position = mTitlePositions[ i ];
212 
213  Okular::DocumentViewport viewport = TextDocumentUtils::calculateViewport( mDocument, position.block );
214 
215  QDomElement item = mDocumentSynopsis.createElement( position.title );
216  item.setAttribute( "Viewport", viewport.toString() );
217 
218  int headingLevel = position.level;
219 
220  // we need a parent, which has to be at a higher heading level than this heading level
221  // so we just work through the stack
222  while ( ! parentNodeStack.isEmpty() ) {
223  int parentLevel = parentNodeStack.top().first;
224  if ( parentLevel < headingLevel ) {
225  // this is OK as a parent
226  parentNode = parentNodeStack.top().second;
227  break;
228  } else {
229  // we'll need to be further into the stack
230  parentNodeStack.pop();
231  }
232  }
233  parentNode.appendChild( item );
234  parentNodeStack.push( qMakePair( headingLevel, QDomNode(item) ) );
235  }
236 }
237 
238 void TextDocumentGeneratorPrivate::initializeGenerator()
239 {
240  Q_Q( TextDocumentGenerator );
241 
242  mConverter->d_ptr->mParent = q->d_func();
243 
244  if ( mGeneralSettings ) {
245  mFont = mGeneralSettings->font();
246  }
247 
248  q->setFeature( Generator::TextExtraction );
249  q->setFeature( Generator::PrintNative );
250  q->setFeature( Generator::PrintToFile );
251 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
252  if ( QFontDatabase::supportsThreadedFontRendering() )
253  q->setFeature( Generator::Threaded );
254 #endif
255 
256  QObject::connect( mConverter, SIGNAL(addAction(Action*,int,int)),
257  q, SLOT(addAction(Action*,int,int)) );
258  QObject::connect( mConverter, SIGNAL(addAnnotation(Annotation*,int,int)),
259  q, SLOT(addAnnotation(Annotation*,int,int)) );
260  QObject::connect( mConverter, SIGNAL(addTitle(int,QString,QTextBlock)),
261  q, SLOT(addTitle(int,QString,QTextBlock)) );
262  QObject::connect( mConverter, SIGNAL(addMetaData(QString,QString,QString)),
263  q, SLOT(addMetaData(QString,QString,QString)) );
264  QObject::connect( mConverter, SIGNAL(addMetaData(DocumentInfo::Key,QString)),
265  q, SLOT(addMetaData(DocumentInfo::Key,QString)) );
266 
267  QObject::connect( mConverter, SIGNAL(error(QString,int)),
268  q, SIGNAL(error(QString,int)) );
269  QObject::connect( mConverter, SIGNAL(warning(QString,int)),
270  q, SIGNAL(warning(QString,int)) );
271  QObject::connect( mConverter, SIGNAL(notice(QString,int)),
272  q, SIGNAL(notice(QString,int)) );
273 }
274 
275 TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, const QString& configName, QObject *parent, const QVariantList &args )
276  : Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
277 {
278  Q_D( TextDocumentGenerator );
279  d->mGeneralSettings = new TextDocumentSettings( configName, this );
280 
281  d->initializeGenerator();
282 }
283 
284 TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, QObject *parent, const QVariantList &args )
285  : Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
286 {
287  Q_D( TextDocumentGenerator );
288 
289  d->initializeGenerator();
290 }
291 
292 TextDocumentGenerator::~TextDocumentGenerator()
293 {
294 }
295 
296 Document::OpenResult TextDocumentGenerator::loadDocumentWithPassword( const QString & fileName, QVector<Okular::Page*> & pagesVector, const QString &password )
297 {
298  Q_D( TextDocumentGenerator );
299  const Document::OpenResult openResult = d->mConverter->convertWithPassword( fileName, password );
300 
301  if ( openResult != Document::OpenSuccess )
302  {
303  d->mDocument = 0;
304 
305  // loading failed, cleanup all the stuff eventually gathered from the converter
306  d->mTitlePositions.clear();
307  Q_FOREACH ( const TextDocumentGeneratorPrivate::LinkPosition &linkPos, d->mLinkPositions )
308  {
309  delete linkPos.link;
310  }
311  d->mLinkPositions.clear();
312  Q_FOREACH ( const TextDocumentGeneratorPrivate::AnnotationPosition &annPos, d->mAnnotationPositions )
313  {
314  delete annPos.annotation;
315  }
316  d->mAnnotationPositions.clear();
317 
318  return openResult;
319  }
320  d->mDocument = d->mConverter->document();
321 
322  d->generateTitleInfos();
323  d->generateLinkInfos();
324  d->generateAnnotationInfos();
325 
326  pagesVector.resize( d->mDocument->pageCount() );
327 
328  const QSize size = d->mDocument->pageSize().toSize();
329 
330  QVector< QLinkedList<Okular::ObjectRect*> > objects( d->mDocument->pageCount() );
331  for ( int i = 0; i < d->mLinkInfos.count(); ++i ) {
332  const TextDocumentGeneratorPrivate::LinkInfo &info = d->mLinkInfos.at( i );
333 
334  // in case that the converter report bogus link info data, do not assert here
335  if ( info.page >= objects.count() )
336  continue;
337 
338  const QRectF rect = info.boundingRect;
339  objects[ info.page ].append( new Okular::ObjectRect( rect.left(), rect.top(), rect.right(), rect.bottom(), false,
340  Okular::ObjectRect::Action, info.link ) );
341  }
342 
343  QVector< QLinkedList<Okular::Annotation*> > annots( d->mDocument->pageCount() );
344  for ( int i = 0; i < d->mAnnotationInfos.count(); ++i ) {
345  const TextDocumentGeneratorPrivate::AnnotationInfo &info = d->mAnnotationInfos[ i ];
346  annots[ info.page ].append( info.annotation );
347  }
348 
349  for ( int i = 0; i < d->mDocument->pageCount(); ++i ) {
350  Okular::Page * page = new Okular::Page( i, size.width(), size.height(), Okular::Rotation0 );
351  pagesVector[ i ] = page;
352 
353  if ( !objects.at( i ).isEmpty() ) {
354  page->setObjectRects( objects.at( i ) );
355  }
356  QLinkedList<Okular::Annotation*>::ConstIterator annIt = annots.at( i ).begin(), annEnd = annots.at( i ).end();
357  for ( ; annIt != annEnd; ++annIt ) {
358  page->addAnnotation( *annIt );
359  }
360  }
361 
362  return openResult;
363 }
364 
365 bool TextDocumentGenerator::doCloseDocument()
366 {
367  Q_D( TextDocumentGenerator );
368  delete d->mDocument;
369  d->mDocument = 0;
370 
371  d->mTitlePositions.clear();
372  d->mLinkPositions.clear();
373  d->mLinkInfos.clear();
374  d->mAnnotationPositions.clear();
375  d->mAnnotationInfos.clear();
376  // do not use clear() for the following two, otherwise they change type
377  d->mDocumentInfo = Okular::DocumentInfo();
378  d->mDocumentSynopsis = Okular::DocumentSynopsis();
379 
380  return true;
381 }
382 
383 bool TextDocumentGenerator::canGeneratePixmap() const
384 {
385  return Generator::canGeneratePixmap();
386 }
387 
388 void TextDocumentGenerator::generatePixmap( Okular::PixmapRequest * request )
389 {
390  Generator::generatePixmap( request );
391 }
392 
393 QImage TextDocumentGeneratorPrivate::image( PixmapRequest * request )
394 {
395  if ( !mDocument )
396  return QImage();
397 
398 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
399  Q_Q( TextDocumentGenerator );
400 #endif
401 
402  QImage image( request->width(), request->height(), QImage::Format_ARGB32 );
403  image.fill( Qt::white );
404 
405  QPainter p;
406  p.begin( &image );
407 
408  qreal width = request->width();
409  qreal height = request->height();
410 
411  const QSize size = mDocument->pageSize().toSize();
412 
413  p.scale( width / (qreal)size.width(), height / (qreal)size.height() );
414 
415  QRect rect;
416  rect = QRect( 0, request->pageNumber() * size.height(), size.width(), size.height() );
417  p.translate( QPoint( 0, request->pageNumber() * size.height() * -1 ) );
418  p.setClipRect( rect );
419 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
420  q->userMutex()->lock();
421 #endif
422  QAbstractTextDocumentLayout::PaintContext context;
423  context.palette.setColor( QPalette::Text, Qt::black );
424 // FIXME Fix Qt, this doesn't work, we have horrible hacks
425 // in the generators that return html, remove that code
426 // if Qt ever gets fixed
427 // context.palette.setColor( QPalette::Link, Qt::blue );
428  context.clip = rect;
429  mDocument->setDefaultFont( mFont );
430  mDocument->documentLayout()->draw( &p, context );
431 #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
432  q->userMutex()->unlock();
433 #endif
434  p.end();
435 
436  return image;
437 }
438 
439 Okular::TextPage* TextDocumentGenerator::textPage( Okular::Page * page )
440 {
441  Q_D( TextDocumentGenerator );
442  return d->createTextPage( page->number() );
443 }
444 
445 bool TextDocumentGenerator::print( QPrinter& printer )
446 {
447  Q_D( TextDocumentGenerator );
448  if ( !d->mDocument )
449  return false;
450 
451  d->mDocument->print( &printer );
452 
453  return true;
454 }
455 
456 const Okular::DocumentInfo* TextDocumentGenerator::generateDocumentInfo()
457 {
458  Q_D( TextDocumentGenerator );
459  return &d->mDocumentInfo;
460 }
461 
462 const Okular::DocumentSynopsis* TextDocumentGenerator::generateDocumentSynopsis()
463 {
464  Q_D( TextDocumentGenerator );
465  if ( !d->mDocumentSynopsis.hasChildNodes() )
466  return 0;
467  else
468  return &d->mDocumentSynopsis;
469 }
470 
471 QVariant TextDocumentGeneratorPrivate::metaData( const QString &key, const QVariant &option ) const
472 {
473  Q_UNUSED( option )
474  if ( key == "DocumentTitle" )
475  {
476  return mDocumentInfo.get( "title" );
477  }
478  return QVariant();
479 }
480 
481 Okular::ExportFormat::List TextDocumentGenerator::exportFormats( ) const
482 {
483  static Okular::ExportFormat::List formats;
484  if ( formats.isEmpty() ) {
485  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ) );
486  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PDF ) );
487 #if QT_VERSION >= 0x040500
488  if ( QTextDocumentWriter::supportedDocumentFormats().contains( "ODF" ) ) {
489  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::OpenDocumentText ) );
490  }
491  if ( QTextDocumentWriter::supportedDocumentFormats().contains( "HTML" ) ) {
492  formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::HTML ) );
493  }
494 #endif
495  }
496 
497  return formats;
498 }
499 
500 bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::ExportFormat &format )
501 {
502  Q_D( TextDocumentGenerator );
503  if ( !d->mDocument )
504  return false;
505 
506  if ( format.mimeType()->name() == QLatin1String( "application/pdf" ) ) {
507  QFile file( fileName );
508  if ( !file.open( QIODevice::WriteOnly ) )
509  return false;
510 
511  QPrinter printer( QPrinter::HighResolution );
512  printer.setOutputFormat( QPrinter::PdfFormat );
513  printer.setOutputFileName( fileName );
514  d->mDocument->print( &printer );
515 
516  return true;
517  } else if ( format.mimeType()->name() == QLatin1String( "text/plain" ) ) {
518  QFile file( fileName );
519  if ( !file.open( QIODevice::WriteOnly ) )
520  return false;
521 
522  QTextStream out( &file );
523  out << d->mDocument->toPlainText();
524 
525  return true;
526 #if QT_VERSION >= 0x040500
527  } else if ( format.mimeType()->name() == QLatin1String( "application/vnd.oasis.opendocument.text" ) ) {
528  QTextDocumentWriter odfWriter( fileName, "odf" );
529 
530  return odfWriter.write( d->mDocument );
531  } else if ( format.mimeType()->name() == QLatin1String( "text/html" ) ) {
532  QTextDocumentWriter odfWriter( fileName, "html" );
533 
534  return odfWriter.write( d->mDocument );
535 #endif
536  }
537  return false;
538 }
539 
540 bool TextDocumentGenerator::reparseConfig()
541 {
542  Q_D( TextDocumentGenerator );
543  const QFont newFont = d->mGeneralSettings->font();
544 
545  if ( newFont != d->mFont ) {
546  d->mFont = newFont;
547  return true;
548  }
549 
550  return false;
551 }
552 
553 void TextDocumentGenerator::addPages( KConfigDialog* /*dlg*/ )
554 {
555  kWarning() << "You forgot to reimplement addPages in your TextDocumentGenerator";
556  return;
557 }
558 
559 TextDocumentSettings* TextDocumentGenerator::generalSettings()
560 {
561  Q_D( TextDocumentGenerator );
562 
563  return d->mGeneralSettings;
564 }
565 
566 #include "textdocumentgenerator.moc"
567 
Okular::TextDocumentSettings::font
QFont font() const
Definition: textdocumentsettings.cpp:73
Okular::TextDocumentConverter::convertWithPassword
virtual Document::OpenResult convertWithPassword(const QString &fileName, const QString &password)
Returns the generated QTextDocument object.
Definition: textdocumentgenerator.cpp:53
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:462
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:209
Okular::TextDocumentGeneratorPrivate::createTextPage
Okular::TextPage * createTextPage(int) const
Generic Generator Implementation.
Definition: textdocumentgenerator.cpp:83
Okular::TextDocumentUtils::calculatePositions
static void calculatePositions(QTextDocument *document, int page, int &start, int &end)
Definition: textdocumentgenerator_p.h:69
QTextDocument::pageSize
pageSize
Okular::TextDocumentGeneratorPrivate::addMetaData
void addMetaData(const QString &key, const QString &value, const QString &title)
Definition: textdocumentgenerator.cpp:160
Okular::TextDocumentGeneratorPrivate::LinkInfo::boundingRect
QRectF boundingRect
Definition: textdocumentgenerator_p.h:174
Okular::PixmapRequest::pageNumber
int pageNumber() const
Returns the page number of the request.
Definition: generator.cpp:486
QTextCursor
QSize::width
int width() const
QPainter::end
bool end()
Okular::TextDocumentGeneratorPrivate::mAnnotationInfos
QList< AnnotationInfo > mAnnotationInfos
Definition: textdocumentgenerator_p.h:193
Okular::TextDocumentGeneratorPrivate::LinkPosition::link
Action * link
Definition: textdocumentgenerator_p.h:167
Okular::TextPage
The TextPage class represents the text of a page by providing.
Definition: textpage.h:90
QStack::pop
T pop()
Okular::TextDocumentGeneratorPrivate::mLinkPositions
QList< LinkPosition > mLinkPositions
Definition: textdocumentgenerator_p.h:169
Okular::TextDocumentConverterPrivate::mDocument
QTextDocument * mDocument
Definition: textdocumentgenerator_p.h:109
QDomNode::appendChild
QDomNode appendChild(const QDomNode &newChild)
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::boundingRect
QRectF boundingRect
Definition: textdocumentgenerator_p.h:190
Okular::TextDocumentConverter::convert
virtual QTextDocument * convert(const QString &fileName)
Returns the generated QTextDocument object.
Definition: textdocumentgenerator.cpp:48
QPrinter::setOutputFileName
void setOutputFileName(const QString &fileName)
QPrinter
QLinkedList::begin
iterator begin()
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
QFont
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:148
QStack::push
void push(const T &t)
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::startPosition
int startPosition
Definition: textdocumentgenerator_p.h:181
QPainter::scale
void scale(qreal sx, qreal sy)
Okular::Page::number
int number() const
Returns the number of the page in the document.
Definition: page.cpp:144
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::annotation
Annotation * annotation
Definition: textdocumentgenerator_p.h:191
QTextCursor::selectedText
QString selectedText() const
Okular::TextDocumentGeneratorPrivate::addTitle
void addTitle(int level, const QString &title, const QTextBlock &position)
Definition: textdocumentgenerator.cpp:150
Okular::TextDocumentGenerator::doCloseDocument
bool doCloseDocument()
This method is called when the document is closed and not used any longer.
Definition: textdocumentgenerator.cpp:365
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:177
Okular::TextDocumentGeneratorPrivate::addAnnotation
void addAnnotation(Annotation *annotation, int cursorBegin, int cursorEnd)
Definition: textdocumentgenerator.cpp:135
QRectF::top
qreal top() const
QPoint
QDomNode
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:70
textdocumentgenerator_p.h
Okular::TextDocumentGenerator::generalSettings
TextDocumentSettings * generalSettings()
Config skeleton for TextDocumentSettingsWidget.
Definition: textdocumentgenerator.cpp:559
Okular::Rotation0
Not rotated.
Definition: global.h:46
QRectF::left
qreal left() const
QFile
page.h
QTextStream
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:1092
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::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:471
Okular::TextDocumentUtils::calculateViewport
static Okular::DocumentViewport calculateViewport(QTextDocument *document, const QTextBlock &block)
Definition: textdocumentgenerator_p.h:82
Okular::Generator::Threaded
Definition: generator.h:202
Okular::TextDocumentGenerator::textPage
Okular::TextPage * textPage(Okular::Page *page)
Returns the text page for the given page.
Definition: textdocumentgenerator.cpp:439
QRectF::bottom
qreal bottom() const
Okular::TextDocumentGeneratorPrivate::LinkInfo::page
int page
Definition: textdocumentgenerator_p.h:173
QLinkedList
QTextDocumentWriter
QRect
Okular::TextDocumentGeneratorPrivate::LinkInfo
Definition: textdocumentgenerator_p.h:171
Okular::ExportFormat::standardFormat
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
Definition: generator.cpp:624
QList::append
void append(const T &value)
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:4680
QVector::resize
void resize(int size)
Okular::TextDocumentGenerator::addPages
void addPages(KConfigDialog *dlg)
Does nothing by default. You need to reimplement it in your generator.
Definition: textdocumentgenerator.cpp:553
Okular::Page::setObjectRects
void setObjectRects(const QLinkedList< ObjectRect * > &rects)
Sets the list of object rects of the page.
Definition: page.cpp:554
QImage::fill
void fill(uint pixelValue)
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:491
QObject
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Okular::TextDocumentGenerator::~TextDocumentGenerator
virtual ~TextDocumentGenerator()
Definition: textdocumentgenerator.cpp:292
Okular::TextDocumentGeneratorPrivate::mDocument
QTextDocument * mDocument
Definition: textdocumentgenerator_p.h:151
action.h
annotations.h
QList::isEmpty
bool isEmpty() const
QPainter
Okular::Annotation::External
Is stored external.
Definition: annotations.h:134
Okular::TextDocumentGeneratorPrivate::mGeneralSettings
TextDocumentSettings * mGeneralSettings
Definition: textdocumentgenerator_p.h:195
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:150
Okular::Document::OpenError
Definition: document.h:106
Okular::TextDocumentGeneratorPrivate
Definition: textdocumentgenerator_p.h:112
QTextDocument::documentLayout
QAbstractTextDocumentLayout * documentLayout() const
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:540
document.h
Okular::TextDocumentGeneratorPrivate::mAnnotationPositions
QList< AnnotationPosition > mAnnotationPositions
Definition: textdocumentgenerator_p.h:185
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::annotation
Annotation * annotation
Definition: textdocumentgenerator_p.h:183
QString
QList
textpage.h
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QAbstractTextDocumentLayout::PaintContext
Okular::TextDocumentConverter::document
QTextDocument * document()
Returns the generated QTextDocument object.
Definition: textdocumentgenerator.cpp:60
Okular::TextDocumentGeneratorPrivate::LinkPosition::endPosition
int endPosition
Definition: textdocumentgenerator_p.h:166
Okular::TextDocumentGeneratorPrivate::generateTitleInfos
void generateTitleInfos()
Definition: textdocumentgenerator.cpp:202
Okular::TextDocumentGeneratorPrivate::AnnotationPosition
Definition: textdocumentgenerator_p.h:179
Okular::ExportFormat::mimeType
KMimeType::Ptr mimeType() const
Returns the mime type of the format.
Definition: generator.cpp:609
Okular::TextDocumentGeneratorPrivate::AnnotationInfo::page
int page
Definition: textdocumentgenerator_p.h:189
Okular::TextDocumentGeneratorPrivate::mDocumentInfo
Okular::DocumentInfo mDocumentInfo
Definition: textdocumentgenerator_p.h:152
Okular::TextDocumentGeneratorPrivate::LinkInfo::link
Action * link
Definition: textdocumentgenerator_p.h:175
QTextDocument::setDefaultFont
void setDefaultFont(const QFont &font)
Okular::ObjectRect::Action
An action.
Definition: area.h:345
QRectF::right
qreal right() const
Okular::TextDocumentGeneratorPrivate::TitlePosition::level
int level
Definition: textdocumentgenerator_p.h:157
QSize
Okular::TextDocumentGeneratorPrivate::mConverter
TextDocumentConverter * mConverter
Definition: textdocumentgenerator_p.h:149
Okular::Generator::PrintNative
Whether the Generator supports native cross-platform printing (QPainter-based).
Definition: generator.h:207
QImage
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:1086
Okular::TextDocumentGenerator
QTextDocument-based Generator.
Definition: textdocumentgenerator.h:153
Okular::ExportFormat::PDF
PDF, aka Portable Document Format.
Definition: generator.h:149
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:275
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:456
Okular::TextDocumentGeneratorPrivate::addAction
void addAction(Action *action, int cursorBegin, int cursorEnd)
Definition: textdocumentgenerator.cpp:122
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:4651
QPainter::setClipRect
void setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)
Okular::TextDocumentGeneratorPrivate::mTitlePositions
QList< TitlePosition > mTitlePositions
Definition: textdocumentgenerator_p.h:161
QVector< Okular::Page * >
Okular::TextDocumentGeneratorPrivate::generateLinkInfos
void generateLinkInfos()
Definition: textdocumentgenerator.cpp:170
textdocumentgenerator.h
Okular::TextDocumentConverter::setDocument
void setDocument(QTextDocument *document)
Sets the converted QTextDocument object.
Definition: textdocumentgenerator.cpp:65
QLatin1String
QTextBlock
QTextDocument
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
QVector::isEmpty
bool isEmpty() const
QRectF
Okular::Annotation
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:90
Okular::TextDocumentGeneratorPrivate::initializeGenerator
void initializeGenerator()
Definition: textdocumentgenerator.cpp:238
Okular::TextDocumentGeneratorPrivate::generateAnnotationInfos
void generateAnnotationInfos()
Definition: textdocumentgenerator.cpp:186
QTextDocumentWriter::write
bool write(const QTextDocument *document)
Okular::ExportFormat::HTML
OpenDocument Text format.
Definition: generator.h:151
QSize::height
int height() const
Okular::TextDocumentGeneratorPrivate::LinkPosition::startPosition
int startPosition
Definition: textdocumentgenerator_p.h:165
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
QString::length
int length() const
Okular::TextDocumentGeneratorPrivate::TitlePosition::title
QString title
Definition: textdocumentgenerator_p.h:158
QPainter::translate
void translate(const QPointF &offset)
Okular::TextDocumentGeneratorPrivate::AnnotationInfo
Definition: textdocumentgenerator_p.h:187
QAbstractTextDocumentLayout::draw
virtual void draw(QPainter *painter, const PaintContext &context)=0
Okular::TextDocumentGeneratorPrivate::TitlePosition
Definition: textdocumentgenerator_p.h:155
Okular::TextDocumentGeneratorPrivate::AnnotationPosition::endPosition
int endPosition
Definition: textdocumentgenerator_p.h:182
Okular::TextDocumentGenerator::print
bool print(QPrinter &printer)
This method is called to print the document to the given printer.
Definition: textdocumentgenerator.cpp:445
Okular::DocumentViewport
A view on the document.
Definition: document.h:1016
Okular::Generator::TextExtraction
Whether the Generator can extract text from the document in the form of TextPage's.
Definition: generator.h:203
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:500
Okular::TextDocumentGeneratorPrivate::mFont
QFont mFont
Definition: textdocumentgenerator_p.h:197
Okular::Page::addAnnotation
void addAnnotation(Annotation *annotation)
Adds a new annotation to the page.
Definition: page.cpp:631
Okular::DocumentViewport::toString
QString toString() const
Returns the viewport as xml description.
Definition: document.cpp:4583
QDomDocument::createElement
QDomElement createElement(const QString &tagName)
Okular::TextDocumentGeneratorPrivate::TitlePosition::block
QTextBlock block
Definition: textdocumentgenerator_p.h:159
Okular::TextDocumentGeneratorPrivate::mDocumentSynopsis
Okular::DocumentSynopsis mDocumentSynopsis
Definition: textdocumentgenerator_p.h:153
Okular::TextDocumentSettings
TextDocumentSettings.
Definition: textdocumentsettings.h:106
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QPrinter::setOutputFormat
void setOutputFormat(OutputFormat format)
Okular::Document::OpenSuccess
Definition: document.h:105
QPainter::begin
bool begin(QPaintDevice *device)
QDomElement
Okular::TextDocumentGenerator::loadDocumentWithPassword
Document::OpenResult loadDocumentWithPassword(const QString &fileName, QVector< Okular::Page * > &pagesVector, const QString &password)
Loads the document with the given fileName and password and fills the pagesVector with the parsed pag...
Definition: textdocumentgenerator.cpp:296
QFontDatabase::supportsThreadedFontRendering
bool supportsThreadedFontRendering()
Okular::TextDocumentGeneratorPrivate::LinkPosition
Definition: textdocumentgenerator_p.h:163
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1167
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:251
Okular::TextDocumentGenerator::exportFormats
Okular::ExportFormat::List exportFormats() const
Returns the list of additional supported export formats.
Definition: textdocumentgenerator.cpp:481
QStack
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:575
QTextDocumentWriter::supportedDocumentFormats
QList< QByteArray > supportedDocumentFormats()
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:388
Okular::TextDocumentConverter::generator
TextDocumentGenerator * generator() const
Returns the generator that owns this converter.
Definition: textdocumentgenerator.cpp:75
Okular::Generator
[Abstract Class] The information generator.
Definition: generator.h:186
Okular::TextDocumentGeneratorPrivate::image
QImage image(PixmapRequest *)
Definition: textdocumentgenerator.cpp:393
QVariant
Okular::TextDocumentGenerator::canGeneratePixmap
bool canGeneratePixmap() const
This method returns whether the generator is ready to handle a new pixmap request.
Definition: textdocumentgenerator.cpp:383
QStack::top
T & top()
QTextCursor::setPosition
void setPosition(int pos, MoveMode m)
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