Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the word column width which is larger like 22in (#1867) #1869

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,10 @@ private int[] computeTblColumnWidths(ITableContent table, int tblWidth) {
tblColumns[i] = -1;
count++;
} else {
tblColumns[i] = WordUtil.convertTo(col.getWidth(), tblWidth, reportDpi);
int colWidth = WordUtil.convertTo(col.getWidth(), tblWidth, reportDpi);
// validate the maximum of column width
colWidth = (colWidth > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : colWidth;
tblColumns[i] = colWidth;
total += tblColumns[i];
}
}
Expand All @@ -1490,7 +1493,14 @@ private int[] computeTblColumnWidths(ITableContent table, int tblWidth) {
return tblColumns;
}
tblWidth = Math.min(tblWidth, context.getCurrentWidth());
return EmitterUtil.resizeTableColumn(tblWidth, tblColumns, count, total);
tblWidth = (tblWidth > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : tblWidth;

int[] tblColWidth = EmitterUtil.resizeTableColumn(tblWidth, tblColumns, count, total);
// validate the maximum of column width
for (int i = 0; i < tblColWidth.length; i++) {
tblColWidth[i] = (tblColWidth[i] > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : tblColWidth[i];
}
return tblColWidth;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class WordUtil {

public static final double INCH_TWIPS = INCH_PT * PT_TWIPS;

/**
* maximum value of word column width 22in to TWIPS
*/
public static final int MAX_ELEMENT_WIDTH_INCH_TWIPS = 31680;

// Bookmark names must begin with a letter and can contain numbers.
// spaces can not be included in a bookmark name,
// but the underscore character can be used to separate words
Expand Down
Loading