#65331 - Wrong mapping of TableRowAlign

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1890234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sayi 2021-05-27 02:53:39 +00:00
parent a574e4463c
commit 25470ddb55
2 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,8 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -24,9 +26,9 @@ import java.util.Map;
*/ */
public enum TableRowAlign { public enum TableRowAlign {
LEFT(1), LEFT(STJcTable.INT_START),
CENTER(2), CENTER(STJcTable.INT_CENTER),
RIGHT(3); RIGHT(STJcTable.INT_END);
private static Map<Integer, TableRowAlign> imap = new HashMap<>(); private static Map<Integer, TableRowAlign> imap = new HashMap<>();

View File

@ -38,6 +38,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblGridCol;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable;
/** /**
@ -574,10 +575,13 @@ class TestXWPFTable {
XWPFTable tbl = doc.createTable(1, 1); XWPFTable tbl = doc.createTable(1, 1);
tbl.setTableAlignment(TableRowAlign.LEFT); tbl.setTableAlignment(TableRowAlign.LEFT);
assertEquals(TableRowAlign.LEFT, tbl.getTableAlignment()); assertEquals(TableRowAlign.LEFT, tbl.getTableAlignment());
assertEquals(STJcTable.INT_START, tbl.getTableAlignment().getValue());
tbl.setTableAlignment(TableRowAlign.CENTER); tbl.setTableAlignment(TableRowAlign.CENTER);
assertEquals(TableRowAlign.CENTER, tbl.getTableAlignment()); assertEquals(TableRowAlign.CENTER, tbl.getTableAlignment());
assertEquals(STJcTable.INT_CENTER, tbl.getTableAlignment().getValue());
tbl.setTableAlignment(TableRowAlign.RIGHT); tbl.setTableAlignment(TableRowAlign.RIGHT);
assertEquals(TableRowAlign.RIGHT, tbl.getTableAlignment()); assertEquals(TableRowAlign.RIGHT, tbl.getTableAlignment());
assertEquals(STJcTable.INT_END, tbl.getTableAlignment().getValue());
tbl.removeTableAlignment(); tbl.removeTableAlignment();
assertNull(tbl.getTableAlignment()); assertNull(tbl.getTableAlignment());
} }