This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 8d53613bcf Bug 69935: Add short-based column setters to ClientAnchor 
(#1006)
8d53613bcf is described below

commit 8d53613bcf4448de3622cba676a4b9a7882f2a19
Author: Yongho Hwang <[email protected]>
AuthorDate: Sat Feb 14 17:50:52 2026 +0900

    Bug 69935: Add short-based column setters to ClientAnchor (#1006)
    
    * Bug 69935: Add short-based column setters to ClientAnchor
    
    Introduce short-based column setters on ClientAnchor to complement the 
existing int-based setters and improve Kotlin property support.
    
    - Add default short setters setCol1(short) and setCol2(short) that delegate 
to the existing int-based setters.
    - Add TestClientAnchorShortSetter to verify both the new short-based 
setters and the existing int-based setters.
    
    Tests:
    - ./gradlew :poi:test --tests 
'org.apache.poi.ss.usermodel.TestClientAnchorShortSetter'
    
    * Replace @since TBD with 6.0.0
    
    * Add license header to TestClieAdd ASF license header to 
TestClientAnchorShortSetterntAnchorShortSetter.java
    
    Added license header to TestClientAnchorShortSetter.java
---
 .../org/apache/poi/ss/usermodel/ClientAnchor.java  | 21 +++++++
 .../ss/usermodel/TestClientAnchorShortSetter.java  | 66 ++++++++++++++++++++++
 2 files changed, 87 insertions(+)

diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/ClientAnchor.java 
b/poi/src/main/java/org/apache/poi/ss/usermodel/ClientAnchor.java
index 4469f4ba09..e706453060 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/ClientAnchor.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/ClientAnchor.java
@@ -121,6 +121,16 @@ public interface ClientAnchor {
      */
     public void setCol1(int col1);
 
+    /**
+     * Sets the column (0 based) of the first cell.
+     *
+     * @param col1 0-based column of the first cell.
+     * @since 6.0.0
+     */
+    default void setCol1(short col1) {
+        setCol1((int) col1);
+    }
+
     /**
      * Returns the column (0 based) of the second cell, or -1 if there is no 
bottom-right anchor cell.
      * This is the case for absolute positioning ({@link 
AnchorType#DONT_MOVE_AND_RESIZE})
@@ -137,12 +147,23 @@ public interface ClientAnchor {
      */
     public void setCol2(int col2);
 
+    /**
+     * Sets the column (0 based) of the second cell.
+     *
+     * @param col2 0-based column of the second cell.
+     * @since 6.0.0
+     */
+    default void setCol2(short col2) {
+        setCol2((int) col2);
+    }
+
     /**
      * Returns the row (0 based) of the first cell, or -1 if there is no 
bottom-right anchor cell.
      * This is the case for absolute positioning ({@link 
AnchorType#DONT_MOVE_AND_RESIZE}).
      *
      * @return 0-based row of the first cell or -1 if none.
      */
+
     public int getRow1();
 
     /**
diff --git 
a/poi/src/test/java/org/apache/poi/ss/usermodel/TestClientAnchorShortSetter.java
 
b/poi/src/test/java/org/apache/poi/ss/usermodel/TestClientAnchorShortSetter.java
new file mode 100644
index 0000000000..2bbee1df48
--- /dev/null
+++ 
b/poi/src/test/java/org/apache/poi/ss/usermodel/TestClientAnchorShortSetter.java
@@ -0,0 +1,66 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.ss.usermodel;
+
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests for the short-based ClientAnchor column setters introduced for Bug 
69935.
+ */
+public class TestClientAnchorShortSetter {
+
+    @Test
+    void shortSettersDelegateToIntSetters() throws Exception {
+        try (Workbook wb = new HSSFWorkbook()) {
+            CreationHelper helper = wb.getCreationHelper();
+
+            // The actual implementation returned here is HSSFClientAnchor
+            ClientAnchor anchor = helper.createClientAnchor();
+
+            // Use the new short-based overloads
+            anchor.setCol1((short) 2);
+            anchor.setCol2((short) 5);
+
+            // Setting rows is not strictly required, but keeps the anchor 
fully initialized
+            anchor.setRow1(1);
+            anchor.setRow2(3);
+
+            // getColX() still returns short; compare using int for convenience
+            assertEquals(2, anchor.getCol1());
+            assertEquals(5, anchor.getCol2());
+        }
+    }
+
+    @Test
+    void intSettersStillWorkAsBefore() throws Exception {
+        try (Workbook wb = new HSSFWorkbook()) {
+            CreationHelper helper = wb.getCreationHelper();
+
+            ClientAnchor anchor = helper.createClientAnchor();
+
+            // Verify that the existing int-based setters still behave as 
before
+            anchor.setCol1(3);
+            anchor.setCol2(7);
+
+            assertEquals(3, anchor.getCol1());
+            assertEquals(7, anchor.getCol2());
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to