Okular

annotations.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Enrico Ros <[email protected]> *
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 #ifndef _OKULAR_ANNOTATIONS_H_
11 #define _OKULAR_ANNOTATIONS_H_
12 
13 #include <QDateTime>
14 #include <QDomDocument>
15 #include <QDomElement>
16 #include <QFont>
17 #include <QLinkedList>
18 #include <QRect>
19 #include <QString>
20 
21 #include "area.h"
22 #include "okularcore_export.h"
23 
24 namespace Okular
25 {
26 class Action;
27 class Annotation;
28 class AnnotationObjectRect;
29 class AnnotationPrivate;
30 class Document;
31 class EmbeddedFile;
32 class Page;
33 class PagePrivate;
34 class Sound;
35 class Movie;
36 class TextAnnotationPrivate;
37 class LineAnnotationPrivate;
38 class GeomAnnotationPrivate;
39 class HighlightAnnotationPrivate;
40 class StampAnnotationPrivate;
41 class InkAnnotationPrivate;
42 class CaretAnnotationPrivate;
43 class FileAttachmentAnnotationPrivate;
44 class SoundAnnotationPrivate;
45 class MovieAnnotationPrivate;
46 class ScreenAnnotationPrivate;
47 class WidgetAnnotationPrivate;
48 class RichMediaAnnotationPrivate;
49 
53 class OKULARCORE_EXPORT AnnotationUtils
54 {
55 public:
61  static Annotation *createAnnotation(const QDomElement &element);
62 
67  static void storeAnnotation(const Annotation *annotation, QDomElement &element, QDomDocument &document);
68 
73  static QDomElement findChildElement(const QDomNode &parentNode, const QString &name);
74 
79  static QRect annotationGeometry(const Annotation *annotation, double scaleX, double scaleY);
80 };
81 
88 class OKULARCORE_EXPORT Annotation
89 {
91  friend class AnnotationObjectRect;
92  friend class Document;
93  friend class DocumentPrivate;
94  friend class ObjectRect;
95  friend class Page;
96  friend class PagePrivate;
98 
99 public:
103  enum SubType {
104  AText = 1,
105  ALine = 2,
106  AGeom = 3,
107  AHighlight = 4,
108  AStamp = 5,
109  AInk = 6,
110  ACaret = 8,
111  AFileAttachment = 9,
112  ASound = 10,
113  AMovie = 11,
114  AScreen = 12,
115  AWidget = 13,
116  ARichMedia = 14,
117  A_BASE = 0
118  };
119 
123  enum Flag {
124  Hidden = 1,
125  FixedSize = 2,
126  FixedRotation = 4,
127  DenyPrint = 8,
128  DenyWrite = 16,
129  DenyDelete = 32,
130  ToggleHidingOnMouse = 64,
131  External = 128,
132  ExternallyDrawn = 256,
133  BeingMoved = 512,
134  BeingResized = 1024
135  };
136 
140  enum LineStyle {
141  Solid = 1,
142  Dashed = 2,
143  Beveled = 4,
144  Inset = 8,
145  Underline = 16
146  };
147 
151  enum LineEffect {
152  NoEffect = 1,
153  Cloudy = 2
154  };
155 
160  Reply = 1,
161  Group = 2,
162  Delete = 4
163  };
164 
169  None = 1,
170  Marked = 2,
171  Unmarked = 4,
172  Accepted = 8,
173  Rejected = 16,
174  Cancelled = 32,
175  Completed = 64
176  };
177 
192  };
193 
202  typedef void (*DisposeDataFunction)(const Okular::Annotation *);
203 
207  virtual ~Annotation();
208 
212  void setAuthor(const QString &author);
213 
217  QString author() const;
218 
222  void setContents(const QString &contents);
223 
227  QString contents() const;
228 
232  void setUniqueName(const QString &name);
233 
237  QString uniqueName() const;
238 
244  void setModificationDate(const QDateTime &date);
245 
249  QDateTime modificationDate() const;
250 
256  void setCreationDate(const QDateTime &date);
257 
261  QDateTime creationDate() const;
262 
267  void setFlags(int flags);
268 
273  int flags() const;
274 
278  void setBoundingRectangle(const NormalizedRect &rectangle);
279 
283  NormalizedRect boundingRectangle() const;
284 
291  NormalizedRect transformedBoundingRectangle() const;
292 
298  void translate(const NormalizedPoint &coord);
299 
307  void adjust(const NormalizedPoint &deltaCoord1, const NormalizedPoint &deltaCoord2);
308 
313  class OKULARCORE_EXPORT Style
314  {
315  public:
319  Style();
320 
324  ~Style();
325 
326  Style(const Style &other);
327  Style &operator=(const Style &other);
328 
332  void setColor(const QColor &color);
333 
337  QColor color() const;
338 
342  void setOpacity(double opacity);
343 
347  double opacity() const;
348 
352  void setWidth(double width);
353 
357  double width() const;
358 
362  void setLineStyle(LineStyle style);
363 
367  LineStyle lineStyle() const;
368 
372  void setXCorners(double xCorners);
373 
377  double xCorners() const;
378 
382  void setYCorners(double yCorners);
383 
387  double yCorners() const;
388 
392  void setMarks(int marks);
393 
397  int marks() const;
398 
402  void setSpaces(int spaces);
403 
407  int spaces() const;
408 
412  void setLineEffect(LineEffect effect);
413 
417  LineEffect lineEffect() const;
418 
422  void setEffectIntensity(double intensity);
423 
427  double effectIntensity() const;
428 
429  private:
430  class Private;
431  Private *const d;
432  };
433 
437  Style &style();
438 
442  const Style &style() const;
443 
448  class OKULARCORE_EXPORT Window
449  {
450  public:
454  Window();
455 
459  ~Window();
460 
461  Window(const Window &other);
462  Window &operator=(const Window &other);
463 
467  void setFlags(int flags);
468 
472  int flags() const;
473 
477  void setTopLeft(const NormalizedPoint &point);
478 
482  NormalizedPoint topLeft() const;
483 
487  void setWidth(int width);
488 
492  int width() const;
493 
497  void setHeight(int height);
498 
502  int height() const;
503 
507  void setTitle(const QString &title);
508 
512  QString title() const;
513 
517  void setSummary(const QString &summary);
518 
522  QString summary() const;
523 
524  private:
525  class Private;
526  Private *const d;
527  };
528 
532  Window &window();
533 
537  const Window &window() const;
538 
543  class OKULARCORE_EXPORT Revision
544  {
545  public:
549  Revision();
550 
554  ~Revision();
555 
556  Revision(const Revision &other);
557  Revision &operator=(const Revision &other);
558 
562  void setAnnotation(Annotation *annotation);
563 
567  Annotation *annotation() const;
568 
573  void setScope(RevisionScope scope);
574 
578  RevisionScope scope() const;
579 
584  void setType(RevisionType type);
585 
589  RevisionType type() const;
590 
591  private:
592  class Private;
593  Private *const d;
594  };
595 
599  QLinkedList<Revision> &revisions();
600 
604  const QLinkedList<Revision> &revisions() const;
605 
617  void setNativeId(const QVariant &id);
618 
624  QVariant nativeId() const;
625 
634  void setDisposeDataFunction(DisposeDataFunction func);
635 
641  bool canBeMoved() const;
642 
646  bool canBeResized() const;
647 
653  bool openDialogAfterCreation() const;
654 
658  virtual SubType subType() const = 0;
659 
663  virtual void store(QDomNode &node, QDomDocument &document) const;
664 
670  QDomNode getAnnotationPropertiesDomNode() const;
671 
677  void setAnnotationProperties(const QDomNode &node);
678 
679 protected:
681  Annotation(AnnotationPrivate &dd);
682  Annotation(AnnotationPrivate &dd, const QDomNode &description);
683  Q_DECLARE_PRIVATE(Annotation)
684  AnnotationPrivate *d_ptr;
686 
687 private:
688  Q_DISABLE_COPY(Annotation)
689 };
690 
699 class OKULARCORE_EXPORT AnnotationProxy
700 {
701 public:
702  enum Capability {
705  Removal
706  };
707 
708  AnnotationProxy();
709 
713  virtual ~AnnotationProxy();
714 
715  AnnotationProxy(const AnnotationProxy &) = delete;
716  AnnotationProxy &operator=(const AnnotationProxy &) = delete;
717 
721  virtual bool supports(Capability capability) const = 0;
722 
728  virtual void notifyAddition(Annotation *annotation, int page) = 0;
729 
738  virtual void notifyModification(const Annotation *annotation, int page, bool appearanceChanged) = 0;
739 
745  virtual void notifyRemoval(Annotation *annotation, int page) = 0;
746 };
747 
748 class OKULARCORE_EXPORT TextAnnotation : public Annotation
749 {
750 public:
754  enum TextType {
755  Linked,
756  InPlace
757  };
758 
762  enum InplaceIntent {
763  Unknown,
764  Callout,
765  TypeWriter
766  };
767 
771  TextAnnotation();
772 
776  explicit TextAnnotation(const QDomNode &description);
777 
781  ~TextAnnotation() override;
782 
787  void setTextType(TextType type);
788 
792  TextType textType() const;
793 
797  void setTextIcon(const QString &icon);
798 
802  QString textIcon() const;
803 
807  void setTextFont(const QFont &font);
808 
812  QFont textFont() const;
813 
819  void setTextColor(const QColor &color);
820 
826  QColor textColor() const;
827 
832  void setInplaceAlignment(int alignment);
833 
838  int inplaceAlignment() const;
839 
845  void setInplaceCallout(const NormalizedPoint &point, int index);
846 
852  NormalizedPoint inplaceCallout(int index) const;
853 
859  NormalizedPoint transformedInplaceCallout(int index) const;
860 
865  void setInplaceIntent(InplaceIntent intent);
866 
870  InplaceIntent inplaceIntent() const;
871 
875  SubType subType() const override;
876 
880  void store(QDomNode &node, QDomDocument &document) const override;
881 
882 private:
883  Q_DECLARE_PRIVATE(TextAnnotation)
884  Q_DISABLE_COPY(TextAnnotation)
885 };
886 
887 class OKULARCORE_EXPORT LineAnnotation : public Annotation
888 {
889 public:
893  enum TermStyle {
894  Square,
895  Circle,
896  Diamond,
897  OpenArrow,
898  ClosedArrow,
899  None,
900  Butt,
901  ROpenArrow,
902  RClosedArrow,
903  Slash
904  };
905 
909  enum LineIntent {
910  Unknown,
911  Arrow,
912  Dimension,
913  PolygonCloud
914  };
915 
919  LineAnnotation();
920 
924  explicit LineAnnotation(const QDomNode &description);
925 
929  ~LineAnnotation() override;
930 
934  void setLinePoints(const QLinkedList<NormalizedPoint> &points);
935 
939  QLinkedList<NormalizedPoint> linePoints() const;
940 
945  QLinkedList<NormalizedPoint> transformedLinePoints() const;
946 
951  void setLineStartStyle(TermStyle style);
952 
956  TermStyle lineStartStyle() const;
957 
962  void setLineEndStyle(TermStyle style);
963 
967  TermStyle lineEndStyle() const;
968 
972  void setLineClosed(bool closed);
973 
977  bool lineClosed() const;
978 
982  void setLineInnerColor(const QColor &color);
983 
987  QColor lineInnerColor() const;
988 
992  void setLineLeadingForwardPoint(double point);
993 
997  double lineLeadingForwardPoint() const;
998 
1002  void setLineLeadingBackwardPoint(double point);
1003 
1007  double lineLeadingBackwardPoint() const;
1008 
1012  void setShowCaption(bool shown);
1013 
1017  bool showCaption() const;
1018 
1023  void setLineIntent(LineIntent intent);
1024 
1028  LineIntent lineIntent() const;
1029 
1033  SubType subType() const override;
1034 
1038  void store(QDomNode &node, QDomDocument &document) const override;
1039 
1040 private:
1041  Q_DECLARE_PRIVATE(LineAnnotation)
1042  Q_DISABLE_COPY(LineAnnotation)
1043 };
1044 
1045 class OKULARCORE_EXPORT GeomAnnotation : public Annotation
1046 {
1047 public:
1048  // common enums
1049  enum GeomType {
1050  InscribedSquare,
1051  InscribedCircle
1052  };
1053 
1057  GeomAnnotation();
1058 
1062  explicit GeomAnnotation(const QDomNode &description);
1063 
1067  ~GeomAnnotation() override;
1068 
1073  void setGeometricalType(GeomType type);
1074 
1078  GeomType geometricalType() const;
1079 
1083  void setGeometricalInnerColor(const QColor &color);
1084 
1088  QColor geometricalInnerColor() const;
1089 
1093  SubType subType() const override;
1094 
1099  void store(QDomNode &node, QDomDocument &document) const override;
1100 
1101 private:
1102  Q_DECLARE_PRIVATE(GeomAnnotation)
1103  Q_DISABLE_COPY(GeomAnnotation)
1104 };
1105 
1106 class OKULARCORE_EXPORT HighlightAnnotation : public Annotation
1107 {
1108 public:
1112  enum HighlightType {
1113  Highlight,
1114  Squiggly,
1115  Underline,
1116  StrikeOut
1117  };
1118 
1122  HighlightAnnotation();
1123 
1127  explicit HighlightAnnotation(const QDomNode &description);
1128 
1132  ~HighlightAnnotation() override;
1133 
1138  void setHighlightType(HighlightType type);
1139 
1143  HighlightType highlightType() const;
1144 
1159  class OKULARCORE_EXPORT Quad
1160  {
1161  public:
1165  Quad();
1166 
1170  ~Quad();
1171 
1172  Quad(const Quad &other);
1173  Quad &operator=(const Quad &other);
1174 
1180  void setPoint(const NormalizedPoint &point, int index);
1181 
1187  NormalizedPoint point(int index) const;
1188 
1194  NormalizedPoint transformedPoint(int index) const;
1195 
1199  void setCapStart(bool value);
1200 
1204  bool capStart() const;
1205 
1209  void setCapEnd(bool value);
1210 
1214  bool capEnd() const;
1215 
1219  void setFeather(double width);
1220 
1224  double feather() const;
1225 
1233  void transform(const QTransform &matrix);
1234 
1235  private:
1236  class Private;
1237  Private *const d;
1238  };
1239 
1243  QList<Quad> &highlightQuads();
1244 
1249  const QList<Quad> &highlightQuads() const;
1250 
1254  SubType subType() const override;
1255 
1260  void store(QDomNode &node, QDomDocument &document) const override;
1261 
1262 private:
1263  Q_DECLARE_PRIVATE(HighlightAnnotation)
1264  Q_DISABLE_COPY(HighlightAnnotation)
1265 };
1266 
1267 class OKULARCORE_EXPORT StampAnnotation : public Annotation
1268 {
1269 public:
1273  StampAnnotation();
1274 
1278  explicit StampAnnotation(const QDomNode &description);
1279 
1283  ~StampAnnotation() override;
1284 
1288  void setStampIconName(const QString &name);
1289 
1293  QString stampIconName() const;
1294 
1298  SubType subType() const override;
1299 
1304  void store(QDomNode &node, QDomDocument &document) const override;
1305 
1306 private:
1307  Q_DECLARE_PRIVATE(StampAnnotation)
1308  Q_DISABLE_COPY(StampAnnotation)
1309 };
1310 
1311 class OKULARCORE_EXPORT InkAnnotation : public Annotation
1312 {
1313 public:
1317  InkAnnotation();
1318 
1322  explicit InkAnnotation(const QDomNode &description);
1323 
1327  ~InkAnnotation() override;
1328 
1332  void setInkPaths(const QList<QLinkedList<NormalizedPoint>> &paths);
1333 
1337  QList<QLinkedList<NormalizedPoint>> inkPaths() const;
1338 
1343  QList<QLinkedList<NormalizedPoint>> transformedInkPaths() const;
1344 
1348  SubType subType() const override;
1349 
1354  void store(QDomNode &node, QDomDocument &document) const override;
1355 
1356 private:
1357  Q_DECLARE_PRIVATE(InkAnnotation)
1358  Q_DISABLE_COPY(InkAnnotation)
1359 };
1360 
1361 class OKULARCORE_EXPORT CaretAnnotation : public Annotation
1362 {
1363 public:
1367  enum CaretSymbol {
1368  None,
1369  P
1370  };
1371 
1375  CaretAnnotation();
1376 
1380  explicit CaretAnnotation(const QDomNode &description);
1381 
1385  ~CaretAnnotation() override;
1386 
1390  void setCaretSymbol(CaretAnnotation::CaretSymbol symbol);
1391 
1395  CaretAnnotation::CaretSymbol caretSymbol() const;
1396 
1400  SubType subType() const override;
1401 
1406  void store(QDomNode &node, QDomDocument &document) const override;
1407 
1408 private:
1409  Q_DECLARE_PRIVATE(CaretAnnotation)
1410  Q_DISABLE_COPY(CaretAnnotation)
1411 };
1412 
1413 class OKULARCORE_EXPORT FileAttachmentAnnotation : public Annotation
1414 {
1415 public:
1419  FileAttachmentAnnotation();
1423  explicit FileAttachmentAnnotation(const QDomNode &description);
1427  ~FileAttachmentAnnotation() override;
1428 
1432  QString fileIconName() const;
1433 
1437  void setFileIconName(const QString &iconName);
1438 
1442  EmbeddedFile *embeddedFile() const;
1443 
1448  void setEmbeddedFile(EmbeddedFile *ef);
1449 
1453  SubType subType() const override;
1454 
1459  void store(QDomNode &node, QDomDocument &document) const override;
1460 
1461 private:
1462  Q_DECLARE_PRIVATE(FileAttachmentAnnotation)
1463  Q_DISABLE_COPY(FileAttachmentAnnotation)
1464 };
1465 
1473 class OKULARCORE_EXPORT SoundAnnotation : public Annotation
1474 {
1475 public:
1479  SoundAnnotation();
1483  explicit SoundAnnotation(const QDomNode &description);
1487  ~SoundAnnotation() override;
1488 
1492  QString soundIconName() const;
1493 
1497  void setSoundIconName(const QString &iconName);
1498 
1502  Sound *sound() const;
1503 
1508  void setSound(Sound *s);
1509 
1513  SubType subType() const override;
1514 
1519  void store(QDomNode &node, QDomDocument &document) const override;
1520 
1521 private:
1522  Q_DECLARE_PRIVATE(SoundAnnotation)
1523  Q_DISABLE_COPY(SoundAnnotation)
1524 };
1525 
1533 class OKULARCORE_EXPORT MovieAnnotation : public Annotation
1534 {
1535 public:
1539  MovieAnnotation();
1543  explicit MovieAnnotation(const QDomNode &description);
1547  ~MovieAnnotation() override;
1551  Movie *movie() const;
1555  void setMovie(Movie *movie);
1559  SubType subType() const override;
1564  void store(QDomNode &parentNode, QDomDocument &document) const override;
1565 
1566 private:
1567  Q_DECLARE_PRIVATE(MovieAnnotation)
1568  Q_DISABLE_COPY(MovieAnnotation)
1569 };
1570 
1579 class OKULARCORE_EXPORT ScreenAnnotation : public Annotation
1580 {
1581 public:
1585  ScreenAnnotation();
1586 
1590  explicit ScreenAnnotation(const QDomNode &description);
1591 
1595  ~ScreenAnnotation() override;
1596 
1600  SubType subType() const override;
1601 
1606  void store(QDomNode &parentNode, QDomDocument &document) const override;
1607 
1613  void setAction(Action *action);
1614 
1620  Action *action() const;
1621 
1627  void setAdditionalAction(AdditionalActionType type, Action *action);
1628 
1634  Action *additionalAction(AdditionalActionType type) const;
1635 
1636 private:
1637  Q_DECLARE_PRIVATE(ScreenAnnotation)
1638  Q_DISABLE_COPY(ScreenAnnotation)
1639 };
1640 
1648 class OKULARCORE_EXPORT WidgetAnnotation : public Annotation
1649 {
1650 public:
1654  WidgetAnnotation();
1655 
1659  explicit WidgetAnnotation(const QDomNode &description);
1660 
1664  ~WidgetAnnotation() override;
1665 
1669  SubType subType() const override;
1670 
1675  void store(QDomNode &parentNode, QDomDocument &document) const override;
1676 
1682  void setAdditionalAction(AdditionalActionType type, Action *action);
1683 
1689  Action *additionalAction(AdditionalActionType type) const;
1690 
1691 private:
1692  Q_DECLARE_PRIVATE(WidgetAnnotation)
1693  Q_DISABLE_COPY(WidgetAnnotation)
1694 };
1695 
1703 class OKULARCORE_EXPORT RichMediaAnnotation : public Annotation
1704 {
1705 public:
1710 
1714  explicit RichMediaAnnotation(const QDomNode &description);
1715 
1719  ~RichMediaAnnotation() override;
1720 
1724  SubType subType() const override;
1725 
1730  void store(QDomNode &parentNode, QDomDocument &document) const override;
1731 
1735  Movie *movie() const;
1736 
1740  void setMovie(Movie *movie);
1741 
1745  void setEmbeddedFile(EmbeddedFile *embeddedFile);
1746 
1750  EmbeddedFile *embeddedFile() const;
1751 
1752 private:
1753  Q_DECLARE_PRIVATE(RichMediaAnnotation)
1754  Q_DISABLE_COPY(RichMediaAnnotation)
1755 };
1756 
1757 }
1758 
1759 #endif
Performed when the cursor enters the annotation&#39;s active area.
Definition: annotations.h:186
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:119
The Revision class contains all information about the revision of the annotation. ...
Definition: annotations.h:543
Performed when the cursor exists the annotation&#39;s active area.
Definition: annotations.h:187
Performed when the annotation loses the input focus.
Definition: annotations.h:191
A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.
Definition: area.h:191
Native annotation interface.
Definition: annotations.h:699
global.h
Definition: action.h:19
An embedded file into the document.
Definition: document.h:1385
The Window class contains all information about the popup window of the annotation that is used to ed...
Definition: annotations.h:448
RevisionType
Describes the type of revision information.
Definition: annotations.h:168
SubType
Describes the type of annotation as defined in PDF standard.
Definition: annotations.h:103
This class describes the object rectangle for an annotation.
Definition: area.h:551
Performed when the page containing the annotation is opened.
Definition: annotations.h:184
Sound annotation.
Definition: annotations.h:1473
Performed when the mouse button is pressed inside the annotation&#39;s active area.
Definition: annotations.h:188
Generator can edit native annotations.
Definition: annotations.h:704
An area with normalized coordinates that contains a reference to an object.
Definition: area.h:453
Performed when the mouse button is released inside the annotation&#39;s active area.
Definition: annotations.h:189
RichMedia annotation.
Definition: annotations.h:1703
Performed when the annotation receives the input focus.
Definition: annotations.h:190
The Document.
Definition: document.h:190
Collector for all the data belonging to a page.
Definition: page.h:52
RevisionScope
Describes the scope of revision information.
Definition: annotations.h:159
Contains information about a sound object.
Definition: sound.h:26
AdditionalActionType
Describes the type of additional actions.
Definition: annotations.h:183
Encapsulates data that describes an action.
Definition: action.h:43
Movie annotation.
Definition: annotations.h:1533
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:88
Performed when the page containing the annotation is closed.
Definition: annotations.h:185
LineStyle
Describes possible line styles for.
Definition: annotations.h:140
Helper class for (recursive) annotation retrieval/storage.
Definition: annotations.h:53
The Style class contains all information about style of the annotation.
Definition: annotations.h:313
Generator can create native annotations.
Definition: annotations.h:703
Screen annotation.
Definition: annotations.h:1579
LineEffect
Describes possible line effects for.
Definition: annotations.h:151
Flag
Describes additional properties of an annotation.
Definition: annotations.h:123
Describes a highlight quad of a text markup annotation.
Definition: annotations.h:1159
Widget annotation.
Definition: annotations.h:1648
Contains information about a movie object.
Definition: movie.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Nov 21 2020 22:36:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.