You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/04/08 12:07:45 UTC
svn commit: r645823 [3/3] - in /poi/branches/ooxml: ./
src/documentation/content/xdocs/
src/scratchpad/src/org/apache/poi/hdgf/chunks/
src/scratchpad/src/org/apache/poi/hdgf/extractor/
src/scratchpad/src/org/apache/poi/hdgf/streams/ src/scratchpad/src/...
Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java?rev=645823&r1=645822&r2=645823&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java Tue Apr 8 03:07:36 2008
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.awt.*;
+import java.awt.geom.Rectangle2D;
/**
* <p>
@@ -143,24 +144,39 @@
* @return the anchor of this shape
*/
public java.awt.Rectangle getAnchor(){
+ Rectangle2D anchor2d = getAnchor2D();
+ return anchor2d.getBounds();
+ }
+
+ /**
+ * Returns the anchor (the bounding box rectangle) of this shape.
+ * All coordinates are expressed in points (72 dpi).
+ *
+ * @return the anchor of this shape
+ */
+ public Rectangle2D getAnchor2D(){
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
- java.awt.Rectangle anchor=null;
+ Rectangle2D anchor=null;
if ((flags & EscherSpRecord.FLAG_CHILD) != 0){
EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(_escherContainer, EscherChildAnchorRecord.RECORD_ID);
anchor = new java.awt.Rectangle();
- anchor.x = rec.getDx1()*POINT_DPI/MASTER_DPI;
- anchor.y = rec.getDy1()*POINT_DPI/MASTER_DPI;
- anchor.width = rec.getDx2()*POINT_DPI/MASTER_DPI - anchor.x;
- anchor.height = rec.getDy2()*POINT_DPI/MASTER_DPI - anchor.y;
+ anchor = new Rectangle2D.Float(
+ (float)rec.getDx1()*POINT_DPI/MASTER_DPI,
+ (float)rec.getDy1()*POINT_DPI/MASTER_DPI,
+ (float)(rec.getDx2()-rec.getDx1())*POINT_DPI/MASTER_DPI,
+ (float)(rec.getDy2()-rec.getDy1())*POINT_DPI/MASTER_DPI
+ );
}
else {
EscherClientAnchorRecord rec = (EscherClientAnchorRecord)getEscherChild(_escherContainer, EscherClientAnchorRecord.RECORD_ID);
anchor = new java.awt.Rectangle();
- anchor.y = rec.getFlag()*POINT_DPI/MASTER_DPI;
- anchor.x = rec.getCol1()*POINT_DPI/MASTER_DPI;
- anchor.width = (rec.getDx1() - rec.getCol1())*POINT_DPI/MASTER_DPI;
- anchor.height = (rec.getRow1() - rec.getFlag())*POINT_DPI/MASTER_DPI;
+ anchor = new Rectangle2D.Float(
+ (float)rec.getCol1()*POINT_DPI/MASTER_DPI,
+ (float)rec.getFlag()*POINT_DPI/MASTER_DPI,
+ (float)(rec.getDx1()-rec.getCol1())*POINT_DPI/MASTER_DPI,
+ (float)(rec.getRow1()-rec.getFlag())*POINT_DPI/MASTER_DPI
+ );
}
return anchor;
}
@@ -171,22 +187,22 @@
*
* @param anchor new anchor
*/
- public void setAnchor(java.awt.Rectangle anchor){
+ public void setAnchor(Rectangle2D anchor){
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
if ((flags & EscherSpRecord.FLAG_CHILD) != 0){
EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(_escherContainer, EscherChildAnchorRecord.RECORD_ID);
- rec.setDx1(anchor.x*MASTER_DPI/POINT_DPI);
- rec.setDy1(anchor.y*MASTER_DPI/POINT_DPI);
- rec.setDx2((anchor.width + anchor.x)*MASTER_DPI/POINT_DPI);
- rec.setDy2((anchor.height + anchor.y)*MASTER_DPI/POINT_DPI);
+ rec.setDx1((int)(anchor.getX()*MASTER_DPI/POINT_DPI));
+ rec.setDy1((int)(anchor.getY()*MASTER_DPI/POINT_DPI));
+ rec.setDx2((int)((anchor.getWidth() + anchor.getX())*MASTER_DPI/POINT_DPI));
+ rec.setDy2((int)((anchor.getHeight() + anchor.getY())*MASTER_DPI/POINT_DPI));
}
else {
EscherClientAnchorRecord rec = (EscherClientAnchorRecord)getEscherChild(_escherContainer, EscherClientAnchorRecord.RECORD_ID);
- rec.setFlag((short)(anchor.y*MASTER_DPI/POINT_DPI));
- rec.setCol1((short)(anchor.x*MASTER_DPI/POINT_DPI));
- rec.setDx1((short)((anchor.width + anchor.x)*MASTER_DPI/POINT_DPI));
- rec.setRow1((short)((anchor.height + anchor.y)*MASTER_DPI/POINT_DPI));
+ rec.setFlag((short)(anchor.getY()*MASTER_DPI/POINT_DPI));
+ rec.setCol1((short)(anchor.getX()*MASTER_DPI/POINT_DPI));
+ rec.setDx1((short)(((anchor.getWidth() + anchor.getX())*MASTER_DPI/POINT_DPI)));
+ rec.setRow1((short)(((anchor.getHeight() + anchor.getY())*MASTER_DPI/POINT_DPI)));
}
}
@@ -197,9 +213,9 @@
* @param x the x coordinate of the top left corner of the shape
* @param y the y coordinate of the top left corner of the shape
*/
- public void moveTo(int x, int y){
- java.awt.Rectangle anchor = getAnchor();
- anchor.setLocation(x, y);
+ public void moveTo(float x, float y){
+ Rectangle2D anchor = getAnchor2D();
+ anchor.setRect(x, y, anchor.getWidth(), anchor.getHeight());
setAnchor(anchor);
}
@@ -252,6 +268,28 @@
opt.addEscherProperty(new EscherSimpleProperty(propId, value));
opt.sortProperties();
}
+ }
+
+ /**
+ * Set an simple escher property for this shape.
+ *
+ * @param propId The id of the property. One of the constants defined in EscherOptRecord.
+ * @param value value of the property. If value = -1 then the property is removed.
+ */
+ public void setEscherProperty(short propId, int value){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ setEscherProperty(opt, propId, value);
+ }
+
+ /**
+ * Get the value of a simple escher property for this shape.
+ *
+ * @param propId The id of the property. One of the constants defined in EscherOptRecord.
+ */
+ public int getEscherProperty(short propId){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, propId);
+ return prop == null ? 0 : prop.getPropertyNumber();
}
/**
Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java?rev=645823&r1=645822&r2=645823&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java Tue Apr 8 03:07:36 2008
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.awt.geom.Rectangle2D;
/**
* Represents a group of shapes.
@@ -186,16 +187,16 @@
*
* @return the anchor of this shape group
*/
- public java.awt.Rectangle getAnchor(){
+ public Rectangle2D getAnchor2D(){
EscherContainerRecord groupInfoContainer = (EscherContainerRecord)_escherContainer.getChild(0);
EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(groupInfoContainer, EscherSpgrRecord.RECORD_ID);
- java.awt.Rectangle anchor=null;
+ Rectangle2D anchor = new Rectangle2D.Float(
+ (float)spgr.getRectX1()*POINT_DPI/MASTER_DPI,
+ (float)spgr.getRectY1()*POINT_DPI/MASTER_DPI,
+ (float)(spgr.getRectX2() - spgr.getRectX1())*POINT_DPI/MASTER_DPI,
+ (float)(spgr.getRectY2() - spgr.getRectY1())*POINT_DPI/MASTER_DPI
+ );
- anchor = new java.awt.Rectangle();
- anchor.x = spgr.getRectX1()*POINT_DPI/MASTER_DPI;
- anchor.y = spgr.getRectY1()*POINT_DPI/MASTER_DPI;
- anchor.width = (spgr.getRectX2() - spgr.getRectX1())*POINT_DPI/MASTER_DPI;
- anchor.height = (spgr.getRectY2() - spgr.getRectY1())*POINT_DPI/MASTER_DPI;
return anchor;
}
Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java?rev=645823&r1=645822&r2=645823&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java Tue Apr 8 03:07:36 2008
@@ -105,9 +105,13 @@
*/
public void setLineColor(Color color){
EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, rgb);
- setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, color == null ? 0x180010 : 0x180018);
+ if (color == null) {
+ setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80000);
+ } else {
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
+ setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, rgb);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, color == null ? 0x180010 : 0x180018);
+ }
}
/**
@@ -212,9 +216,13 @@
*/
public void setFillColor(Color color){
EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, color == null ? 0x150010 : 0x150011);
+ if(color == null) {
+ setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000);
+ } else {
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
+ setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
+ setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150011);
+ }
}
}
Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java?rev=645823&r1=645822&r2=645823&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java Tue Apr 8 03:07:36 2008
@@ -17,25 +17,21 @@
package org.apache.poi.hdgf.extractor;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.PrintStream;
import junit.framework.TestCase;
import org.apache.poi.hdgf.HDGFDiagram;
-import org.apache.poi.hdgf.chunks.Chunk;
-import org.apache.poi.hdgf.chunks.ChunkFactory;
-import org.apache.poi.hdgf.pointers.Pointer;
-import org.apache.poi.hdgf.pointers.PointerFactory;
-import org.apache.poi.hssf.record.formula.eval.StringOperationEval;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class TestVisioExtractor extends TestCase {
- private String filename;
+ private String dirname;
+ private String defFilename;
protected void setUp() throws Exception {
- String dirname = System.getProperty("HDGF.testdata.path");
- filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
+ dirname = System.getProperty("HDGF.testdata.path");
+ defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd";
}
/**
@@ -44,14 +40,14 @@
public void testCreation() throws Exception {
VisioTextExtractor extractor;
- extractor = new VisioTextExtractor(new FileInputStream(filename));
+ extractor = new VisioTextExtractor(new FileInputStream(defFilename));
assertNotNull(extractor);
assertNotNull(extractor.getAllText());
assertEquals(3, extractor.getAllText().length);
extractor = new VisioTextExtractor(
new POIFSFileSystem(
- new FileInputStream(filename)
+ new FileInputStream(defFilename)
)
);
assertNotNull(extractor);
@@ -61,7 +57,7 @@
extractor = new VisioTextExtractor(
new HDGFDiagram(
new POIFSFileSystem(
- new FileInputStream(filename)
+ new FileInputStream(defFilename)
)
)
);
@@ -72,7 +68,7 @@
public void testExtraction() throws Exception {
VisioTextExtractor extractor =
- new VisioTextExtractor(new FileInputStream(filename));
+ new VisioTextExtractor(new FileInputStream(defFilename));
// Check the array fetch
String[] text = extractor.getAllText();
@@ -88,13 +84,30 @@
assertEquals("Test View\nI am a test view\nSome random text, on a page\n", textS);
}
+ public void testProblemFiles() throws Exception {
+ File a = new File(dirname, "44594.vsd");
+ VisioTextExtractor.main(new String[] {a.toString()});
+
+ File b = new File(dirname, "44594-2.vsd");
+ VisioTextExtractor.main(new String[] {b.toString()});
+
+ File c = new File(dirname, "ShortChunk1.vsd");
+ VisioTextExtractor.main(new String[] {c.toString()});
+
+ File d = new File(dirname, "ShortChunk2.vsd");
+ VisioTextExtractor.main(new String[] {d.toString()});
+
+ File e = new File(dirname, "ShortChunk3.vsd");
+ VisioTextExtractor.main(new String[] {e.toString()});
+ }
+
public void testMain() throws Exception {
PrintStream oldOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream capture = new PrintStream(baos);
System.setOut(capture);
- VisioTextExtractor.main(new String[] {filename});
+ VisioTextExtractor.main(new String[] {defFilename});
// Put things back
System.setOut(oldOut);
Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java?rev=645823&r1=645822&r2=645823&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java Tue Apr 8 03:07:36 2008
@@ -98,7 +98,7 @@
assertEquals(0, prop.getValue());
prop = props.findByName("font.size");
- assertEquals(49, prop.getValue());
+ assertEquals(44, prop.getValue());
}
@@ -138,7 +138,7 @@
assertEquals(0, prop.getValue());
prop = props.findByName("font.size");
- assertEquals(36, prop.getValue());
+ assertEquals(32, prop.getValue());
}
/**
@@ -164,7 +164,7 @@
assertEquals(0, prop.getValue());
prop = props.findByName("font.size");
- assertEquals(24, prop.getValue());
+ assertEquals(18, prop.getValue());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org