aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-06-13 11:56:21 +0000
committerYegor Kozlov <yegor@apache.org>2011-06-13 11:56:21 +0000
commitb0f8fcc9eed5d055759f7cdf93b21f81f1b7a49d (patch)
tree80edf1edc68dfa4b3280cac9157fe5933b603a85 /src/ooxml/java
parent87140f2bc9dd4d2fa0f382b8495a8f122bdefd75 (diff)
downloadpoi-b0f8fcc9eed5d055759f7cdf93b21f81f1b7a49d.tar.gz
poi-b0f8fcc9eed5d055759f7cdf93b21f81f1b7a49d.zip
Bug 50458: Fixed missing shapeId in XSSF drawings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1135103 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
index 5c449473e8..446e0ecea7 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java
@@ -37,6 +37,7 @@ import org.apache.poi.util.Internal;
import org.apache.poi.xssf.model.CommentsTable;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTConnector;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGroupShape;
@@ -141,9 +142,11 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
* @return the newly created textbox.
*/
public XSSFTextBox createTextbox(XSSFClientAnchor anchor){
+ long shapeId = newShapeId();
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
CTShape ctShape = ctAnchor.addNewSp();
ctShape.set(XSSFSimpleShape.prototype());
+ ctShape.getNvSpPr().getCNvPr().setId(shapeId);
XSSFTextBox shape = new XSSFTextBox(this, ctShape);
shape.anchor = anchor;
return shape;
@@ -163,10 +166,13 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
{
PackageRelationship rel = addPictureReference(pictureIndex);
+ long shapeId = newShapeId();
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
CTPicture ctShape = ctAnchor.addNewPic();
ctShape.set(XSSFPicture.prototype());
+ ctShape.getNvPicPr().getCNvPr().setId(shapeId);
+
XSSFPicture shape = new XSSFPicture(this, ctShape);
shape.anchor = anchor;
shape.setPictureReference(rel);
@@ -227,9 +233,11 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
*/
public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor)
{
+ long shapeId = newShapeId();
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
CTShape ctShape = ctAnchor.addNewSp();
ctShape.set(XSSFSimpleShape.prototype());
+ ctShape.getNvSpPr().getCNvPr().setId(shapeId);
XSSFSimpleShape shape = new XSSFSimpleShape(this, ctShape);
shape.anchor = anchor;
return shape;
@@ -354,4 +362,8 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
ctAnchor.setEditAs(aditAs);
return ctAnchor;
}
+
+ private long newShapeId(){
+ return drawing.sizeOfTwoCellAnchorArray() + 1;
+ }
}