Skip to content

Commit

Permalink
ignore whitespace for table placeholders. close #2261.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Jan 2, 2024
1 parent 0fdac55 commit c6a7f5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,10 @@ public static void setPlaceHolders(String caseId, String fileInFileSystem, Strin
CalculationTable tab = (CalculationTable) values.get(key);
for (Table t : allTables) {
if (t.getColumnCount() == 1 && t.getRowCount() == 1) {
if (key.equals(t.getCellByPosition(0, 0).getStringValue())) {
String cellContent=t.getCellByPosition(0, 0).getStringValue();
if(cellContent!=null)
cellContent=cellContent.trim();
if (key.equals(cellContent)) {
Border border = new Border(Color.WHITE, 1.0, SupportedLinearMeasure.PT);
for (int i = 0; i < tab.getData()[0].length - 1; i++) {
t.appendColumn();
Expand Down Expand Up @@ -1173,7 +1176,10 @@ public static void setPlaceHolders(String caseId, String fileInFileSystem, Strin
StyledCalculationTable tab = (StyledCalculationTable) values.get(key);
for (Table t : allTables) {
if (t.getColumnCount() == 1 && t.getRowCount() == 1) {
if (key.equals(t.getCellByPosition(0, 0).getStringValue())) {
String cellContent=t.getCellByPosition(0, 0).getStringValue();
if(cellContent!=null)
cellContent=cellContent.trim();
if (key.equals(cellContent)) {
Border border = new Border(Color.BLACK, 0.05, SupportedLinearMeasure.PT);
border.setColor(new org.odftoolkit.odfdom.type.Color(tab.getBorderColor()));
for (int i = 0; i < tab.getColumnCount() - 1; i++) {
Expand Down Expand Up @@ -1423,7 +1429,10 @@ public static java.util.List<String> getPlaceHolders(String file, List<String> a
for (String r : PlaceHolders.ALLTABLEPLACEHOLDERS) {
for (Table t : allTables) {
if (t.getColumnCount() == 1 && t.getRowCount() == 1) {
if (r.equals(t.getCellByPosition(0, 0).getStringValue())) {
String cellContent=t.getCellByPosition(0, 0).getStringValue();
if(cellContent!=null)
cellContent=cellContent.trim();
if (r.equals(cellContent)) {
resultList.add(r);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,10 @@ public static void setPlaceHolders(String caseId, String fileInFileSystem, Strin
CalculationTable tab = (CalculationTable) values.get(key);
for (XWPFTable t : allTables) {
if (t.getRow(0).getTableCells().size() == 1 && t.getNumberOfRows() == 1) {
if (key.equals(t.getRow(0).getCell(0).getText())) {
String cellContent=t.getRow(0).getCell(0).getText();
if(cellContent!=null)
cellContent=cellContent.trim();
if (key.equals(cellContent)) {
for (int i = 0; i < tab.getData()[0].length - 1; i++) {
t.addNewCol();

Expand All @@ -766,7 +769,7 @@ public static void setPlaceHolders(String caseId, String fileInFileSystem, Strin
t.createRow();
}
int firstDataRow = 0;
if (tab.getColumnLabels().size() > 0) {
if (!tab.getColumnLabels().isEmpty()) {
firstDataRow = 1;
t.createRow();
for (int i = 0; i < tab.getColumnLabels().size(); i++) {
Expand All @@ -788,7 +791,10 @@ public static void setPlaceHolders(String caseId, String fileInFileSystem, Strin
XWPFTable t = null;
for (XWPFTable tableCandidate : allTables) {
if (tableCandidate.getRow(0).getTableCells().size() == 1 && tableCandidate.getNumberOfRows() == 1) {
if (key.equals(tableCandidate.getRow(0).getCell(0).getText())) {
String cellContent=tableCandidate.getRow(0).getCell(0).getText();
if(cellContent!=null)
cellContent=cellContent.trim();
if (key.equals(cellContent)) {

t = tableCandidate;
break;
Expand Down Expand Up @@ -924,7 +930,10 @@ public static java.util.List<String> getPlaceHolders(String file, List<String> a
for (XWPFTable t : allTables) {
try {
if (t.getRow(0).getTableCells().size() == 1 && t.getNumberOfRows() == 1) {
if (r.equals(t.getRow(0).getCell(0).getText())) {
String cellContent=t.getRow(0).getCell(0).getText();
if(cellContent!=null)
cellContent=cellContent.trim();
if (r.equals(cellContent)) {
resultList.add(r);
}
}
Expand Down

0 comments on commit c6a7f5c

Please sign in to comment.