Skip to content

Commit 4b932dd

Browse files
BlackEgoistiText-CI
authored andcommitted
Make PdfPolyGeomAnnotation abstract
Add package private PdfPolygonAnnotation and PdfPolylineAnnotation DEVSIX-526 Autoported commit. Original commit hash: [a6905f16c]
1 parent 6f0141d commit 4b932dd

File tree

5 files changed

+140
-22
lines changed

5 files changed

+140
-22
lines changed

itext/itext.kernel/itext/kernel/pdf/annot/PdfAnnotation.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,24 @@ public static iText.Kernel.Pdf.Annot.PdfAnnotation MakeAnnotation(PdfObject pdfO
395395
annotation = new PdfLineAnnotation((PdfDictionary)pdfObject);
396396
}
397397
else {
398-
if (PdfName.Polygon.Equals(subtype) || PdfName.PolyLine.Equals(subtype)) {
399-
annotation = new PdfPolyGeomAnnotation((PdfDictionary)pdfObject);
398+
if (PdfName.Polygon.Equals(subtype)) {
399+
annotation = new PdfPolygonAnnotation((PdfDictionary)pdfObject);
400400
}
401401
else {
402-
if (PdfName.Redact.Equals(subtype)) {
403-
annotation = new PdfRedactAnnotation((PdfDictionary)pdfObject);
402+
if (PdfName.PolyLine.Equals(subtype)) {
403+
annotation = new PdfPolylineAnnotation((PdfDictionary)pdfObject);
404404
}
405405
else {
406-
if (PdfName.Watermark.Equals(subtype)) {
407-
annotation = new PdfWatermarkAnnotation((PdfDictionary)pdfObject);
406+
if (PdfName.Redact.Equals(subtype)) {
407+
annotation = new PdfRedactAnnotation((PdfDictionary)pdfObject);
408408
}
409409
else {
410-
annotation = new PdfAnnotation.PdfUnknownAnnotation((PdfDictionary)pdfObject);
410+
if (PdfName.Watermark.Equals(subtype)) {
411+
annotation = new PdfWatermarkAnnotation((PdfDictionary)pdfObject);
412+
}
413+
else {
414+
annotation = new PdfAnnotation.PdfUnknownAnnotation((PdfDictionary)pdfObject);
415+
}
411416
}
412417
}
413418
}

itext/itext.kernel/itext/kernel/pdf/annot/PdfPolyGeomAnnotation.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,22 @@ source product.
4141
For more information, please contact iText Software Corp. at this
4242
4343
*/
44+
using System;
4445
using Common.Logging;
4546
using iText.Kernel.Colors;
4647
using iText.Kernel.Geom;
4748
using iText.Kernel.Pdf;
4849

4950
namespace iText.Kernel.Pdf.Annot {
50-
public class PdfPolyGeomAnnotation : PdfMarkupAnnotation {
51-
/// <summary>Subtypes</summary>
51+
public abstract class PdfPolyGeomAnnotation : PdfMarkupAnnotation {
52+
[System.ObsoleteAttribute(@", use iText.Kernel.Pdf.PdfName.Polygon instead.")]
5253
public static readonly PdfName Polygon = PdfName.Polygon;
5354

55+
[System.ObsoleteAttribute(@", use iText.Kernel.Pdf.PdfName.PolyLine instead.")]
5456
public static readonly PdfName PolyLine = PdfName.PolyLine;
5557

56-
private PdfPolyGeomAnnotation(Rectangle rect, PdfName subtype, float[] vertices)
58+
internal PdfPolyGeomAnnotation(Rectangle rect, float[] vertices)
5759
: base(rect) {
58-
SetSubtype(subtype);
5960
SetVertices(vertices);
6061
}
6162

@@ -68,16 +69,12 @@ protected internal PdfPolyGeomAnnotation(PdfDictionary pdfObject)
6869
}
6970

7071
public static iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation CreatePolygon(Rectangle rect, float[] vertices) {
71-
return new iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation(rect, Polygon, vertices);
72+
return new PdfPolygonAnnotation(rect, vertices);
7273
}
7374

7475
public static iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation CreatePolyLine(Rectangle rect, float[] vertices
7576
) {
76-
return new iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation(rect, PolyLine, vertices);
77-
}
78-
79-
public override PdfName GetSubtype() {
80-
return GetPdfObject().GetAsName(PdfName.Subtype);
77+
return new PdfPolylineAnnotation(rect, vertices);
8178
}
8279

8380
public virtual PdfArray GetVertices() {
@@ -159,10 +156,6 @@ public virtual iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation SetPath(PdfArray pat
159156
return (iText.Kernel.Pdf.Annot.PdfPolyGeomAnnotation)Put(PdfName.Path, path);
160157
}
161158

162-
private void SetSubtype(PdfName subtype) {
163-
Put(PdfName.Subtype, subtype);
164-
}
165-
166159
/// <summary>The dictionaries for some annotation types (such as free text and polygon annotations) can include the BS entry.
167160
/// </summary>
168161
/// <remarks>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2019 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using iText.Kernel.Geom;
44+
using iText.Kernel.Pdf;
45+
46+
namespace iText.Kernel.Pdf.Annot {
47+
internal class PdfPolygonAnnotation : PdfPolyGeomAnnotation {
48+
internal PdfPolygonAnnotation(PdfDictionary pdfObject)
49+
: base(pdfObject) {
50+
}
51+
52+
internal PdfPolygonAnnotation(Rectangle rect, float[] vertices)
53+
: base(rect, vertices) {
54+
}
55+
56+
public override PdfName GetSubtype() {
57+
return PdfName.Polygon;
58+
}
59+
}
60+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2019 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using iText.Kernel.Geom;
44+
using iText.Kernel.Pdf;
45+
46+
namespace iText.Kernel.Pdf.Annot {
47+
internal class PdfPolylineAnnotation : PdfPolyGeomAnnotation {
48+
internal PdfPolylineAnnotation(Rectangle rect, float[] vertices)
49+
: base(rect, vertices) {
50+
}
51+
52+
internal PdfPolylineAnnotation(PdfDictionary pdfObject)
53+
: base(pdfObject) {
54+
}
55+
56+
public override PdfName GetSubtype() {
57+
return PdfName.PolyLine;
58+
}
59+
}
60+
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dbc6439b90fff2ed2e2cc5a85bc605789de5e10e
1+
a6905f16c4a4ca84ac3538526c8d030e14bcb034

0 commit comments

Comments
 (0)