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; }
/** * 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; }
/** * 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; }
lock.setExt(STExt.EDIT); CTShape shape = group.addNewShape(); shape.setId("PowerPlusWaterMarkObject" + idx); shape.setSpid("_x0000_s102" + (4 + idx)); shape.setType("#_x0000_t136"); shape.setStyle("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin"); shape.setWrapcoords("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068"); shape.setFillcolor("black"); shape.setStroked(STTrueFalse.FALSE); CTTextPath shapeTextPath = shape.addNewTextpath(); shapeTextPath.setStyle("font-family:"Cambria";font-size:1pt"); shapeTextPath.setString(text);
private void addWaterMark(Object obj, String watermark, String color) { if (obj instanceof XWPFDocument) { XWPFDocument doc = (XWPFDocument) obj; // create header-footer XWPFHeaderFooterPolicy headerFooterPolicy = doc.getHeaderFooterPolicy(); if (headerFooterPolicy == null) headerFooterPolicy = doc.createHeaderFooterPolicy(); // create default Watermark - fill color black and not rotated headerFooterPolicy.createWatermark(watermark); // get the default header // Note: createWatermark also sets FIRST and EVEN headers // but this code does not updating those other headers XWPFHeader header = headerFooterPolicy.getHeader(XWPFHeaderFooterPolicy.DEFAULT); XWPFParagraph paragraph = header.getParagraphArray(0); // get com.microsoft.schemas.vml.CTShape where fill color and rotation is set XmlObject[] xmlobjects = paragraph.getCTP().getRArray(0).getPictArray(0).selectChildren(new QName("urn:schemas-microsoft-com:vml", "shape")); if (xmlobjects.length > 0) { com.microsoft.schemas.vml.CTShape ctshape = (com.microsoft.schemas.vml.CTShape)xmlobjects[0]; // set fill color ctshape.setFillcolor(color); // set rotation ctshape.setStyle(ctshape.getStyle() + ";rotation:315"); } } else if (obj instanceof HWPFDocument) { } } }
ctShape.setStyle("width:80pt;height:24pt"); CTTxbxContent ctTxbxContent = ctShape.addNewTextbox().addNewTxbxContent(); XWPFParagraph textboxparagraph = new XWPFParagraph(ctTxbxContent.addNewP(), (IBody)header); XWPFRun textboxrun = textboxparagraph.createRun(); ctShape.setStyle("width:80pt;height:24pt"); ctTxbxContent = ctShape.addNewTextbox().addNewTxbxContent(); textboxparagraph = new XWPFParagraph(ctTxbxContent.addNewP(), (IBody)header); textboxrun = textboxparagraph.createRun();
/** * 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); } }
@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]); }
lock.setExt(STExt.EDIT); CTShape shape = group.addNewShape(); shape.setId("PowerPlusWaterMarkObject" + idx); shape.setSpid("_x0000_s102" + (4 + idx)); shape.setType("#_x0000_t136"); shape.setStyle("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin"); shape.setWrapcoords("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068"); shape.setFillcolor("black"); shape.setStroked(STTrueFalse.FALSE); CTTextPath shapeTextPath = shape.addNewTextpath(); shapeTextPath.setStyle("font-family:"Cambria";font-size:1pt"); shapeTextPath.setString(text);
/** * 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); } }
@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); } }
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; }
/** * 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); } }
String position = ca.getCol1() + ", " + dx1Pixels + ", " + ca.getRow1() + ", " + dy1Pixels + ", " + ca .getCol2() + ", " + dx2Pixels + ", " + ca.getRow2() + ", " + dy2Pixels; vmlShape.getClientDataArray(0).setAnchorArray(0, position);
/** * 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; }
/** * 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]); }
/** * 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); } }
@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); } }
String position = ca.getCol1() + ", " + dx1Pixels + ", " + ca.getRow1() + ", " + dy1Pixels + ", " + ca .getCol2() + ", " + dx2Pixels + ", " + ca.getRow2() + ", " + dy2Pixels; vmlShape.getClientDataArray(0).setAnchorArray(0, position);