pjfanning commented on code in PR #843:
URL: https://github.com/apache/poi/pull/843#discussion_r2205448462


##########
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java:
##########
@@ -306,6 +306,80 @@ public int getNumberOfRows() {
         return ctTbl.sizeOfTrArray();
     }
 
+    /**
+     * Get the indentation value in 20ths of a point (twips).
+     *
+     * <p>This element specifies the indentation which shall be added before 
the leading edge of
+     * the current table in the document (the left edge in a left-to-right 
table, and the right
+     * edge in a right-to-left table).</p>
+     * <p>If the table alignment is not left/start, this property shall be 
ignored.</p>
+     *
+     * @see boolean isSetIndent()
+     * @return indentation value as an integer (20ths of a point)
+     */
+    public int getIndent() {
+        CTTblPr tblPr = getTblPr();
+        if (tblPr.isSetTblInd()) {
+            STTblWidth.Enum typeValue = tblPr.getTblInd().getType();
+            if (typeValue == null) {
+                // "§17.4.87: If [type] is omitted, then its value shall be 
assumed to be dxa"
+                typeValue = STTblWidth.DXA;
+            }
+            switch (typeValue.intValue()) {
+                case STTblWidth.INT_DXA:
+                    return (int) 
Units.toDXA(POIXMLUnits.parseLength(tblPr.getTblInd().xgetW()));
+                case STTblWidth.INT_NIL:
+                    // "§17.18.90: [nil] Specifies that the current width is 
zero, regardless of
+                    // any width value specified on the parent element"
+                    return 0;
+                case STTblWidth.INT_PCT:
+                case STTblWidth.INT_AUTO:
+                    // "§17.4.50: Any width value of type pct or auto for this 
element shall be ignored"
+                    return 0;
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Set the indentation in 20ths of a point (twips).
+     * @see int getIndent()
+     * @param indent Indentation value (20ths of a point)
+     */
+    public void setIndent(int indent) {
+        CTTblPr tblPr = getTblPr();
+        CTTblWidth tblInd = tblPr.isSetTblInd() ? tblPr.getTblInd() : 
tblPr.addNewTblInd();
+        tblInd.setW(new BigInteger(Integer.toString(indent)));

Review Comment:
   Are you sure that BigInteger is the right type here? setW takes an Object 
but I wouldn't be surprised if it needs to be a specific set of classes that 
need to be used.
   
   There is an xsetW method thats take this type.
   ```
   /**
    * An XML 
ST_MeasurementOrPercent(@http://schemas.openxmlformats.org/wordprocessingml/2006/main).
    *
    * This is a union type. Instances are of one of the following types:
    *     
org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnqualifiedPercentage
    *     
org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STPercentage
    *     
org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STUniversalMeasure
    */
   public interface STMeasurementOrPercent
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to