Skip to content

Commit

Permalink
Merge branch 'release_branch_DEVSIX-5576' into master-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
iText-CI committed Sep 29, 2021
2 parents 87fffa6 + 9c5e0c3 commit c4daee4
Show file tree
Hide file tree
Showing 1,672 changed files with 42,462 additions and 35,472 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The iText 7 Core/Community release contains:
- ```sign-x.y.z.jar```: use this if you need support for digital signatures
- ```styled-xml-parser-x.y.z.jar```: use this if you need support for SVG or html2pdf
- ```svg-x.y.z.jar```: SVG support
- ```commons-x.y.z.jar```: commons module

The **iText 7 Community** source code is hosted on [Github][github], where you can also [download the latest releases][latest].

Expand Down
2 changes: 1 addition & 1 deletion barcodes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.1.16</version>
<version>7.2.0</version>
</parent>
<artifactId>barcodes</artifactId>
<name>iText 7 - barcodes</name>
Expand Down
9 changes: 5 additions & 4 deletions barcodes/src/main/java/com/itextpdf/barcodes/Barcode128.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;

import com.itextpdf.kernel.PdfException;
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.kernel.colors.Color;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
Expand Down Expand Up @@ -352,7 +353,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
for (int k = 0; k < tLen; ++k) {
c = text.charAt(k);
if (c > 127 && c != FNC1)
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
}
c = text.charAt(0);
char currentCode = getStartSymbol(codeSet);
Expand Down Expand Up @@ -383,7 +384,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
++index;
}
if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet))
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
while (index < tLen) {
switch (currentCode) {
case START_A: {
Expand Down Expand Up @@ -452,7 +453,7 @@ else if (c < ' ') {
break;
}
if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet))
throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1);
throw new PdfException(BarcodeExceptionMessageConstant.THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128);
}
return out;
}
Expand Down
14 changes: 9 additions & 5 deletions barcodes/src/main/java/com/itextpdf/barcodes/BarcodeCodabar.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;

import com.itextpdf.kernel.PdfException;
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
Expand Down Expand Up @@ -167,19 +167,23 @@ public static byte[] getBarsCodabar(String text) {
text = text.toUpperCase();
int len = text.length();
if (len < 2) {
throw new IllegalArgumentException(PdfException.CodabarMustHaveAtLeastStartAndStopCharacter);
throw new IllegalArgumentException(
BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER);
}
if (CHARS.indexOf(text.charAt(0)) < START_STOP_IDX || CHARS.indexOf(text.charAt(len - 1)) < START_STOP_IDX) {
throw new IllegalArgumentException(PdfException.CodabarMustHaveOneAbcdAsStartStopCharacter);
throw new IllegalArgumentException(
BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER);
}
byte[] bars = new byte[text.length() * 8 - 1];
for (int k = 0; k < len; ++k) {
int idx = CHARS.indexOf(text.charAt(k));
if (idx >= START_STOP_IDX && k > 0 && k < len - 1) {
throw new IllegalArgumentException(PdfException.InCodabarStartStopCharactersAreOnlyAllowedAtTheExtremes);
throw new IllegalArgumentException(BarcodeExceptionMessageConstant.
IN_CODABAR_START_STOP_CHARACTERS_ARE_ONLY_ALLOWED_AT_THE_EXTREMES);
}
if (idx < 0) {
throw new IllegalArgumentException(PdfException.IllegalCharacterInCodabarBarcode);
throw new IllegalArgumentException(
BarcodeExceptionMessageConstant.ILLEGAL_CHARACTER_IN_CODABAR_BARCODE);
}
System.arraycopy(BARS[idx], 0, bars, k * 8, 7);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;

import com.itextpdf.kernel.PdfException;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;


import com.itextpdf.kernel.PdfException;
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
import com.itextpdf.io.font.FontProgram;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
Expand Down Expand Up @@ -159,6 +158,6 @@ public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor)
*/
@Override
public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
throw new UnsupportedOperationException(PdfException.TwoBarcodeMustBeExternally);
throw new UnsupportedOperationException(BarcodeExceptionMessageConstant.TWO_BARCODE_MUST_BE_EXTERNALLY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;


import com.itextpdf.kernel.PdfException;
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
Expand Down Expand Up @@ -163,7 +163,7 @@ public static char getChecksum(String text) {
public static byte[] getBarsInter25(String text) {
text = keepNumbers(text);
if ((text.length() & 1) != 0) {
throw new PdfException(PdfException.TextMustBeEven);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_MUST_BE_EVEN);
}
byte[] bars = new byte[text.length() * 5 + 7];
int pb = 0;
Expand Down
21 changes: 11 additions & 10 deletions barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;

import com.itextpdf.kernel.PdfException;
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.io.font.PdfEncodings;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
Expand Down Expand Up @@ -726,13 +727,13 @@ public void paintCode() {
int maxErr, lenErr, tot, pad;
if ((options & PDF417_USE_RAW_CODEWORDS) != 0) {
if (lenCodewords > MAX_DATA_CODEWORDS || lenCodewords < 1 || lenCodewords != codewords[0]) {
throw new PdfException(PdfException.InvalidCodewordSize);
throw new PdfException(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE);
}
} else {
if (code == null)
throw new PdfException(PdfException.TextCannotBeNull);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_CANNOT_BE_NULL);
if (code.length > ABSOLUTE_MAX_TEXT_SIZE) {
throw new PdfException(PdfException.TextIsTooBig);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
}
segmentList = new SegmentList();
breakString();
Expand Down Expand Up @@ -1316,7 +1317,7 @@ void byteCompaction(int start, int length) {
int k, j;
int size = length / 6 * 5 + length % 6;
if (size + cwPtr > MAX_DATA_CODEWORDS) {
throw new PdfException(PdfException.TextIsTooBig);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
}
length += start;
for (k = start; k < length; k += 6) {
Expand Down Expand Up @@ -1501,7 +1502,7 @@ private void numberCompaction(byte[] input, int start, int length) {
else
size = full + size / 3 + 1;
if (size + cwPtr > MAX_DATA_CODEWORDS) {
throw new PdfException(PdfException.TextIsTooBig);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
}
length += start;
for (k = start; k < length; k += 44) {
Expand All @@ -1512,13 +1513,13 @@ private void numberCompaction(byte[] input, int start, int length) {

private void macroCodes() {
if (macroSegmentId < 0) {
throw new PdfException(PdfException.MacroSegmentIdMustBeGtOrEqZero);
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_GT_OR_EQ_ZERO);
}
if (macroSegmentId >= macroSegmentCount) {
throw new PdfException(PdfException.MacroSegmentIdMustBeLtMacroSegmentCount);
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_LT_MACRO_SEGMENT_COUNT);
}
if (macroSegmentCount < 1) {
throw new PdfException(PdfException.MacroSegmentIdMustBeGtZero);
throw new PdfException(BarcodeExceptionMessageConstant.MACRO_SEGMENT_ID_MUST_BE_GT_ZERO);
}

macroIndex = cwPtr;
Expand Down Expand Up @@ -1671,7 +1672,7 @@ private void textCompaction(byte[] input, int start, int length) {
dest[ptr++] = PS;
size = (ptr + fullBytes) / 2;
if (size + cwPtr > MAX_DATA_CODEWORDS) {
throw new PdfException(PdfException.TextIsTooBig);
throw new PdfException(BarcodeExceptionMessageConstant.TEXT_IS_TOO_BIG);
}
length = ptr;
ptr = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This file is part of the iText (R) project.
import com.itextpdf.barcodes.qrcode.ByteMatrix;
import com.itextpdf.barcodes.qrcode.EncodeHintType;
import com.itextpdf.barcodes.qrcode.QRCodeWriter;
import com.itextpdf.barcodes.qrcode.WriterException;
import com.itextpdf.barcodes.exceptions.WriterException;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.colors.Color;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2021 iText Group NV
Authors: iText Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itextpdf.barcodes.exceptions;

/**
* Class that bundles all the error message templates as constants.
*/
public final class BarcodeExceptionMessageConstant {
public static final String CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER = "Codabar must have at least start "
+ "and stop character.";
public static final String CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER = "Codabar must have one of 'ABCD' "
+ "as start/stop character.";
public static final String ILLEGAL_CHARACTER_IN_CODABAR_BARCODE = "Illegal character in Codabar Barcode.";
public static final String IN_CODABAR_START_STOP_CHARACTERS_ARE_ONLY_ALLOWED_AT_THE_EXTREMES = "In Codabar, "
+ "start/stop characters are only allowed at the extremes.";
public static final String INVALID_CODEWORD_SIZE = "Invalid codeword size.";
public static final String MACRO_SEGMENT_ID_MUST_BE_GT_OR_EQ_ZERO = "macroSegmentId must be >= 0";
public static final String MACRO_SEGMENT_ID_MUST_BE_GT_ZERO = "macroSegmentId must be > 0";
public static final String MACRO_SEGMENT_ID_MUST_BE_LT_MACRO_SEGMENT_COUNT = "macroSegmentId "
+ "must be < macroSemgentCount";
public static final String TEXT_CANNOT_BE_NULL = "Text cannot be null.";
public static final String TEXT_IS_TOO_BIG = "Text is too big.";
public static final String TEXT_MUST_BE_EVEN = "The text length must be even.";
public static final String TWO_BARCODE_MUST_BE_EXTERNALLY = "The two barcodes must be composed externally.";
public static final String THERE_ARE_ILLEGAL_CHARACTERS_FOR_BARCODE_128 = "There are illegal characters for "
+ "barcode 128 in {0}.";

private BarcodeExceptionMessageConstant(){}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ This file is part of the iText (R) project.
For more information, please contact iText Software Corp. at this
address: [email protected]
*/
package com.itextpdf.barcodes.qrcode;
package com.itextpdf.barcodes.exceptions;

import com.itextpdf.commons.exceptions.ITextException;

/**
* A base class which covers the range of exceptions which may occur when encoding a barcode using
* the Writer framework.
*
* @author [email protected] (Daniel Switkin)
*/
public final class WriterException extends Exception {
public final class WriterException extends ITextException {

private static final long serialVersionUID = -7600391573888999764L;

/**
* Creates a WriterException.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes.qrcode;

import com.itextpdf.barcodes.exceptions.WriterException;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes.qrcode;

import com.itextpdf.barcodes.exceptions.WriterException;

/**
* @author [email protected] (Satoru Takabayashi) - creator
* @author [email protected] (Daniel Switkin) - ported from C++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes.qrcode;

import com.itextpdf.barcodes.exceptions.WriterException;

import java.util.Map;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.barcodes;

import com.itextpdf.kernel.PdfException;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.kernel.colors.ColorConstants;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This file is part of the iText (R) project.
package com.itextpdf.barcodes;

import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.kernel.PdfException;
import com.itextpdf.kernel.exceptions.PdfException;
import com.itextpdf.kernel.colors.ColorConstants;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
Expand Down
Loading

0 comments on commit c4daee4

Please sign in to comment.