7#include "annotations.h"
8#include "annotations_p.h"
11#include <QApplication>
16#include <QStandardPaths>
17#include <QSvgRenderer>
25#include "document_p.h"
41 return ((b.
x - a.
x) * (c.
y - a.
y) - (b.
y - a.
y) * (c.
x - a.
x)) > 0;
49static double distanceSqr(
double x,
double y,
double xScale,
double yScale,
const QList<NormalizedPoint> &path)
62 if (thisDistance < distance) {
92static double strokeDistance(
double distance,
double penWidth)
94 return fmax(distance - pow(penWidth, 2), 0);
107 int typeNumber = annElement.
attribute(QStringLiteral(
"type")).
toInt();
108 switch (typeNumber) {
110 annotation =
new TextAnnotation(annElement);
113 annotation =
new LineAnnotation(annElement);
116 annotation =
new GeomAnnotation(annElement);
119 annotation =
new HighlightAnnotation(annElement);
122 annotation =
new StampAnnotation(annElement);
125 annotation =
new InkAnnotation(annElement);
128 annotation =
new CaretAnnotation(annElement);
142 ann->
store(annElement, document);
151 if (element.
tagName() == name) {
163 if (annotation->
subType() ==
Annotation::AText && (
static_cast<const TextAnnotation *
>(annotation)->textType() == TextAnnotation::Linked)) {
167 return rect24.
united(rect);
177 static std::unique_ptr<QSvgRenderer> svgStampFile;
178 if (!svgStampFile.get()) {
181 svgStampFile = std::make_unique<QSvgRenderer>(stampFile);
182 if (!svgStampFile->isValid()) {
183 svgStampFile.reset();
206 pixmap.
load(nameOrPath);
218AnnotationProxy::AnnotationProxy()
228class Annotation::Style::Private
240 , m_effectIntensity(1.0)
253 double m_effectIntensity;
274 if (
this != &other) {
293 d->m_opacity = opacity;
323 d->m_xCorners = xCorners;
328 return d->m_xCorners;
333 d->m_yCorners = yCorners;
338 return d->m_yCorners;
353 d->m_spaces = spaces;
363 d->m_effect = effect;
373 d->m_effectIntensity = intensity;
378 return d->m_effectIntensity;
381class Annotation::Window::Private
417 if (
this != &other) {
436 d->m_topLeft = point;
456 d->m_height = height;
476 d->m_summary = summary;
484class Annotation::Revision::Private
488 : m_annotation(nullptr)
495 RevisionScope m_scope;
517 if (
this != &other) {
526 d->m_annotation = annotation;
531 return d->m_annotation;
554AnnotationPrivate::AnnotationPrivate()
557 , m_disposeFunc(nullptr)
561AnnotationPrivate::~AnnotationPrivate()
564 if (m_revisions.isEmpty()) {
569 delete revision.annotation();
573AnnotationPrivate *AnnotationPrivate::get(
Annotation *a)
575 return a ? a->d_ptr :
nullptr;
578Annotation::Annotation(AnnotationPrivate &dd)
583Annotation::Annotation(AnnotationPrivate &dd,
const QDomNode &description)
586 d_ptr->setAnnotationProperties(description);
591 if (d_ptr->m_disposeFunc) {
592 d_ptr->m_disposeFunc(
this);
619 return d->m_contents;
625 d->m_uniqueName = name;
631 return d->m_uniqueName;
637 d->m_modifyDate = date;
643 return d->m_modifyDate;
649 d->m_creationDate = date;
655 return d->m_creationDate;
673 d->m_boundary = rectangle;
674 d->resetTransformation();
676 d->transform(d->m_page->rotationMatrix());
683 return d->m_boundary;
689 return d->m_transformedBoundary;
696 d->resetTransformation();
698 d->transform(d->m_page->rotationMatrix());
705 d->adjust(deltaCoord1, deltaCoord2);
706 d->resetTransformation();
708 d->transform(d->m_page->rotationMatrix());
715 return d->openDialogAfterCreation();
745 return d->m_revisions;
751 return d->m_revisions;
763 return d->m_nativeId;
769 d->m_disposeFunc = func;
775 d->m_nativeData = std::move(data);
781 return d->m_nativeData.get();
789 if (!d->m_page || !d->m_page->m_doc->m_parent->canModifyPageAnnotation(
this)) {
806 if (!d->m_page || !d->m_page->m_doc->m_parent->canModifyPageAnnotation(
this)) {
810 return d->canBeResized();
821 if (!d->m_author.isEmpty()) {
824 if (!d->m_contents.isEmpty()) {
825 e.
setAttribute(QStringLiteral(
"contents"), d->m_contents);
827 if (!d->m_uniqueName.isEmpty()) {
828 e.
setAttribute(QStringLiteral(
"uniqueName"), d->m_uniqueName);
830 if (d->m_modifyDate.isValid()) {
833 if (d->m_creationDate.isValid()) {
841 if (d->m_style.color().isValid()) {
844 if (d->m_style.opacity() != 1.0) {
857 if (d->m_style.width() != 1 || d->m_style.lineStyle() !=
Solid || d->m_style.xCorners() != 0 || d->m_style.yCorners() != 0.0 || d->m_style.marks() != 3 || d->m_style.spaces() != 0) {
861 psE.
setAttribute(QStringLiteral(
"style"), (
int)d->m_style.lineStyle());
864 psE.
setAttribute(QStringLiteral(
"marks"), d->m_style.marks());
865 psE.
setAttribute(QStringLiteral(
"spaces"), d->m_style.spaces());
869 if (d->m_style.lineEffect() !=
NoEffect || d->m_style.effectIntensity() != 1.0) {
872 peE.
setAttribute(QStringLiteral(
"effect"), (
int)d->m_style.lineEffect());
877 if (d->m_window.flags() != -1 || !d->m_window.title().isEmpty() || !d->m_window.summary().isEmpty()) {
880 wE.
setAttribute(QStringLiteral(
"flags"), d->m_window.flags());
883 wE.
setAttribute(QStringLiteral(
"width"), d->m_window.width());
884 wE.
setAttribute(QStringLiteral(
"height"), d->m_window.height());
885 wE.
setAttribute(QStringLiteral(
"title"), d->m_window.title());
886 wE.
setAttribute(QStringLiteral(
"summary"), d->m_window.summary());
890 if (d->m_revisions.isEmpty()) {
895 for (
const Revision &revision : std::as_const(d->m_revisions)) {
900 r.
setAttribute(QStringLiteral(
"revScope"), (
int)revision.scope());
901 r.
setAttribute(QStringLiteral(
"revType"), (
int)revision.type());
919 Okular::PagePrivate *p = d_ptr->m_page;
920 QVariant nativeID = d_ptr->m_nativeId;
925 AnnotationPrivate *new_d_ptr = d_ptr->getNewAnnotationPrivate();
930 d_ptr->setAnnotationProperties(node);
934 d_ptr->m_nativeId = nativeID;
935 d_ptr->m_flags = d_ptr->m_flags | internalFlags;
936 d_ptr->m_disposeFunc = disposeFunc;
939 d_ptr->transform(d_ptr->m_page->rotationMatrix());
942double AnnotationPrivate::distanceSqr(
double x,
double y,
double xScale,
double yScale)
const
944 return m_transformedBoundary.distanceSqr(x, y, xScale, yScale);
947void AnnotationPrivate::annotationTransform(
const QTransform &matrix)
949 resetTransformation();
953void AnnotationPrivate::transform(
const QTransform &matrix)
955 m_transformedBoundary.transform(matrix);
958void AnnotationPrivate::baseTransform(
const QTransform &matrix)
960 m_boundary.transform(matrix);
963void AnnotationPrivate::resetTransformation()
965 m_transformedBoundary = m_boundary;
970 m_boundary.left = m_boundary.left + coord.
x;
971 m_boundary.right = m_boundary.right + coord.
x;
972 m_boundary.top = m_boundary.top + coord.
y;
973 m_boundary.bottom = m_boundary.bottom + coord.
y;
978 m_boundary.left = m_boundary.left + qBound(-m_boundary.left, deltaCoord1.
x, m_boundary.right - m_boundary.left);
979 m_boundary.top = m_boundary.top + qBound(-m_boundary.top, deltaCoord1.
y, m_boundary.bottom - m_boundary.top);
981 m_boundary.right = m_boundary.right + qBound(m_boundary.left - m_boundary.right, deltaCoord2.
x, 1. - m_boundary.right);
982 m_boundary.bottom = m_boundary.bottom + qBound(m_boundary.top - m_boundary.bottom, deltaCoord2.
y, 1. - m_boundary.bottom);
985bool AnnotationPrivate::openDialogAfterCreation()
const
990void AnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
1000 m_author = e.
attribute(QStringLiteral(
"author"));
1003 m_contents = e.
attribute(QStringLiteral(
"contents"));
1006 m_uniqueName = e.
attribute(QStringLiteral(
"uniqueName"));
1023 m_style.setOpacity(e.
attribute(QStringLiteral(
"opacity")).toDouble());
1039 m_style.setWidth(ee.
attribute(QStringLiteral(
"width")).toDouble());
1041 m_style.setXCorners(ee.
attribute(QStringLiteral(
"xcr")).toDouble());
1042 m_style.setYCorners(ee.
attribute(QStringLiteral(
"ycr")).toDouble());
1043 m_style.setMarks(ee.
attribute(QStringLiteral(
"marks")).toInt());
1044 m_style.setSpaces(ee.
attribute(QStringLiteral(
"spaces")).toInt());
1049 m_style.setEffectIntensity(ee.
attribute(QStringLiteral(
"intensity")).toDouble());
1053 m_window.setFlags(ee.
attribute(QStringLiteral(
"flags")).toInt());
1055 m_window.setWidth(ee.
attribute(QStringLiteral(
"width")).toInt());
1056 m_window.setHeight(ee.
attribute(QStringLiteral(
"height")).toInt());
1057 m_window.setTitle(ee.
attribute(QStringLiteral(
"title")));
1058 m_window.setSummary(ee.
attribute(QStringLiteral(
"summary")));
1078 m_revisions.append(revision);
1082 m_transformedBoundary = m_boundary;
1085bool AnnotationPrivate::canBeResized()
const
1094class Okular::TextAnnotationPrivate :
public Okular::AnnotationPrivate
1097 TextAnnotationPrivate()
1098 : AnnotationPrivate()
1099 , m_textType(TextAnnotation::Linked)
1100 , m_textIcon(QStringLiteral(
"Comment"))
1102 , m_inplaceIntent(TextAnnotation::
Unknown)
1107 void baseTransform(
const QTransform &matrix)
override;
1108 void resetTransformation()
override;
1110 bool openDialogAfterCreation()
const override;
1111 void setAnnotationProperties(
const QDomNode &node)
override;
1112 bool canBeResized()
const override;
1113 AnnotationPrivate *getNewAnnotationPrivate()
override;
1115 TextAnnotation::TextType m_textType;
1122 TextAnnotation::InplaceIntent m_inplaceIntent;
1128TextAnnotation::TextAnnotation()
1133TextAnnotation::TextAnnotation(
const QDomNode &description)
1134 :
Annotation(*new TextAnnotationPrivate(), description)
1138TextAnnotation::~TextAnnotation()
1142void TextAnnotation::setTextType(TextType textType)
1144 Q_D(TextAnnotation);
1145 d->m_textType = textType;
1148TextAnnotation::TextType TextAnnotation::textType()
const
1150 Q_D(
const TextAnnotation);
1151 return d->m_textType;
1154void TextAnnotation::setTextIcon(
const QString &icon)
1156 Q_D(TextAnnotation);
1157 d->m_textIcon = icon;
1160QString TextAnnotation::textIcon()
const
1162 Q_D(
const TextAnnotation);
1163 return d->m_textIcon;
1166void TextAnnotation::setTextFont(
const QFont &font)
1168 Q_D(TextAnnotation);
1169 d->m_textFont = font;
1172QFont TextAnnotation::textFont()
const
1174 Q_D(
const TextAnnotation);
1175 return d->m_textFont;
1178void TextAnnotation::setTextColor(
const QColor &color)
1180 Q_D(TextAnnotation);
1181 d->m_textColor = color;
1184QColor TextAnnotation::textColor()
const
1186 Q_D(
const TextAnnotation);
1187 return d->m_textColor;
1190void TextAnnotation::setInplaceAlignment(
int alignment)
1192 Q_D(TextAnnotation);
1193 d->m_inplaceAlign = alignment;
1196int TextAnnotation::inplaceAlignment()
const
1198 Q_D(
const TextAnnotation);
1199 return d->m_inplaceAlign;
1202void TextAnnotation::setInplaceCallout(
const NormalizedPoint &point,
int index)
1204 if (index < 0 || index > 2) {
1208 Q_D(TextAnnotation);
1209 d->m_inplaceCallout[index] = point;
1214 if (index < 0 || index > 2) {
1218 Q_D(
const TextAnnotation);
1219 return d->m_inplaceCallout[index];
1222NormalizedPoint TextAnnotation::transformedInplaceCallout(
int index)
const
1224 if (index < 0 || index > 2) {
1228 Q_D(
const TextAnnotation);
1229 return d->m_transformedInplaceCallout[index];
1232void TextAnnotation::setInplaceIntent(InplaceIntent intent)
1234 Q_D(TextAnnotation);
1235 d->m_inplaceIntent = intent;
1238TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent()
const
1240 Q_D(
const TextAnnotation);
1241 return d->m_inplaceIntent;
1251 Q_D(
const TextAnnotation);
1260 if (d->m_textType != Linked) {
1261 textElement.
setAttribute(QStringLiteral(
"type"), (
int)d->m_textType);
1263 if (!d->m_textIcon.isEmpty()) {
1264 textElement.
setAttribute(QStringLiteral(
"icon"), d->m_textIcon);
1267 textElement.
setAttribute(QStringLiteral(
"font"), d->m_textFont.toString());
1269 if (d->m_textColor.isValid()) {
1270 textElement.
setAttribute(QStringLiteral(
"fontColor"), d->m_textColor.name());
1272 if (d->m_inplaceAlign) {
1273 textElement.
setAttribute(QStringLiteral(
"align"), d->m_inplaceAlign);
1275 if (d->m_inplaceIntent != Unknown) {
1276 textElement.
setAttribute(QStringLiteral(
"intent"), (
int)d->m_inplaceIntent);
1280 if (d->m_inplaceCallout[0].x != 0.0) {
1292void TextAnnotationPrivate::transform(
const QTransform &matrix)
1294 AnnotationPrivate::transform(matrix);
1297 np.transform(matrix);
1301void TextAnnotationPrivate::baseTransform(
const QTransform &matrix)
1303 AnnotationPrivate::baseTransform(matrix);
1306 np.transform(matrix);
1310void TextAnnotationPrivate::resetTransformation()
1312 AnnotationPrivate::resetTransformation();
1314 for (
int i = 0; i < 3; ++i) {
1315 m_transformedInplaceCallout[i] = m_inplaceCallout[i];
1321 AnnotationPrivate::translate(coord);
1323#define ADD_COORD(c1, c2) \
1325 c1.x = c1.x + c2.x; \
1326 c1.y = c1.y + c2.y; \
1328 ADD_COORD(m_inplaceCallout[0], coord)
1329 ADD_COORD(m_inplaceCallout[1], coord)
1330 ADD_COORD(m_inplaceCallout[2], coord)
1334bool TextAnnotationPrivate::openDialogAfterCreation()
const
1336 return (m_textType == Okular::TextAnnotation::Linked) || (m_inplaceIntent == TextAnnotation::InplaceIntent::Unknown);
1339void TextAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
1341 Okular::AnnotationPrivate::setAnnotationProperties(node);
1354 m_textType = (TextAnnotation::TextType)e.
attribute(QStringLiteral(
"type")).
toInt();
1357 m_textIcon = e.
attribute(QStringLiteral(
"icon"));
1369 m_inplaceIntent = (TextAnnotation::InplaceIntent)e.
attribute(QStringLiteral(
"intent")).
toInt();
1394 for (
int i = 0; i < 3; ++i) {
1395 m_transformedInplaceCallout[i] = m_inplaceCallout[i];
1399bool TextAnnotationPrivate::canBeResized()
const
1401 if (m_textType != TextAnnotation::Linked) {
1407AnnotationPrivate *TextAnnotationPrivate::getNewAnnotationPrivate()
1409 return new TextAnnotationPrivate();
1414class Okular::LineAnnotationPrivate :
public Okular::AnnotationPrivate
1417 LineAnnotationPrivate()
1418 : AnnotationPrivate()
1419 , m_lineStartStyle(LineAnnotation::
None)
1420 , m_lineEndStyle(LineAnnotation::
None)
1421 , m_lineClosed(false)
1422 , m_lineShowCaption(false)
1423 , m_lineLeadingFwdPt(0)
1424 , m_lineLeadingBackPt(0)
1425 , m_lineIntent(LineAnnotation::
Unknown)
1430 void baseTransform(
const QTransform &matrix)
override;
1431 void resetTransformation()
override;
1433 double distanceSqr(
double x,
double y,
double xScale,
double yScale)
const override;
1434 void setAnnotationProperties(
const QDomNode &node)
override;
1435 AnnotationPrivate *getNewAnnotationPrivate()
override;
1439 LineAnnotation::TermStyle m_lineStartStyle;
1440 LineAnnotation::TermStyle m_lineEndStyle;
1441 bool m_lineClosed : 1;
1442 bool m_lineShowCaption : 1;
1444 double m_lineLeadingFwdPt;
1445 double m_lineLeadingBackPt;
1446 LineAnnotation::LineIntent m_lineIntent;
1449LineAnnotation::LineAnnotation()
1454LineAnnotation::LineAnnotation(
const QDomNode &description)
1455 :
Annotation(*new LineAnnotationPrivate(), description)
1459LineAnnotation::~LineAnnotation()
1465 Q_D(LineAnnotation);
1466 d->m_linePoints = points;
1471 Q_D(
const LineAnnotation);
1472 return d->m_linePoints;
1477 Q_D(
const LineAnnotation);
1478 return d->m_transformedLinePoints;
1481void LineAnnotation::setLineStartStyle(TermStyle style)
1483 Q_D(LineAnnotation);
1484 d->m_lineStartStyle =
style;
1487LineAnnotation::TermStyle LineAnnotation::lineStartStyle()
const
1489 Q_D(
const LineAnnotation);
1490 return d->m_lineStartStyle;
1493void LineAnnotation::setLineEndStyle(TermStyle style)
1495 Q_D(LineAnnotation);
1496 d->m_lineEndStyle =
style;
1499LineAnnotation::TermStyle LineAnnotation::lineEndStyle()
const
1501 Q_D(
const LineAnnotation);
1502 return d->m_lineEndStyle;
1505void LineAnnotation::setLineClosed(
bool closed)
1507 Q_D(LineAnnotation);
1508 d->m_lineClosed = closed;
1511bool LineAnnotation::lineClosed()
const
1513 Q_D(
const LineAnnotation);
1514 return d->m_lineClosed;
1517void LineAnnotation::setLineInnerColor(
const QColor &color)
1519 Q_D(LineAnnotation);
1520 d->m_lineInnerColor = color;
1523QColor LineAnnotation::lineInnerColor()
const
1525 Q_D(
const LineAnnotation);
1526 return d->m_lineInnerColor;
1529void LineAnnotation::setLineLeadingForwardPoint(
double point)
1531 Q_D(LineAnnotation);
1532 d->m_lineLeadingFwdPt = point;
1535double LineAnnotation::lineLeadingForwardPoint()
const
1537 Q_D(
const LineAnnotation);
1538 return d->m_lineLeadingFwdPt;
1541void LineAnnotation::setLineLeadingBackwardPoint(
double point)
1543 Q_D(LineAnnotation);
1544 d->m_lineLeadingBackPt = point;
1547double LineAnnotation::lineLeadingBackwardPoint()
const
1549 Q_D(
const LineAnnotation);
1550 return d->m_lineLeadingBackPt;
1553void LineAnnotation::setShowCaption(
bool show)
1555 Q_D(LineAnnotation);
1556 d->m_lineShowCaption = show;
1559bool LineAnnotation::showCaption()
const
1561 Q_D(
const LineAnnotation);
1562 return d->m_lineShowCaption;
1565void LineAnnotation::setLineIntent(LineIntent intent)
1567 Q_D(LineAnnotation);
1568 d->m_lineIntent = intent;
1571LineAnnotation::LineIntent LineAnnotation::lineIntent()
const
1573 Q_D(
const LineAnnotation);
1574 return d->m_lineIntent;
1584 Q_D(
const LineAnnotation);
1593 if (d->m_lineStartStyle != None) {
1594 lineElement.
setAttribute(QStringLiteral(
"startStyle"), (
int)d->m_lineStartStyle);
1596 if (d->m_lineEndStyle != None) {
1597 lineElement.
setAttribute(QStringLiteral(
"endStyle"), (
int)d->m_lineEndStyle);
1599 if (d->m_lineClosed) {
1600 lineElement.
setAttribute(QStringLiteral(
"closed"), d->m_lineClosed);
1602 if (d->m_lineInnerColor.isValid()) {
1603 lineElement.
setAttribute(QStringLiteral(
"innerColor"), d->m_lineInnerColor.name());
1605 if (d->m_lineLeadingFwdPt != 0.0) {
1608 if (d->m_lineLeadingBackPt != 0.0) {
1611 if (d->m_lineShowCaption) {
1612 lineElement.
setAttribute(QStringLiteral(
"showCaption"), d->m_lineShowCaption);
1614 if (d->m_lineIntent != Unknown) {
1615 lineElement.
setAttribute(QStringLiteral(
"intent"), d->m_lineIntent);
1619 int points = d->m_linePoints.count();
1633void LineAnnotationPrivate::transform(
const QTransform &matrix)
1635 AnnotationPrivate::transform(matrix);
1638 while (it.hasNext()) {
1639 it.next().transform(matrix);
1643void LineAnnotationPrivate::baseTransform(
const QTransform &matrix)
1645 AnnotationPrivate::baseTransform(matrix);
1648 while (it.hasNext()) {
1649 it.next().transform(matrix);
1653void LineAnnotationPrivate::resetTransformation()
1655 AnnotationPrivate::resetTransformation();
1657 m_transformedLinePoints = m_linePoints;
1662 AnnotationPrivate::translate(coord);
1665 while (it.hasNext()) {
1667 p.
x = p.
x + coord.
x;
1668 p.
y = p.
y + coord.
y;
1672void LineAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
1674 Okular::AnnotationPrivate::setAnnotationProperties(node);
1687 m_lineStartStyle = (LineAnnotation::TermStyle)e.
attribute(QStringLiteral(
"startStyle")).
toInt();
1690 m_lineEndStyle = (LineAnnotation::TermStyle)e.
attribute(QStringLiteral(
"endStyle")).
toInt();
1705 m_lineShowCaption = e.
attribute(QStringLiteral(
"showCaption")).
toInt();
1708 m_lineIntent = (LineAnnotation::LineIntent)e.
attribute(QStringLiteral(
"intent")).
toInt();
1724 m_linePoints.append(p);
1731 m_transformedLinePoints = m_linePoints;
1734AnnotationPrivate *LineAnnotationPrivate::getNewAnnotationPrivate()
1736 return new LineAnnotationPrivate();
1739double LineAnnotationPrivate::distanceSqr(
double x,
double y,
double xScale,
double yScale)
const
1744 transformedLinePoints.
append(transformedLinePoints.
first());
1747 if (m_lineInnerColor.
isValid()) {
1749 for (
const NormalizedPoint &p : std::as_const(transformedLinePoints)) {
1758 return strokeDistance(::distanceSqr(x, y, xScale, yScale, transformedLinePoints), m_style.width() * xScale / (m_page->m_width * 2));
1763class Okular::GeomAnnotationPrivate :
public Okular::AnnotationPrivate
1766 GeomAnnotationPrivate()
1767 : AnnotationPrivate()
1768 , m_geomType(GeomAnnotation::InscribedSquare)
1771 void setAnnotationProperties(
const QDomNode &node)
override;
1772 bool canBeResized()
const override;
1773 AnnotationPrivate *getNewAnnotationPrivate()
override;
1774 double distanceSqr(
double x,
double y,
double xScale,
double yScale)
const override;
1776 GeomAnnotation::GeomType m_geomType;
1780GeomAnnotation::GeomAnnotation()
1785GeomAnnotation::GeomAnnotation(
const QDomNode &description)
1786 :
Annotation(*new GeomAnnotationPrivate(), description)
1790GeomAnnotation::~GeomAnnotation()
1794void GeomAnnotation::setGeometricalType(GeomType type)
1796 Q_D(GeomAnnotation);
1797 d->m_geomType =
type;
1800GeomAnnotation::GeomType GeomAnnotation::geometricalType()
const
1802 Q_D(
const GeomAnnotation);
1803 return d->m_geomType;
1806void GeomAnnotation::setGeometricalInnerColor(
const QColor &color)
1808 Q_D(GeomAnnotation);
1809 d->m_geomInnerColor = color;
1812QColor GeomAnnotation::geometricalInnerColor()
const
1814 Q_D(
const GeomAnnotation);
1815 return d->m_geomInnerColor;
1825 Q_D(
const GeomAnnotation);
1834 if (d->m_geomType != InscribedSquare) {
1835 geomElement.
setAttribute(QStringLiteral(
"type"), (
int)d->m_geomType);
1837 if (d->m_geomInnerColor.isValid()) {
1838 geomElement.
setAttribute(QStringLiteral(
"color"), d->m_geomInnerColor.name());
1842void GeomAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
1844 Okular::AnnotationPrivate::setAnnotationProperties(node);
1856 m_geomType = (GeomAnnotation::GeomType)e.
attribute(QStringLiteral(
"type")).
toInt();
1863 m_style.setWidth(e.
attribute(QStringLiteral(
"width")).toInt());
1871bool GeomAnnotationPrivate::canBeResized()
const
1876AnnotationPrivate *GeomAnnotationPrivate::getNewAnnotationPrivate()
1878 return new GeomAnnotationPrivate();
1881double GeomAnnotationPrivate::distanceSqr(
double x,
double y,
double xScale,
double yScale)
const
1885 bool withinShape =
false;
1886 switch (m_geomType) {
1887 case GeomAnnotation::InscribedCircle: {
1889 const double centerX = (m_transformedBoundary.left + m_transformedBoundary.right) / 2.0;
1890 const double centerY = (m_transformedBoundary.top + m_transformedBoundary.bottom) / 2.0;
1891 const double focusX = (m_transformedBoundary.right - centerX);
1892 const double focusY = (m_transformedBoundary.bottom - centerY);
1894 const double focusXSqr = pow(focusX, 2);
1895 const double focusYSqr = pow(focusY, 2);
1904 const double lambda = sqrt(focusXSqr * focusYSqr / (focusYSqr * pow(x - centerX, 2) + focusXSqr * pow(y - centerY, 2)));
1908 if (m_geomInnerColor.
isValid()) {
1917 projection.x += lambda * (x - centerX);
1918 projection.y += lambda * (y - centerY);
1920 distance = projection.distanceSqr(x, y, xScale, yScale);
1924 case GeomAnnotation::InscribedSquare:
1926 if (m_geomInnerColor.
isValid()) {
1927 return AnnotationPrivate::distanceSqr(x, y, xScale, yScale);
1931 NormalizedPoint(m_transformedBoundary.right, m_transformedBoundary.top),
1932 NormalizedPoint(m_transformedBoundary.right, m_transformedBoundary.bottom),
1933 NormalizedPoint(m_transformedBoundary.left, m_transformedBoundary.bottom),
1934 NormalizedPoint(m_transformedBoundary.left, m_transformedBoundary.top)};
1935 distance = ::distanceSqr(x, y, xScale, yScale, edges);
1937 if (m_transformedBoundary.contains(x, y)) {
1944 distance = strokeDistance(distance, m_style.width() * xScale / m_page->m_width);
1952class HighlightAnnotation::Quad::Private
1964 bool m_capStart : 1;
1987 if (
this != &other) {
1996 if (index < 0 || index > 3) {
2000 d->m_points[index] = point;
2005 if (index < 0 || index > 3) {
2009 return d->m_points[index];
2014 if (index < 0 || index > 3) {
2018 return d->m_transformedPoints[index];
2023 d->m_capStart = value;
2028 return d->m_capStart;
2033 d->m_capEnd = value;
2043 d->m_feather = width;
2048 return d->m_feather;
2053 for (
int i = 0; i < 4; ++i) {
2054 d->m_transformedPoints[i] = d->m_points[i];
2055 d->m_transformedPoints[i].transform(matrix);
2059class Okular::HighlightAnnotationPrivate :
public Okular::AnnotationPrivate
2062 HighlightAnnotationPrivate()
2063 : AnnotationPrivate()
2064 , m_highlightType(HighlightAnnotation::
Highlight)
2068 void transform(
const QTransform &matrix)
override;
2069 void baseTransform(
const QTransform &matrix)
override;
2070 double distanceSqr(
double x,
double y,
double xScale,
double yScale)
const override;
2071 void setAnnotationProperties(
const QDomNode &node)
override;
2072 AnnotationPrivate *getNewAnnotationPrivate()
override;
2074 HighlightAnnotation::HighlightType m_highlightType;
2078HighlightAnnotation::HighlightAnnotation()
2079 :
Annotation(*new HighlightAnnotationPrivate())
2083HighlightAnnotation::HighlightAnnotation(
const QDomNode &description)
2084 :
Annotation(*new HighlightAnnotationPrivate(), description)
2088HighlightAnnotation::~HighlightAnnotation()
2092void HighlightAnnotation::setHighlightType(HighlightType type)
2094 Q_D(HighlightAnnotation);
2095 d->m_highlightType =
type;
2098HighlightAnnotation::HighlightType HighlightAnnotation::highlightType()
const
2100 Q_D(
const HighlightAnnotation);
2101 return d->m_highlightType;
2106 Q_D(HighlightAnnotation);
2107 return d->m_highlightQuads;
2112 Q_D(
const HighlightAnnotation);
2113 return d->m_highlightQuads;
2118 Q_D(
const HighlightAnnotation);
2128 hlElement.
setAttribute(QStringLiteral(
"type"), (
int)d->m_highlightType);
2130 if (d->m_highlightQuads.count() < 1) {
2135 for (; it !=
end; ++it) {
2138 const Quad &q = *it;
2162void HighlightAnnotationPrivate::transform(
const QTransform &matrix)
2164 AnnotationPrivate::transform(matrix);
2167 while (it.hasNext()) {
2168 it.next().transform(matrix);
2172void HighlightAnnotationPrivate::baseTransform(
const QTransform &matrix)
2174 AnnotationPrivate::baseTransform(matrix);
2177 while (it.hasNext()) {
2178 it.next().transform(matrix);
2182void HighlightAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2184 Okular::AnnotationPrivate::setAnnotationProperties(node);
2185 m_highlightQuads.clear();
2198 m_highlightType = (HighlightAnnotation::HighlightType)e.
attribute(QStringLiteral(
"type")).
toInt();
2220 m_highlightQuads.append(q);
2228AnnotationPrivate *HighlightAnnotationPrivate::getNewAnnotationPrivate()
2230 return new HighlightAnnotationPrivate();
2233double HighlightAnnotationPrivate::distanceSqr(
double x,
double y,
double xScale,
double yScale)
const
2236 double outsideDistance = DBL_MAX;
2242 pathPoints << quad.transformedPoint(0);
2243 int directionVote = 0;
2244 for (
int i = 1; i < 5; ++i) {
2246 directionVote += (isLeftOfVector(pathPoints.
back(), thisPoint, point)) ? 1 : -1;
2247 pathPoints << thisPoint;
2249 if (abs(directionVote) == 4) {
2255 const double thisOutsideDistance = ::distanceSqr(x, y, xScale, yScale, pathPoints);
2256 if (thisOutsideDistance < outsideDistance) {
2257 outsideDistance = thisOutsideDistance;
2261 return outsideDistance;
2266class Okular::StampAnnotationPrivate :
public Okular::AnnotationPrivate
2269 StampAnnotationPrivate()
2270 : AnnotationPrivate()
2271 , m_stampIconName(QStringLiteral(
"Draft"))
2274 void setAnnotationProperties(
const QDomNode &node)
override;
2275 bool canBeResized()
const override;
2276 AnnotationPrivate *getNewAnnotationPrivate()
override;
2281StampAnnotation::StampAnnotation()
2286StampAnnotation::StampAnnotation(
const QDomNode &description)
2287 :
Annotation(*new StampAnnotationPrivate(), description)
2291StampAnnotation::~StampAnnotation()
2295void StampAnnotation::setStampIconName(
const QString &name)
2297 Q_D(StampAnnotation);
2298 d->m_stampIconName =
name;
2301QString StampAnnotation::stampIconName()
const
2303 Q_D(
const StampAnnotation);
2304 return d->m_stampIconName;
2314 Q_D(
const StampAnnotation);
2324 stampElement.
setAttribute(QStringLiteral(
"icon"), d->m_stampIconName);
2328void StampAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2330 Okular::AnnotationPrivate::setAnnotationProperties(node);
2343 m_stampIconName = e.
attribute(QStringLiteral(
"icon"));
2351bool StampAnnotationPrivate::canBeResized()
const
2356AnnotationPrivate *StampAnnotationPrivate::getNewAnnotationPrivate()
2358 return new StampAnnotationPrivate();
2361#if HAVE_NEW_SIGNATURE_API
2364class Okular::SignatureAnnotationPrivate :
public Okular::AnnotationPrivate
2367 SignatureAnnotationPrivate()
2368 : AnnotationPrivate()
2372 void setAnnotationProperties(
const QDomNode &node)
override;
2373 bool canBeResized()
const override;
2374 AnnotationPrivate *getNewAnnotationPrivate()
override;
2380 double m_fontSize = 10;
2381 double m_leftFontSize = 20;
2386SignatureAnnotation::SignatureAnnotation()
2387 :
Annotation(*new SignatureAnnotationPrivate())
2391SignatureAnnotation::~SignatureAnnotation()
2400QString SignatureAnnotation::text()
const
2402 Q_D(
const SignatureAnnotation);
2406void SignatureAnnotation::setText(
const QString &text)
2408 Q_D(SignatureAnnotation);
2412QString SignatureAnnotation::leftText()
const
2414 Q_D(
const SignatureAnnotation);
2415 return d->m_leftText;
2418void SignatureAnnotation::setLeftText(
const QString &text)
2420 Q_D(SignatureAnnotation);
2421 d->m_leftText = text;
2424QString SignatureAnnotation::imagePath()
const
2426 Q_D(
const SignatureAnnotation);
2427 return d->m_imagePath;
2430void SignatureAnnotation::setImagePath(
const QString &imagePath)
2432 Q_D(SignatureAnnotation);
2433 d->m_imagePath = imagePath;
2436QString SignatureAnnotation::fieldPartialName()
const
2438 Q_D(
const SignatureAnnotation);
2439 return d->m_fieldPartialName;
2441void SignatureAnnotation::setFieldPartialName(
const QString &fieldPartialName)
2443 Q_D(SignatureAnnotation);
2444 d->m_fieldPartialName = fieldPartialName;
2447double SignatureAnnotation::fontSize()
const
2449 Q_D(
const SignatureAnnotation);
2450 return d->m_fontSize;
2453void SignatureAnnotation::setFontSize(
double fontSize)
2455 Q_D(SignatureAnnotation);
2456 d->m_fontSize = fontSize;
2459double SignatureAnnotation::leftFontSize()
const
2461 Q_D(
const SignatureAnnotation);
2462 return d->m_leftFontSize;
2465void SignatureAnnotation::setLeftFontSize(
double fontSize)
2467 Q_D(SignatureAnnotation);
2468 d->m_leftFontSize = fontSize;
2473 Q_D(SignatureAnnotation);
2474 d->m_signFunction = func;
2479 Q_D(SignatureAnnotation);
2480 return d->m_signFunction(data, fileName);
2483int SignatureAnnotation::page()
const
2485 Q_D(
const SignatureAnnotation);
2489void SignatureAnnotation::setPage(
int page)
2491 Q_D(SignatureAnnotation);
2500void SignatureAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2502 Okular::AnnotationPrivate::setAnnotationProperties(node);
2507bool SignatureAnnotationPrivate::canBeResized()
const
2512AnnotationPrivate *SignatureAnnotationPrivate::getNewAnnotationPrivate()
2514 return new SignatureAnnotationPrivate();
2520class Okular::InkAnnotationPrivate :
public Okular::AnnotationPrivate
2523 InkAnnotationPrivate()
2524 : AnnotationPrivate()
2529 void baseTransform(
const QTransform &matrix)
override;
2530 void resetTransformation()
override;
2531 double distanceSqr(
double x,
double y,
double xScale,
double yScale)
const override;
2533 void setAnnotationProperties(
const QDomNode &node)
override;
2534 AnnotationPrivate *getNewAnnotationPrivate()
override;
2540InkAnnotation::InkAnnotation()
2545InkAnnotation::InkAnnotation(
const QDomNode &description)
2546 :
Annotation(*new InkAnnotationPrivate(), description)
2550InkAnnotation::~InkAnnotation()
2557 d->m_inkPaths = paths;
2562 Q_D(
const InkAnnotation);
2563 return d->m_inkPaths;
2568 Q_D(
const InkAnnotation);
2569 return d->m_transformedInkPaths;
2579 Q_D(
const InkAnnotation);
2588 if (d->m_inkPaths.count() < 1) {
2593 for (; pIt != pEnd; ++pIt) {
2606double InkAnnotationPrivate::distanceSqr(
double x,
double y,
double xScale,
double yScale)
const
2610 const double thisDistance = ::distanceSqr(x, y, xScale, yScale, path);
2611 if (thisDistance < distance) {
2615 return strokeDistance(distance, m_style.width() * xScale / (m_page->m_width * 2));
2618void InkAnnotationPrivate::transform(
const QTransform &matrix)
2620 AnnotationPrivate::transform(matrix);
2622 for (
int i = 0; i < m_transformedInkPaths.
count(); ++i) {
2624 while (it.hasNext()) {
2625 it.next().transform(matrix);
2630void InkAnnotationPrivate::baseTransform(
const QTransform &matrix)
2632 AnnotationPrivate::baseTransform(matrix);
2634 for (
int i = 0; i < m_inkPaths.count(); ++i) {
2636 while (it.hasNext()) {
2637 it.next().transform(matrix);
2642void InkAnnotationPrivate::resetTransformation()
2644 AnnotationPrivate::resetTransformation();
2646 m_transformedInkPaths = m_inkPaths;
2651 AnnotationPrivate::translate(coord);
2653 for (
int i = 0; i < m_inkPaths.count(); ++i) {
2655 while (it.hasNext()) {
2657 p.
x = p.
x + coord.
x;
2658 p.
y = p.
y + coord.
y;
2663void InkAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2665 Okular::AnnotationPrivate::setAnnotationProperties(node);
2706 m_inkPaths.append(path);
2714 m_transformedInkPaths = m_inkPaths;
2717AnnotationPrivate *InkAnnotationPrivate::getNewAnnotationPrivate()
2719 return new InkAnnotationPrivate();
2724class Okular::CaretAnnotationPrivate :
public Okular::AnnotationPrivate
2727 CaretAnnotationPrivate()
2728 : AnnotationPrivate()
2729 , m_symbol(CaretAnnotation::
None)
2733 void setAnnotationProperties(
const QDomNode &node)
override;
2734 AnnotationPrivate *getNewAnnotationPrivate()
override;
2736 CaretAnnotation::CaretSymbol m_symbol;
2739static QString caretSymbolToString(CaretAnnotation::CaretSymbol symbol)
2742 case CaretAnnotation::None:
2743 return QStringLiteral(
"None");
2744 case CaretAnnotation::P:
2745 return QStringLiteral(
"P");
2750static CaretAnnotation::CaretSymbol caretSymbolFromString(
const QString &symbol)
2753 return CaretAnnotation::None;
2755 return CaretAnnotation::P;
2757 return CaretAnnotation::None;
2760void CaretAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2762 Okular::AnnotationPrivate::setAnnotationProperties(node);
2775 m_symbol = caretSymbolFromString(e.
attribute(QStringLiteral(
"symbol")));
2783AnnotationPrivate *CaretAnnotationPrivate::getNewAnnotationPrivate()
2785 return new CaretAnnotationPrivate();
2788CaretAnnotation::CaretAnnotation()
2793CaretAnnotation::CaretAnnotation(
const QDomNode &description)
2794 :
Annotation(*new CaretAnnotationPrivate(), description)
2798CaretAnnotation::~CaretAnnotation()
2802void CaretAnnotation::setCaretSymbol(CaretAnnotation::CaretSymbol symbol)
2804 Q_D(CaretAnnotation);
2805 d->m_symbol = symbol;
2808CaretAnnotation::CaretSymbol CaretAnnotation::caretSymbol()
const
2810 Q_D(
const CaretAnnotation);
2821 Q_D(
const CaretAnnotation);
2830 if (d->m_symbol !=
None) {
2831 caretElement.
setAttribute(QStringLiteral(
"symbol"), caretSymbolToString(d->m_symbol));
2837class Okular::FileAttachmentAnnotationPrivate :
public Okular::AnnotationPrivate
2840 FileAttachmentAnnotationPrivate()
2841 : AnnotationPrivate()
2842 , icon(QStringLiteral(
"PushPin"))
2846 ~FileAttachmentAnnotationPrivate()
override
2851 void setAnnotationProperties(
const QDomNode &node)
override;
2852 AnnotationPrivate *getNewAnnotationPrivate()
override;
2859void FileAttachmentAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2861 Okular::AnnotationPrivate::setAnnotationProperties(node);
2877AnnotationPrivate *FileAttachmentAnnotationPrivate::getNewAnnotationPrivate()
2879 return new FileAttachmentAnnotationPrivate();
2882FileAttachmentAnnotation::FileAttachmentAnnotation()
2883 :
Annotation(*new FileAttachmentAnnotationPrivate())
2887FileAttachmentAnnotation::FileAttachmentAnnotation(
const QDomNode &description)
2888 :
Annotation(*new FileAttachmentAnnotationPrivate(), description)
2892FileAttachmentAnnotation::~FileAttachmentAnnotation()
2911QString FileAttachmentAnnotation::fileIconName()
const
2913 Q_D(
const FileAttachmentAnnotation);
2917void FileAttachmentAnnotation::setFileIconName(
const QString &iconName)
2919 Q_D(FileAttachmentAnnotation);
2923EmbeddedFile *FileAttachmentAnnotation::embeddedFile()
const
2925 Q_D(
const FileAttachmentAnnotation);
2929void FileAttachmentAnnotation::setEmbeddedFile(
EmbeddedFile *ef)
2931 Q_D(FileAttachmentAnnotation);
2937class Okular::SoundAnnotationPrivate :
public Okular::AnnotationPrivate
2940 SoundAnnotationPrivate()
2941 : AnnotationPrivate()
2942 , icon(QStringLiteral(
"Speaker"))
2946 ~SoundAnnotationPrivate()
override
2951 void setAnnotationProperties(
const QDomNode &node)
override;
2952 AnnotationPrivate *getNewAnnotationPrivate()
override;
2959void SoundAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
2961 Okular::AnnotationPrivate::setAnnotationProperties(node);
2977AnnotationPrivate *SoundAnnotationPrivate::getNewAnnotationPrivate()
2979 return new SoundAnnotationPrivate();
2988 :
Annotation(*new SoundAnnotationPrivate(), description)
3037class Okular::MovieAnnotationPrivate :
public Okular::AnnotationPrivate
3040 MovieAnnotationPrivate()
3041 : AnnotationPrivate()
3045 ~MovieAnnotationPrivate()
override
3050 void setAnnotationProperties(
const QDomNode &node)
override;
3051 AnnotationPrivate *getNewAnnotationPrivate()
override;
3057void MovieAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
3059 Okular::AnnotationPrivate::setAnnotationProperties(node);
3075AnnotationPrivate *MovieAnnotationPrivate::getNewAnnotationPrivate()
3077 return new MovieAnnotationPrivate();
3086 :
Annotation(*new MovieAnnotationPrivate(), description)
3123class Okular::ScreenAnnotationPrivate :
public Okular::AnnotationPrivate
3126 ScreenAnnotationPrivate();
3127 ~ScreenAnnotationPrivate()
override;
3129 void setAnnotationProperties(
const QDomNode &node)
override;
3130 AnnotationPrivate *getNewAnnotationPrivate()
override;
3136ScreenAnnotationPrivate::ScreenAnnotationPrivate()
3141ScreenAnnotationPrivate::~ScreenAnnotationPrivate()
3144 qDeleteAll(m_additionalActions);
3147void ScreenAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
3149 Okular::AnnotationPrivate::setAnnotationProperties(node);
3165AnnotationPrivate *ScreenAnnotationPrivate::getNewAnnotationPrivate()
3167 return new ScreenAnnotationPrivate();
3176 :
Annotation(*new ScreenAnnotationPrivate(), description)
3202 if (d->m_additionalActions.contains(type)) {
3203 delete d->m_additionalActions.value(type);
3206 d->m_additionalActions.insert(type,
action);
3212 if (!d->m_additionalActions.contains(type)) {
3215 return d->m_additionalActions.value(type);
3235class Okular::WidgetAnnotationPrivate :
public Okular::AnnotationPrivate
3238 ~WidgetAnnotationPrivate()
override;
3239 void setAnnotationProperties(
const QDomNode &node)
override;
3240 AnnotationPrivate *getNewAnnotationPrivate()
override;
3245WidgetAnnotationPrivate::~WidgetAnnotationPrivate()
3247 qDeleteAll(m_additionalActions);
3250void WidgetAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
3252 Okular::AnnotationPrivate::setAnnotationProperties(node);
3268AnnotationPrivate *WidgetAnnotationPrivate::getNewAnnotationPrivate()
3270 return new WidgetAnnotationPrivate();
3279 :
Annotation(*new WidgetAnnotationPrivate, description)
3305 if (d->m_additionalActions.contains(type)) {
3306 delete d->m_additionalActions.value(type);
3309 d->m_additionalActions.insert(type, action);
3315 if (!d->m_additionalActions.contains(type)) {
3318 return d->m_additionalActions.value(type);
3324class Okular::RichMediaAnnotationPrivate :
public Okular::AnnotationPrivate
3327 RichMediaAnnotationPrivate();
3328 ~RichMediaAnnotationPrivate()
override;
3329 void setAnnotationProperties(
const QDomNode &node)
override;
3330 AnnotationPrivate *getNewAnnotationPrivate()
override;
3337RichMediaAnnotationPrivate::RichMediaAnnotationPrivate()
3339 , embeddedFile(nullptr)
3343RichMediaAnnotationPrivate::~RichMediaAnnotationPrivate()
3346 delete embeddedFile;
3349void RichMediaAnnotationPrivate::setAnnotationProperties(
const QDomNode &node)
3351 Okular::AnnotationPrivate::setAnnotationProperties(node);
3367AnnotationPrivate *RichMediaAnnotationPrivate::getNewAnnotationPrivate()
3369 return new RichMediaAnnotationPrivate();
3373 :
Annotation(*new RichMediaAnnotationPrivate())
3378 :
Annotation(*new RichMediaAnnotationPrivate, description)
3420 return d->embeddedFile;
3427 delete d->embeddedFile;
Encapsulates data that describes an action.
virtual ~AnnotationProxy()
Destroys the annotation proxy.
static QDomElement findChildElement(const QDomNode &parentNode, const QString &name)
Returns the child element with the given name from the direct children of parentNode or a null elemen...
static QPixmap loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio=true)
Returns a pixmap for a stamp symbol.
static QRect annotationGeometry(const Annotation *annotation, double scaleX, double scaleY)
Returns the geometry of the given annotation scaled by scaleX and scaleY.
static Annotation * createAnnotation(const QDomElement &element)
Restore an annotation (with revisions if needed) from the dom element.
static void storeAnnotation(const Annotation *annotation, QDomElement &element, QDomDocument &document)
Saves the annotation as a child of element taking care of saving all revisions if it has any.
The Revision class contains all information about the revision of the annotation.
Annotation * annotation() const
Returns the annotation the revision belongs to.
Revision()
Creates a new revision.
void setType(RevisionType type)
Sets the type of the revision.
void setScope(RevisionScope scope)
Sets the scope of the revision.
void setAnnotation(Annotation *annotation)
Sets the annotation the revision belongs to.
~Revision()
Destroys the revision.
RevisionType type() const
Returns the type of the revision.
RevisionScope scope() const
Returns the scope of the revision.
The Style class contains all information about style of the annotation.
double opacity() const
Returns the opacity of the style.
void setSpaces(int spaces)
Sets the spaces of the style.
void setColor(const QColor &color)
Sets the color of the style.
LineStyle lineStyle() const
Returns the line style of the style.
double xCorners() const
Returns the x-corners of the style.
~Style()
Destroys the style.
QColor color() const
Returns the color of the style.
void setOpacity(double opacity)
Sets the opacity of the style.
void setYCorners(double yCorners)
Sets the y-corners of the style.
void setEffectIntensity(double intensity)
Sets the effect intensity of the style.
LineEffect lineEffect() const
Returns the line effect of the style.
int marks() const
Returns the marks of the style.
void setLineStyle(LineStyle style)
Sets the line style of the style.
void setXCorners(double xCorners)
Sets the x-corners of the style.
void setMarks(int marks)
Sets the marks of the style.
double effectIntensity() const
Returns the effect intensity of the style.
double yCorners() const
Returns the y-corners of the style.
double width() const
Returns the width of the style.
int spaces() const
Returns the spaces of the style.
void setLineEffect(LineEffect effect)
Sets the line effect of the style.
void setWidth(double width)
Sets the width of the style.
Style()
Creates a new style.
The Window class contains all information about the popup window of the annotation that is used to ed...
int flags() const
Returns the flags of the window.
void setSummary(const QString &summary)
Sets the summary of the window.
QString summary() const
Returns the summary of the window.
~Window()
Destroys the window.
void setHeight(int height)
Sets the height of the window.
void setFlags(int flags)
Sets the flags of the window.
NormalizedPoint topLeft() const
Returns the top-left point of the window.
Window()
Creates a new window.
void setTitle(const QString &title)
Sets the title of the window.
int height() const
Returns the height of the window.
QString title() const
Returns the title of the window.
void setTopLeft(const NormalizedPoint &point)
Sets the top-left point of the window.
void setWidth(int width)
Sets the width of the window.
int width() const
Returns the width of the window.
Annotation struct holds properties shared by all annotations.
bool canBeResized() const
Returns whether the annotation can be resized.
QDateTime modificationDate() const
Returns the last modification date of the annotation.
void setModificationDate(const QDateTime &date)
Sets the last modification date of the annotation.
bool canBeMoved() const
Returns whether the annotation can be moved.
QDateTime creationDate() const
Returns the creation date of the annotation.
QString author() const
Returns the author of the annotation.
NormalizedRect transformedBoundingRectangle() const
Returns the transformed bounding rectangle of the annotation.
void setNativeData(std::shared_ptr< void > data)
Sets some native internal data with shared ownership.
Window & window()
Returns a reference to the window object of the annotation.
QString contents() const
Returns the contents of the annotation.
int flags() const
Returns the flags of the annotation.
void setContents(const QString &contents)
Sets the contents of the annotation.
void adjust(const NormalizedPoint &deltaCoord1, const NormalizedPoint &deltaCoord2)
Adjust the annotation by the specified coordinates.
NormalizedRect boundingRectangle() const
Returns the bounding rectangle of the annotation.
void setBoundingRectangle(const NormalizedRect &rectangle)
Sets the bounding rectangle of the annotation.
RevisionType
Describes the type of revision information.
void setNativeId(const QVariant &id)
Sets the "native" id of the annotation.
void setCreationDate(const QDateTime &date)
Sets the creation date of the annotation.
virtual void store(QDomNode &node, QDomDocument &document) const
Stores the annotation as xml in document under the given parent node.
void setDisposeDataFunction(DisposeDataFunction func)
Sets a function to be called when the annotation is destroyed.
QVariant nativeId() const
Returns the "native" id of the annotation.
@ ExternallyDrawn
Is drawn externally (by the generator which provided it)
@ BeingMoved
Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it.
@ External
Is stored external.
@ BeingResized
Is being resized (mouse drag and drop). If ExternallyDrawn, the generator must not draw it.
LineEffect
Describes possible line effects for.
QString uniqueName() const
Returns the unique name of the annotation.
QDomNode getAnnotationPropertiesDomNode() const
Retrieve the QDomNode representing this annotation's properties.
virtual ~Annotation()
Destroys the annotation.
void setUniqueName(const QString &name)
Sets the unique name of the annotation.
RevisionScope
Describes the scope of revision information.
AdditionalActionType
Describes the type of additional actions.
void(*) DisposeDataFunction(const Okular::Annotation *)
A function to be called when the annotation is destroyed.
void setFlags(int flags)
Sets the flags of the annotation.
LineStyle
Describes possible line styles for.
void setAuthor(const QString &author)
Sets the author of the annotation.
QList< Revision > & revisions()
Returns a reference to the revision list of the annotation.
void translate(const NormalizedPoint &coord)
Move the annotation by the specified coordinates.
Style & style()
Returns a reference to the style object of the annotation.
void setAnnotationProperties(const QDomNode &node)
Sets annotations internal properties according to the contents of node.
const void * nativeData() const
bool openDialogAfterCreation() const
Returns whether the annotation dialog should be open after creation of the annotation or not.
SubType
Describes the type of annotation as defined in PDF standard.
@ AHighlight
A highlight annotation.
@ AGeom
A geometrical annotation.
@ AText
A textual annotation.
@ ARichMedia
A rich media annotation.
@ ALine
A line annotation.
@ AMovie
A movie annotation.
@ AFileAttachment
A file attachment annotation.
@ AScreen
A screen annotation.
@ ACaret
A caret annotation.
@ ASound
A sound annotation.
@ AWidget
A widget annotation.
@ AStamp
A stamp annotation.
virtual SubType subType() const =0
Returns the sub type of the annotation.
An embedded file into the document.
Describes a highlight quad of a text markup annotation.
void setCapEnd(bool value)
Sets whether a cap should be used at the end.
~Quad()
Destroys the quad.
double feather() const
Returns the width of the drawing feather.
Quad()
Creates a new quad.
bool capStart() const
Returns whether a cap should be used at the start.
NormalizedPoint point(int index) const
Returns the normalized point at index.
bool capEnd() const
Returns whether a cap should be used at the end.
void setPoint(const NormalizedPoint &point, int index)
Sets the normalized point at index.
void setFeather(double width)
Sets the width of the drawing feather.
void transform(const QTransform &matrix)
Transforms the quad coordinates with the transformation defined by matrix.
void setCapStart(bool value)
Sets whether a cap should be used at the start.
NormalizedPoint transformedPoint(int index) const
Returns the transformed (e.g.
SubType subType() const override
Returns the sub type of the movie annotation.
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the movie annotation as xml in document under the given parentNode.
~MovieAnnotation() override
Destroys the movie annotation.
void setMovie(Movie *movie)
Sets the new movie object.
Movie * movie() const
Gets the movie object.
MovieAnnotation()
Creates a new movie annotation.
Contains information about a movie object.
Data needed to create a new signature.
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
double distanceSqr(double x, double y, double xScale, double yScale) const
Returns squared distance to normalized point (x, y) on a reference area of size xScale x yScale.
double x
The normalized x coordinate.
double y
The normalized y coordinate.
A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.
double left
The normalized left coordinate.
QRect geometry(int xScale, int yScale) const
Returns the rectangle mapped to a reference area of xScale x yScale.
double top
The normalized top coordinate.
void setAdditionalAction(AdditionalActionType type, Action *action)
Sets the additional action of the given type.
void setAction(Action *action)
Sets the action that is executed when the annotation is triggered.
Action * action() const
Returns the action that is executed when the annotation is triggered or 0 if not action has been defi...
Action * additionalAction(AdditionalActionType type) const
Returns the additional action of the given type or 0 if no action has been defined.
ScreenAnnotation()
Creates a new screen annotation.
~ScreenAnnotation() override
Destroys the screen annotation.
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the screen annotation as xml in document under the given parentNode.
SubType subType() const override
Returns the sub type of the screen annotation.
QString soundIconName() const
Gets the name of the icon.
void store(QDomNode &node, QDomDocument &document) const override
Stores the sound annotation as xml in document under the given parent node.
~SoundAnnotation() override
Destroys the sound annotation.
void setSoundIconName(const QString &iconName)
Sets the iconName of the icon for the sound annotation.
Sound * sound() const
Gets the sound object.
SubType subType() const override
Returns the sub type of the sound annotation.
SoundAnnotation()
Creates a new sound annotation.
void setSound(Sound *s)
Sets the s representing the sound of the file attachment annotation.
Contains information about a sound object.
Type type(const QSqlDatabase &db)
QString path(const QString &relativePath)
QString name(StandardAction id)
const QList< QKeySequence > & end()
KOSM_EXPORT double distance(const std::vector< const OSM::Node * > &path, Coordinate coord)
bool isValid() const const
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QString data() const const
QDomElement createElement(const QString &tagName)
QString attribute(const QString &name, const QString &defValue) const const
bool hasAttribute(const QString &name) const const
void setAttribute(const QString &name, const QString &value)
QString tagName() const const
QDomNode appendChild(const QDomNode &newChild)
QDomNode firstChild() const const
bool isElement() const const
bool isNull() const const
QDomNode nextSibling() const const
QDomCDATASection toCDATASection() const const
QDomElement toElement() const const
bool exists() const const
bool fromString(const QString &descrip)
QPixmap pixmap(QWindow *window, const QSize &size, Mode mode, State state) const const
QIcon fromTheme(const QString &name)
void append(QList< T > &&value)
qsizetype count() const const
void fill(const QColor &color)
bool isNull() const const
bool load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
QPixmap scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
bool containsPoint(const QPointF &point, Qt::FillRule fillRule) const const
QRect united(const QRect &rectangle) const const
QSizeF size() const const
QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const const
QSize toSize() const const
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
qsizetype count() const const
QString & append(QChar ch)
const_iterator constBegin() const const
const_iterator constEnd() const const
bool isEmpty() const const
QString number(double n, char format, int precision)
double toDouble(bool *ok) const const
int toInt(bool *ok, int base) const const
QString toLower() const const
QRectF boundsOnElement(const QString &id) const const
bool elementExists(const QString &id) const const
bool isValid() const const
void render(QPainter *painter)
KeepAspectRatioByExpanding
QString toString(StringFormat mode) const const