Skip to content

Commit 5d480ae

Browse files
committed
Fix backward compatibility issues
DEVSIX-1056
1 parent 0a03a0c commit 5d480ae

File tree

2 files changed

+26
-48
lines changed

2 files changed

+26
-48
lines changed

kernel/src/main/java/com/itextpdf/kernel/font/PdfFont.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ public boolean containsGlyph(int unicode) {
150150
* @return true if font contains glyph, represented with the unicode code point,
151151
* otherwise false.
152152
*/
153-
public abstract boolean containsGlyph(String text, int from);
153+
public boolean containsGlyph(String text, int from) {
154+
throw new java.lang.IllegalStateException("containsGlyph(String text, int from) must be overridden");
155+
}
154156

155157
public abstract GlyphLine createGlyphLine(String content);
156158

@@ -164,7 +166,9 @@ public boolean containsGlyph(int unicode) {
164166
* @param glyphs array for a new glyphs, shall not be null.
165167
* @return number of processed chars from text.
166168
*/
167-
public abstract int appendGlyphs(String text, int from, int to, List<Glyph> glyphs);
169+
public int appendGlyphs(String text, int from, int to, List<Glyph> glyphs) {
170+
throw new java.lang.IllegalStateException("appendGlyphs(String text, int from, int to, List<Glyph> glyphs) must be overridden");
171+
}
168172

169173
/**
170174
* Append any single glyph, even notdef.
@@ -175,7 +179,9 @@ public boolean containsGlyph(int unicode) {
175179
* @param glyphs array for a new glyph, shall not be null.
176180
* @return number of processed chars: 2 in case surrogate pair, otherwise 1
177181
*/
178-
public abstract int appendAnyGlyph(String text, int from, List<Glyph> glyphs);
182+
public int appendAnyGlyph(String text, int from, List<Glyph> glyphs) {
183+
throw new java.lang.IllegalStateException("appendAnyGlyph(String text, int from, List<Glyph> glyphs) must be overridden");
184+
}
179185

180186
/**
181187
* Converts the text into bytes to be placed in the document.
@@ -196,7 +202,9 @@ public boolean containsGlyph(int unicode) {
196202
* @param content the encoded string
197203
* @return the {@link GlyphLine} containing the glyphs encoded by the passed string
198204
*/
199-
public abstract GlyphLine decodeIntoGlyphLine(PdfString content);
205+
public GlyphLine decodeIntoGlyphLine(PdfString content) {
206+
throw new java.lang.IllegalStateException("decodeIntoGlyphLine(PdfString content) must be overridden");
207+
}
200208

201209
public abstract float getContentWidth(PdfString content);
202210

layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
247247
// Cells' up moves occured while split processing
248248
// key is column number (there can be only one move during one split)
249249
// value is the previous row number of the cell
250-
Map<Integer, Integer> rowMoves = new HashMap<Integer, Integer>();
250+
Map<Integer, Integer> rowMoves = new HashMap<>();
251251

252252
MarginsCollapseHandler marginsCollapseHandler = null;
253253
boolean marginsCollapsingEnabled = Boolean.TRUE.equals(getPropertyAsBoolean(Property.COLLAPSING_MARGINS));
@@ -687,7 +687,6 @@ public LayoutResult layout(LayoutContext layoutContext) {
687687
while (0 != cellProcessingQueue.size()) {
688688
CellRendererInfo cellInfo = cellProcessingQueue.pop();
689689
col = cellInfo.column;
690-
int rowN = cellInfo.finishRowInd;
691690
CellRenderer cell = cellInfo.cellRenderer;
692691
float collapsedWithNextRowBorderWidth = null == cell.getBorders()[2] ? 0 : cell.getBorders()[2].getWidth();
693692
cell.deleteOwnProperty(Property.BORDER_BOTTOM);
@@ -939,8 +938,8 @@ public LayoutResult layout(LayoutContext layoutContext) {
939938
logger.warn(LogMessageConstant.CLIP_ELEMENT);
940939
// Process borders
941940
if (status == LayoutResult.NOTHING) {
942-
ArrayList<Border> topBorders = new ArrayList<Border>();
943-
ArrayList<Border> bottomBorders = new ArrayList<Border>();
941+
ArrayList<Border> topBorders = new ArrayList<>();
942+
ArrayList<Border> bottomBorders = new ArrayList<>();
944943
for (int i = 0; i < numberOfColumns; i++) {
945944
topBorders.add(borders[0]);
946945
bottomBorders.add(borders[2]);
@@ -1015,13 +1014,13 @@ public LayoutResult layout(LayoutContext layoutContext) {
10151014

10161015
// if table is empty we still need to process table borders
10171016
if (0 == childRenderers.size() && null == headerRenderer && null == footerRenderer) {
1018-
List<Border> topHorizontalBorders = new ArrayList<Border>();
1019-
List<Border> bottomHorizontalBorders = new ArrayList<Border>();
1017+
List<Border> topHorizontalBorders = new ArrayList<>();
1018+
List<Border> bottomHorizontalBorders = new ArrayList<>();
10201019
for (int i = 0; i < numberOfColumns; i++) {
10211020
bottomHorizontalBorders.add(Border.NO_BORDER);
10221021
}
1023-
List<Border> leftVerticalBorders = new ArrayList<Border>();
1024-
List<Border> rightVerticalBorders = new ArrayList<Border>();
1022+
List<Border> leftVerticalBorders = new ArrayList<>();
1023+
List<Border> rightVerticalBorders = new ArrayList<>();
10251024

10261025
// process bottom border of the last added row
10271026
if (tableModel.isComplete() && 0 != lastFlushedRowBottomBorder.size()) {
@@ -1290,41 +1289,12 @@ public void move(float dxRight, float dyUp) {
12901289
}
12911290
}
12921291

1293-
protected float[] calculateScaledColumnWidths(Table tableModel, float tableWidth, float leftBorderWidth, float rightBorderWidth) {
1294-
float[] scaledWidths = new float[tableModel.getNumberOfColumns()];
1295-
float widthSum = 0;
1296-
float totalPointWidth = 0;
1297-
int col;
1298-
for (col = 0; col < tableModel.getNumberOfColumns(); col++) {
1299-
UnitValue columnUnitWidth = tableModel.getColumnWidth(col);
1300-
float columnWidth;
1301-
if (columnUnitWidth.isPercentValue()) {
1302-
columnWidth = tableWidth * columnUnitWidth.getValue() / 100;
1303-
scaledWidths[col] = columnWidth;
1304-
widthSum += columnWidth;
1305-
} else {
1306-
totalPointWidth += columnUnitWidth.getValue();
1307-
}
1308-
}
1309-
float freeTableSpaceWidth = tableWidth - widthSum;
1310-
1311-
if (totalPointWidth > 0) {
1312-
for (col = 0; col < tableModel.getNumberOfColumns(); col++) {
1313-
float columnWidth;
1314-
UnitValue columnUnitWidth = tableModel.getColumnWidth(col);
1315-
if (columnUnitWidth.isPointValue()) {
1316-
columnWidth = (freeTableSpaceWidth / totalPointWidth) * columnUnitWidth.getValue();
1317-
scaledWidths[col] = columnWidth;
1318-
widthSum += columnWidth;
1319-
}
1320-
}
1321-
}
1322-
1323-
for (col = 0; col < tableModel.getNumberOfColumns(); col++) {
1324-
scaledWidths[col] *= (tableWidth - leftBorderWidth / 2 - rightBorderWidth / 2) / widthSum;
1325-
}
1326-
1327-
return scaledWidths;
1292+
/**
1293+
* @deprecated Method will be removed in 7.1.
1294+
*/
1295+
@Deprecated
1296+
protected float[] calculateScaledColumnWidths(Table tableModel, float tableWidth) {
1297+
return countedColumnWidth;
13281298
}
13291299

13301300
protected TableRenderer[] split(int row) {
@@ -1803,7 +1773,7 @@ private void updateFirstRowBorders(int colN) {
18031773

18041774
// collapse with table border or header bottom borders
18051775
private void correctFirstRowTopBorders(Border tableBorder, int colN) {
1806-
int col = 0;
1776+
int col;
18071777
int row = 0;
18081778
List<Border> topBorders = horizontalBorders.get(0);
18091779
List<Border> bordersToBeCollapsedWith = null != headerRenderer

0 commit comments

Comments
 (0)