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


##########
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java:
##########
@@ -506,13 +506,18 @@ public ParagraphAlignment getAlignment() {
      * specified in the style hierarchy, then no alignment is applied to the
      * paragraph.
      *
-     * @param align the paragraph alignment to apply to this paragraph.
+     * @param align the paragraph alignment to apply to this paragraph. It can
+     *              be null to unset it and fall back to the style hierarchy.
      */
     public void setAlignment(ParagraphAlignment align) {
         CTPPr pr = getCTPPr();
-        CTJc jc = pr.isSetJc() ? pr.getJc() : pr.addNewJc();
-        STJc.Enum en = STJc.Enum.forInt(align.getValue());
-        jc.setVal(en);
+        if (align == null) {
+            pr.unsetJc();

Review Comment:
   * is there some way that getCTPPr(init = false) could be used here? we have 
equivalent code elsewhere
   * we don't want to create a CTPPr instance if none already exists for the 
null input caese



##########
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java:
##########
@@ -488,11 +488,11 @@ public String getFootnoteText() {
      * specified in the style hierarchy, then no alignment is applied to the
      * paragraph.
      *
-     * @return the paragraph alignment of this paragraph.
+     * @return the paragraph alignment of this paragraph. Can be null if not 
set.

Review Comment:
   This is a breaking change. I know you don't like the way things work but 
unfortunately, in a 20 year old project with lots of users, we can't just 
change API behaviours. We have no major releases planned, just patch releases - 
so if you want to break the API, this change will need to wait.
   
   Can you instead consider adding a new method `public boolean 
isAlignmentSet()`? New methods won't cause backward compatibility issues.



-- 
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