From c580758b2c981397a3f22862ee84af3bae01dcea Mon Sep 17 00:00:00 2001 From: David North Date: Wed, 3 Jun 2015 12:50:10 +0000 Subject: [PATCH] Use a different arbitrary value for the ID of the comment shape type. This appears to prevent Excel >= 2010 from turning POI-written comments into the wrong shape (giant curved arrow). Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=55410 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1683315 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java | 3 ++- .../org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java index a1458662bf..75f292fa63 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java @@ -68,6 +68,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { private static final QName QNAME_SHAPE_LAYOUT = new QName("urn:schemas-microsoft-com:office:office", "shapelayout"); private static final QName QNAME_SHAPE_TYPE = new QName("urn:schemas-microsoft-com:vml", "shapetype"); private static final QName QNAME_SHAPE = new QName("urn:schemas-microsoft-com:vml", "shape"); + private static final String COMMENT_SHAPE_TYPE_ID = "_x0000_t202"; // this ID value seems to have significance to Excel >= 2010; see https://issues.apache.org/bugzilla/show_bug.cgi?id=55409 /** * regexp to parse shape ids, in VML they have weird form of id="_x0000_s1026" @@ -190,7 +191,7 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { _qnames.add(QNAME_SHAPE_LAYOUT); CTShapetype shapetype = CTShapetype.Factory.newInstance(); - _shapeTypeId = "_xssf_cell_comment"; + _shapeTypeId = COMMENT_SHAPE_TYPE_ID; shapetype.setId(_shapeTypeId); shapetype.setCoordsize("21600,21600"); shapetype.setSpt(202); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java index 346abe0790..5bb3acd0fb 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFVMLDrawing.java @@ -54,14 +54,14 @@ public class TestXSSFVMLDrawing extends TestCase { assertEquals("21600,21600", type.getCoordsize()); assertEquals(202.0f, type.getSpt()); assertEquals("m,l,21600r21600,l21600,xe", type.getPath2()); - assertEquals("_xssf_cell_comment", type.getId()); + assertEquals("_x0000_t202", type.getId()); assertEquals(STTrueFalse.T, type.getPathArray(0).getGradientshapeok()); assertEquals(STConnectType.RECT, type.getPathArray(0).getConnecttype()); CTShape shape = vml.newCommentShape(); assertEquals(3, items.size()); assertSame(items.get(2), shape); - assertEquals("#_xssf_cell_comment", shape.getType()); + assertEquals("#_x0000_t202", shape.getType()); assertEquals("position:absolute; visibility:hidden", shape.getStyle()); assertEquals("#ffffe1", shape.getFillcolor()); assertEquals(STInsetMode.AUTO, shape.getInsetmode()); -- 2.39.5