• 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
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 
102  bool openDocument( const QString & docFile, const KUrl & url, const KMimeType::Ptr &mime );
103 
107  void closeDocument();
108 
112  void addObserver( DocumentObserver *observer );
113 
117  void removeObserver( DocumentObserver *observer );
118 
122  void reparseConfig();
123 
127  QWidget *widget() const;
128 
132  bool isOpened() const;
133 
138  const DocumentInfo * documentInfo() const;
139 
144  const DocumentSynopsis * documentSynopsis() const;
145 
153  void startFontReading();
154 
159  void stopFontReading();
160 
165  bool canProvideFontInformation() const;
166 
171  const QList<EmbeddedFile*> *embeddedFiles() const;
172 
177  const Page * page( int number ) const;
178 
182  const DocumentViewport & viewport() const;
183 
188  void setVisiblePageRects( const QVector< VisiblePageRect * > & visiblePageRects, DocumentObserver *excludeObserver = 0 );
189 
193  const QVector< VisiblePageRect * > & visiblePageRects() const;
194 
198  uint currentPage() const;
199 
203  uint pages() const;
204 
208  KUrl currentDocument() const;
209 
214  bool isAllowed( Permission action ) const;
215 
219  bool supportsSearching() const;
220 
224  bool supportsPageSizes() const;
225 
231  bool supportsTiles() const;
232 
238  PageSize::List pageSizes() const;
239 
243  bool canExportToText() const;
244 
248  bool exportToText( const QString& fileName ) const;
249 
254  QList<ExportFormat> exportFormats() const;
255 
259  bool exportTo( const QString& fileName, const ExportFormat& format ) const;
260 
264  bool historyAtBegin() const;
265 
269  bool historyAtEnd() const;
270 
275  QVariant metaData( const QString & key, const QVariant & option = QVariant() ) const;
276 
280  Rotation rotation() const;
281 
286  QSizeF allPagesSize() const;
287 
292  QString pageSizeString( int page ) const;
293 
297  KXMLGUIClient* guiClient();
298 
305  void setViewportPage( int page, DocumentObserver *excludeObserver = 0, bool smoothMove = false );
306 
313  void setViewport( const DocumentViewport &viewport, DocumentObserver *excludeObserver = 0, bool smoothMove = false );
314 
319  void setPrevViewport();
320 
325  void setNextViewport();
326 
330  void setNextDocumentViewport( const DocumentViewport &viewport );
331 
337  void setNextDocumentDestination( const QString &namedDestination );
338 
342  void setZoom( int factor, DocumentObserver *excludeObserver = 0 );
343 
347  enum PixmapRequestFlag
348  {
349  NoOption = 0,
350  RemoveAllPrevious = 1
351  };
352  Q_DECLARE_FLAGS( PixmapRequestFlags, PixmapRequestFlag )
353 
354 
359  void requestPixmaps( const QLinkedList<PixmapRequest*> &requests );
360 
368  void requestPixmaps( const QLinkedList<PixmapRequest*> &requests, PixmapRequestFlags reqOptions );
369 
373  void requestTextPage( uint number );
374 
378  void addPageAnnotation( int page, Annotation *annotation );
379 
385  bool canModifyPageAnnotation( const Annotation * annotation ) const;
386 
393  void prepareToModifyAnnotationProperties( Annotation * annotation );
394 
402  void modifyPageAnnotationProperties( int page, Annotation * annotation );
403 
412  void translatePageAnnotation( int page, Annotation *annotation, const Okular::NormalizedPoint & delta );
413 
414 
426  void editPageAnnotationContents( int page, Annotation* annotation, const QString & newContents,
427  int newCursorPos, int prevCursorPos, int prevAnchorPos );
428 
434  bool canRemovePageAnnotation( const Annotation * annotation ) const;
435 
439  void removePageAnnotation( int page, Annotation *annotation );
440 
444  void removePageAnnotations( int page, const QList<Annotation*> &annotations );
445 
452  void setPageTextSelection( int page, RegularAreaRect * rect, const QColor & color );
453 
458  bool canUndo() const;
459 
464  bool canRedo() const;
465 
469  enum SearchType
470  {
471  NextMatch,
472  PreviousMatch,
473  AllDocument,
474  GoogleAll,
475  GoogleAny
476  };
477 
481  enum SearchStatus
482  {
483  MatchFound,
484  NoMatchFound,
485  SearchCancelled
486  };
487 
499  void searchText( int searchID, const QString & text, bool fromStart, Qt::CaseSensitivity caseSensitivity,
500  SearchType type, bool moveViewport, const QColor & color, bool noDialogs = false );
501 
505  void continueSearch( int searchID );
506 
513  void continueSearch( int searchID, SearchType type );
514 
518  void resetSearch( int searchID );
519 
523  BookmarkManager * bookmarkManager() const;
524 
528  void processAction( const Action *action );
529 
533  QList<int> bookmarkedPageList() const;
534 
538  QString bookmarkedPageRange() const;
539 
543  void processSourceReference( const SourceReference *reference );
544 
548  bool canConfigurePrinter() const;
549 
553  enum PrintingType
554  {
555  NoPrinting,
556  NativePrinting,
557  PostscriptPrinting
558  };
559 
564  PrintingType printingSupport() const;
565 
569  bool supportsPrintToFile() const;
570 
574  bool print( QPrinter &printer );
575 
580  QString printError() const;
581 
586  QWidget* printConfigurationWidget() const;
587 
592  void fillConfigDialog( KConfigDialog * dialog );
593 
597  int configurableGenerators() const;
598 
602  QStringList supportedMimeTypes() const;
603 
607  const KComponentData* componentData() const;
608 
616  enum SaveCapability
617  {
618  SaveFormsCapability = 1,
619  SaveAnnotationsCapability = 2
620  };
621 
628  bool canSaveChanges( SaveCapability cap ) const;
629 
639  bool canSaveChanges() const;
640 
647  bool saveChanges( const QString &fileName );
648 
655  bool saveChanges( const QString &fileName, QString *errorText );
656 
664  void registerView( View *view );
665 
671  void unregisterView( View *view );
672 
678  QByteArray fontData(const FontInfo &font) const;
679 
685  bool openDocumentArchive( const QString & docFile, const KUrl & url );
686 
692  bool saveDocumentArchive( const QString &fileName );
693 
703  const SourceReference * dynamicSourceReference( int pageNr, double absX, double absY );
704 
712  QPrinter::Orientation orientation() const;
713 
720  void setAnnotationEditingEnabled( bool enable );
721 
722  public Q_SLOTS:
727  void setRotation( int rotation );
728 
733  void setPageSize( const PageSize &size );
734 
738  void cancelSearch();
739 
744  void undo();
745 
750  void redo();
751 
758  void editFormText( int pageNumber,
759  Okular::FormFieldText* form,
760  const QString & newContents,
761  int newCursorPos,
762  int prevCursorPos,
763  int prevAnchorPos );
764 
769  void editFormList( int pageNumber,
770  Okular::FormFieldChoice* form,
771  const QList<int> & newChoices );
772 
773 
782  void editFormCombo( int pageNumber,
783  Okular::FormFieldChoice *form,
784  const QString & newText,
785  int newCursorPos,
786  int prevCursorPos,
787  int prevAnchorPos );
788 
794  void editFormButtons( int pageNumber,
795  const QList< Okular::FormFieldButton* > & formButtons,
796  const QList< bool > & newButtonStates );
797 
798  Q_SIGNALS:
803  void close();
804 
809  void quit();
810 
815  void linkFind();
816 
821  void linkGoToPage();
822 
827  void linkPresentation();
828 
833  void linkEndPresentation();
834 
839  void openUrl( const KUrl &url );
840 
847  void error( const QString &text, int duration );
848 
855  void warning( const QString &text, int duration );
856 
863  void notice( const QString &text, int duration );
864 
869  void gotFont( const Okular::FontInfo& font );
870 
876  void fontReadingProgress( int page );
877 
881  void fontReadingEnded();
882 
886  void searchFinished( int id, Okular::Document::SearchStatus endStatus );
887 
898  void sourceReferenceActivated(const QString& absFileName, int line, int col, bool *handled);
899 
903  void processMovieAction( const Okular::MovieAction *action );
904 
909  void canUndoChanged( bool undoAvailable );
910 
915  void canRedoChanged( bool redoAvailable );
916 
922  void processRenditionAction( const Okular::RenditionAction *action );
923 
932  void annotationContentsChangedByUndoRedo( Okular::Annotation* annotation, const QString & contents, int cursorPos, int anchorPos );
933 
942  void formTextChangedByUndoRedo( int page, Okular::FormFieldText* form, const QString & contents, int cursorPos, int anchorPos );
943 
949  void formListChangedByUndoRedo( int page, Okular::FormFieldChoice* form, const QList< int > & choices );
950 
956  void formComboChangedByUndoRedo( int page, Okular::FormFieldChoice* form, const QString & text, int cursorPos, int anchorPos );
957 
963  void formButtonsChangedByUndoRedo( int page, const QList< Okular::FormFieldButton* > & formButtons );
964  private:
966  friend class DocumentPrivate;
967  friend class Part;
968  friend class ::DocumentItem;
969  friend class EditAnnotationContentsCommand;
970  friend class EditFormTextCommand;
971  friend class EditFormListCommand;
972  friend class EditFormComboCommand;
973  friend class EditFormButtonsCommand;
975  DocumentPrivate *const d;
976 
977  Q_DISABLE_COPY( Document )
978 
979  Q_PRIVATE_SLOT( d, void saveDocumentInfo() const )
980  Q_PRIVATE_SLOT( d, void slotTimedMemoryCheck() )
981  Q_PRIVATE_SLOT( d, void sendGeneratorPixmapRequest() )
982  Q_PRIVATE_SLOT( d, void rotationFinished( int page, Okular::Page *okularPage ) )
983  Q_PRIVATE_SLOT( d, void fontReadingProgress( int page ) )
984  Q_PRIVATE_SLOT( d, void fontReadingGotFont( const Okular::FontInfo& font ) )
985  Q_PRIVATE_SLOT( d, void slotGeneratorConfigChanged( const QString& ) )
986  Q_PRIVATE_SLOT( d, void refreshPixmaps( int ) )
987  Q_PRIVATE_SLOT( d, void _o_configChanged() )
988 
989  // search thread simulators
990  Q_PRIVATE_SLOT( d, void doContinueDirectionMatchSearch(void *doContinueDirectionMatchSearchStruct) )
991  Q_PRIVATE_SLOT( d, void doContinueAllDocumentSearch(void *pagesToNotifySet, void *pageMatchesMap, int currentPage, int searchID, const QString & text, int caseSensitivity, const QColor & color) )
992  Q_PRIVATE_SLOT( d, void doContinueGooglesDocumentSearch(void *pagesToNotifySet, void *pageMatchesMap, int currentPage, int searchID, const QStringList & words, int caseSensitivity, const QColor & color, bool matchAll) )
993 };
994 
995 
1003 class OKULAR_EXPORT DocumentViewport
1004 {
1005  public:
1009  DocumentViewport( int number = -1 );
1010 
1014  DocumentViewport( const QString &description );
1015 
1019  QString toString() const;
1020 
1024  bool isValid() const;
1025 
1029  bool operator==( const DocumentViewport &other ) const;
1030  bool operator<( const DocumentViewport &other ) const;
1031 
1035  int pageNumber;
1036 
1040  enum Position
1041  {
1042  Center = 1,
1043  TopLeft = 2
1044  };
1045 
1050  struct {
1051  bool enabled;
1052  double normalizedX;
1053  double normalizedY;
1054  Position pos;
1055  } rePos;
1056 
1060  struct {
1061  bool enabled;
1062  bool width;
1063  bool height;
1064  } autoFit;
1065 };
1066 
1073 class OKULAR_EXPORT DocumentInfo : public QDomDocument
1074 {
1075  public:
1079  enum Key {
1080  Title,
1081  Subject,
1082  Description,
1083  Author,
1084  Creator,
1085  Producer,
1086  Copyright,
1087  Pages,
1088  CreationDate,
1089  ModificationDate,
1090  MimeType,
1091  Category,
1092  Keywords,
1093  FilePath,
1094  DocumentSize,
1095  PagesSize
1096  };
1097 
1101  DocumentInfo();
1102 
1107  void set( const QString &key, const QString &value,
1108  const QString &title = QString() );
1109 
1114  void set( Key key, const QString &value );
1115 
1120  QString get( const QString &key ) const;
1121 
1126  static QString getKeyString( Key key );
1127 
1132  static QString getKeyTitle( Key key );
1133 
1134 };
1135 
1154 class OKULAR_EXPORT DocumentSynopsis : public QDomDocument
1155 {
1156  public:
1160  DocumentSynopsis();
1161 
1166  DocumentSynopsis( const QDomDocument &document );
1167 };
1168 
1178 class OKULAR_EXPORT EmbeddedFile
1179 {
1180  public:
1184  EmbeddedFile();
1185 
1189  virtual ~EmbeddedFile();
1190 
1194  virtual QString name() const = 0;
1195 
1200  virtual QString description() const = 0;
1201 
1205  virtual QByteArray data() const = 0;
1206 
1213  virtual int size() const = 0;
1214 
1219  virtual QDateTime modificationDate() const = 0;
1220 
1225  virtual QDateTime creationDate() const = 0;
1226 
1227 };
1228 
1232 class OKULAR_EXPORT VisiblePageRect
1233 {
1234  public:
1241  explicit VisiblePageRect( int pageNumber = -1, const NormalizedRect &rectangle = NormalizedRect() );
1242 
1246  int pageNumber;
1247 
1251  NormalizedRect rect;
1252 };
1253 
1254 }
1255 
1256 Q_DECLARE_METATYPE( Okular::DocumentInfo::Key )
1257 Q_DECLARE_OPERATORS_FOR_FLAGS( Okular::Document::PixmapRequestFlags )
1258 
1259 #endif
1260 
1261 /* 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:1054
Okular::PageSize::List
QList< PageSize > List
Definition: pagesize.h:29
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::Document::NoPrinting
Printing Not Supported.
Definition: document.h:555
Okular::DocumentInfo::Category
The category of the document.
Definition: document.h:1091
KXMLGUIClient
Okular::DocumentInfo::Copyright
The copyright of the document.
Definition: document.h:1086
Okular::DocumentInfo::MimeType
The mime type of the document.
Definition: document.h:1090
Okular::Document::NativePrinting
Native Cross-Platform Printing.
Definition: document.h:556
Okular::DocumentInfo::Author
The author of the document.
Definition: document.h:1083
Okular::View
View on the document.
Definition: view.h:32
Okular::DocumentInfo::FilePath
The path of the file.
Definition: document.h:1093
QWidget
Okular::DocumentInfo::Subject
The subject of the document.
Definition: document.h:1081
Okular::Document::AllDocument
Search complete document.
Definition: document.h:473
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:1051
Okular::Document::SearchType
SearchType
Describes the possible search types.
Definition: document.h:469
Okular::Document::SaveCapability
SaveCapability
Saving capabilities.
Definition: document.h:616
Okular::EmbeddedFile
An embedded file into the document.
Definition: document.h:1178
QObject
global.h
Okular::EditAnnotationContentsCommand
Definition: documentcommands_p.h:140
DocumentItem
Definition: documentitem.h:37
okular_export.h
Okular::DocumentInfo::Key
Key
The list of predefined keys.
Definition: document.h:1079
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:1080
Okular::MovieAction
The Movie action executes an operation on a video on activation.
Definition: action.h:432
Okular::EditFormButtonsCommand
Definition: documentcommands_p.h:232
Okular::Document::PrintingType
PrintingType
What type of printing a document supports.
Definition: document.h:553
Okular::Document::PixmapRequestFlag
PixmapRequestFlag
Describes the possible options for the pixmap requests.
Definition: document.h:347
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:1088
Okular::Document::SearchStatus
SearchStatus
Describes how search ended.
Definition: document.h:481
Okular::Document::NoMatchFound
No match was found.
Definition: document.h:484
Okular::FormFieldChoice
Interface of a choice form field.
Definition: form.h:258
Okular::Document::GoogleAll
Search all words in google style.
Definition: document.h:474
Okular::Part
This is a "Part".
Definition: part.h:96
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:1232
Okular::DocumentViewport::pageNumber
int pageNumber
The number of the page nearest the center of the viewport.
Definition: document.h:1035
Okular::Document::PreviousMatch
Search previous match.
Definition: document.h:472
Okular::DocumentInfo::Keywords
The keywords which describe the content of the document.
Definition: document.h:1092
Okular::DocumentPrivate
Definition: document_p.h:83
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::VisiblePageRect::rect
NormalizedRect rect
The rectangle in normalized coordinates.
Definition: document.h:1251
Okular::SourceReference
Defines a source reference.
Definition: sourcereference.h:25
Okular::DocumentViewport::normalizedX
double normalizedX
Definition: document.h:1052
Okular::EditFormListCommand
Definition: documentcommands_p.h:185
Okular::EditFormComboCommand
Definition: documentcommands_p.h:206
Okular::DocumentInfo::Pages
The number of pages of the document.
Definition: document.h:1087
Okular::DocumentViewport::normalizedY
double normalizedY
Definition: document.h:1053
Okular::DocumentInfo::DocumentSize
The size of the document.
Definition: document.h:1094
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:75
Okular::DocumentInfo::Creator
The creator of the document (this can be different from the author)
Definition: document.h:1084
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:164
description
static const char description[]
Definition: main.cpp:33
OKULAR_EXPORT
#define OKULAR_EXPORT
Definition: okular_export.h:30
Okular::Permission
Permission
Describes the DRM capabilities.
Definition: global.h:20
Okular::DocumentViewport
A view on the document.
Definition: document.h:1003
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:483
Okular::DocumentViewport::width
bool width
Definition: document.h:1062
Okular::Document::NextMatch
Search next match.
Definition: document.h:471
Okular::DocumentViewport::Position
Position
Describes the relative position of the viewport.
Definition: document.h:1040
Okular::DocumentInfo::Description
The description of the document.
Definition: document.h:1082
Okular::VisiblePageRect::pageNumber
int pageNumber
The page number where the rectangle is located.
Definition: document.h:1246
Okular::DocumentSynopsis
A DOM tree that describes the Table of Contents.
Definition: document.h:1154
Okular::BookmarkManager
Bookmarks manager utility.
Definition: bookmarkmanager.h:32
Okular::DocumentViewport::height
bool height
Definition: document.h:1063
Okular::PixmapRequest
Describes a pixmap type request.
Definition: generator.h:522
Okular::DocumentInfo::ModificationDate
The date of last modification of the document.
Definition: document.h:1089
Okular::DocumentInfo::Producer
The producer of the document (e.g. some software)
Definition: document.h:1085
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal