aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2015-11-25 07:16:43 +0000
committerJaven O'Neal <onealj@apache.org>2015-11-25 07:16:43 +0000
commitef017d70c17b663c17bd52773b0b09a5f67c22fe (patch)
tree94f43ba39ca5a9e818e38243eb5d204d58f9f00b /src/ooxml
parent54c2a6bbce184e9dfa5771b0320988a9835cee82 (diff)
downloadpoi-ef017d70c17b663c17bd52773b0b09a5f67c22fe.tar.gz
poi-ef017d70c17b663c17bd52773b0b09a5f67c22fe.zip
bug 58636: upgrade anchor types from int to AnchorType enum
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1716313 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java17
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java8
3 files changed, 17 insertions, 15 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
index 14dbaff14d..8045912abf 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
@@ -28,7 +28,8 @@ import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
* @author Yegor Kozlov
*/
public final class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
- private int anchorType;
+ private AnchorType DEFAULT_ANCHOR_TYPE = AnchorType.MOVE_AND_RESIZE;
+ private AnchorType anchorType;
/**
* Starting anchor point
@@ -44,6 +45,7 @@ public final class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* Creates a new client anchor and defaults all the anchor positions to 0.
*/
public XSSFClientAnchor() {
+ anchorType = DEFAULT_ANCHOR_TYPE;
cell1 = CTMarker.Factory.newInstance();
cell1.setCol(0);
cell1.setColOff(0);
@@ -88,6 +90,7 @@ public final class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* @param cell2 ending anchor point
*/
protected XSSFClientAnchor(CTMarker cell1, CTMarker cell2) {
+ anchorType = DEFAULT_ANCHOR_TYPE;
this.cell1 = cell1;
this.cell2 = cell2;
}
@@ -214,20 +217,20 @@ public final class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
/**
* Sets the anchor type
- * <p>
- * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
+ * @param anchorType the anchor type to set
*/
- public void setAnchorType( int anchorType )
+ @Override
+ public void setAnchorType( AnchorType anchorType )
{
this.anchorType = anchorType;
}
/**
* Gets the anchor type
- * <p>
- * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
+ * @return the anchor type
*/
- public int getAnchorType()
+ @Override
+ public AnchorType getAnchorType()
{
return anchorType;
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
index ba45cfff48..64dfc5dd00 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
@@ -34,7 +34,6 @@ import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.util.CellAddress;
-import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Units;
import org.apache.poi.xssf.model.CommentsTable;
@@ -373,9 +372,9 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
anchor.setFrom(ctAnchor.getFrom());
STEditAs.Enum aditAs;
switch(anchor.getAnchorType()) {
- case ClientAnchor.DONT_MOVE_AND_RESIZE: aditAs = STEditAs.ABSOLUTE; break;
- case ClientAnchor.MOVE_AND_RESIZE: aditAs = STEditAs.TWO_CELL; break;
- case ClientAnchor.MOVE_DONT_RESIZE: aditAs = STEditAs.ONE_CELL; break;
+ case DONT_MOVE_AND_RESIZE: aditAs = STEditAs.ABSOLUTE; break;
+ case MOVE_AND_RESIZE: aditAs = STEditAs.TWO_CELL; break;
+ case MOVE_DONT_RESIZE: aditAs = STEditAs.ONE_CELL; break;
default: aditAs = STEditAs.ONE_CELL;
}
ctAnchor.setEditAs(aditAs);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
index 7f6db45517..edaa974a2c 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
@@ -23,7 +23,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.poi.ss.usermodel.BaseTestPicture;
-import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
@@ -70,9 +70,9 @@ public final class TestXSSFPicture extends BaseTestPicture {
assertArrayEquals(jpegData, pictures.get(jpegIdx).getData());
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- assertEquals(ClientAnchor.MOVE_AND_RESIZE, anchor.getAnchorType());
- anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);
- assertEquals(ClientAnchor.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());
+ assertEquals(AnchorType.MOVE_AND_RESIZE, anchor.getAnchorType());
+ anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
+ assertEquals(AnchorType.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());
XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);
assertTrue(anchor.equals(shape.getAnchor()));