Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

XSLFTextBox.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xslf.usermodel;
  20. import org.apache.poi.util.Beta;
  21. import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
  22. import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
  23. import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
  24. import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
  25. import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
  26. import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
  27. import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
  28. import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
  29. import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
  30. /**
  31. * @author Yegor Kozlov
  32. */
  33. @Beta
  34. public class XSLFTextBox extends XSLFAutoShape {
  35. /*package*/ XSLFTextBox(CTShape shape, XSLFSheet sheet){
  36. super(shape, sheet);
  37. }
  38. /**
  39. *
  40. * @param shapeId 1-based shapeId
  41. */
  42. static CTShape prototype(int shapeId){
  43. CTShape ct = CTShape.Factory.newInstance();
  44. CTShapeNonVisual nvSpPr = ct.addNewNvSpPr();
  45. CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr();
  46. cnv.setName("TextBox " + shapeId);
  47. cnv.setId(shapeId + 1);
  48. nvSpPr.addNewCNvSpPr().setTxBox(true);
  49. nvSpPr.addNewNvPr();
  50. CTShapeProperties spPr = ct.addNewSpPr();
  51. CTPresetGeometry2D prst = spPr.addNewPrstGeom();
  52. prst.setPrst(STShapeType.RECT);
  53. prst.addNewAvLst();
  54. CTTextBody txBody = ct.addNewTxBody();
  55. txBody.addNewBodyPr();
  56. txBody.addNewLstStyle();
  57. return ct;
  58. }
  59. }