You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestXSSFShape.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xssf.usermodel;
  16. import static org.junit.Assert.assertEquals;
  17. import static org.junit.Assert.assertNotNull;
  18. import java.io.IOException;
  19. import java.util.List;
  20. import org.apache.poi.xssf.XSSFTestDataSamples;
  21. import org.junit.Test;
  22. /**
  23. * Tests for XSSFShape
  24. */
  25. public final class TestXSSFShape {
  26. @Test
  27. public void test58325_one() throws IOException {
  28. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("58325_lt.xlsx")) {
  29. check58325(wb, 1);
  30. }
  31. }
  32. @Test
  33. public void test58325_three() throws IOException {
  34. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("58325_db.xlsx")) {
  35. check58325(wb, 3);
  36. }
  37. }
  38. private void check58325(XSSFWorkbook wb, int expectedShapes) {
  39. XSSFSheet sheet = wb.getSheet("MetasNM001");
  40. assertNotNull(sheet);
  41. StringBuilder str = new StringBuilder();
  42. str.append("sheet ").append(sheet.getSheetName()).append(" - ");
  43. XSSFDrawing drawing = sheet.getDrawingPatriarch();
  44. //drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
  45. List<XSSFShape> shapes = drawing.getShapes();
  46. str.append("drawing.getShapes().size() = ").append(shapes.size());
  47. for (XSSFShape shape : shapes) {
  48. str.append(", ").append(shape);
  49. str.append(", Col1:").append(((XSSFClientAnchor) shape.getAnchor()).getCol1());
  50. str.append(", Col2:").append(((XSSFClientAnchor) shape.getAnchor()).getCol2());
  51. str.append(", Row1:").append(((XSSFClientAnchor) shape.getAnchor()).getRow1());
  52. str.append(", Row2:").append(((XSSFClientAnchor) shape.getAnchor()).getRow2());
  53. }
  54. assertEquals("Having shapes: " + str,
  55. expectedShapes, shapes.size());
  56. }
  57. }