You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/06/19 18:49:40 UTC

svn commit: r786577 - in /poi/trunk/src: documentation/content/xdocs/ scratchpad/src/org/apache/poi/hslf/model/ scratchpad/testcases/org/apache/poi/hslf/model/

Author: yegor
Date: Fri Jun 19 16:49:39 2009
New Revision: 786577

URL: http://svn.apache.org/viewvc?rev=786577&view=rev
Log:
fixed SimpleShape#getLineWidth to handle default line width, see Bugzilla #46392

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=786577&r1=786576&r2=786577&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jun 19 16:49:39 2009
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="add">46793 - fixed SimpleShape#getLineWidth to handle default line width </action>
            <action dev="POI-DEVELOPERS" type="add">47356 - removed unused private fields in HWPF BorderCode</action>
            <action dev="POI-DEVELOPERS" type="add">47355 - Improved  HWPF TableCell to expose TableCellDescriptor</action>
            <action dev="POI-DEVELOPERS" type="fix">46610 - Improved HWPF to better handle unicode</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java?rev=786577&r1=786576&r2=786577&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java Fri Jun 19 16:49:39 2009
@@ -74,7 +74,6 @@
         if (lineColor != null){
             graphics.setPaint(lineColor);
             float width = (float)shape.getLineWidth();
-            if(width == 0) width = 0.75f;
 
             int dashing = shape.getLineDashing();
             //TODO: implement more dashing styles

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java?rev=786577&r1=786576&r2=786577&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java Fri Jun 19 16:49:39 2009
@@ -40,6 +40,8 @@
  */
 public abstract class SimpleShape extends Shape {
 
+    public final static double DEFAULT_LINE_WIDTH = 0.75;
+
     /**
      * Records stored in EscherClientDataRecord
      */
@@ -101,7 +103,8 @@
     public double getLineWidth(){
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
         EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
-        return prop == null ? 0 : (double)prop.getPropertyValue()/EMU_PER_POINT;
+        double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.getPropertyValue()/EMU_PER_POINT;
+        return width;
     }
 
     /**

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=786577&r1=786576&r2=786577&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Fri Jun 19 16:49:39 2009
@@ -21,8 +21,7 @@
 import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.hslf.usermodel.RichTextRun;
 import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.ddf.EscherDggRecord;
-import org.apache.poi.ddf.EscherDgRecord;
+import org.apache.poi.ddf.*;
 
 import java.awt.*;
 import java.awt.Rectangle;
@@ -311,6 +310,20 @@
         assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
     }
 
+    public void testLineWidth() throws IOException {
+        SimpleShape sh = new AutoShape(ShapeTypes.RightTriangle);
+
+        EscherOptRecord opt = (EscherOptRecord)SimpleShape.getEscherChild(sh.getSpContainer(), EscherOptRecord.RECORD_ID);
+        EscherSimpleProperty prop = (EscherSimpleProperty)SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
+        assertNull(prop);
+        assertEquals(SimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth());
+
+        sh.setLineWidth(1.0);
+        prop = (EscherSimpleProperty)SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
+        assertNotNull(prop);
+        assertEquals(1.0, sh.getLineWidth());
+    }
+
     public void testShapeId() throws IOException {
         SlideShow ppt = new SlideShow();
         Slide slide = ppt.createSlide();



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