Skip to content

Commit

Permalink
Fixes #8 Bad value for paragraph alignment enum. Provides correct map…
Browse files Browse the repository at this point in the history
…ping for all @align values
  • Loading branch information
contrext committed Aug 23, 2019
1 parent 224790d commit 8e58c44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,13 @@ private XWPFTableRow makeTableRow(
XWPFParagraph p = cell.addParagraph();
makeParagraph(p, cursor);
if (null != align) {
if ("JUSTIFY".equalsIgnoreCase(align)) {
align = "DISTRIBUTE"; // Slight mistmatch between markup and model
}
if ("CHAR".equalsIgnoreCase(align)) {
// I'm not sure this is the best mapping but it seemed close enough
align = "NUM_TAB"; // Slight mistmatch between markup and model
}
ParagraphAlignment alignment = ParagraphAlignment.valueOf(align.toUpperCase());
p.setAlignment(alignment);
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/simplewp/simplewpml-test-01.swpx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
</cols>
<tbody>
<tr>
<td><p><run>R1 C1</run></p></td>
<td><p><run>R1 C2</run></p></td>
<td><p><run>R1 C3</run></p></td>
<td align="left"><p><run>R1 C1 Left align</run></p></td>
<td align="center"><p><run>R1 C2 center align</run></p></td>
<td align="right"><p><run>R1 C3 right align</run></p></td>
</tr>
<tr>
<td><p><run>R2 C1</run></p></td>
<td><p><run>R2 C2</run></p></td>
<td align="char"><p><run>R2 C1 "char" align</run></p></td>
<td align="justify"><p><run>R2 C2 justify align</run></p></td>
<td><p><run>R2 C3</run></p></td>
</tr>
</tbody>
Expand Down

0 comments on commit 8e58c44

Please sign in to comment.