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.

SXSSFDrawing.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.streaming;
  16. import java.util.Iterator;
  17. import java.util.Spliterator;
  18. import org.apache.poi.ss.usermodel.ClientAnchor;
  19. import org.apache.poi.ss.usermodel.Comment;
  20. import org.apache.poi.ss.usermodel.Drawing;
  21. import org.apache.poi.ss.usermodel.ObjectData;
  22. import org.apache.poi.xssf.usermodel.XSSFDrawing;
  23. import org.apache.poi.xssf.usermodel.XSSFPicture;
  24. import org.apache.poi.xssf.usermodel.XSSFShape;
  25. /**
  26. * Streaming version of Drawing.
  27. * Delegates most tasks to the non-streaming XSSF code.
  28. * TODO: Potentially, Comment and Chart need a similar streaming wrapper like Picture.
  29. */
  30. public class SXSSFDrawing implements Drawing<XSSFShape> {
  31. private final SXSSFWorkbook _wb;
  32. private final XSSFDrawing _drawing;
  33. public SXSSFDrawing(SXSSFWorkbook workbook, XSSFDrawing drawing) {
  34. this._wb = workbook;
  35. this._drawing = drawing;
  36. }
  37. @Override
  38. public SXSSFPicture createPicture(ClientAnchor anchor, int pictureIndex) {
  39. XSSFPicture pict = _drawing.createPicture(anchor, pictureIndex);
  40. return new SXSSFPicture(_wb, pict);
  41. }
  42. @Override
  43. public Comment createCellComment(ClientAnchor anchor) {
  44. return _drawing.createCellComment(anchor);
  45. }
  46. @Override
  47. public ClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) {
  48. return _drawing.createAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
  49. }
  50. @Override
  51. public ObjectData createObjectData(ClientAnchor anchor, int storageId, int pictureIndex) {
  52. return _drawing.createObjectData(anchor, storageId, pictureIndex);
  53. }
  54. @Override
  55. public Iterator<XSSFShape> iterator() {
  56. return _drawing.getShapes().iterator();
  57. }
  58. /**
  59. * @since POI 5.2.0
  60. */
  61. @Override
  62. public Spliterator<XSSFShape> spliterator() {
  63. return _drawing.getShapes().spliterator();
  64. }
  65. }