• 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
document.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2005 by Enrico Ros <eros.kde@email.it> *
3  * Copyright (C) 2004-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 #ifndef _OKULAR_DOCUMENT_H_
12 #define _OKULAR_DOCUMENT_H_
13 
14 #include "okular_export.h"
15 #include "area.h"
16 #include "global.h"
17 #include "pagesize.h"
18 
19 #include <QtCore/QObject>
20 #include <QtCore/QStringList>
21 #include <QtCore/QVector>
22 #include <QtGui/QPrinter>
23 #include <QtXml/QDomDocument>
24 
25 #include <kmimetype.h>
26 
27 class QPrintDialog;
28 class KComponentData;
29 class KBookmark;
30 class KConfigDialog;
31 class KXMLGUIClient;
32 class KUrl;
33 class DocumentItem;
34 
35 namespace Okular {
36 
37 class Annotation;
38 class BookmarkManager;
39 class DocumentInfo;
40 class DocumentObserver;
41 class DocumentPrivate;
42 class DocumentSynopsis;
43 class DocumentViewport;
44 class EmbeddedFile;
45 class ExportFormat;
46 class FontInfo;
47 class FormFieldText;
48 class FormFieldButton;
49 class FormFieldChoice;
50 class Generator;
51 class Action;
52 class MovieAction;
53 class Page;
54 class PixmapRequest;
55 class RenditionAction;
56 class SourceReference;
57 class View;
58 class VisiblePageRect;
59 
61 #define PART_SEARCH_ID 1
62 #define PAGEVIEW_SEARCH_ID 2
63 #define SW_SEARCH_ID 3
64 #define PRESENTATION_SEARCH_ID 4
65 
66 
84 class OKULAR_EXPORT Document : public QObject
85 {
86  Q_OBJECT
87 
88  public:
92  explicit Document( QWidget *widget );
93 
97  ~Document();
98 
103  enum OpenResult
104  {
105  OpenSuccess, //< The document was opened successfully
106  OpenError, //< The document failed to open
107  OpenNeedsPassword //< The document needs a password to be opened or the one provided is not the correct
108  };
109 
114  OpenResult openDocument( const QString & docFile, const KUrl & url, const KMimeType::Ptr &mime, const QString &password = QString() );
115 
119  void closeDocument();
120 
124  void addObserver( DocumentObserver *observer );
125 
129  void removeObserver( DocumentObserver *observer );
130 
134  void reparseConfig();
135 
139  bool isOpened() const;
140 
145  const DocumentInfo * documentInfo() const;
146 
151  const DocumentSynopsis * documentSynopsis() const;
152 
160  void startFontReading();
161 
166  void stopFontReading();
167 
172  bool canProvideFontInformation() const;
173 
178  const QList<EmbeddedFile*> *embeddedFiles() const;
179 
184  const Page * page( int number ) const;
185 
189  const DocumentViewport & viewport() const;
190 
195  void setVisiblePageRects( const QVector< VisiblePageRect * > & visiblePageRects, DocumentObserver *excludeObserver = 0 );
196 
200  const QVector< VisiblePageRect * > & visiblePageRects() const;
201 
205  uint currentPage() const;
206 
210  uint pages() const;
211 
215  KUrl currentDocument() const;
216 
221  bool isAllowed( Permission action ) const;
222 
226  bool supportsSearching() const;
227 
231  bool supportsPageSizes() const;
232 
238  bool supportsTiles() const;
239 
245  PageSize::List pageSizes() const;
246 
250  bool canExportToText() const;
251 
255  bool exportToText( const QString& fileName ) const;
256 
261  QList<ExportFormat> exportFormats() const;
262 
266  bool exportTo( const QString& fileName, const ExportFormat& format ) const;
267 
271  bool historyAtBegin() const;
272 
276  bool historyAtEnd() const;
277 
282  QVariant metaData( const QString & key, const QVariant & option = QVariant() ) const;
283 
287  Rotation rotation() const;
288 
293  QSizeF allPagesSize() const;
294 
299  QString pageSizeString( int page ) const;
300 
304  KXMLGUIClient* guiClient();
305 
312  void setViewportPage( int page, DocumentObserver *excludeObserver = 0, bool smoothMove = false );
313 
320  void setViewport( const DocumentViewport &viewport, DocumentObserver *excludeObserver = 0, bool smoothMove = false );
321 
326  void setPrevViewport();
327 
332  void setNextViewport();
333 
337  void setNextDocumentViewport( const DocumentViewport &viewport );
338 
344  void setNextDocumentDestination( const QString &namedDestination );
345 
349  void setZoom( int factor, DocumentObserver *excludeObserver = 0 );
350 
354  enum PixmapRequestFlag
355  {
356  NoOption = 0,
357  RemoveAllPrevious = 1
358  };
359  Q_DECLARE_FLAGS( PixmapRequestFlags, PixmapRequestFlag )
360 
361 
366  void requestPixmaps( const QLinkedList<PixmapRequest*> &requests );
367 
375  void requestPixmaps( const QLinkedList<PixmapRequest*> &requests, PixmapRequestFlags reqOptions );
376 
380  void requestTextPage( uint number );
381 
385  void addPageAnnotation( int page, Annotation *annotation );
386 
392  bool canModifyPageAnnotation( const Annotation * annotation ) const;
393 
400  void prepareToModifyAnnotationProperties( Annotation * annotation );
401 
409  void modifyPageAnnotationProperties( int page, Annotation * annotation );
410 
419  void translatePageAnnotation( int page, Annotation *annotation, const Okular::NormalizedPoint & delta );
420 
421 
433  void editPageAnnotationContents( int page, Annotation* annotation, const QString & newContents,
434  int newCursorPos, int prevCursorPos, int prevAnchorPos );
435 
441  bool canRemovePageAnnotation( const Annotation * annotation ) const;
442 
446  void removePageAnnotation( int page, Annotation *annotation );
447 
451  void removePageAnnotations( int page, const QList<Annotation*> &annotations );
452 
459  void setPageTextSelection( int page, RegularAreaRect * rect, const QColor & color );
460 
465  bool canUndo() const;
466 
471  bool canRedo() const;
472 
476  enum SearchType
477  {
478  NextMatch,
479  PreviousMatch,
480  AllDocument,
481  GoogleAll,
482  GoogleAny
483  };
484 
488  enum SearchStatus
489  {
490  MatchFound,
491  NoMatchFound,
492  SearchCancelled,
493  EndOfDocumentReached
494  };
495 
506  void searchText( int searchID, const QString & text, bool fromStart, Qt::CaseSensitivity caseSensitivity,
507  SearchType type, bool moveViewport, const QColor & color );
508 
512  void continueSearch( int searchID );
513 
520  void continueSearch( int searchID, SearchType type );
521 
525  void resetSearch( int searchID );
526 
530  BookmarkManager * bookmarkManager() const;
531 
535  void processAction( const Action *action );
536 
540  QList<int> bookmarkedPageList() const;
541 
545  QString bookmarkedPageRange() const;
546 
550  void processSourceReference( const SourceReference *reference );
551 
555  bool canConfigurePrinter() const;
556 
560  enum PrintingType
561  {
562  NoPrinting,
563  NativePrinting,
564  PostscriptPrinting
565  };
566 
571  PrintingType printingSupport() const;
572 
576  bool supportsPrintToFile() const;
577 
581  bool print( QPrinter &printer );
582 
587  QString printError() const;
588 
593  QWidget* printConfigurationWidget() const;
594 
599  void fillConfigDialog( KConfigDialog * dialog );
600 
604  int configurableGenerators() const;
605 
609  QStringList supportedMimeTypes() const;
610 
614  const KComponentData* componentData() const;
615 
623  enum SaveCapability
624  {
625  SaveFormsCapability = 1,
626  SaveAnnotationsCapability = 2
627  };
628 
635  bool canSaveChanges( SaveCapability cap ) const;
636 
646  bool canSaveChanges() const;
647 
654  bool saveChanges( const QString &fileName );
655 
662  bool saveChanges( const QString &fileName, QString *errorText );
663 
671  void registerView( View *view );
672 
678  void unregisterView( View *view );
679 
685  QByteArray fontData(const FontInfo &font) const;
686 
692  OpenResult openDocumentArchive( const QString & docFile, const KUrl & url, const QString &password = QString() );
693 
699  bool saveDocumentArchive( const QString &fileName );
700 
710  const SourceReference * dynamicSourceReference( int pageNr, double absX, double absY );
711 
719  QPrinter::Orientation orientation() const;
720 
727  void setAnnotationEditingEnabled( bool enable );
728 
734  void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
735 
736  public Q_SLOTS:
741  void setRotation( int rotation );
742 
747  void setPageSize( const PageSize &size );
748 
752  void cancelSearch();
753 
758  void undo();
759 
764  void redo();
765 
772  void editFormText( int pageNumber,
773  Okular::FormFieldText* form,
774  const QString & newContents,
775  int newCursorPos,
776  int prevCursorPos,
777  int prevAnchorPos );
778 
783  void editFormList( int pageNumber,
784  Okular::FormFieldChoice* form,
785  const QList<int> & newChoices );
786 
787 
796  void editFormCombo( int pageNumber,
797  Okular::FormFieldChoice *form,
798  const QString & newText,
799  int newCursorPos,
800  int prevCursorPos,
801  int prevAnchorPos );
802 
808  void editFormButtons( int pageNumber,
809  const QList< Okular::FormFieldButton* > & formButtons,
810  const QList< bool > & newButtonStates );
811 
812  Q_SIGNALS:
817  void close();
818 
823  void quit();
824 
829  void linkFind();
830 
835  void linkGoToPage();
836 
841  void linkPresentation();
842 
847  void linkEndPresentation();
848 
853  void openUrl( const KUrl &url );
854 
861  void error( const QString &text, int duration );
862 
869  void warning( const QString &text, int duration );
870 
877  void notice( const QString &text, int duration );
878 
883  void gotFont( const Okular::FontInfo& font );
884 
890  void fontReadingProgress( int page );
891 
895  void fontReadingEnded();
896 
900  void searchFinished( int searchID, Okular::Document::SearchStatus endStatus );
901 
912  void sourceReferenceActivated(const QString& absFileName, int line, int col, bool *handled);
913 
917  void processMovieAction( const Okular::MovieAction *action );
918 
923  void canUndoChanged( bool undoAvailable );
924 
929  void canRedoChanged( bool redoAvailable );
930 
936  void processRenditionAction( const Okular::RenditionAction *action );
937 
946  void annotationContentsChangedByUndoRedo( Okular::Annotation* annotation, const QString & contents, int cursorPos, int anchorPos );
947 
956  void formTextChangedByUndoRedo( int page, Okular::FormFieldText* form, const QString & contents, int cursorPos, int anchorPos );
957 
963  void formListChangedByUndoRedo( int page, Okular::FormFieldChoice* form, const QList< int > & choices );
964 
970  void formComboChangedByUndoRedo( int page, Okular::FormFieldChoice* form, const QString & text, int cursorPos, int anchorPos );
971 
977  void formButtonsChangedByUndoRedo( int page, const QList< Okular::FormFieldButton* > & formButtons );
978  private:
980  friend class DocumentPrivate;
981  friend class ::DocumentItem;
982  friend class EditAnnotationContentsCommand;
983  friend class EditFormTextCommand;
984  friend class EditFormListCommand;
985  friend class EditFormComboCommand;
986  friend class EditFormButtonsCommand;
988  DocumentPrivate *const d;
989 
990  Q_DISABLE_COPY( Document )
991 
992  Q_PRIVATE_SLOT( d, void saveDocumentInfo() const )
993  Q_PRIVATE_SLOT( d, void slotTimedMemoryCheck() )
994  Q_PRIVATE_SLOT( d, void sendGeneratorPixmapRequest() )
995  Q_PRIVATE_SLOT( d, void rotationFinished( int page, Okular::Page *okularPage ) )
996  Q_PRIVATE_SLOT( d, void fontReadingProgress( int page ) )
997  Q_PRIVATE_SLOT( d, void fontReadingGotFont( const Okular::FontInfo& font ) )
998  Q_PRIVATE_SLOT( d, void slotGeneratorConfigChanged( const QString& ) )
999  Q_PRIVATE_SLOT( d, void refreshPixmaps( int ) )
1000  Q_PRIVATE_SLOT( d, void _o_configChanged() )
1001 
1002  // search thread simulators
1003  Q_PRIVATE_SLOT( d, void doContinueDirectionMatchSearch(void *doContinueDirectionMatchSearchStruct) )
1004  Q_PRIVATE_SLOT( d, void doContinueAllDocumentSearch(void *pagesToNotifySet, void *pageMatchesMap, int currentPage, int searchID) )
1005  Q_PRIVATE_SLOT( d, void doContinueGooglesDocumentSearch(void *pagesToNotifySet, void *pageMatchesMap, int currentPage, int searchID, const QStringList & words) )
1006 };
1007 
1008 
1016 class OKULAR_EXPORT DocumentViewport
1017 {
1018  public:
1022  DocumentViewport( int number = -1 );
1023 
1027  DocumentViewport( const QString &description );
1028 
1032  QString toString() const;
1033 
1037  bool isValid() const;
1038 
1042  bool operator==( const DocumentViewport &other ) const;
1043  bool operator<( const DocumentViewport &other ) const;
1044 
1048  int pageNumber;
1049 
1053  enum Position
1054  {
1055  Center = 1,
1056  TopLeft = 2
1057  };
1058 
1063  struct {
1064  bool enabled;
1065  double normalizedX;
1066  double normalizedY;
1067  Position pos;
1068  } rePos;
1069 
1073  struct {
1074  bool enabled;
1075  bool width;
1076  bool height;
1077  } autoFit;
1078 };
1079 
1086 class OKULAR_EXPORT DocumentInfo : public QDomDocument
1087 {
1088  public:
1092  enum Key {
1093  Title,
1094  Subject,
1095  Description,
1096  Author,
1097  Creator,
1098  Producer,
1099  Copyright,
1100  Pages,
1101  CreationDate,
1102  ModificationDate,
1103  MimeType,
1104  Category,
1105  Keywords,
1106  FilePath,
1107  DocumentSize,
1108  PagesSize
1109  };
1110 
1114  DocumentInfo();
1115 
1120  void set( const QString &key, const QString &value,
1121  const QString &title = QString() );
1122 
1127  void set( Key key, const QString &value );
1128 
1133  QString get( const QString &key ) const;
1134 
1139  static QString getKeyString( Key key );
1140 
1145  static QString getKeyTitle( Key key );
1146 
1147 };
1148 
1167 class OKULAR_EXPORT DocumentSynopsis : public QDomDocument
1168 {
1169  public:
1173  DocumentSynopsis();
1174 
1179  DocumentSynopsis( const QDomDocument &document );
1180 };
1181 
1191 class OKULAR_EXPORT EmbeddedFile
1192 {
1193  public:
1197  EmbeddedFile();
1198 
1202  virtual ~EmbeddedFile();
1203 
1207  virtual QString name() const = 0;
1208 
1213  virtual QString description() const = 0;
1214 
1218  virtual QByteArray data() const = 0;
1219 
1226  virtual int size() const = 0;
1227 
1232  virtual QDateTime modificationDate() const = 0;
1233 
1238  virtual QDateTime creationDate() const = 0;
1239 
1240 };
1241 
1245 class OKULAR_EXPORT VisiblePageRect
1246 {
1247  public:
1254  explicit VisiblePageRect( int pageNumber = -1, const NormalizedRect &rectangle = NormalizedRect() );
1255 
1259  int pageNumber;
1260 
1264  NormalizedRect rect;
1265 };
1266 
1267 }
1268 
1269 Q_DECLARE_METATYPE( Okular::DocumentInfo::Key )
1270 Q_DECLARE_OPERATORS_FOR_FLAGS( Okular::Document::PixmapRequestFlags )
1271 
1272 #endif
1273 
1274 /* kate: replace-tabs on; indent-width 4; */
Okular::NormalizedPoint
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:47
Okular::DocumentViewport::pos
Position pos
Definition: document.h:1067
QWidget
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::Document::NoPrinting
Printing Not Supported.
Definition: document.h:562
Okular::DocumentInfo::Category
The category of the document.
Definition: document.h:1104
KXMLGUIClient
Okular::DocumentInfo::Copyright
The copyright of the document.
Definition: document.h:1099
QByteArray
Okular::DocumentInfo::MimeType
The mime type of the document.
Definition: document.h:1103
Okular::Document::NativePrinting
Native Cross-Platform Printing.
Definition: document.h:563
QPrinter
Okular::DocumentInfo::Author
The author of the document.
Definition: document.h:1096
Okular::View
View on the document.
Definition: view.h:32
Okular::DocumentInfo::FilePath
The path of the file.
Definition: document.h:1106
Okular::DocumentInfo::Subject
The subject of the document.
Definition: document.h:1094
Okular::Document::AllDocument
Search complete document.
Definition: document.h:480
Okular::NormalizedRect
NormalizedRect is a helper class which stores the coordinates of a normalized rect, which is a rectangle of.
Definition: area.h:105
area.h
Okular::RegularAreaRect
Definition: area.h:860
Okular::DocumentViewport::enabled
bool enabled
Definition: document.h:1064
Okular::Document::SearchType
SearchType
Describes the possible search types.
Definition: document.h:476
Okular::Document::SaveCapability
SaveCapability
Saving capabilities.
Definition: document.h:623
Okular::EmbeddedFile
An embedded file into the document.
Definition: document.h:1191
global.h
Okular::EditAnnotationContentsCommand
Definition: documentcommands_p.h:141
DocumentItem
Definition: documentitem.h:37
okular_export.h
Okular::DocumentInfo::Key
Key
The list of predefined keys.
Definition: document.h:1092
Okular::Document::OpenResult
OpenResult
Describes the result of an open document operation.
Definition: document.h:103
Okular::FormFieldText
Interface of a text form field.
Definition: form.h:176
pagesize.h
Okular::DocumentInfo::Title
The title of the document.
Definition: document.h:1093
Okular::MovieAction
The Movie action executes an operation on a video on activation.
Definition: action.h:432
Okular::EditFormButtonsCommand
Definition: documentcommands_p.h:233
QLinkedList
Okular::Document::PrintingType
PrintingType
What type of printing a document supports.
Definition: document.h:560
Okular::Document::PixmapRequestFlag
PixmapRequestFlag
Describes the possible options for the pixmap requests.
Definition: document.h:354
Okular::FontInfo
A small class that represents the information of a font.
Definition: fontinfo.h:27
Okular::DocumentInfo::CreationDate
The date of creation of the document.
Definition: document.h:1101
QPrintDialog
Okular::Document::SearchStatus
SearchStatus
Describes how search ended.
Definition: document.h:488
QObject
Okular::Document::NoMatchFound
No match was found.
Definition: document.h:491
Okular::FormFieldChoice
Interface of a choice form field.
Definition: form.h:258
Okular::Document::GoogleAll
Search all words in google style.
Definition: document.h:481
Okular::Document::OpenError
Definition: document.h:106
Okular::Document
The Document.
Definition: document.h:84
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
Okular::VisiblePageRect
An area of a specified page.
Definition: document.h:1245
QString
QList
QColor
QStringList
Okular::DocumentViewport::pageNumber
int pageNumber
The number of the page nearest the center of the viewport.
Definition: document.h:1048
Okular::Document::PreviousMatch
Search previous match.
Definition: document.h:479
Okular::DocumentInfo::Keywords
The keywords which describe the content of the document.
Definition: document.h:1105
QDomDocument
Okular::DocumentPrivate
Definition: document_p.h:77
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::VisiblePageRect::rect
NormalizedRect rect
The rectangle in normalized coordinates.
Definition: document.h:1264
Okular::SourceReference
Defines a source reference.
Definition: sourcereference.h:25
Okular::DocumentViewport::normalizedX
double normalizedX
Definition: document.h:1065
Okular::EditFormListCommand
Definition: documentcommands_p.h:186
Okular::EditFormComboCommand
Definition: documentcommands_p.h:207
QVector
Okular::DocumentInfo::Pages
The number of pages of the document.
Definition: document.h:1100
QSizeF
Okular::DocumentViewport::normalizedY
double normalizedY
Definition: document.h:1066
Okular::DocumentInfo::DocumentSize
The size of the document.
Definition: document.h:1107
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
Okular::DocumentInfo::Creator
The creator of the document (this can be different from the author)
Definition: document.h:1097
Okular::Annotation
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:90
Okular::PageSize
A small class that represents the size of a page.
Definition: pagesize.h:26
Okular::DocumentObserver
Base class for objects being notified when something changes.
Definition: observer.h:28
Okular::EditFormTextCommand
Definition: documentcommands_p.h:165
description
static const char description[]
Definition: main.cpp:33
OKULAR_EXPORT
#define OKULAR_EXPORT
Definition: okular_export.h:30
Okular::Document::SearchCancelled
The search was cancelled.
Definition: document.h:492
Okular::Permission
Permission
Describes the DRM capabilities.
Definition: global.h:20
Okular::DocumentViewport
A view on the document.
Definition: document.h:1016
Okular::RenditionAction
The Rendition action executes an operation on a video or executes some JavaScript code on activation...
Definition: action.h:491
Okular::Document::MatchFound
Any match was found.
Definition: document.h:490
Okular::DocumentViewport::width
bool width
Definition: document.h:1075
Okular::Document::NextMatch
Search next match.
Definition: document.h:478
Okular::DocumentViewport::Position
Position
Describes the relative position of the viewport.
Definition: document.h:1053
Okular::Document::OpenSuccess
Definition: document.h:105
Okular::DocumentInfo::Description
The description of the document.
Definition: document.h:1095
Okular::VisiblePageRect::pageNumber
int pageNumber
The page number where the rectangle is located.
Definition: document.h:1259
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1167
Okular::BookmarkManager
Bookmarks manager utility.
Definition: bookmarkmanager.h:32
QDateTime
Okular::DocumentViewport::height
bool height
Definition: document.h:1076
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:575
Okular::DocumentInfo::ModificationDate
The date of last modification of the document.
Definition: document.h:1102
QVariant
Okular::DocumentInfo::Producer
The producer of the document (e.g. some software)
Definition: document.h:1098
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