<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="add">added modifiers for anchor type to XSSFClientAnchor</action>
<action dev="POI-DEVELOPERS" type="add">46772 - support built-in data formats in XSSFDataFormat</action>
<action dev="POI-DEVELOPERS" type="fix">46719 - fixed XSSFSheet.shiftRows to correctly preserve row heights</action>
<action dev="POI-DEVELOPERS" type="fix">46715 - preserve custom column widths across re-serialization of XSSFWorkbook</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="add">added modifiers for anchor type to XSSFClientAnchor</action>
<action dev="POI-DEVELOPERS" type="add">46772 - support built-in data formats in XSSFDataFormat</action>
<action dev="POI-DEVELOPERS" type="fix">46719 - fixed XSSFSheet.shiftRows to correctly preserve row heights</action>
<action dev="POI-DEVELOPERS" type="fix">46715 - preserve custom column widths across re-serialization of XSSFWorkbook</action>
* @author Yegor Kozlov\r
*/\r
public interface ClientAnchor {\r
+ /**\r
+ * Move and Resize With Anchor Cells\r
+ * <p>\r
+ * Specifies that the current drawing shall move and\r
+ * resize to maintain its row and column anchors (i.e. the\r
+ * object is anchored to the actual from and to row and column)\r
+ * </p>\r
+ */\r
+ public static final int MOVE_AND_RESIZE = 0;\r
+\r
+ /**\r
+ * Move With Cells but Do Not Resize\r
+ * <p>\r
+ * Specifies that the current drawing shall move with its\r
+ * row and column (i.e. the object is anchored to the\r
+ * actual from row and column), but that the size shall remain absolute.\r
+ * </p>\r
+ * <p>\r
+ * If additional rows/columns are added between the from and to locations of the drawing,\r
+ * the drawing shall move its to anchors as needed to maintain this same absolute size.\r
+ * </p>\r
+ */\r
+ public static final int MOVE_DONT_RESIZE = 2;\r
+\r
+ /**\r
+ * Do Not Move or Resize With Underlying Rows/Columns\r
+ * <p>\r
+ * Specifies that the current start and end positions shall\r
+ * be maintained with respect to the distances from the\r
+ * absolute start point of the worksheet.\r
+ * </p>\r
+ * <p>\r
+ * If additional rows/columns are added before the\r
+ * drawing, the drawing shall move its anchors as needed\r
+ * to maintain this same absolute position.\r
+ * </p>\r
+ */\r
+ public static final int DONT_MOVE_AND_RESIZE = 3;\r
\r
/**\r
* Returns the column (0 based) of the first cell.\r
* @param dx2 the x coordinate within the second cell\r
*/\r
public void setDx2(int dx2);\r
+\r
+\r
+ /**\r
+ * Sets the anchor type\r
+ * <p>\r
+ * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.\r
+ * </p>\r
+ * @param anchorType the anchor type\r
+ * @see #MOVE_AND_RESIZE\r
+ * @see #MOVE_DONT_RESIZE\r
+ * @see #DONT_MOVE_AND_RESIZE\r
+ */\r
+ public void setAnchorType( int anchorType );\r
+\r
+ /**\r
+ * Gets the anchor type\r
+ * <p>\r
+ * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.\r
+ * </p>\r
+ * @return the anchor type\r
+ * @see #MOVE_AND_RESIZE\r
+ * @see #MOVE_DONT_RESIZE\r
+ * @see #DONT_MOVE_AND_RESIZE\r
+ */\r
+ public int getAnchorType();\r
+\r
}\r
* @author Yegor Kozlov\r
*/\r
public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {\r
+ private int anchorType;\r
\r
/**\r
* Starting anchor point\r
protected void setTo(CTMarker to){\r
cell2 = to;\r
}\r
+\r
+\r
+ /**\r
+ * Sets the anchor type\r
+ * <p>\r
+ * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.\r
+ */\r
+ public void setAnchorType( int anchorType )\r
+ {\r
+ this.anchorType = anchorType;\r
+ }\r
+\r
+ /**\r
+ * Gets the anchor type\r
+ * <p>\r
+ * 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.\r
+ */\r
+ public int getAnchorType()\r
+ {\r
+ return anchorType;\r
+ }\r
+\r
}\r
PackageRelationship rel = addPictureReference(pictureIndex);\r
\r
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);\r
- ctAnchor.setEditAs(STEditAs.ONE_CELL);\r
CTPicture ctShape = ctAnchor.addNewPic();\r
ctShape.set(XSSFPicture.prototype());\r
\r
ctAnchor.addNewClientData();\r
anchor.setTo(ctAnchor.getTo());\r
anchor.setFrom(ctAnchor.getFrom());\r
+ STEditAs.Enum aditAs;\r
+ switch(anchor.getAnchorType()) {\r
+ case ClientAnchor.DONT_MOVE_AND_RESIZE: aditAs = STEditAs.ABSOLUTE; break;\r
+ case ClientAnchor.MOVE_AND_RESIZE: aditAs = STEditAs.TWO_CELL; break;\r
+ case ClientAnchor.MOVE_DONT_RESIZE: aditAs = STEditAs.ONE_CELL; break;\r
+ default: aditAs = STEditAs.ONE_CELL;\r
+ }\r
+ ctAnchor.setEditAs(aditAs);\r
return ctAnchor;\r
}\r
}\r
package org.apache.poi.xssf.usermodel;\r
\r
import junit.framework.TestCase;\r
-import org.apache.poi.xssf.XSSFTestDataSamples;\r
-import org.apache.poi.POIXMLDocumentPart;\r
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;\r
+import org.apache.poi.ss.usermodel.ClientAnchor;\r
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor;\r
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs;\r
\r
import java.util.List;\r
import java.util.Arrays;\r
-import java.io.IOException;\r
\r
/**\r
* @author Yegor Kozlov\r
assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));\r
\r
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);\r
+ assertEquals(ClientAnchor.MOVE_AND_RESIZE, anchor.getAnchorType());\r
+ anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);\r
+ assertEquals(ClientAnchor.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());\r
+\r
XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);\r
assertTrue(anchor.equals(shape.getAnchor()));\r
assertNotNull(shape.getPictureData());\r
assertTrue(Arrays.equals(jpegData, shape.getPictureData().getData()));\r
\r
+ CTTwoCellAnchor ctShapeHolder = drawing.getCTDrawing().getTwoCellAnchorArray(0);\r
+ // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE\r
+ assertEquals(STEditAs.ABSOLUTE, ctShapeHolder.getEditAs());\r
}\r
}\r