poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r756965 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/
Date Sat, 21 Mar 2009 16:28:27 GMT
Author: yegor
Date: Sat Mar 21 16:28:26 2009
New Revision: 756965

URL: http://svn.apache.org/viewvc?rev=756965&view=rev
Log:
added modifiers for anchor type to XSSFClientAnchor

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ClientAnchor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Sat Mar 21 16:28:26 2009
@@ -37,6 +37,7 @@
 
 		<!-- 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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat Mar 21 16:28:26 2009
@@ -34,6 +34,7 @@
 	<!-- 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>

Modified: poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ClientAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ClientAnchor.java?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ClientAnchor.java (original)
+++ poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ClientAnchor.java Sat
Mar 21 16:28:26 2009
@@ -23,6 +23,44 @@
  * @author Yegor Kozlov
  */
 public interface ClientAnchor {
+    /**
+     * Move and Resize With Anchor Cells
+     * <p>
+     * Specifies that the current drawing shall move and
+     * resize to maintain its row and column anchors (i.e. the
+     * object is anchored to the actual from and to row and column)
+     * </p>
+     */
+    public static final int MOVE_AND_RESIZE = 0;
+
+    /**
+     * Move With Cells but Do Not Resize
+     * <p>
+     * Specifies that the current drawing shall move with its
+     * row and column (i.e. the object is anchored to the
+     * actual from row and column), but that the size shall remain absolute.
+     * </p>
+     * <p>
+     * If additional rows/columns are added between the from and to locations of the drawing,
+     * the drawing shall move its to anchors as needed to maintain this same absolute size.
+     * </p>
+     */
+    public static final int MOVE_DONT_RESIZE = 2;
+
+    /**
+     * Do Not Move or Resize With Underlying Rows/Columns
+     * <p>
+     * Specifies that the current start and end positions shall
+     * be maintained with respect to the distances from the
+     * absolute start point of the worksheet.
+     * </p>
+     * <p>
+     * If additional rows/columns are added before the
+     * drawing, the drawing shall move its anchors as needed
+     * to maintain this same absolute position.
+     * </p>
+     */
+    public static final int DONT_MOVE_AND_RESIZE = 3;
 
     /**
      * Returns the column (0 based) of the first cell.
@@ -135,4 +173,30 @@
      * @param dx2 the x coordinate within the second cell
      */
     public void setDx2(int dx2);
+
+
+    /**
+     * 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.
+     * </p>
+     * @param anchorType the anchor type
+     * @see #MOVE_AND_RESIZE
+     * @see #MOVE_DONT_RESIZE
+     * @see #DONT_MOVE_AND_RESIZE
+     */
+    public void setAnchorType( int 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.
+     * </p>
+     * @return the anchor type
+     * @see #MOVE_AND_RESIZE
+     * @see #MOVE_DONT_RESIZE
+     * @see #DONT_MOVE_AND_RESIZE
+     */
+    public int getAnchorType();
+
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java Sat Mar 21
16:28:26 2009
@@ -26,6 +26,7 @@
  * @author Yegor Kozlov
  */
 public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
+    private int anchorType;
 
     /**
      * Starting anchor point
@@ -193,4 +194,26 @@
     protected void setTo(CTMarker to){
         cell2 = to;
     }
+
+
+    /**
+     * 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.
+     */
+    public void setAnchorType( int 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.
+     */
+    public int getAnchorType()
+    {
+        return anchorType;
+    }
+
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java Sat Mar 21 16:28:26
2009
@@ -138,7 +138,6 @@
         PackageRelationship rel = addPictureReference(pictureIndex);
 
         CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
-        ctAnchor.setEditAs(STEditAs.ONE_CELL);
         CTPicture ctShape = ctAnchor.addNewPic();
         ctShape.set(XSSFPicture.prototype());
 
@@ -235,6 +234,14 @@
         ctAnchor.addNewClientData();
         anchor.setTo(ctAnchor.getTo());
         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;
+            default: aditAs = STEditAs.ONE_CELL;
+        }
+        ctAnchor.setEditAs(aditAs);
         return ctAnchor;
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java?rev=756965&r1=756964&r2=756965&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java Sat Mar
21 16:28:26 2009
@@ -17,13 +17,12 @@
 package org.apache.poi.xssf.usermodel;
 
 import junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs;
 
 import java.util.List;
 import java.util.Arrays;
-import java.io.IOException;
 
 /**
  * @author Yegor Kozlov
@@ -46,10 +45,17 @@
         assertTrue(Arrays.equals(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());
+
         XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);
         assertTrue(anchor.equals(shape.getAnchor()));
         assertNotNull(shape.getPictureData());
         assertTrue(Arrays.equals(jpegData, shape.getPictureData().getData()));
 
+        CTTwoCellAnchor ctShapeHolder = drawing.getCTDrawing().getTwoCellAnchorArray(0);
+        // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE
+        assertEquals(STEditAs.ABSOLUTE, ctShapeHolder.getEditAs());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message