use of com.microsoft.schemas.vml.CTShape in project poi by apache.
the class XWPFHeaderFooterPolicy method getWatermarkParagraph.
/*
* This is the default Watermark paragraph; the only variable is the text message
* TODO: manage all the other variables
*/
private XWPFParagraph getWatermarkParagraph(String text, int idx) {
CTP p = CTP.Factory.newInstance();
byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
p.setRsidP(rsidr);
p.setRsidRDefault(rsidrdefault);
CTPPr pPr = p.addNewPPr();
pPr.addNewPStyle().setVal("Header");
// start watermark paragraph
CTR r = p.addNewR();
CTRPr rPr = r.addNewRPr();
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");
CTTextPath shapeTypeTextPath = shapetype.addNewTextpath();
shapeTypeTextPath.setOn(STTrueFalse.T);
shapeTypeTextPath.setFitshape(STTrueFalse.T);
CTHandles handles = shapetype.addNewHandles();
CTH h = handles.addNewH();
h.setPosition("#0,bottomRight");
h.setXrange("6629,14971");
CTLock lock = shapetype.addNewLock();
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);
pict.set(group);
// end watermark paragraph
return new XWPFParagraph(p, doc);
}
use of com.microsoft.schemas.vml.CTShape in project poi by apache.
the class XSSFVMLDrawing method newCommentShape.
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;
}
use of com.microsoft.schemas.vml.CTShape in project poi by apache.
the class TestXSSFComment method getSetRow.
@Test
public void getSetRow() {
CommentsTable sheetComments = new CommentsTable();
XSSFVMLDrawing vml = new XSSFVMLDrawing();
CTComment ctComment = sheetComments.newComment(CellAddress.A1);
CTShape vmlShape = vml.newCommentShape();
XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
comment.setRow(1);
assertEquals(1, comment.getRow());
assertEquals(1, new CellReference(ctComment.getRef()).getRow());
assertEquals(1, vmlShape.getClientDataArray(0).getRowArray(0).intValue());
comment.setRow(5);
assertEquals(5, comment.getRow());
assertEquals(5, new CellReference(ctComment.getRef()).getRow());
assertEquals(5, vmlShape.getClientDataArray(0).getRowArray(0).intValue());
}
use of com.microsoft.schemas.vml.CTShape in project poi by apache.
the class TestXSSFVMLDrawing method testFindCommentShape.
@Test
public void testFindCommentShape() throws IOException, XmlException {
XSSFVMLDrawing vml = new XSSFVMLDrawing();
InputStream stream = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("vmlDrawing1.vml");
try {
vml.read(stream);
} finally {
stream.close();
}
CTShape sh_a1 = vml.findCommentShape(0, 0);
assertNotNull(sh_a1);
assertEquals("_x0000_s1025", sh_a1.getId());
CTShape sh_b1 = vml.findCommentShape(0, 1);
assertNotNull(sh_b1);
assertEquals("_x0000_s1026", sh_b1.getId());
CTShape sh_c1 = vml.findCommentShape(0, 2);
assertNull(sh_c1);
CTShape sh_d1 = vml.newCommentShape();
assertEquals("_x0000_s1027", sh_d1.getId());
sh_d1.getClientDataArray(0).setRowArray(0, new BigInteger("0"));
sh_d1.getClientDataArray(0).setColumnArray(0, new BigInteger("3"));
assertSame(sh_d1, vml.findCommentShape(0, 3));
//newly created drawing
XSSFVMLDrawing newVml = new XSSFVMLDrawing();
assertNull(newVml.findCommentShape(0, 0));
sh_a1 = newVml.newCommentShape();
assertEquals("_x0000_s1025", sh_a1.getId());
sh_a1.getClientDataArray(0).setRowArray(0, new BigInteger("0"));
sh_a1.getClientDataArray(0).setColumnArray(0, new BigInteger("1"));
assertSame(sh_a1, newVml.findCommentShape(0, 1));
}
use of com.microsoft.schemas.vml.CTShape in project poi by apache.
the class TestXSSFVMLDrawing method testNew.
@Test
public void testNew() throws IOException, XmlException {
XSSFVMLDrawing vml = new XSSFVMLDrawing();
List<XmlObject> items = vml.getItems();
assertEquals(2, items.size());
assertTrue(items.get(0) instanceof CTShapeLayout);
CTShapeLayout layout = (CTShapeLayout) items.get(0);
assertEquals(STExt.EDIT, layout.getExt());
assertEquals(STExt.EDIT, layout.getIdmap().getExt());
assertEquals("1", layout.getIdmap().getData());
assertTrue(items.get(1) instanceof CTShapetype);
CTShapetype type = (CTShapetype) items.get(1);
assertEquals("21600,21600", type.getCoordsize());
assertEquals(202.0f, type.getSpt(), 0);
assertEquals("m,l,21600r21600,l21600,xe", type.getPath2());
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("#_x0000_t202", shape.getType());
assertEquals("position:absolute; visibility:hidden", shape.getStyle());
assertEquals("#ffffe1", shape.getFillcolor());
assertEquals(STInsetMode.AUTO, shape.getInsetmode());
assertEquals("#ffffe1", shape.getFillArray(0).getColor());
CTShadow shadow = shape.getShadowArray(0);
assertEquals(STTrueFalse.T, shadow.getOn());
assertEquals("black", shadow.getColor());
assertEquals(STTrueFalse.T, shadow.getObscured());
assertEquals(STConnectType.NONE, shape.getPathArray(0).getConnecttype());
assertEquals("mso-direction-alt:auto", shape.getTextboxArray(0).getStyle());
CTClientData cldata = shape.getClientDataArray(0);
assertEquals(STObjectType.NOTE, cldata.getObjectType());
assertEquals(1, cldata.sizeOfMoveWithCellsArray());
assertEquals(1, cldata.sizeOfSizeWithCellsArray());
assertEquals("1, 15, 0, 2, 3, 15, 3, 16", cldata.getAnchorArray(0));
assertEquals("False", cldata.getAutoFillArray(0).toString());
assertEquals(0, cldata.getRowArray(0).intValue());
assertEquals(0, cldata.getColumnArray(0).intValue());
assertEquals("[]", cldata.getVisibleList().toString());
cldata.setVisibleArray(new STTrueFalseBlank.Enum[] { STTrueFalseBlank.Enum.forString("True") });
assertEquals("[True]", cldata.getVisibleList().toString());
//serialize and read again
ByteArrayOutputStream out = new ByteArrayOutputStream();
vml.write(out);
XSSFVMLDrawing vml2 = new XSSFVMLDrawing();
vml2.read(new ByteArrayInputStream(out.toByteArray()));
List<XmlObject> items2 = vml2.getItems();
assertEquals(3, items2.size());
assertTrue(items2.get(0) instanceof CTShapeLayout);
assertTrue(items2.get(1) instanceof CTShapetype);
assertTrue(items2.get(2) instanceof CTShape);
}
Aggregations