/** * Sets whether this comment is visible. * * @param visible <code>true</code> if the comment is visible, <code>false</code> otherwise */ @Override public void setVisible(boolean visible) { if(_vmlShape != null){ String style; if(visible) style = "position:absolute;visibility:visible"; else style = "position:absolute;visibility:hidden"; _vmlShape.setStyle(style); } }
/** * Returns whether this comment is visible. * * @return <code>true</code> if the comment is visible, <code>false</code> otherwise */ @Override public boolean isVisible() { boolean visible = false; if(_vmlShape != null) { String style = _vmlShape.getStyle(); visible = style != null && style.contains("visibility:visible"); } return visible; }
private static void avoidXmlbeansCorruptPointer(CTShape vmlShape) { // There is a very odd xmlbeans bug when changing the row // arrays which can lead to corrupt pointer // This call seems to fix them again... See bug #50795 //noinspection ResultOfMethodCallIgnored vmlShape.getClientDataList().toString(); } }
rPr.addNewNoProof(); CTPicture pict = r.addNewPict(); CTGroup group = CTGroup.Factory.newInstance(); CTShapetype shapetype = group.addNewShapetype(); shapetype.setId("_x0000_t136"); shapetype.setCoordsize("1600,21600"); shapetype.setSpt(136); shapetype.setAdj("10800"); shapetype.setPath2("m@7,0l@8,0m@5,21600l@6,21600e"); CTFormulas formulas = shapetype.addNewFormulas(); formulas.addNewF().setEqn("sum #0 0 10800"); formulas.addNewF().setEqn("prod #0 2 1"); formulas.addNewF().setEqn("sum 21600 0 @1"); formulas.addNewF().setEqn("sum 0 0 @2"); formulas.addNewF().setEqn("sum 21600 0 @3"); formulas.addNewF().setEqn("if @0 @3 0"); formulas.addNewF().setEqn("if @0 21600 @1"); formulas.addNewF().setEqn("if @0 0 @2"); formulas.addNewF().setEqn("if @0 @4 21600"); formulas.addNewF().setEqn("mid @5 @6"); formulas.addNewF().setEqn("mid @8 @5"); formulas.addNewF().setEqn("mid @7 @8"); formulas.addNewF().setEqn("mid @6 @7"); formulas.addNewF().setEqn("sum @6 0 @5"); CTPath path = shapetype.addNewPath(); path.setTextpathok(STTrueFalse.T); path.setConnecttype(STConnectType.CUSTOM); path.setConnectlocs("@9,0;@10,10800;@11,21600;@12,10800"); path.setConnectangles("270,180,90,0");
protected CTShape newCommentShape(){ CTShape shape = CTShape.Factory.newInstance(); shape.setId("_x0000_s" + (++_shapeId)); shape.setType("#" + _shapeTypeId); shape.setStyle("position:absolute; visibility:hidden"); shape.setFillcolor("#ffffe1"); shape.setInsetmode(STInsetMode.AUTO); shape.addNewFill().setColor("#ffffe1"); CTShadow shadow = shape.addNewShadow(); shadow.setOn(STTrueFalse.T); shadow.setColor("black"); shadow.setObscured(STTrueFalse.T); shape.addNewPath().setConnecttype(STConnectType.NONE); shape.addNewTextbox().setStyle("mso-direction-alt:auto"); CTClientData cldata = shape.addNewClientData(); cldata.setObjectType(STObjectType.NOTE); cldata.addNewMoveWithCells(); cldata.addNewSizeWithCells(); cldata.addNewAnchor().setStringValue("1, 15, 0, 2, 3, 15, 3, 16"); cldata.addNewAutoFill().setStringValue("False"); cldata.addNewRow().setBigIntegerValue(new BigInteger("0")); cldata.addNewColumn().setBigIntegerValue(new BigInteger("0")); _items.add(shape); _qnames.add(QNAME_SHAPE); return shape; }
/** * Initialize a new Speadsheet VML drawing */ private void newDrawing(){ CTShapeLayout layout = CTShapeLayout.Factory.newInstance(); layout.setExt(STExt.EDIT); CTIdMap idmap = layout.addNewIdmap(); idmap.setExt(STExt.EDIT); idmap.setData("1"); _items.add(layout); _qnames.add(QNAME_SHAPE_LAYOUT); CTShapetype shapetype = CTShapetype.Factory.newInstance(); _shapeTypeId = COMMENT_SHAPE_TYPE_ID; shapetype.setId(_shapeTypeId); shapetype.setCoordsize("21600,21600"); shapetype.setSpt(202); shapetype.setPath2("m,l,21600r21600,l21600,xe"); shapetype.addNewStroke().setJoinstyle(STStrokeJoinStyle.MITER); CTPath path = shapetype.addNewPath(); path.setGradientshapeok(STTrueFalse.T); path.setConnecttype(STConnectType.RECT); _items.add(shapetype); _qnames.add(QNAME_SHAPE_TYPE); }
_items.add(CTShapeLayout.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS)); } else if (qname.equals(QNAME_SHAPE_TYPE)) { CTShapetype st = CTShapetype.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS); _items.add(st); _shapeTypeId = st.getId(); } else if (qname.equals(QNAME_SHAPE)) { CTShape shape = CTShape.Factory.parse(obj.xmlText(), DEFAULT_XML_OPTIONS); String id = shape.getId(); if(id != null) { Matcher m = ptrn_shapeId.matcher(id);
/** * Find a shape with ClientData of type "NOTE" and the specified row and column * * @return the comment shape or <code>null</code> */ public CTShape findCommentShape(int row, int col){ for(XmlObject itm : _items){ if(itm instanceof CTShape){ CTShape sh = (CTShape)itm; if(sh.sizeOfClientDataArray() > 0){ CTClientData cldata = sh.getClientDataArray(0); if(cldata.getObjectType() == STObjectType.NOTE){ int crow = cldata.getRowArray(0).intValue(); int ccol = cldata.getColumnArray(0).intValue(); if(crow == row && ccol == col) { return sh; } } } } } return null; }
@Override public ClientAnchor getClientAnchor() { if(_vmlShape == null) { return null; } String position = _vmlShape.getClientDataArray(0).getAnchorArray(0); int[] pos = new int[8]; int i = 0; for (String s : position.split(",")) { pos[i++] = Integer.parseInt(s.trim()); } return new XSSFClientAnchor(pos[1]*EMU_PER_PIXEL, pos[3]*EMU_PER_PIXEL, pos[5]*EMU_PER_PIXEL, pos[7]*EMU_PER_PIXEL, pos[0], pos[2], pos[4], pos[6]); }
rPr.addNewNoProof(); CTPicture pict = r.addNewPict(); CTGroup group = CTGroup.Factory.newInstance(); CTShapetype shapetype = group.addNewShapetype(); shapetype.setId("_x0000_t136"); shapetype.setCoordsize("1600,21600"); shapetype.setSpt(136); shapetype.setAdj("10800"); shapetype.setPath2("m@7,0l@8,0m@5,21600l@6,21600e"); CTFormulas formulas = shapetype.addNewFormulas(); formulas.addNewF().setEqn("sum #0 0 10800"); formulas.addNewF().setEqn("prod #0 2 1"); formulas.addNewF().setEqn("sum 21600 0 @1"); formulas.addNewF().setEqn("sum 0 0 @2"); formulas.addNewF().setEqn("sum 21600 0 @3"); formulas.addNewF().setEqn("if @0 @3 0"); formulas.addNewF().setEqn("if @0 21600 @1"); formulas.addNewF().setEqn("if @0 0 @2"); formulas.addNewF().setEqn("if @0 @4 21600"); formulas.addNewF().setEqn("mid @5 @6"); formulas.addNewF().setEqn("mid @8 @5"); formulas.addNewF().setEqn("mid @7 @8"); formulas.addNewF().setEqn("mid @6 @7"); formulas.addNewF().setEqn("sum @6 0 @5"); CTPath path = shapetype.addNewPath(); path.setTextpathok(STTrueFalse.T); path.setConnecttype(STConnectType.CUSTOM); path.setConnectlocs("@9,0;@10,10800;@11,21600;@12,10800"); path.setConnectangles("270,180,90,0");
protected CTShape newCommentShape(){ CTShape shape = CTShape.Factory.newInstance(); shape.setId("_x0000_s" + (++_shapeId)); shape.setType("#" + _shapeTypeId); shape.setStyle("position:absolute; visibility:hidden"); shape.setFillcolor("#ffffe1"); shape.setInsetmode(STInsetMode.AUTO); shape.addNewFill().setColor("#ffffe1"); CTShadow shadow = shape.addNewShadow(); shadow.setOn(STTrueFalse.T); shadow.setColor("black"); shadow.setObscured(STTrueFalse.T); shape.addNewPath().setConnecttype(STConnectType.NONE); shape.addNewTextbox().setStyle("mso-direction-alt:auto"); CTClientData cldata = shape.addNewClientData(); cldata.setObjectType(STObjectType.NOTE); cldata.addNewMoveWithCells(); cldata.addNewSizeWithCells(); cldata.addNewAnchor().setStringValue("1, 15, 0, 2, 3, 15, 3, 16"); cldata.addNewAutoFill().setStringValue("False"); cldata.addNewRow().setBigIntegerValue(new BigInteger("0")); cldata.addNewColumn().setBigIntegerValue(new BigInteger("0")); _items.add(shape); _qnames.add(QNAME_SHAPE); return shape; }
/** * Initialize a new Speadsheet VML drawing */ private void newDrawing(){ CTShapeLayout layout = CTShapeLayout.Factory.newInstance(); layout.setExt(STExt.EDIT); CTIdMap idmap = layout.addNewIdmap(); idmap.setExt(STExt.EDIT); idmap.setData("1"); _items.add(layout); _qnames.add(QNAME_SHAPE_LAYOUT); CTShapetype shapetype = CTShapetype.Factory.newInstance(); _shapeTypeId = COMMENT_SHAPE_TYPE_ID; shapetype.setId(_shapeTypeId); shapetype.setCoordsize("21600,21600"); shapetype.setSpt(202); shapetype.setPath2("m,l,21600r21600,l21600,xe"); shapetype.addNewStroke().setJoinstyle(STStrokeJoinStyle.MITER); CTPath path = shapetype.addNewPath(); path.setGradientshapeok(STTrueFalse.T); path.setConnecttype(STConnectType.RECT); _items.add(shapetype); _qnames.add(QNAME_SHAPE_TYPE); }
/** * Creates a new XSSFComment, associated with a given * low level comment object. */ public XSSFComment(CommentsTable comments, CTComment comment, CTShape vmlShape) { _comment = comment; _comments = comments; _vmlShape = vmlShape; // we potentially need to adjust the column/row information in the shape // the same way as we do in setRow()/setColumn() if(comment != null && vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) { CellReference ref = new CellReference(comment.getRef()); CTClientData clientData = vmlShape.getClientDataArray(0); clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow()))); clientData.setColumnArray(0, new BigInteger(String.valueOf(ref.getCol()))); avoidXmlbeansCorruptPointer(vmlShape); } }
/** * Sets whether this comment is visible. * * @param visible <code>true</code> if the comment is visible, <code>false</code> otherwise */ @Override public void setVisible(boolean visible) { if(_vmlShape != null){ String style; if(visible) style = "position:absolute;visibility:visible"; else style = "position:absolute;visibility:hidden"; _vmlShape.setStyle(style); } }
/** * Returns whether this comment is visible. * * @return <code>true</code> if the comment is visible, <code>false</code> otherwise */ @Override public boolean isVisible() { boolean visible = false; if(_vmlShape != null) { String style = _vmlShape.getStyle(); visible = style != null && style.contains("visibility:visible"); } return visible; }
@Override public void setAddress(CellAddress address) { CellAddress oldRef = new CellAddress(_comment.getRef()); if (address.equals(oldRef)) { // nothing to do return; } _comment.setRef(address.formatAsString()); _comments.referenceUpdated(oldRef, _comment); if (_vmlShape != null) { CTClientData clientData = _vmlShape.getClientDataArray(0); clientData.setRowArray(0, new BigInteger(String.valueOf(address.getRow()))); clientData.setColumnArray(0, new BigInteger(String.valueOf(address.getColumn()))); avoidXmlbeansCorruptPointer(_vmlShape); } }
private static void avoidXmlbeansCorruptPointer(CTShape vmlShape) { // There is a very odd xmlbeans bug when changing the row // arrays which can lead to corrupt pointer // This call seems to fix them again... See bug #50795 //noinspection ResultOfMethodCallIgnored vmlShape.getClientDataList().toString(); } }
/** * Find a shape with ClientData of type "NOTE" and the specified row and column * * @return the comment shape or <code>null</code> */ public CTShape findCommentShape(int row, int col){ for(XmlObject itm : _items){ if(itm instanceof CTShape){ CTShape sh = (CTShape)itm; if(sh.sizeOfClientDataArray() > 0){ CTClientData cldata = sh.getClientDataArray(0); if(cldata.getObjectType() == STObjectType.NOTE){ int crow = cldata.getRowArray(0).intValue(); int ccol = cldata.getColumnArray(0).intValue(); if(crow == row && ccol == col) { return sh; } } } } } return null; }
String position = ca.getCol1() + ", " + dx1Pixels + ", " + ca.getRow1() + ", " + dy1Pixels + ", " + ca .getCol2() + ", " + dx2Pixels + ", " + ca.getRow2() + ", " + dy2Pixels; vmlShape.getClientDataArray(0).setAnchorArray(0, position);
@Override public ClientAnchor getClientAnchor() { if(_vmlShape == null) { return null; } String position = _vmlShape.getClientDataArray(0).getAnchorArray(0); int[] pos = new int[8]; int i = 0; for (String s : position.split(",")) { pos[i++] = Integer.parseInt(s.trim()); } return new XSSFClientAnchor(pos[1]*EMU_PER_PIXEL, pos[3]*EMU_PER_PIXEL, pos[5]*EMU_PER_PIXEL, pos[7]*EMU_PER_PIXEL, pos[0], pos[2], pos[4], pos[6]); }