fixed SimpleShape#getLineWidth to handle default line width, see Bugzilla #46392
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@786577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ef203cac9
commit
62650ee519
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.5-beta7" date="2009-??-??">
|
<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">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="add">47355 - Improved HWPF TableCell to expose TableCellDescriptor</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">46610 - Improved HWPF to better handle unicode</action>
|
<action dev="POI-DEVELOPERS" type="fix">46610 - Improved HWPF to better handle unicode</action>
|
||||||
|
@ -74,7 +74,6 @@ public final class ShapePainter {
|
|||||||
if (lineColor != null){
|
if (lineColor != null){
|
||||||
graphics.setPaint(lineColor);
|
graphics.setPaint(lineColor);
|
||||||
float width = (float)shape.getLineWidth();
|
float width = (float)shape.getLineWidth();
|
||||||
if(width == 0) width = 0.75f;
|
|
||||||
|
|
||||||
int dashing = shape.getLineDashing();
|
int dashing = shape.getLineDashing();
|
||||||
//TODO: implement more dashing styles
|
//TODO: implement more dashing styles
|
||||||
|
@ -40,6 +40,8 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
*/
|
*/
|
||||||
public abstract class SimpleShape extends Shape {
|
public abstract class SimpleShape extends Shape {
|
||||||
|
|
||||||
|
public final static double DEFAULT_LINE_WIDTH = 0.75;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records stored in EscherClientDataRecord
|
* Records stored in EscherClientDataRecord
|
||||||
*/
|
*/
|
||||||
@ -101,7 +103,8 @@ public abstract class SimpleShape extends Shape {
|
|||||||
public double getLineWidth(){
|
public double getLineWidth(){
|
||||||
EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
|
EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
|
||||||
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,8 +21,7 @@ import junit.framework.TestCase;
|
|||||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||||
import org.apache.poi.hslf.HSLFSlideShow;
|
import org.apache.poi.hslf.HSLFSlideShow;
|
||||||
import org.apache.poi.ddf.EscherDggRecord;
|
import org.apache.poi.ddf.*;
|
||||||
import org.apache.poi.ddf.EscherDgRecord;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
@ -311,6 +310,20 @@ public final class TestShapes extends TestCase {
|
|||||||
assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
|
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 {
|
public void testShapeId() throws IOException {
|
||||||
SlideShow ppt = new SlideShow();
|
SlideShow ppt = new SlideShow();
|
||||||
Slide slide = ppt.createSlide();
|
Slide slide = ppt.createSlide();
|
||||||
|
Loading…
Reference in New Issue
Block a user