From 25470ddb551a13ab66a512166ea628b6fc28b06a Mon Sep 17 00:00:00 2001 From: Sayi Date: Thu, 27 May 2021 02:53:39 +0000 Subject: [PATCH] #65331 - Wrong mapping of TableRowAlign git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1890234 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xwpf/usermodel/TableRowAlign.java | 8 +++++--- .../java/org/apache/poi/xwpf/usermodel/TestXWPFTable.java | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java index 0345ecafa0..35e80d33b1 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/TableRowAlign.java @@ -16,6 +16,8 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJcTable; + import java.util.HashMap; import java.util.Map; @@ -24,9 +26,9 @@ import java.util.Map; */ public enum TableRowAlign { - LEFT(1), - CENTER(2), - RIGHT(3); + LEFT(STJcTable.INT_START), + CENTER(STJcTable.INT_CENTER), + RIGHT(STJcTable.INT_END); private static Map imap = new HashMap<>(); diff --git a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTable.java b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTable.java index 70faecbd96..67e911c15a 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTable.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTable.java @@ -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.CTText; 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); tbl.setTableAlignment(TableRowAlign.LEFT); assertEquals(TableRowAlign.LEFT, tbl.getTableAlignment()); + assertEquals(STJcTable.INT_START, tbl.getTableAlignment().getValue()); tbl.setTableAlignment(TableRowAlign.CENTER); assertEquals(TableRowAlign.CENTER, tbl.getTableAlignment()); + assertEquals(STJcTable.INT_CENTER, tbl.getTableAlignment().getValue()); tbl.setTableAlignment(TableRowAlign.RIGHT); assertEquals(TableRowAlign.RIGHT, tbl.getTableAlignment()); + assertEquals(STJcTable.INT_END, tbl.getTableAlignment().getValue()); tbl.removeTableAlignment(); assertNull(tbl.getTableAlignment()); } -- 2.39.5