[poppler] poppler/Annot.cc poppler/Annot.h poppler/AnnotStampImageHelper.h qt5/src qt6/src
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Sep 12 22:34:15 UTC 2021
poppler/Annot.cc | 16 ++++++++--------
poppler/Annot.h | 4 ++--
poppler/AnnotStampImageHelper.h | 5 ++---
qt5/src/poppler-annotation.cc | 10 +++++-----
qt5/src/poppler-annotation.h | 8 ++++++++
qt6/src/poppler-annotation.cc | 10 +++++-----
qt6/src/poppler-annotation.h | 8 ++++++++
7 files changed, 38 insertions(+), 23 deletions(-)
New commits:
commit a1901ee99bf46beac43d129bb3f6ad2f9ed758af
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun Sep 12 22:29:40 2021 +0200
Misc annotation stamp improvements
Mark a few variables/functions as const
Remove unused function from AnnotStampImageHelper.h
Remove unneded GooString from AnnotStamp::generateStampAppearance
Set pointer to null after delete in AnnotStamp::clearCustomImage
only invalidate appearance in AnnotStamp::clearCustomImage if we did something
Add since markers to the new public API
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 89b46890..84c8d474 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1855,12 +1855,12 @@ double AnnotAppearanceBuilder::lineEndingXExtendBBox(AnnotLineEndingStyle ending
return 0;
}
-Object Annot::createForm(const GooString *appearBuf, double *bbox, bool transparencyGroup, Dict *resDict)
+Object Annot::createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Dict *resDict)
{
return createForm(appearBuf, bbox, transparencyGroup, resDict ? Object(resDict) : Object());
}
-Object Annot::createForm(const GooString *appearBuf, double *bbox, bool transparencyGroup, Object &&resDictObject)
+Object Annot::createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Object &&resDictObject)
{
Dict *appearDict = new Dict(doc->getXRef());
appearDict->set("Length", Object(appearBuf->getLength()));
@@ -5404,21 +5404,20 @@ void AnnotStamp::initialize(PDFDoc *docA, Dict *dict)
void AnnotStamp::generateStampAppearance()
{
Ref imgRef = stampImageHelper->getRef();
- std::string imgStrName = "X" + std::to_string(imgRef.num);
- GooString imgRefName(imgStrName);
+ const std::string imgStrName = "X" + std::to_string(imgRef.num);
AnnotAppearanceBuilder appearBuilder;
appearBuilder.append("q\n");
appearBuilder.append("/GS0 gs\n");
appearBuilder.appendf("{0:.3f} 0 0 {1:.3f} 0 0 cm\n", rect->x2 - rect->x1, rect->y2 - rect->y1);
appearBuilder.append("/");
- appearBuilder.append(imgRefName.c_str());
+ appearBuilder.append(imgStrName.c_str());
appearBuilder.append(" Do\n");
appearBuilder.append("Q\n");
- Dict *resDict = createResourcesDict(imgRefName.c_str(), Object(imgRef), "GS0", opacity, nullptr);
+ Dict *resDict = createResourcesDict(imgStrName.c_str(), Object(imgRef), "GS0", opacity, nullptr);
- double bboxArray[4] = { 0, 0, rect->x2 - rect->x1, rect->y2 - rect->y1 };
+ const double bboxArray[4] = { 0, 0, rect->x2 - rect->x1, rect->y2 - rect->y1 };
const GooString *appearBuf = appearBuilder.buffer();
appearance = createForm(appearBuf, bboxArray, false, resDict);
}
@@ -5485,8 +5484,9 @@ void AnnotStamp::clearCustomImage()
if (stampImageHelper != nullptr) {
stampImageHelper->removeAnnotStampImageObject();
delete stampImageHelper;
+ stampImageHelper = nullptr;
+ invalidateAppearance();
}
- invalidateAppearance();
}
//------------------------------------------------------------------------
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 9e399f19..788d6a00 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -758,8 +758,8 @@ private:
protected:
virtual ~Annot();
virtual void removeReferencedObjects(); // Called by Page::removeAnnot
- Object createForm(const GooString *appearBuf, double *bbox, bool transparencyGroup, Dict *resDict);
- Object createForm(const GooString *appearBuf, double *bbox, bool transparencyGroup, Object &&resDictObject); // overload to support incRef/decRef
+ Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Dict *resDict);
+ Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Object &&resDictObject); // overload to support incRef/decRef
Dict *createResourcesDict(const char *formName, Object &&formStream, const char *stateName, double opacity, const char *blendMode);
bool isVisible(bool printing);
int getRotation() const;
diff --git a/poppler/AnnotStampImageHelper.h b/poppler/AnnotStampImageHelper.h
index 75313a20..ebe6e919 100644
--- a/poppler/AnnotStampImageHelper.h
+++ b/poppler/AnnotStampImageHelper.h
@@ -3,6 +3,7 @@
// AnnotStampImageHelper.h
//
// Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11 at gmail.com>
+// Copyright (C) 2021 Albert Astals Cid <aacid at kde.org>
//
// Licensed under GPLv2 or later
//
@@ -41,15 +42,13 @@ public:
~AnnotStampImageHelper() { }
// Returns the ref to the created Image XObject
- Ref getRef() { return ref; }
+ Ref getRef() const { return ref; }
// Returns the width of the image
int getWidth() const { return width; }
// Returns the height of the image
int getHeight() const { return height; }
- Object &getAnnotStampImageHelperObject() { return imgObj; }
-
// Removes the created Image XObject as well as its soft mask from the XRef Table
void removeAnnotStampImageObject();
diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index 35d3020a..5c35e87f 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -1,5 +1,5 @@
/* poppler-annotation.cc: qt interface to poppler
- * Copyright (C) 2006, 2009, 2012-2015, 2018-2020 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2009, 2012-2015, 2018-2021 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006, 2008, 2010 Pino Toscano <pino at kde.org>
* Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
* Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso at hotmail.it>
@@ -154,8 +154,8 @@ AnnotationPrivate::AnnotationPrivate() : flags(0), revisionScope(Annotation::Roo
void getRawDataFromQImage(const QImage &qimg, int bitsPerPixel, QByteArray *data, QByteArray *sMaskData)
{
- int height = qimg.height();
- int width = qimg.width();
+ const int height = qimg.height();
+ const int width = qimg.width();
switch (bitsPerPixel) {
case 1:
@@ -3256,8 +3256,8 @@ AnnotStampImageHelper *StampAnnotationPrivate::convertQImageToAnnotStampImageHel
QByteArray data;
QByteArray sMaskData;
- int width = convertedQImage.width();
- int height = convertedQImage.height();
+ const int width = convertedQImage.width();
+ const int height = convertedQImage.height();
int bitsPerComponent = 1;
ColorSpace colorSpace = ColorSpace::DeviceGray;
diff --git a/qt5/src/poppler-annotation.h b/qt5/src/poppler-annotation.h
index d98d9cc7..c8c4c6ac 100644
--- a/qt5/src/poppler-annotation.h
+++ b/qt5/src/poppler-annotation.h
@@ -110,6 +110,8 @@ public:
* This class wraps Poppler's Object implementing the appearance stream
* for the calling annotation. It can be used to preserve the current
* Appearance Stream for the calling annotation.
+ *
+ * \since 21.10.0
*/
class POPPLER_QT5_EXPORT AnnotationAppearance
{
@@ -450,11 +452,15 @@ public:
/**
* Returns the current appearance stream of this annotation.
+ *
+ * \since 21.10.0
*/
std::unique_ptr<AnnotationAppearance> annotationAppearance() const;
/**
* Sets the annotation's appearance stream with the @p annotationAppearance.
+ *
+ * \since 21.10.0
*/
void setAnnotationAppearance(const AnnotationAppearance &annotationAppearance);
@@ -817,6 +823,8 @@ public:
/**
Set a custom icon for this stamp annotation.
+
+ \since 21.10.0
*/
void setStampCustomImage(const QImage &image);
diff --git a/qt6/src/poppler-annotation.cc b/qt6/src/poppler-annotation.cc
index 167a0d8e..5c9df939 100644
--- a/qt6/src/poppler-annotation.cc
+++ b/qt6/src/poppler-annotation.cc
@@ -1,5 +1,5 @@
/* poppler-annotation.cc: qt interface to poppler
- * Copyright (C) 2006, 2009, 2012-2015, 2018-2020 Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2009, 2012-2015, 2018-2021 Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2006, 2008, 2010 Pino Toscano <pino at kde.org>
* Copyright (C) 2012, Guillermo A. Amaral B. <gamaral at kde.org>
* Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso at hotmail.it>
@@ -90,8 +90,8 @@ AnnotationPrivate::AnnotationPrivate() : revisionScope(Annotation::Root), revisi
void getRawDataFromQImage(const QImage &qimg, int bitsPerPixel, QByteArray *data, QByteArray *sMaskData)
{
- int height = qimg.height();
- int width = qimg.width();
+ const int height = qimg.height();
+ const int width = qimg.width();
switch (bitsPerPixel) {
case 1:
@@ -2642,8 +2642,8 @@ AnnotStampImageHelper *StampAnnotationPrivate::convertQImageToAnnotStampImageHel
QByteArray data;
QByteArray sMaskData;
- int width = convertedQImage.width();
- int height = convertedQImage.height();
+ const int width = convertedQImage.width();
+ const int height = convertedQImage.height();
int bitsPerComponent = 1;
ColorSpace colorSpace = ColorSpace::DeviceGray;
diff --git a/qt6/src/poppler-annotation.h b/qt6/src/poppler-annotation.h
index 5039e6e0..644c9167 100644
--- a/qt6/src/poppler-annotation.h
+++ b/qt6/src/poppler-annotation.h
@@ -81,6 +81,8 @@ class Page;
* This class wraps Poppler's Object implementing the appearance stream
* for the calling annotation. It can be used to preserve the current
* Appearance Stream for the calling annotation.
+ *
+ * \since 21.10.0
*/
class POPPLER_QT6_EXPORT AnnotationAppearance
{
@@ -406,11 +408,15 @@ public:
/**
* Returns the current appearance stream of this annotation.
+ *
+ * \since 21.10.0
*/
std::unique_ptr<AnnotationAppearance> annotationAppearance() const;
/**
* Sets the annotation's appearance stream with the @p annotationAppearance.
+ *
+ * \since 21.10.0
*/
void setAnnotationAppearance(const AnnotationAppearance &annotationAppearance);
@@ -753,6 +759,8 @@ public:
/**
Set a custom icon for this stamp annotation.
+
+ \since 21.10.0
*/
void setStampCustomImage(const QImage &image);
More information about the poppler
mailing list