mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Bug 56854 - XMLBeans performance when using getXXXList() and other proxy methods
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1620997 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a6da94159
commit
f39e6bea74
@ -371,9 +371,10 @@ public class POIXMLProperties {
|
||||
*
|
||||
* @return next property id starting with 2
|
||||
*/
|
||||
protected int nextPid(){
|
||||
@SuppressWarnings("deprecation")
|
||||
protected int nextPid(){
|
||||
int propid = 1;
|
||||
for(CTProperty p : props.getProperties().getPropertyList()){
|
||||
for(CTProperty p : props.getProperties().getPropertyArray()){
|
||||
if(p.getPid() > propid) propid = p.getPid();
|
||||
}
|
||||
return propid + 1;
|
||||
@ -385,8 +386,9 @@ public class POIXMLProperties {
|
||||
* @param name the name to check
|
||||
* @return whether a property with the given name exists in the custom properties
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean contains(String name){
|
||||
for(CTProperty p : props.getProperties().getPropertyList()){
|
||||
for(CTProperty p : props.getProperties().getPropertyArray()){
|
||||
if(p.getName().equals(name)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -19,7 +19,6 @@ package org.apache.poi;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
|
||||
import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty;
|
||||
@ -126,13 +125,13 @@ public class POIXMLPropertiesTextExtractor extends POIXMLTextExtractor {
|
||||
* Returns the custom document properties, if
|
||||
* there are any
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getCustomPropertiesText() {
|
||||
StringBuffer text = new StringBuffer();
|
||||
StringBuilder text = new StringBuilder();
|
||||
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
|
||||
props = getDocument().getProperties().getCustomProperties().getUnderlyingProperties();
|
||||
|
||||
List<CTProperty> properties = props.getPropertyList();
|
||||
for(CTProperty property : properties) {
|
||||
for(CTProperty property : props.getPropertyArray()) {
|
||||
String val = "(not implemented!)";
|
||||
|
||||
if (property.isSetLpwstr()) {
|
||||
|
||||
@ -31,7 +31,20 @@ import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFRelation;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
|
||||
|
||||
/**
|
||||
* Experimental class to do low level processing of pptx files.
|
||||
@ -53,6 +66,7 @@ public class XSLFSlideShow extends POIXMLDocument {
|
||||
*/
|
||||
private List<PackagePart> embedds;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException {
|
||||
super(container);
|
||||
|
||||
@ -64,7 +78,7 @@ public class XSLFSlideShow extends POIXMLDocument {
|
||||
PresentationDocument.Factory.parse(getCorePart().getInputStream());
|
||||
|
||||
embedds = new LinkedList<PackagePart>();
|
||||
for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdList()) {
|
||||
for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
|
||||
PackagePart corePart = getCorePart();
|
||||
PackagePart slidePart = corePart.getRelatedPart(
|
||||
corePart.getRelationship(ctSlide.getId2()));
|
||||
|
||||
@ -118,6 +118,7 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor {
|
||||
* @param notesText Should we retrieve text from notes?
|
||||
* @param masterText Should we retrieve text from master slides?
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getText(boolean slideText, boolean notesText, boolean masterText) {
|
||||
StringBuffer text = new StringBuffer();
|
||||
|
||||
@ -150,7 +151,7 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor {
|
||||
|
||||
// If the slide has comments, do those too
|
||||
if (comments != null) {
|
||||
for (CTComment comment : comments.getCTCommentsList().getCmList()) {
|
||||
for (CTComment comment : comments.getCTCommentsList().getCmArray()) {
|
||||
// Do the author if we can
|
||||
if (commentAuthors != null) {
|
||||
CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId());
|
||||
|
||||
@ -19,12 +19,17 @@
|
||||
|
||||
package org.apache.poi.xslf.model.geom;
|
||||
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuide;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuideList;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomRect;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTPath2D;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTPath2DList;
|
||||
|
||||
/**
|
||||
* Definition of a custom geometric shape
|
||||
*
|
||||
@ -36,19 +41,20 @@ public class CustomGeometry implements Iterable<Path>{
|
||||
List<Path> paths = new ArrayList<Path>();
|
||||
Path textBounds;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public CustomGeometry(CTCustomGeometry2D geom) {
|
||||
CTGeomGuideList avLst = geom.getAvLst();
|
||||
if(avLst != null) for(CTGeomGuide gd : avLst.getGdList()){
|
||||
if(avLst != null) for(CTGeomGuide gd : avLst.getGdArray()){
|
||||
adjusts.add(new AdjustValue(gd));
|
||||
}
|
||||
|
||||
CTGeomGuideList gdLst = geom.getGdLst();
|
||||
if(gdLst != null) for(CTGeomGuide gd : gdLst.getGdList()){
|
||||
if(gdLst != null) for(CTGeomGuide gd : gdLst.getGdArray()){
|
||||
guides.add(new Guide(gd));
|
||||
}
|
||||
|
||||
CTPath2DList pathLst = geom.getPathLst();
|
||||
if(pathLst != null) for(CTPath2D spPath : pathLst.getPathList()){
|
||||
if(pathLst != null) for(CTPath2D spPath : pathLst.getPathArray()){
|
||||
paths.add(new Path(spPath));
|
||||
}
|
||||
|
||||
|
||||
@ -20,8 +20,6 @@ package org.apache.poi.xslf.usermodel;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DrawingTable {
|
||||
private final CTTable table;
|
||||
|
||||
@ -29,12 +27,13 @@ public class DrawingTable {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DrawingTableRow[] getRows() {
|
||||
List<CTTableRow> ctTableRows = table.getTrList();
|
||||
DrawingTableRow[] o = new DrawingTableRow[ctTableRows.size()];
|
||||
CTTableRow[] ctTableRows = table.getTrArray();
|
||||
DrawingTableRow[] o = new DrawingTableRow[ctTableRows.length];
|
||||
|
||||
for (int i=0; i<o.length; i++) {
|
||||
o[i] = new DrawingTableRow(ctTableRows.get(i));
|
||||
o[i] = new DrawingTableRow(ctTableRows[i]);
|
||||
}
|
||||
|
||||
return o;
|
||||
|
||||
@ -20,8 +20,6 @@ package org.apache.poi.xslf.usermodel;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DrawingTableRow {
|
||||
private final CTTableRow row;
|
||||
|
||||
@ -29,12 +27,13 @@ public class DrawingTableRow {
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DrawingTableCell[] getCells() {
|
||||
List<CTTableCell> ctTableCells = row.getTcList();
|
||||
DrawingTableCell[] o = new DrawingTableCell[ctTableCells.size()];
|
||||
CTTableCell[] ctTableCells = row.getTcArray();
|
||||
DrawingTableCell[] o = new DrawingTableCell[ctTableCells.length];
|
||||
|
||||
for (int i=0; i<o.length; i++) {
|
||||
o[i] = new DrawingTableCell(ctTableCells.get(i));
|
||||
o[i] = new DrawingTableCell(ctTableCells[i]);
|
||||
}
|
||||
|
||||
return o;
|
||||
|
||||
@ -20,8 +20,6 @@ package org.apache.poi.xslf.usermodel;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DrawingTextBody {
|
||||
private final CTTextBody textBody;
|
||||
|
||||
@ -29,12 +27,13 @@ public class DrawingTextBody {
|
||||
this.textBody = textBody;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DrawingParagraph[] getParagraphs() {
|
||||
List<CTTextParagraph> paragraphs = textBody.getPList();
|
||||
DrawingParagraph[] o = new DrawingParagraph[paragraphs.size()];
|
||||
CTTextParagraph[] paragraphs = textBody.getPArray();
|
||||
DrawingParagraph[] o = new DrawingParagraph[paragraphs.length];
|
||||
|
||||
for (int i=0; i<o.length; i++) {
|
||||
o[i] = new DrawingParagraph(paragraphs.get(i));
|
||||
o[i] = new DrawingParagraph(paragraphs[i]);
|
||||
}
|
||||
|
||||
return o;
|
||||
|
||||
@ -19,6 +19,25 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.util.Internal;
|
||||
@ -47,25 +66,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillPropertie
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STPathShadeType;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Encapsulates logic to translate DrawingML objects to Java2D
|
||||
*/
|
||||
@ -548,6 +548,7 @@ class RenderableShape {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Collection<Outline> computeOutlines(Graphics2D graphics) {
|
||||
|
||||
Collection<Outline> lst = new ArrayList<Outline>();
|
||||
@ -576,7 +577,7 @@ class RenderableShape {
|
||||
public Guide getAdjustValue(String name) {
|
||||
CTPresetGeometry2D prst = _shape.getSpPr().getPrstGeom();
|
||||
if (prst.isSetAvLst()) {
|
||||
for (CTGeomGuide g : prst.getAvLst().getGdList()) {
|
||||
for (CTGeomGuide g : prst.getAvLst().getGdArray()) {
|
||||
if (g.getName().equals(name)) {
|
||||
return new Guide(g);
|
||||
}
|
||||
|
||||
@ -115,6 +115,7 @@ public class XMLSlideShow extends POIXMLDocument {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onDocumentRead() throws IOException {
|
||||
try {
|
||||
PresentationDocument doc =
|
||||
@ -140,8 +141,7 @@ public class XMLSlideShow extends POIXMLDocument {
|
||||
|
||||
_slides = new ArrayList<XSLFSlide>();
|
||||
if (_presentation.isSetSldIdLst()) {
|
||||
List<CTSlideIdListEntry> slideIds = _presentation.getSldIdLst().getSldIdList();
|
||||
for (CTSlideIdListEntry slId : slideIds) {
|
||||
for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdArray()) {
|
||||
XSLFSlide sh = shIdMap.get(slId.getId2());
|
||||
if (sh == null) {
|
||||
_logger.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was defined, but didn't exist in package, skipping");
|
||||
@ -201,13 +201,14 @@ public class XMLSlideShow extends POIXMLDocument {
|
||||
* @param layout
|
||||
* @return created slide
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public XSLFSlide createSlide(XSLFSlideLayout layout) {
|
||||
int slideNumber = 256, cnt = 1;
|
||||
CTSlideIdList slideList;
|
||||
if (!_presentation.isSetSldIdLst()) slideList = _presentation.addNewSldIdLst();
|
||||
else {
|
||||
slideList = _presentation.getSldIdLst();
|
||||
for(CTSlideIdListEntry slideId : slideList.getSldIdList()){
|
||||
for(CTSlideIdListEntry slideId : slideList.getSldIdArray()){
|
||||
slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber);
|
||||
cnt++;
|
||||
}
|
||||
@ -283,16 +284,16 @@ public class XMLSlideShow extends POIXMLDocument {
|
||||
_slides.add(newIndex, _slides.remove(oldIndex));
|
||||
|
||||
// fix ordering in the low-level xml
|
||||
List<CTSlideIdListEntry> slideIds = _presentation.getSldIdLst().getSldIdList();
|
||||
CTSlideIdListEntry oldEntry = slideIds.get(oldIndex);
|
||||
slideIds.add(newIndex, oldEntry);
|
||||
slideIds.remove(oldEntry);
|
||||
CTSlideIdList sldIdLst = _presentation.getSldIdLst();
|
||||
CTSlideIdListEntry oldEntry = sldIdLst.getSldIdArray(oldIndex);
|
||||
sldIdLst.insertNewSldId(newIndex).set(oldEntry);
|
||||
sldIdLst.removeSldId(oldIndex);
|
||||
}
|
||||
|
||||
public XSLFSlide removeSlide(int index){
|
||||
XSLFSlide slide = _slides.remove(index);
|
||||
removeRelation(slide);
|
||||
_presentation.getSldIdLst().getSldIdList().remove(index);
|
||||
_presentation.getSldIdLst().removeSldId(index);
|
||||
return slide;
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
@ -26,8 +28,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthor;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthorList;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CmAuthorLstDocument;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Beta
|
||||
public class XSLFCommentAuthors extends POIXMLDocumentPart {
|
||||
private final CTCommentAuthorList _authors;
|
||||
@ -61,9 +61,10 @@ public class XSLFCommentAuthors extends POIXMLDocumentPart {
|
||||
return _authors;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public CTCommentAuthor getAuthorById(long id) {
|
||||
// TODO Have a map
|
||||
for (CTCommentAuthor author : _authors.getCmAuthorList()) {
|
||||
for (CTCommentAuthor author : _authors.getCmAuthorArray()) {
|
||||
if (author.getId() == id) {
|
||||
return author;
|
||||
}
|
||||
|
||||
@ -66,6 +66,6 @@ public class XSLFComments extends POIXMLDocumentPart {
|
||||
}
|
||||
|
||||
public CTComment getCommentAt(int pos) {
|
||||
return _comments.getCmList().get(pos);
|
||||
return _comments.getCmArray(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.POIXMLException;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
@ -32,10 +36,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFra
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Beta
|
||||
public class XSLFCommonSlideData {
|
||||
private final CTCommonSlideData data;
|
||||
@ -44,6 +44,7 @@ public class XSLFCommonSlideData {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<DrawingTextBody> getDrawingText() {
|
||||
CTGroupShape gs = data.getSpTree();
|
||||
|
||||
@ -51,11 +52,11 @@ public class XSLFCommonSlideData {
|
||||
|
||||
processShape(gs, out);
|
||||
|
||||
for (CTGroupShape shape : gs.getGrpSpList()) {
|
||||
for (CTGroupShape shape : gs.getGrpSpArray()) {
|
||||
processShape(shape, out);
|
||||
}
|
||||
|
||||
for (CTGraphicalObjectFrame frame: gs.getGraphicFrameList()) {
|
||||
for (CTGraphicalObjectFrame frame: gs.getGraphicFrameArray()) {
|
||||
CTGraphicalObjectData data = frame.getGraphic().getGraphicData();
|
||||
XmlCursor c = data.newCursor();
|
||||
c.selectPath("declare namespace pic='"+CTTable.type.getName().getNamespaceURI()+"' .//pic:tbl");
|
||||
@ -97,9 +98,9 @@ public class XSLFCommonSlideData {
|
||||
return paragraphs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void processShape(CTGroupShape gs, List<DrawingTextBody> out) {
|
||||
List<CTShape> shapes = gs.getSpList();
|
||||
for (CTShape shape : shapes) {
|
||||
for (CTShape shape : gs.getSpArray()) {
|
||||
CTTextBody ctTextBody = shape.getTxBody();
|
||||
if (ctTextBody==null) {
|
||||
continue;
|
||||
|
||||
@ -19,6 +19,11 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
@ -35,11 +40,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
/**
|
||||
* Represents a custom geometric shape.
|
||||
* This shape will consist of a series of lines and curves described within a creation path.
|
||||
@ -120,12 +120,13 @@ public class XSLFFreeformShape extends XSLFAutoShape {
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public GeneralPath getPath() {
|
||||
GeneralPath path = new GeneralPath();
|
||||
Rectangle2D bounds = getAnchor();
|
||||
|
||||
CTCustomGeometry2D geom = getSpPr().getCustGeom();
|
||||
for(CTPath2D spPath : geom.getPathLst().getPathList()){
|
||||
for(CTPath2D spPath : geom.getPathLst().getPathArray()){
|
||||
double scaleW = bounds.getWidth() / Units.toPoints(spPath.getW());
|
||||
double scaleH = bounds.getHeight() / Units.toPoints(spPath.getH());
|
||||
for(XmlObject ch : spPath.selectPath("*")){
|
||||
|
||||
@ -213,7 +213,7 @@ public class XSLFPictureShape extends XSLFSimpleShape {
|
||||
if(blip.isSetExtLst()) {
|
||||
|
||||
CTOfficeArtExtensionList extLst = blip.getExtLst();
|
||||
for(CTOfficeArtExtension ext : extLst.getExtList()){
|
||||
for(CTOfficeArtExtension ext : extLst.getExtArray()){
|
||||
String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer";
|
||||
XmlObject[] obj = ext.selectPath(xpath);
|
||||
if(obj != null && obj.length == 1){
|
||||
|
||||
@ -51,6 +51,7 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
|
||||
private CTTable _table;
|
||||
private List<XSLFTableRow> _rows;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
/*package*/ XSLFTable(CTGraphicalObjectFrame shape, XSLFSheet sheet){
|
||||
super(shape, sheet);
|
||||
|
||||
@ -71,8 +72,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
|
||||
}
|
||||
|
||||
_table = (CTTable) rs[0];
|
||||
_rows = new ArrayList<XSLFTableRow>(_table.sizeOfTrArray());
|
||||
for(CTTableRow row : _table.getTrList()) _rows.add(new XSLFTableRow(row, this));
|
||||
CTTableRow[] trArray = _table.getTrArray();
|
||||
_rows = new ArrayList<XSLFTableRow>(trArray.length);
|
||||
for(CTTableRow row : trArray) _rows.add(new XSLFTableRow(row, this));
|
||||
}
|
||||
|
||||
@Internal
|
||||
|
||||
@ -19,15 +19,15 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import org.apache.poi.util.Units;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.Units;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
|
||||
|
||||
/**
|
||||
* Represents a table in a .pptx presentation
|
||||
*
|
||||
@ -38,11 +38,13 @@ public class XSLFTableRow implements Iterable<XSLFTableCell> {
|
||||
private List<XSLFTableCell> _cells;
|
||||
private XSLFTable _table;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
/*package*/ XSLFTableRow(CTTableRow row, XSLFTable table){
|
||||
_row = row;
|
||||
_table = table;
|
||||
_cells = new ArrayList<XSLFTableCell>(_row.sizeOfTcArray());
|
||||
for(CTTableCell cell : _row.getTcList()) {
|
||||
CTTableCell[] tcArray = _row.getTcArray();
|
||||
_cells = new ArrayList<XSLFTableCell>(tcArray.length);
|
||||
for(CTTableCell cell : tcArray) {
|
||||
_cells.add(new XSLFTableCell(cell, table.getSheet()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,12 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
@ -24,12 +30,6 @@ import org.apache.xmlbeans.XmlException;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyle;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@Beta
|
||||
public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable<XSLFTableStyle>{
|
||||
private CTTableStyleList _tblStyleLst;
|
||||
@ -39,12 +39,14 @@ public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable<XSLF
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public XSLFTableStyles(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
|
||||
super(part, rel);
|
||||
|
||||
_tblStyleLst = CTTableStyleList.Factory.parse(getPackagePart().getInputStream());
|
||||
_styles = new ArrayList<XSLFTableStyle>(_tblStyleLst.sizeOfTblStyleArray());
|
||||
for(CTTableStyle c : _tblStyleLst.getTblStyleList()){
|
||||
CTTableStyle[] tblStyleArray = _tblStyleLst.getTblStyleArray();
|
||||
_styles = new ArrayList<XSLFTableStyle>(tblStyleArray.length);
|
||||
for(CTTableStyle c : tblStyleArray){
|
||||
_styles.add(new XSLFTableStyle(c));
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,14 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.POIXMLException;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.Units;
|
||||
@ -36,14 +44,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a shape that can hold text.
|
||||
*
|
||||
@ -58,13 +58,14 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
|
||||
*/
|
||||
private boolean _isTextBroken;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
/*package*/ XSLFTextShape(XmlObject shape, XSLFSheet sheet) {
|
||||
super(shape, sheet);
|
||||
|
||||
_paragraphs = new ArrayList<XSLFTextParagraph>();
|
||||
CTTextBody txBody = getTextBody(false);
|
||||
if (txBody != null) {
|
||||
for (CTTextParagraph p : txBody.getPList()) {
|
||||
for (CTTextParagraph p : txBody.getPArray()) {
|
||||
_paragraphs.add(new XSLFTextParagraph(p, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ package org.apache.poi.xssf.eventusermodel;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
||||
@ -159,11 +158,11 @@ public class XSSFSheetXMLHandler extends DefaultHandler {
|
||||
this(styles, strings, sheetContentsHandler, new DataFormatter(), formulasNotResults);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void init() {
|
||||
if (commentsTable != null) {
|
||||
commentCellRefs = new LinkedList<CellReference>();
|
||||
List<CTComment> commentList = commentsTable.getCTComments().getCommentList().getCommentList();
|
||||
for (CTComment comment : commentList) {
|
||||
for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) {
|
||||
commentCellRefs.add(new CellReference(comment.getRef()));
|
||||
}
|
||||
}
|
||||
@ -187,6 +186,7 @@ public class XSSFSheetXMLHandler extends DefaultHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unused")
|
||||
public void startElement(String uri, String localName, String name,
|
||||
Attributes attributes) throws SAXException {
|
||||
|
||||
|
||||
@ -149,15 +149,18 @@ public class CommentsTable extends POIXMLDocumentPart {
|
||||
|
||||
public boolean removeComment(String cellRef) {
|
||||
CTCommentList lst = comments.getCommentList();
|
||||
if(lst != null) for(int i=0; i < lst.sizeOfCommentArray(); i++) {
|
||||
CTComment comment = lst.getCommentArray(i);
|
||||
if (cellRef.equals(comment.getRef())) {
|
||||
lst.removeComment(i);
|
||||
|
||||
if(commentRefs != null) {
|
||||
commentRefs.remove(cellRef);
|
||||
if(lst != null) {
|
||||
int commentCount = lst.sizeOfCommentArray();
|
||||
for(int i=0; i < commentCount; i++) {
|
||||
CTComment comment = lst.getCommentArray(i);
|
||||
if (cellRef.equals(comment.getRef())) {
|
||||
lst.removeComment(i);
|
||||
|
||||
if(commentRefs != null) {
|
||||
commentRefs.remove(cellRef);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -24,7 +24,6 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
@ -66,13 +65,14 @@ public class MapInfo extends POIXMLDocumentPart {
|
||||
readFrom(part.getInputStream());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void readFrom(InputStream is) throws IOException {
|
||||
try {
|
||||
MapInfoDocument doc = MapInfoDocument.Factory.parse(is);
|
||||
mapInfo = doc.getMapInfo();
|
||||
|
||||
maps= new HashMap<Integer, XSSFMap>();
|
||||
for(CTMap map :mapInfo.getMapList()){
|
||||
for(CTMap map :mapInfo.getMapArray()){
|
||||
maps.put((int)map.getID(), new XSSFMap(map,this));
|
||||
}
|
||||
|
||||
@ -104,10 +104,11 @@ public class MapInfo extends POIXMLDocumentPart {
|
||||
* @param schemaId the schema ID
|
||||
* @return CTSchema by it's ID
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public CTSchema getCTSchemaById(String schemaId){
|
||||
CTSchema xmlSchema = null;
|
||||
|
||||
for(CTSchema schema: mapInfo.getSchemaList()){
|
||||
for(CTSchema schema: mapInfo.getSchemaArray()){
|
||||
if(schema.getID().equals(schemaId)){
|
||||
xmlSchema = schema;
|
||||
break;
|
||||
|
||||
@ -94,10 +94,11 @@ public class SingleXmlCells extends POIXMLDocumentPart {
|
||||
*
|
||||
* @return all the SimpleXmlCell contained in this SingleXmlCells element
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<XSSFSingleXmlCell> getAllSimpleXmlCell(){
|
||||
List<XSSFSingleXmlCell> list = new Vector<XSSFSingleXmlCell>();
|
||||
|
||||
for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellList()){
|
||||
for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellArray()){
|
||||
list.add(new XSSFSingleXmlCell(singleXmlCell,this));
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -19,40 +19,40 @@ package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.ss.usermodel.Chart;
|
||||
import org.apache.poi.ss.usermodel.charts.AxisPosition;
|
||||
import org.apache.poi.ss.usermodel.charts.ChartAxis;
|
||||
import org.apache.poi.ss.usermodel.charts.ChartAxisFactory;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartDataFactory;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFValueAxis;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFManualLayout;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartLegend;
|
||||
import org.apache.poi.ss.usermodel.charts.ChartData;
|
||||
import org.apache.poi.ss.usermodel.charts.AxisPosition;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartDataFactory;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFChartLegend;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFManualLayout;
|
||||
import org.apache.poi.xssf.usermodel.charts.XSSFValueAxis;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPageMargins;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
|
||||
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
@ -306,14 +306,16 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA
|
||||
parseValueAxis();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void parseCategoryAxis() {
|
||||
for (CTCatAx catAx : chart.getPlotArea().getCatAxList()) {
|
||||
for (CTCatAx catAx : chart.getPlotArea().getCatAxArray()) {
|
||||
axis.add(new XSSFCategoryAxis(this, catAx));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void parseValueAxis() {
|
||||
for (CTValAx valAx : chart.getPlotArea().getValAxList()) {
|
||||
for (CTValAx valAx : chart.getPlotArea().getValAxArray()) {
|
||||
axis.add(new XSSFValueAxis(this, valAx));
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class XSSFPivotCacheDefinition extends POIXMLDocumentPart{
|
||||
for(int i=columnStart; i<=columnEnd; i++) {
|
||||
CTCacheField cf = cFields.addNewCacheField();
|
||||
if(i==columnEnd){
|
||||
cFields.setCount(cFields.getCacheFieldList().size());
|
||||
cFields.setCount(cFields.sizeOfCacheFieldArray());
|
||||
}
|
||||
//General number format
|
||||
cf.setNumFmtId(0);
|
||||
|
||||
@ -240,7 +240,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
}
|
||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields();
|
||||
|
||||
List<CTPivotField> pivotFieldList = pivotTableDefinition.getPivotFields().getPivotFieldList();
|
||||
CTPivotField pivotField = CTPivotField.Factory.newInstance();
|
||||
CTItems items = pivotField.addNewItems();
|
||||
|
||||
@ -249,10 +248,8 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
for(int i = 0; i <= lastRowIndex; i++) {
|
||||
items.addNewItem().setT(STItemType.DEFAULT);
|
||||
}
|
||||
items.setCount(items.getItemList().size());
|
||||
pivotFieldList.set(columnIndex, pivotField);
|
||||
|
||||
pivotFields.setPivotFieldArray(pivotFieldList.toArray(new CTPivotField[pivotFieldList.size()]));
|
||||
items.setCount(items.sizeOfItemArray());
|
||||
pivotFields.setPivotFieldArray(columnIndex, pivotField);
|
||||
|
||||
CTRowFields rowFields;
|
||||
if(pivotTableDefinition.getRowFields() != null) {
|
||||
@ -262,7 +259,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
}
|
||||
|
||||
rowFields.addNewField().setX(columnIndex);
|
||||
rowFields.setCount(rowFields.getFieldList().size());
|
||||
rowFields.setCount(rowFields.sizeOfFieldArray());
|
||||
}
|
||||
|
||||
@Beta
|
||||
@ -307,7 +304,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
colFields = pivotTableDefinition.addNewColFields();
|
||||
}
|
||||
colFields.addNewField().setX(-2);
|
||||
colFields.setCount(colFields.getFieldList().size());
|
||||
colFields.setCount(colFields.sizeOfFieldArray());
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +335,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
dataField.setName(function.getName());
|
||||
dataField.setFld(columnIndex);
|
||||
dataFields.setCount(dataFields.getDataFieldList().size());
|
||||
dataFields.setCount(dataFields.sizeOfDataFieldArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,13 +351,11 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields();
|
||||
List<CTPivotField> pivotFieldList = pivotFields.getPivotFieldList();
|
||||
CTPivotField pivotField = CTPivotField.Factory.newInstance();
|
||||
|
||||
pivotField.setDataField(isDataField);
|
||||
pivotField.setShowAll(false);
|
||||
pivotFieldList.set(columnIndex, pivotField);
|
||||
pivotFields.setPivotFieldArray(pivotFieldList.toArray(new CTPivotField[pivotFieldList.size()]));
|
||||
pivotFields.setPivotFieldArray(columnIndex, pivotField);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,7 +373,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
}
|
||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields();
|
||||
|
||||
List<CTPivotField> pivotFieldList = pivotTableDefinition.getPivotFields().getPivotFieldList();
|
||||
CTPivotField pivotField = CTPivotField.Factory.newInstance();
|
||||
CTItems items = pivotField.addNewItems();
|
||||
|
||||
@ -387,8 +381,8 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
for(int i = 0; i <= lastRowIndex; i++) {
|
||||
items.addNewItem().setT(STItemType.DEFAULT);
|
||||
}
|
||||
items.setCount(items.getItemList().size());
|
||||
pivotFieldList.set(columnIndex, pivotField);
|
||||
items.setCount(items.sizeOfItemArray());
|
||||
pivotFields.setPivotFieldArray(columnIndex, pivotField);
|
||||
|
||||
CTPageFields pageFields;
|
||||
if (pivotTableDefinition.getPageFields()!= null) {
|
||||
@ -402,7 +396,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
pageField.setHier(-1);
|
||||
pageField.setFld(columnIndex);
|
||||
|
||||
pageFields.setCount(pageFields.getPageFieldList().size());
|
||||
pageFields.setCount(pageFields.sizeOfPageFieldArray());
|
||||
pivotTableDefinition.getLocation().setColPageCount(pageFields.getCount());
|
||||
}
|
||||
|
||||
@ -459,6 +453,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
||||
pivotField.setDataField(false);
|
||||
pivotField.setShowAll(false);
|
||||
}
|
||||
pivotFields.setCount(pivotFields.getPivotFieldList().size());
|
||||
pivotFields.setCount(pivotFields.sizeOfPivotFieldArray());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1342,8 +1342,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
/**
|
||||
* Do not leave the width attribute undefined (see #52186).
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setColWidthAttribute(CTCols ctCols) {
|
||||
for (CTCol col : ctCols.getColList()) {
|
||||
for (CTCol col : ctCols.getColArray()) {
|
||||
if (!col.isSetWidth()) {
|
||||
col.setWidth(getDefaultColumnWidth());
|
||||
col.setCustomWidth(false);
|
||||
@ -1380,10 +1381,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private short getMaxOutlineLevelCols() {
|
||||
CTCols ctCols = worksheet.getColsArray(0);
|
||||
short outlineLevel = 0;
|
||||
for (CTCol col : ctCols.getColList()) {
|
||||
for (CTCol col : ctCols.getColArray()) {
|
||||
outlineLevel = col.getOutlineLevel() > outlineLevel ? col.getOutlineLevel() : outlineLevel;
|
||||
}
|
||||
return outlineLevel;
|
||||
@ -3543,7 +3545,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
+ ":$" + rowRef2.getCellRefParts()[1];
|
||||
}
|
||||
|
||||
StringBuffer rng = new StringBuffer();
|
||||
StringBuilder rng = new StringBuilder();
|
||||
rng.append(c);
|
||||
if(rng.length() > 0 && r.length() > 0) {
|
||||
rng.append(',');
|
||||
|
||||
@ -19,21 +19,21 @@
|
||||
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.record.cf.CellRangeUtil;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.ComparisonOperator;
|
||||
import org.apache.poi.ss.usermodel.ConditionalFormatting;
|
||||
import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
|
||||
import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
|
||||
import org.apache.poi.ss.usermodel.ComparisonOperator;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.hssf.record.cf.CellRangeUtil;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTConditionalFormatting;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
@ -115,6 +115,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin
|
||||
return rule;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) {
|
||||
if (regions == null) {
|
||||
throw new IllegalArgumentException("regions must not be null");
|
||||
@ -144,7 +145,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin
|
||||
|
||||
|
||||
int priority = 1;
|
||||
for(CTConditionalFormatting c : _sheet.getCTWorksheet().getConditionalFormattingList()){
|
||||
for(CTConditionalFormatting c : _sheet.getCTWorksheet().getConditionalFormattingArray()){
|
||||
priority += c.sizeOfCfRuleArray();
|
||||
}
|
||||
|
||||
@ -220,7 +221,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin
|
||||
*/
|
||||
public void removeConditionalFormatting(int index) {
|
||||
checkIndex(index);
|
||||
_sheet.getCTWorksheet().getConditionalFormattingList().remove(index);
|
||||
_sheet.getCTWorksheet().removeConditionalFormatting(index);
|
||||
}
|
||||
|
||||
private void checkIndex(int index) {
|
||||
|
||||
@ -128,13 +128,14 @@ public class XSSFTable extends POIXMLDocumentPart {
|
||||
*
|
||||
* @return the xpath of the table's root element
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getCommonXpath() {
|
||||
|
||||
if(commonXPath == null){
|
||||
|
||||
String[] commonTokens ={};
|
||||
|
||||
for(CTTableColumn column :ctTable.getTableColumns().getTableColumnList()){
|
||||
for(CTTableColumn column :ctTable.getTableColumns().getTableColumnArray()){
|
||||
if(column.getXmlColumnPr()!=null){
|
||||
String xpath = column.getXmlColumnPr().getXpath();
|
||||
String[] tokens = xpath.split("/");
|
||||
@ -173,11 +174,12 @@ public class XSSFTable extends POIXMLDocumentPart {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<XSSFXmlColumnPr> getXmlColumnPrs() {
|
||||
|
||||
if(xmlColumnPr==null){
|
||||
xmlColumnPr = new ArrayList<XSSFXmlColumnPr>();
|
||||
for (CTTableColumn column:ctTable.getTableColumns().getTableColumnList()){
|
||||
for (CTTableColumn column:ctTable.getTableColumns().getTableColumnArray()){
|
||||
if (column.getXmlColumnPr()!=null){
|
||||
XSSFXmlColumnPr columnPr = new XSSFXmlColumnPr(this,column,column.getXmlColumnPr());
|
||||
xmlColumnPr.add(columnPr);
|
||||
@ -285,6 +287,7 @@ public class XSSFTable extends POIXMLDocumentPart {
|
||||
* Headers <em>must</em> be in sync, otherwise Excel will display a
|
||||
* "Found unreadable content" message on startup.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updateHeaders(){
|
||||
XSSFSheet sheet = (XSSFSheet)getParent();
|
||||
CellReference ref = getStartCellReference();
|
||||
@ -296,7 +299,7 @@ public class XSSFTable extends POIXMLDocumentPart {
|
||||
|
||||
if (row != null && row.getCTRow().validate()) {
|
||||
int cellnum = firstHeaderColumn;
|
||||
for (CTTableColumn col : getCTTable().getTableColumns().getTableColumnList()) {
|
||||
for (CTTableColumn col : getCTTable().getTableColumns().getTableColumnArray()) {
|
||||
XSSFCell cell = row.getCell(cellnum);
|
||||
if (cell != null) {
|
||||
col.setName(cell.getStringCellValue());
|
||||
|
||||
@ -1410,10 +1410,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void reprocessNamedRanges() {
|
||||
namedRanges = new ArrayList<XSSFName>();
|
||||
if(workbook.isSetDefinedNames()) {
|
||||
for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameList()) {
|
||||
for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) {
|
||||
namedRanges.add(new XSSFName(ctName, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ package org.apache.poi.xssf.usermodel.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -50,52 +49,39 @@ public class ColumnHelper {
|
||||
cleanColumns();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void cleanColumns() {
|
||||
this.newCols = CTCols.Factory.newInstance();
|
||||
|
||||
CTCols aggregateCols = CTCols.Factory.newInstance();
|
||||
List<CTCols> colsList = worksheet.getColsList();
|
||||
assert(colsList != null);
|
||||
CTCols[] colsArray = worksheet.getColsArray();
|
||||
assert(colsArray != null);
|
||||
|
||||
for (CTCols cols : colsList) {
|
||||
for (CTCol col : cols.getColList()) {
|
||||
for (CTCols cols : colsArray) {
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
cloneCol(aggregateCols, col);
|
||||
}
|
||||
}
|
||||
|
||||
sortColumns(aggregateCols);
|
||||
|
||||
CTCol[] colArray = new CTCol[aggregateCols.getColList().size()];
|
||||
aggregateCols.getColList().toArray(colArray);
|
||||
CTCol[] colArray = aggregateCols.getColArray();
|
||||
sweepCleanColumns(newCols, colArray, null);
|
||||
|
||||
int i = colsList.size();
|
||||
int i = colsArray.length;
|
||||
for (int y = i - 1; y >= 0; y--) {
|
||||
worksheet.removeCols(y);
|
||||
}
|
||||
worksheet.addNewCols();
|
||||
worksheet.setColsArray(0, newCols);
|
||||
}
|
||||
|
||||
private static class CTColByMaxComparator implements Comparator<CTCol> {
|
||||
|
||||
public int compare(CTCol arg0, CTCol arg1) {
|
||||
if (arg0.getMax() < arg1.getMax()) {
|
||||
return -1;
|
||||
} else {
|
||||
if (arg0.getMax() > arg1.getMax()) return 1;
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="http://en.wikipedia.org/wiki/Sweep_line_algorithm">Sweep line algorithm</a>
|
||||
*/
|
||||
private void sweepCleanColumns(CTCols cols, CTCol[] flattenedColsArray, CTCol overrideColumn) {
|
||||
List<CTCol> flattenedCols = new ArrayList<CTCol>(Arrays.asList(flattenedColsArray));
|
||||
TreeSet<CTCol> currentElements = new TreeSet<CTCol>(new CTColByMaxComparator());
|
||||
TreeSet<CTCol> currentElements = new TreeSet<CTCol>(CTColComparator.BY_MAX);
|
||||
ListIterator<CTCol> flIter = flattenedCols.listIterator();
|
||||
CTCol haveOverrideColumn = null;
|
||||
long lastMaxIndex = 0;
|
||||
@ -103,7 +89,8 @@ public class ColumnHelper {
|
||||
while (flIter.hasNext()) {
|
||||
CTCol col = flIter.next();
|
||||
long currentIndex = col.getMin();
|
||||
long nextIndex = (col.getMax() > currentMax) ? col.getMax() : currentMax;
|
||||
long colMax = col.getMax();
|
||||
long nextIndex = (colMax > currentMax) ? colMax : currentMax;
|
||||
if (flIter.hasNext()) {
|
||||
nextIndex = flIter.next().getMin();
|
||||
flIter.previous();
|
||||
@ -116,10 +103,10 @@ public class ColumnHelper {
|
||||
}
|
||||
if (!currentElements.isEmpty() && lastMaxIndex < currentIndex) {
|
||||
// we need to process previous elements first
|
||||
insertCol(cols, lastMaxIndex, currentIndex - 1, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn);
|
||||
insertCol(cols, lastMaxIndex, currentIndex - 1, currentElements.toArray(new CTCol[currentElements.size()]), true, haveOverrideColumn);
|
||||
}
|
||||
currentElements.add(col);
|
||||
if (col.getMax() > currentMax) currentMax = col.getMax();
|
||||
if (colMax > currentMax) currentMax = colMax;
|
||||
if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
|
||||
while (currentIndex <= nextIndex && !currentElements.isEmpty()) {
|
||||
Set<CTCol> currentIndexElements = new HashSet<CTCol>();
|
||||
@ -130,26 +117,21 @@ public class ColumnHelper {
|
||||
CTCol currentElem = currentElements.first();
|
||||
currentElemIndex = currentElem.getMax();
|
||||
currentIndexElements.add(currentElem);
|
||||
|
||||
for (CTCol cc : currentElements.tailSet(currentElem)) {
|
||||
if (cc == null || cc.getMax() == currentElemIndex) break;
|
||||
currentIndexElements.add(cc);
|
||||
if (col.getMax() > currentMax) currentMax = col.getMax();
|
||||
|
||||
while (true) {
|
||||
CTCol higherElem = currentElements.higher(currentElem);
|
||||
if (higherElem == null || higherElem.getMax() != currentElemIndex)
|
||||
break;
|
||||
currentElem = higherElem;
|
||||
currentIndexElements.add(currentElem);
|
||||
if (colMax > currentMax) currentMax = colMax;
|
||||
if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
|
||||
}
|
||||
|
||||
// JDK 6 code
|
||||
// while (currentElements.higher(currentElem) != null && currentElements.higher(currentElem).getMax() == currentElemIndex) {
|
||||
// currentElem = currentElements.higher(currentElem);
|
||||
// currentIndexElements.add(currentElem);
|
||||
// if (col.getMax() > currentMax) currentMax = col.getMax();
|
||||
// if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
if (currentElemIndex < nextIndex || !flIter.hasNext()) {
|
||||
insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn);
|
||||
insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[currentElements.size()]), true, haveOverrideColumn);
|
||||
if (flIter.hasNext()) {
|
||||
if (nextIndex > currentElemIndex) {
|
||||
currentElements.removeAll(currentIndexElements);
|
||||
@ -170,10 +152,10 @@ public class ColumnHelper {
|
||||
sortColumns(cols);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void sortColumns(CTCols newCols) {
|
||||
CTCol[] colArray = new CTCol[newCols.getColList().size()];
|
||||
newCols.getColList().toArray(colArray);
|
||||
Arrays.sort(colArray, new CTColComparator());
|
||||
CTCol[] colArray = newCols.getColArray();
|
||||
Arrays.sort(colArray, CTColComparator.BY_MIN_MAX);
|
||||
newCols.setColArray(colArray);
|
||||
}
|
||||
|
||||
@ -198,46 +180,46 @@ public class ColumnHelper {
|
||||
* as 1 based.
|
||||
*/
|
||||
public CTCol getColumn1Based(long index1, boolean splitColumns) {
|
||||
CTCols colsArray = worksheet.getColsArray(0);
|
||||
CTCols cols = worksheet.getColsArray(0);
|
||||
|
||||
// Fetching the array is quicker than working on the new style
|
||||
// list, assuming we need to read many of them (which we often do),
|
||||
// and assuming we're not making many changes (which we're not)
|
||||
@SuppressWarnings("deprecation")
|
||||
CTCol[] cols = colsArray.getColArray();
|
||||
|
||||
for (int i = 0; i < cols.length; i++) {
|
||||
CTCol colArray = cols[i];
|
||||
if (colArray.getMin() <= index1 && colArray.getMax() >= index1) {
|
||||
CTCol[] colArray = cols.getColArray();
|
||||
|
||||
for (CTCol col : colArray) {
|
||||
long colMin = col.getMin();
|
||||
long colMax = col.getMax();
|
||||
if (colMin <= index1 && colMax >= index1) {
|
||||
if (splitColumns) {
|
||||
if (colArray.getMin() < index1) {
|
||||
insertCol(colsArray, colArray.getMin(), (index1 - 1), new CTCol[]{colArray});
|
||||
if (colMin < index1) {
|
||||
insertCol(cols, colMin, (index1 - 1), new CTCol[]{col});
|
||||
}
|
||||
if (colArray.getMax() > index1) {
|
||||
insertCol(colsArray, (index1 + 1), colArray.getMax(), new CTCol[]{colArray});
|
||||
if (colMax > index1) {
|
||||
insertCol(cols, (index1 + 1), colMax, new CTCol[]{col});
|
||||
}
|
||||
colArray.setMin(index1);
|
||||
colArray.setMax(index1);
|
||||
col.setMin(index1);
|
||||
col.setMax(index1);
|
||||
}
|
||||
return colArray;
|
||||
return col;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public CTCols addCleanColIntoCols(CTCols cols, CTCol col) {
|
||||
CTCols newCols = CTCols.Factory.newInstance();
|
||||
for (CTCol c : cols.getColList()) {
|
||||
for (CTCol c : cols.getColArray()) {
|
||||
cloneCol(newCols, c);
|
||||
}
|
||||
cloneCol(newCols, col);
|
||||
sortColumns(newCols);
|
||||
CTCol[] colArray = new CTCol[newCols.getColList().size()];
|
||||
newCols.getColList().toArray(colArray);
|
||||
CTCol[] colArray = newCols.getColArray();
|
||||
CTCols returnCols = CTCols.Factory.newInstance();
|
||||
sweepCleanColumns(returnCols, colArray, col);
|
||||
colArray = new CTCol[returnCols.getColList().size()];
|
||||
returnCols.getColList().toArray(colArray);
|
||||
colArray = returnCols.getColArray();
|
||||
cols.setColArray(colArray);
|
||||
return returnCols;
|
||||
}
|
||||
@ -272,9 +254,11 @@ public class ColumnHelper {
|
||||
public boolean columnExists(CTCols cols, long index) {
|
||||
return columnExists1Based(cols, index+1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean columnExists1Based(CTCols cols, long index1) {
|
||||
for (int i = 0; i < cols.sizeOfColArray(); i++) {
|
||||
if (cols.getColArray(i).getMin() == index1) {
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
if (col.getMin() == index1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -343,20 +327,24 @@ public class ColumnHelper {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean columnExists(CTCols cols, long min, long max) {
|
||||
for (int i = 0; i < cols.sizeOfColArray(); i++) {
|
||||
if (cols.getColArray(i).getMin() == min && cols.getColArray(i).getMax() == max) {
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
if (col.getMin() == min && col.getMax() == max) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getIndexOfColumn(CTCols cols, CTCol col) {
|
||||
for (int i = 0; i < cols.sizeOfColArray(); i++) {
|
||||
if (cols.getColArray(i).getMin() == col.getMin() && cols.getColArray(i).getMax() == col.getMax()) {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getIndexOfColumn(CTCols cols, CTCol searchCol) {
|
||||
int i = 0;
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
if (col.getMin() == searchCol.getMin() && col.getMax() == searchCol.getMax()) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTConditionalFormatting;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
|
||||
|
||||
/**
|
||||
@ -213,28 +214,29 @@ public final class XSSFRowShifter {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updateConditionalFormatting(FormulaShifter shifter) {
|
||||
XSSFWorkbook wb = sheet.getWorkbook();
|
||||
int sheetIndex = wb.getSheetIndex(sheet);
|
||||
|
||||
|
||||
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
|
||||
List<CTConditionalFormatting> cfList = sheet.getCTWorksheet().getConditionalFormattingList();
|
||||
for(int j = 0; j< cfList.size(); j++){
|
||||
CTConditionalFormatting cf = cfList.get(j);
|
||||
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
|
||||
int cfCount = ctWorksheet.sizeOfConditionalFormattingArray();
|
||||
for(int j = 0; j< cfCount; j++){
|
||||
CTConditionalFormatting cf = ctWorksheet.getConditionalFormattingArray(j);
|
||||
|
||||
ArrayList<CellRangeAddress> cellRanges = new ArrayList<CellRangeAddress>();
|
||||
for (Object stRef : cf.getSqref()) {
|
||||
String[] regions = stRef.toString().split(" ");
|
||||
for (int i = 0; i < regions.length; i++) {
|
||||
cellRanges.add(CellRangeAddress.valueOf(regions[i]));
|
||||
for (String region : regions) {
|
||||
cellRanges.add(CellRangeAddress.valueOf(region));
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
List<CellRangeAddress> temp = new ArrayList<CellRangeAddress>();
|
||||
for (int i = 0; i < cellRanges.size(); i++) {
|
||||
CellRangeAddress craOld = cellRanges.get(i);
|
||||
for (CellRangeAddress craOld : cellRanges) {
|
||||
CellRangeAddress craNew = shiftRange(shifter, craOld, sheetIndex);
|
||||
if (craNew == null) {
|
||||
changed = true;
|
||||
@ -249,7 +251,7 @@ public final class XSSFRowShifter {
|
||||
if (changed) {
|
||||
int nRanges = temp.size();
|
||||
if (nRanges == 0) {
|
||||
cfList.remove(j);
|
||||
ctWorksheet.removeConditionalFormatting(j);
|
||||
continue;
|
||||
}
|
||||
List<String> refs = new ArrayList<String>();
|
||||
@ -257,14 +259,14 @@ public final class XSSFRowShifter {
|
||||
cf.setSqref(refs);
|
||||
}
|
||||
|
||||
for(CTCfRule cfRule : cf.getCfRuleList()){
|
||||
List<String> formulas = cfRule.getFormulaList();
|
||||
for (int i = 0; i < formulas.size(); i++) {
|
||||
String formula = formulas.get(i);
|
||||
for(CTCfRule cfRule : cf.getCfRuleArray()){
|
||||
int formulaCount = cfRule.sizeOfFormulaArray();
|
||||
for (int i = 0; i < formulaCount; i++) {
|
||||
String formula = cfRule.getFormulaArray(i);
|
||||
Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex);
|
||||
if (shifter.adjustFormula(ptgs, sheetIndex)) {
|
||||
String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
|
||||
formulas.set(i, shiftedFmla);
|
||||
cfRule.setFormulaArray(i, shiftedFmla);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,26 +21,26 @@ import java.util.Comparator;
|
||||
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
|
||||
|
||||
public class CTColComparator implements Comparator<CTCol>{
|
||||
public class CTColComparator {
|
||||
|
||||
public int compare(CTCol o1, CTCol o2) {
|
||||
if (o1.getMin() < o2.getMin()) {
|
||||
return -1;
|
||||
private CTColComparator() {}
|
||||
|
||||
public static final Comparator<CTCol> BY_MAX = new Comparator<CTCol>() {
|
||||
@Override
|
||||
public int compare(CTCol col1, CTCol col2) {
|
||||
long col1max = col1.getMax();
|
||||
long col2max = col2.getMax();
|
||||
return col1max < col2max ? -1 : col1max > col2max ? 1 : 0;
|
||||
}
|
||||
else if (o1.getMin() > o2.getMin()) {
|
||||
return 1;
|
||||
};
|
||||
|
||||
public static final Comparator<CTCol> BY_MIN_MAX = new Comparator<CTCol>() {
|
||||
@Override
|
||||
public int compare(CTCol col1, CTCol col2) {
|
||||
long col11min = col1.getMin();
|
||||
long col2min = col2.getMin();
|
||||
return col11min < col2min ? -1 : col11min > col2min ? 1 : BY_MAX.compare(col1, col2);
|
||||
}
|
||||
else {
|
||||
if (o1.getMax() < o2.getMax()) {
|
||||
return -1;
|
||||
}
|
||||
if (o1.getMax() > o2.getMax()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -33,13 +33,15 @@ public class XWPFCommentsDecorator extends XWPFParagraphDecorator {
|
||||
public XWPFCommentsDecorator(XWPFParagraphDecorator nextDecorator) {
|
||||
this(nextDecorator.paragraph, nextDecorator);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public XWPFCommentsDecorator(XWPFParagraph paragraph, XWPFParagraphDecorator nextDecorator) {
|
||||
super(paragraph, nextDecorator);
|
||||
|
||||
XWPFComment comment;
|
||||
commentText = new StringBuffer();
|
||||
|
||||
for(CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartList())
|
||||
for(CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartArray())
|
||||
{
|
||||
if((comment = paragraph.getDocument().getCommentByID(anchor.getId().toString())) != null)
|
||||
commentText.append("\tComment by " + comment.getAuthor()+": "+comment.getText());
|
||||
|
||||
@ -52,10 +52,10 @@ public class XWPFHyperlinkDecorator extends XWPFParagraphDecorator {
|
||||
hyperlinkText = new StringBuffer();
|
||||
|
||||
// loop over hyperlink anchors
|
||||
for(CTHyperlink link : paragraph.getCTP().getHyperlinkList()){
|
||||
for (CTR r : link.getRList()) {
|
||||
for(CTHyperlink link : paragraph.getCTP().getHyperlinkArray()){
|
||||
for (CTR r : link.getRArray()) {
|
||||
// Loop over text runs
|
||||
for (CTText text : r.getTList()){
|
||||
for (CTText text : r.getTArray()){
|
||||
hyperlinkText.append(text.getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,17 +35,18 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
|
||||
private final String tag;
|
||||
private final IBody part;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public AbstractXWPFSDT(CTSdtPr pr, IBody part){
|
||||
|
||||
List<CTString> aliases = pr.getAliasList();
|
||||
if (aliases != null && aliases.size() > 0){
|
||||
title = aliases.get(0).getVal();
|
||||
CTString[] aliases = pr.getAliasArray();
|
||||
if (aliases != null && aliases.length > 0){
|
||||
title = aliases[0].getVal();
|
||||
} else {
|
||||
title = "";
|
||||
}
|
||||
List<CTString> tags = pr.getTagList();
|
||||
if (tags != null && tags.size() > 0){
|
||||
tag = tags.get(0).getVal();
|
||||
CTString[] tags = pr.getTagArray();
|
||||
if (tags != null && tags.length > 0){
|
||||
tag = tags[0].getVal();
|
||||
} else {
|
||||
tag = "";
|
||||
}
|
||||
|
||||
@ -31,13 +31,14 @@ public class XWPFComment
|
||||
protected String author;
|
||||
protected StringBuffer text;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public XWPFComment(CTComment comment, XWPFDocument document)
|
||||
{
|
||||
text = new StringBuffer();
|
||||
id = comment.getId().toString();
|
||||
author = comment.getAuthor();
|
||||
|
||||
for(CTP ctp : comment.getPList())
|
||||
for(CTP ctp : comment.getPArray())
|
||||
{
|
||||
XWPFParagraph p = new XWPFParagraph(ctp, document);
|
||||
text.append(p.getText());
|
||||
|
||||
@ -184,7 +184,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
} else if (relation.equals(XWPFRelation.COMMENT.getRelation())) {
|
||||
// TODO Create according XWPFComment class, extending POIXMLDocumentPart
|
||||
CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream());
|
||||
for (CTComment ctcomment : cmntdoc.getComments().getCommentList()) {
|
||||
for (CTComment ctcomment : cmntdoc.getComments().getCommentArray()) {
|
||||
comments.add(new XWPFComment(ctcomment, this));
|
||||
}
|
||||
} else if (relation.equals(XWPFRelation.SETTINGS.getRelation())) {
|
||||
@ -232,6 +232,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void initFootnotes() throws XmlException, IOException {
|
||||
for(POIXMLDocumentPart p : getRelations()){
|
||||
String relation = p.getPackageRelationship().getRelationshipType();
|
||||
@ -241,7 +242,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
} else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
|
||||
EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
|
||||
|
||||
for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteList()) {
|
||||
for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) {
|
||||
endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
|
||||
}
|
||||
}
|
||||
@ -364,10 +365,8 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
}
|
||||
|
||||
public XWPFHyperlink getHyperlinkByID(String id) {
|
||||
Iterator<XWPFHyperlink> iter = hyperlinks.iterator();
|
||||
while (iter.hasNext()) {
|
||||
XWPFHyperlink link = iter.next();
|
||||
if(link.getId().equals(id))
|
||||
for (XWPFHyperlink link : hyperlinks) {
|
||||
if (link.getId().equals(id))
|
||||
return link;
|
||||
}
|
||||
|
||||
@ -396,10 +395,8 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
}
|
||||
|
||||
public XWPFComment getCommentByID(String id) {
|
||||
Iterator<XWPFComment> iter = comments.iterator();
|
||||
while (iter.hasNext()) {
|
||||
XWPFComment comment = iter.next();
|
||||
if(comment.getId().equals(id))
|
||||
for (XWPFComment comment : comments) {
|
||||
if (comment.getId().equals(id))
|
||||
return comment;
|
||||
}
|
||||
|
||||
@ -1187,14 +1184,15 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
* @param table
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void insertTable(int pos, XWPFTable table) {
|
||||
bodyElements.add(pos, table);
|
||||
int i;
|
||||
for (i = 0; i < ctDocument.getBody().getTblList().size(); i++) {
|
||||
CTTbl tbl = ctDocument.getBody().getTblArray(i);
|
||||
int i = 0;
|
||||
for (CTTbl tbl : ctDocument.getBody().getTblArray()) {
|
||||
if (tbl == table.getCTTbl()) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
tables.add(i, table);
|
||||
}
|
||||
|
||||
@ -123,14 +123,15 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
|
||||
* @param table
|
||||
* @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void insertTable(int pos, XWPFTable table) {
|
||||
bodyElements.add(pos, table);
|
||||
int i;
|
||||
for (i = 0; i < ctFtnEdn.getTblList().size(); i++) {
|
||||
CTTbl tbl = ctFtnEdn.getTblArray(i);
|
||||
int i = 0;
|
||||
for (CTTbl tbl : ctFtnEdn.getTblArray()) {
|
||||
if(tbl == table.getCTTbl()){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
tables.add(i, table);
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@ import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument;
|
||||
@ -68,6 +67,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
|
||||
* Read document
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onDocumentRead () throws IOException {
|
||||
FootnotesDocument notesDoc;
|
||||
try {
|
||||
@ -79,7 +79,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
|
||||
}
|
||||
|
||||
// Find our footnotes
|
||||
for(CTFtnEdn note : ctFootnotes.getFootnoteList()) {
|
||||
for(CTFtnEdn note : ctFootnotes.getFootnoteArray()) {
|
||||
listFootnote.add(new XWPFFootnote(note, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,14 +436,15 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
|
||||
* @param pos
|
||||
* @param table
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void insertTable(int pos, XWPFTable table) {
|
||||
bodyElements.add(pos, table);
|
||||
int i;
|
||||
for (i = 0; i < headerFooter.getTblList().size(); i++) {
|
||||
CTTbl tbl = headerFooter.getTblArray(i);
|
||||
int i = 0;
|
||||
for (CTTbl tbl : headerFooter.getTblArray()) {
|
||||
if(tbl == table.getCTTbl()){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
tables.add(i, table);
|
||||
|
||||
|
||||
@ -38,8 +38,9 @@ public class XWPFLatentStyles {
|
||||
/**
|
||||
* checks wheter specific LatentStyleID is a latentStyle
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean isLatentStyle(String latentStyleID){
|
||||
for ( CTLsdException lsd: latentStyles.getLsdExceptionList()) {
|
||||
for ( CTLsdException lsd: latentStyles.getLsdExceptionArray()) {
|
||||
if(lsd.getName().equals(latentStyleID));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
|
||||
* read numbering form an existing package
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onDocumentRead() throws IOException{
|
||||
NumberingDocument numberingDoc = null;
|
||||
InputStream is;
|
||||
@ -79,10 +80,10 @@ public class XWPFNumbering extends POIXMLDocumentPart {
|
||||
numberingDoc = NumberingDocument.Factory.parse(is);
|
||||
ctNumbering = numberingDoc.getNumbering();
|
||||
//get any Nums
|
||||
for(CTNum ctNum : ctNumbering.getNumList()) {
|
||||
for(CTNum ctNum : ctNumbering.getNumArray()) {
|
||||
nums.add(new XWPFNum(ctNum, this));
|
||||
}
|
||||
for(CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumList()){
|
||||
for(CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumArray()){
|
||||
abstractNums.add(new XWPFAbstractNum(ctAbstractNum, this));
|
||||
}
|
||||
isNew = false;
|
||||
@ -144,7 +145,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
|
||||
*/
|
||||
public BigInteger addNum(XWPFNum num){
|
||||
ctNumbering.addNewNum();
|
||||
int pos = (ctNumbering.getNumList().size()) - 1;
|
||||
int pos = ctNumbering.sizeOfNumArray() - 1;
|
||||
ctNumbering.setNumArray(pos, num.getCTNum());
|
||||
nums.add(num);
|
||||
return num.getCTNum().getNumId();
|
||||
|
||||
@ -137,7 +137,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
}
|
||||
if (o instanceof CTHyperlink) {
|
||||
CTHyperlink link = (CTHyperlink) o;
|
||||
for (CTR r : link.getRList()) {
|
||||
for (CTR r : link.getRArray()) {
|
||||
XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this);
|
||||
runs.add(hr);
|
||||
iruns.add(hr);
|
||||
@ -152,14 +152,14 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
iruns.add(cc);
|
||||
}
|
||||
if (o instanceof CTRunTrackChange) {
|
||||
for (CTR r : ((CTRunTrackChange) o).getRList()) {
|
||||
for (CTR r : ((CTRunTrackChange) o).getRArray()) {
|
||||
XWPFRun cr = new XWPFRun(r, this);
|
||||
runs.add(cr);
|
||||
iruns.add(cr);
|
||||
}
|
||||
}
|
||||
if (o instanceof CTSimpleField) {
|
||||
for (CTR r : ((CTSimpleField) o).getRList()) {
|
||||
for (CTR r : ((CTSimpleField) o).getRArray()) {
|
||||
XWPFRun cr = new XWPFRun(r, this);
|
||||
runs.add(cr);
|
||||
iruns.add(cr);
|
||||
@ -1170,7 +1170,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
*/
|
||||
protected void addRun(CTR run){
|
||||
int pos;
|
||||
pos = paragraph.getRList().size();
|
||||
pos = paragraph.sizeOfRArray();
|
||||
paragraph.addNewR();
|
||||
paragraph.setRArray(pos, run);
|
||||
}
|
||||
@ -1230,9 +1230,10 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
startChar = startPos.getChar();
|
||||
int beginRunPos = 0, candCharPos = 0;
|
||||
boolean newList = false;
|
||||
for (int runPos=startRun; runPos<paragraph.getRList().size(); runPos++) {
|
||||
CTR[] rArray = paragraph.getRArray();
|
||||
for (int runPos=startRun; runPos<rArray.length; runPos++) {
|
||||
int beginTextPos = 0,beginCharPos = 0, textPos = 0, charPos = 0;
|
||||
CTR ctRun = paragraph.getRArray(runPos);
|
||||
CTR ctRun = rArray[runPos];
|
||||
XmlCursor c = ctRun.newCursor();
|
||||
c.selectPath("./*");
|
||||
while(c.toNextSelection()){
|
||||
@ -1298,15 +1299,17 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
int runEnd = segment.getEndRun();
|
||||
int textEnd = segment.getEndText();
|
||||
int charEnd = segment.getEndChar();
|
||||
StringBuffer out = new StringBuffer();
|
||||
StringBuilder out = new StringBuilder();
|
||||
CTR[] rArray = paragraph.getRArray();
|
||||
for(int i=runBegin; i<=runEnd;i++){
|
||||
int startText=0, endText = paragraph.getRArray(i).getTList().size()-1;
|
||||
CTText[] tArray = rArray[i].getTArray();
|
||||
int startText=0, endText = tArray.length-1;
|
||||
if(i==runBegin)
|
||||
startText=textBegin;
|
||||
if(i==runEnd)
|
||||
endText = textEnd;
|
||||
for(int j=startText;j<=endText;j++){
|
||||
String tmpText = paragraph.getRArray(i).getTArray(j).getStringValue();
|
||||
String tmpText = tArray[j].getStringValue();
|
||||
int startChar=0, endChar = tmpText.length()-1;
|
||||
if((j==textBegin)&&(i==runBegin))
|
||||
startChar=charBegin;
|
||||
@ -1314,7 +1317,6 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
||||
endChar = charEnd;
|
||||
}
|
||||
out.append(tmpText.substring(startChar, endChar+1));
|
||||
|
||||
}
|
||||
}
|
||||
return out.toString();
|
||||
|
||||
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
@ -95,6 +96,7 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
||||
* @param r the CTR bean which holds the run attributes
|
||||
* @param p the parent paragraph
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public XWPFRun(CTR r, IRunBody p) {
|
||||
this.run = r;
|
||||
this.parent = p;
|
||||
@ -103,16 +105,13 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
||||
* reserve already occupied drawing ids, so reserving new ids later will
|
||||
* not corrupt the document
|
||||
*/
|
||||
List<CTDrawing> drawingList = r.getDrawingList();
|
||||
for (CTDrawing ctDrawing : drawingList) {
|
||||
List<CTAnchor> anchorList = ctDrawing.getAnchorList();
|
||||
for (CTAnchor anchor : anchorList) {
|
||||
for (CTDrawing ctDrawing : r.getDrawingArray()) {
|
||||
for (CTAnchor anchor : ctDrawing.getAnchorArray()) {
|
||||
if (anchor.getDocPr() != null) {
|
||||
getDocument().getDrawingIdManager().reserve(anchor.getDocPr().getId());
|
||||
}
|
||||
}
|
||||
List<CTInline> inlineList = ctDrawing.getInlineList();
|
||||
for (CTInline inline : inlineList) {
|
||||
for (CTInline inline : ctDrawing.getInlineArray()) {
|
||||
if (inline.getDocPr() != null) {
|
||||
getDocument().getDrawingIdManager().reserve(inline.getDocPr().getId());
|
||||
}
|
||||
@ -120,17 +119,17 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
||||
}
|
||||
|
||||
// Look for any text in any of our pictures or drawings
|
||||
StringBuffer text = new StringBuffer();
|
||||
StringBuilder text = new StringBuilder();
|
||||
List<XmlObject> pictTextObjs = new ArrayList<XmlObject>();
|
||||
pictTextObjs.addAll(r.getPictList());
|
||||
pictTextObjs.addAll(drawingList);
|
||||
pictTextObjs.addAll(Arrays.asList(r.getPictArray()));
|
||||
pictTextObjs.addAll(Arrays.asList(r.getDrawingArray()));
|
||||
for(XmlObject o : pictTextObjs) {
|
||||
XmlObject[] t = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
|
||||
for (int m = 0; m < t.length; m++) {
|
||||
NodeList kids = t[m].getDomNode().getChildNodes();
|
||||
XmlObject[] ts = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
|
||||
for (XmlObject t : ts) {
|
||||
NodeList kids = t.getDomNode().getChildNodes();
|
||||
for (int n = 0; n < kids.getLength(); n++) {
|
||||
if (kids.item(n) instanceof Text) {
|
||||
if(text.length() > 0)
|
||||
if (text.length() > 0)
|
||||
text.append("\n");
|
||||
text.append(kids.item(n).getNodeValue());
|
||||
}
|
||||
@ -317,7 +316,7 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
||||
* @param value the literal text which shall be displayed in the document
|
||||
*/
|
||||
public void setText(String value) {
|
||||
setText(value,run.getTList().size());
|
||||
setText(value,run.sizeOfTArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -50,8 +50,8 @@ public class XWPFSDTContent implements ISDTContent {
|
||||
private List<ISDTContents> bodyElements = new ArrayList<ISDTContents>();
|
||||
|
||||
public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent){
|
||||
for (CTR ctr : sdtRun.getRList()){
|
||||
XWPFRun run = new XWPFRun((CTR) ctr, parent);
|
||||
for (CTR ctr : sdtRun.getRArray()){
|
||||
XWPFRun run = new XWPFRun(ctr, parent);
|
||||
runs.add(run);
|
||||
bodyElements.add(run);
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@ import org.apache.xmlbeans.XmlOptions;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
|
||||
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
|
||||
@ -74,6 +73,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
|
||||
* Read document
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onDocumentRead() throws IOException{
|
||||
StylesDocument stylesDoc;
|
||||
try {
|
||||
@ -86,7 +86,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
|
||||
}
|
||||
|
||||
// Build up all the style objects
|
||||
for(CTStyle style : ctStyles.getStyleList()) {
|
||||
for(CTStyle style : ctStyles.getStyleArray()) {
|
||||
listStyle.add(new XWPFStyle(style, this));
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
|
||||
public void addStyle(XWPFStyle style){
|
||||
listStyle.add(style);
|
||||
ctStyles.addNewStyle();
|
||||
int pos = (ctStyles.getStyleList().size()) - 1;
|
||||
int pos = ctStyles.sizeOfStyleArray() - 1;
|
||||
ctStyles.setStyleArray(pos, style.getCTStyle());
|
||||
}
|
||||
/**
|
||||
|
||||
@ -93,6 +93,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public XWPFTable(CTTbl table, IBody part){
|
||||
this.part = part;
|
||||
this.ctTbl = table;
|
||||
@ -103,12 +104,12 @@ public class XWPFTable implements IBodyElement, ISDTContents {
|
||||
if (table.sizeOfTrArray() == 0)
|
||||
createEmptyTable(table);
|
||||
|
||||
for (CTRow row : table.getTrList()) {
|
||||
StringBuffer rowText = new StringBuffer();
|
||||
for (CTRow row : table.getTrArray()) {
|
||||
StringBuilder rowText = new StringBuilder();
|
||||
XWPFTableRow tabRow = new XWPFTableRow(row, this);
|
||||
tableRows.add(tabRow);
|
||||
for (CTTc cell : row.getTcList()) {
|
||||
for (CTP ctp : cell.getPList()) {
|
||||
for (CTTc cell : row.getTcArray()) {
|
||||
for (CTP ctp : cell.getPArray()) {
|
||||
XWPFParagraph p = new XWPFParagraph(ctp, part);
|
||||
if (rowText.length() > 0) {
|
||||
rowText.append('\t');
|
||||
|
||||
@ -79,7 +79,7 @@ public class XWPFTableCell implements IBody, ICell {
|
||||
this.part = part;
|
||||
this.tableRow = tableRow;
|
||||
// NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt.
|
||||
if(cell.getPList().size()<1)
|
||||
if(cell.sizeOfPArray()<1)
|
||||
cell.addNewP();
|
||||
bodyElements = new ArrayList<IBodyElement>();
|
||||
paragraphs = new ArrayList<XWPFParagraph>();
|
||||
@ -398,16 +398,17 @@ public class XWPFTableCell implements IBody, ICell {
|
||||
* inserts an existing XWPFTable to the arrays bodyElements and tables
|
||||
* @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int, org.apache.poi.xwpf.usermodel.XWPFTable)
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void insertTable(int pos, XWPFTable table) {
|
||||
bodyElements.add(pos, table);
|
||||
int i;
|
||||
for (i = 0; i < ctTc.getTblList().size(); i++) {
|
||||
CTTbl tbl = ctTc.getTblArray(i);
|
||||
if(tbl == table.getCTTbl()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
tables.add(i, table);
|
||||
bodyElements.add(pos, table);
|
||||
int i = 0;
|
||||
for (CTTbl tbl : ctTc.getTblArray()) {
|
||||
if (tbl == table.getCTTbl()) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
tables.add(i, table);
|
||||
}
|
||||
|
||||
public String getText(){
|
||||
|
||||
@ -152,10 +152,11 @@ public class XWPFTableRow {
|
||||
* who belongs to this row
|
||||
* @return a list of {@link XWPFTableCell}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<XWPFTableCell> getTableCells(){
|
||||
if(tableCells == null){
|
||||
List<XWPFTableCell> cells = new ArrayList<XWPFTableCell>();
|
||||
for (CTTc tableCell : ctRow.getTcList()) {
|
||||
for (CTTc tableCell : ctRow.getTcArray()) {
|
||||
cells.add(new XWPFTableCell(tableCell, this, table.getBody()));
|
||||
}
|
||||
//TODO: it is possible to have an SDT that contains a cell in within a row
|
||||
@ -201,7 +202,7 @@ public class XWPFTableRow {
|
||||
boolean isCant = false;
|
||||
CTTrPr trpr = getTrPr();
|
||||
if (trpr.sizeOfCantSplitArray() > 0) {
|
||||
CTOnOff onoff = trpr.getCantSplitList().get(0);
|
||||
CTOnOff onoff = trpr.getCantSplitArray(0);
|
||||
isCant = onoff.getVal().equals(STOnOff.ON);
|
||||
}
|
||||
return isCant;
|
||||
@ -229,7 +230,7 @@ public class XWPFTableRow {
|
||||
boolean repeat = false;
|
||||
CTTrPr trpr = getTrPr();
|
||||
if (trpr.sizeOfTblHeaderArray() > 0) {
|
||||
CTOnOff rpt = trpr.getTblHeaderList().get(0);
|
||||
CTOnOff rpt = trpr.getTblHeaderArray(0);
|
||||
repeat = rpt.getVal().equals(STOnOff.ON);
|
||||
}
|
||||
return repeat;
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.poi.xslf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
@ -61,22 +62,19 @@ public class TestXSLFSlideShow extends TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSlideBasics() throws Exception {
|
||||
XSLFSlideShow xml = new XSLFSlideShow(pack);
|
||||
|
||||
// Should have 1 master
|
||||
assertEquals(1, xml.getSlideMasterReferences().sizeOfSldMasterIdArray());
|
||||
assertEquals(1, xml.getSlideMasterReferences().getSldMasterIdList().size());
|
||||
|
||||
|
||||
// Should have three sheets
|
||||
assertEquals(2, xml.getSlideReferences().sizeOfSldIdArray());
|
||||
assertEquals(2, xml.getSlideReferences().getSldIdList().size());
|
||||
|
||||
|
||||
// Check they're as expected
|
||||
CTSlideIdListEntry[] slides = new CTSlideIdListEntry[
|
||||
xml.getSlideReferences().getSldIdList().size()];
|
||||
xml.getSlideReferences().getSldIdList().toArray(slides);
|
||||
|
||||
CTSlideIdListEntry[] slides = xml.getSlideReferences().getSldIdArray();
|
||||
|
||||
assertEquals(256, slides[0].getId());
|
||||
assertEquals(257, slides[1].getId());
|
||||
assertEquals("rId2", slides[0].getId2());
|
||||
@ -91,9 +89,7 @@ public class TestXSLFSlideShow extends TestCase {
|
||||
assertNotNull(xml.getNotes(slides[1]));
|
||||
|
||||
// And again for the master
|
||||
CTSlideMasterIdListEntry[] masters = new CTSlideMasterIdListEntry[
|
||||
xml.getSlideMasterReferences().getSldMasterIdList().size()];
|
||||
xml.getSlideMasterReferences().getSldMasterIdList().toArray(masters);
|
||||
CTSlideMasterIdListEntry[] masters = xml.getSlideMasterReferences().getSldMasterIdArray();
|
||||
|
||||
assertEquals(2147483648l, masters[0].getId());
|
||||
assertEquals("rId1", masters[0].getId2());
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
@ -58,6 +59,7 @@ public class TestXMLSlideShow extends TestCase {
|
||||
assertTrue(xml.getSlideMasters().length > 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSlideBasics() throws Exception {
|
||||
XMLSlideShow xml = new XMLSlideShow(pack);
|
||||
|
||||
@ -68,9 +70,7 @@ public class TestXMLSlideShow extends TestCase {
|
||||
assertEquals(2, xml.getSlides().length);
|
||||
|
||||
// Check they're as expected
|
||||
CTSlideIdListEntry[] slides = new CTSlideIdListEntry[
|
||||
xml.getCTPresentation().getSldIdLst().getSldIdList().size()];
|
||||
xml.getCTPresentation().getSldIdLst().getSldIdList().toArray(slides);
|
||||
CTSlideIdListEntry[] slides = xml.getCTPresentation().getSldIdLst().getSldIdArray();
|
||||
|
||||
assertEquals(256, slides[0].getId());
|
||||
assertEquals(257, slides[1].getId());
|
||||
@ -86,9 +86,7 @@ public class TestXMLSlideShow extends TestCase {
|
||||
assertNotNull(xml.getSlides()[1].getNotes());
|
||||
|
||||
// Next up look for the slide master
|
||||
CTSlideMasterIdListEntry[] masters = new CTSlideMasterIdListEntry[
|
||||
xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdList().size()];
|
||||
xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdList().toArray(masters);
|
||||
CTSlideMasterIdListEntry[] masters = xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdArray();
|
||||
|
||||
assertEquals(2147483648l, masters[0].getId());
|
||||
assertEquals("rId1", masters[0].getId2());
|
||||
|
||||
@ -16,12 +16,19 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
@ -243,13 +250,14 @@ public class TestXSLFSimpleShape extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
public void testShadowEffects(){
|
||||
XMLSlideShow ppt = new XMLSlideShow();
|
||||
XSLFSlide slide = ppt.createSlide();
|
||||
CTStyleMatrix styleMatrix = slide.getTheme().getXmlObject().getThemeElements().getFmtScheme();
|
||||
CTEffectStyleList lst = styleMatrix.getEffectStyleLst();
|
||||
assertNotNull(lst);
|
||||
for(CTEffectStyleItem ef : lst.getEffectStyleList()){
|
||||
for(CTEffectStyleItem ef : lst.getEffectStyleArray()){
|
||||
CTOuterShadowEffect obj = ef.getEffectLst().getOuterShdw();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public final class TestCalculationChain extends TestCase {
|
||||
CalculationChain chain = wb.getCalculationChain();
|
||||
//the bean holding the reference to the formula to be deleted
|
||||
CTCalcCell c = chain.getCTCalcChain().getCArray(0);
|
||||
int cnt = chain.getCTCalcChain().getCList().size();
|
||||
int cnt = chain.getCTCalcChain().sizeOfCArray();
|
||||
assertEquals(10, c.getI());
|
||||
assertEquals("E1", c.getR());
|
||||
|
||||
@ -44,7 +44,7 @@ public final class TestCalculationChain extends TestCase {
|
||||
|
||||
//the count of items is less by one
|
||||
c = chain.getCTCalcChain().getCArray(0);
|
||||
int cnt2 = chain.getCTCalcChain().getCList().size();
|
||||
int cnt2 = chain.getCTCalcChain().sizeOfCArray();
|
||||
assertEquals(cnt - 1, cnt2);
|
||||
//the first item in the calculation chain is the former second one
|
||||
assertEquals(10, c.getI());
|
||||
|
||||
@ -50,7 +50,7 @@ public final class TestMapInfo extends TestCase {
|
||||
|
||||
assertNotNull(ctMapInfo);
|
||||
|
||||
assertEquals(1, ctMapInfo.getSchemaList().size());
|
||||
assertEquals(1, ctMapInfo.sizeOfSchemaArray());
|
||||
|
||||
for (XSSFMap map : mapInfo.getAllXSSFMaps()) {
|
||||
Node xmlSchema = map.getSchema();
|
||||
|
||||
@ -964,9 +964,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(text, cell.getStringCellValue());
|
||||
|
||||
assertEquals(4, cell.getRichStringCellValue().numFormattingRuns());
|
||||
assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRList().get(0).getT());
|
||||
assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRArray(0).getT());
|
||||
|
||||
String r3 = cell.getRichStringCellValue().getCTRst().getRList().get(2).getT();
|
||||
String r3 = cell.getRichStringCellValue().getCTRst().getRArray(2).getT();
|
||||
assertEquals("line.\n", r3.substring(r3.length()-6));
|
||||
|
||||
// Save and re-check
|
||||
|
||||
@ -45,6 +45,7 @@ public class TestXSSFColGrouping extends TestCase {
|
||||
* Tests that POI doesn't produce "col" elements without "width" attribute.
|
||||
* POI-52186
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testNoColsWithoutWidthWhenGrouping() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet("test");
|
||||
@ -60,7 +61,7 @@ public class TestXSSFColGrouping extends TestCase {
|
||||
|
||||
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
logger.log(POILogger.DEBUG, "test52186/cols:" + cols);
|
||||
for (CTCol col : cols.getColList()) {
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth());
|
||||
}
|
||||
}
|
||||
@ -69,6 +70,7 @@ public class TestXSSFColGrouping extends TestCase {
|
||||
* Tests that POI doesn't produce "col" elements without "width" attribute.
|
||||
* POI-52186
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testNoColsWithoutWidthWhenGroupingAndCollapsing() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet("test");
|
||||
@ -90,7 +92,7 @@ public class TestXSSFColGrouping extends TestCase {
|
||||
assertEquals("Unexpected width of column "+ i, 5000, sheet.getColumnWidth(i));
|
||||
}
|
||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
for (CTCol col : cols.getColList()) {
|
||||
for (CTCol col : cols.getColArray()) {
|
||||
assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth());
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public final class TestXSSFFont extends BaseTestFont{
|
||||
|
||||
|
||||
xssfFont.setBold(true);
|
||||
assertEquals(ctFont.getBList().size(),1);
|
||||
assertEquals(ctFont.sizeOfBArray(),1);
|
||||
assertEquals(true, ctFont.getBArray(0).getVal());
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public final class TestXSSFFont extends BaseTestFont{
|
||||
assertEquals(false, xssfFont.getItalic());
|
||||
|
||||
xssfFont.setItalic(true);
|
||||
assertEquals(ctFont.getIList().size(),1);
|
||||
assertEquals(ctFont.sizeOfIArray(),1);
|
||||
assertEquals(true, ctFont.getIArray(0).getVal());
|
||||
assertEquals(true,ctFont.getIArray(0).getVal());
|
||||
}
|
||||
@ -150,7 +150,7 @@ public final class TestXSSFFont extends BaseTestFont{
|
||||
assertEquals(false, xssfFont.getStrikeout());
|
||||
|
||||
xssfFont.setStrikeout(true);
|
||||
assertEquals(ctFont.getStrikeList().size(),1);
|
||||
assertEquals(ctFont.sizeOfStrikeArray(),1);
|
||||
assertEquals(true, ctFont.getStrikeArray(0).getVal());
|
||||
assertEquals(true,ctFont.getStrikeArray(0).getVal());
|
||||
}
|
||||
@ -191,11 +191,11 @@ public final class TestXSSFFont extends BaseTestFont{
|
||||
assertEquals(Font.U_SINGLE, xssfFont.getUnderline());
|
||||
|
||||
xssfFont.setUnderline(Font.U_DOUBLE);
|
||||
assertEquals(ctFont.getUList().size(),1);
|
||||
assertEquals(ctFont.sizeOfUArray(),1);
|
||||
assertEquals(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal());
|
||||
|
||||
xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
|
||||
assertEquals(ctFont.getUList().size(),1);
|
||||
assertEquals(ctFont.sizeOfUArray(),1);
|
||||
assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
@ -308,22 +308,22 @@ public final class TestXSSFRichTextString extends TestCase {
|
||||
|
||||
str = new XSSFRichTextString("Incorrect\nLine-Breaking");
|
||||
str.applyFont(0, 8, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
assertEquals("<xml-fragment>Incorrec</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment>t\nLine-Breaking</xml-fragment>", t2.xmlText());
|
||||
|
||||
str = new XSSFRichTextString("Incorrect\nLine-Breaking");
|
||||
str.applyFont(0, 9, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
assertEquals("<xml-fragment>Incorrect</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">\nLine-Breaking</xml-fragment>", t2.xmlText());
|
||||
|
||||
str = new XSSFRichTextString("Incorrect\n Line-Breaking");
|
||||
str.applyFont(0, 9, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
assertEquals("<xml-fragment>Incorrect</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">\n Line-Breaking</xml-fragment>", t2.xmlText());
|
||||
|
||||
@ -333,15 +333,15 @@ public final class TestXSSFRichTextString extends TestCase {
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">Tab\tseparated\n</xml-fragment>", t1.xmlText());
|
||||
|
||||
str.applyFont(0, 3, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
assertEquals("<xml-fragment>Tab</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">\tseparated\n</xml-fragment>", t2.xmlText());
|
||||
|
||||
str = new XSSFRichTextString("Tab\tseparated\n");
|
||||
str.applyFont(0, 4, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
// YK: don't know why, but XmlBeans converts leading tab characters to spaces
|
||||
//assertEquals("<xml-fragment>Tab\t</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">separated\n</xml-fragment>", t2.xmlText());
|
||||
@ -349,9 +349,9 @@ public final class TestXSSFRichTextString extends TestCase {
|
||||
str = new XSSFRichTextString("\n\n\nNew Line\n\n");
|
||||
str.applyFont(0, 3, font);
|
||||
str.applyFont(11, 13, font);
|
||||
t1 = str.getCTRst().getRList().get(0).xgetT();
|
||||
t2 = str.getCTRst().getRList().get(1).xgetT();
|
||||
t3 = str.getCTRst().getRList().get(2).xgetT();
|
||||
t1 = str.getCTRst().getRArray(0).xgetT();
|
||||
t2 = str.getCTRst().getRArray(1).xgetT();
|
||||
t3 = str.getCTRst().getRArray(2).xgetT();
|
||||
// YK: don't know why, but XmlBeans converts leading tab characters to spaces
|
||||
assertEquals("<xml-fragment xml:space=\"preserve\">\n\n\n</xml-fragment>", t1.xmlText());
|
||||
assertEquals("<xml-fragment>New Line</xml-fragment>", t2.xmlText());
|
||||
|
||||
@ -335,6 +335,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void groupUngroupColumn() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
@ -344,36 +345,36 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
sheet.groupColumn(10, 11);
|
||||
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(2, cols.sizeOfColArray());
|
||||
List<CTCol> colArray = cols.getColList();
|
||||
CTCol[] colArray = cols.getColArray();
|
||||
assertNotNull(colArray);
|
||||
assertEquals(2 + 1, colArray.get(0).getMin()); // 1 based
|
||||
assertEquals(7 + 1, colArray.get(0).getMax()); // 1 based
|
||||
assertEquals(1, colArray.get(0).getOutlineLevel());
|
||||
assertEquals(2 + 1, colArray[0].getMin()); // 1 based
|
||||
assertEquals(7 + 1, colArray[0].getMax()); // 1 based
|
||||
assertEquals(1, colArray[0].getOutlineLevel());
|
||||
|
||||
//two level
|
||||
sheet.groupColumn(1, 2);
|
||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(4, cols.sizeOfColArray());
|
||||
colArray = cols.getColList();
|
||||
assertEquals(2, colArray.get(1).getOutlineLevel());
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(2, colArray[1].getOutlineLevel());
|
||||
|
||||
//three level
|
||||
sheet.groupColumn(6, 8);
|
||||
sheet.groupColumn(2, 3);
|
||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(7, cols.sizeOfColArray());
|
||||
colArray = cols.getColList();
|
||||
assertEquals(3, colArray.get(1).getOutlineLevel());
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(3, colArray[1].getOutlineLevel());
|
||||
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||
|
||||
sheet.ungroupColumn(8, 10);
|
||||
colArray = cols.getColList();
|
||||
colArray = cols.getColArray();
|
||||
//assertEquals(3, colArray[1].getOutlineLevel());
|
||||
|
||||
sheet.ungroupColumn(4, 6);
|
||||
sheet.ungroupColumn(2, 2);
|
||||
colArray = cols.getColList();
|
||||
assertEquals(4, colArray.size());
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(4, colArray.length);
|
||||
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||
}
|
||||
|
||||
@ -758,9 +759,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
XSSFSheet xs = sheet;
|
||||
CTWorksheet cts = xs.getCTWorksheet();
|
||||
|
||||
List<CTCols> cols_s = cts.getColsList();
|
||||
assertEquals(1, cols_s.size());
|
||||
CTCols cols = cols_s.get(0);
|
||||
assertEquals(1, cts.sizeOfColsArray());
|
||||
CTCols cols = cts.getColsArray(0);
|
||||
assertEquals(1, cols.sizeOfColArray());
|
||||
CTCol col = cols.getColArray(0);
|
||||
|
||||
@ -773,9 +773,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
// Now set another
|
||||
sheet.setColumnWidth(3, 33 * 256);
|
||||
|
||||
cols_s = cts.getColsList();
|
||||
assertEquals(1, cols_s.size());
|
||||
cols = cols_s.get(0);
|
||||
assertEquals(1, cts.sizeOfColsArray());
|
||||
cols = cts.getColsArray(0);
|
||||
assertEquals(2, cols.sizeOfColArray());
|
||||
|
||||
col = cols.getColArray(0);
|
||||
@ -960,6 +959,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
* but CTRows are kept in ascending order
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void createRow() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
@ -983,27 +983,27 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
row3.createCell(5);
|
||||
|
||||
|
||||
List<CTRow> xrow = sheetData.getRowList();
|
||||
assertEquals(3, xrow.size());
|
||||
CTRow[] xrow = sheetData.getRowArray();
|
||||
assertEquals(3, xrow.length);
|
||||
|
||||
//rows are sorted: {0, 1, 2}
|
||||
assertEquals(4, xrow.get(0).sizeOfCArray());
|
||||
assertEquals(1, xrow.get(0).getR());
|
||||
assertTrue(xrow.get(0).equals(row3.getCTRow()));
|
||||
assertEquals(4, xrow[0].sizeOfCArray());
|
||||
assertEquals(1, xrow[0].getR());
|
||||
assertTrue(xrow[0].equals(row3.getCTRow()));
|
||||
|
||||
assertEquals(3, xrow.get(1).sizeOfCArray());
|
||||
assertEquals(2, xrow.get(1).getR());
|
||||
assertTrue(xrow.get(1).equals(row2.getCTRow()));
|
||||
assertEquals(3, xrow[1].sizeOfCArray());
|
||||
assertEquals(2, xrow[1].getR());
|
||||
assertTrue(xrow[1].equals(row2.getCTRow()));
|
||||
|
||||
assertEquals(2, xrow.get(2).sizeOfCArray());
|
||||
assertEquals(3, xrow.get(2).getR());
|
||||
assertTrue(xrow.get(2).equals(row1.getCTRow()));
|
||||
assertEquals(2, xrow[2].sizeOfCArray());
|
||||
assertEquals(3, xrow[2].getR());
|
||||
assertTrue(xrow[2].equals(row1.getCTRow()));
|
||||
|
||||
List<CTCell> xcell = xrow.get(0).getCList();
|
||||
assertEquals("D1", xcell.get(0).getR());
|
||||
assertEquals("A1", xcell.get(1).getR());
|
||||
assertEquals("C1", xcell.get(2).getR());
|
||||
assertEquals("F1", xcell.get(3).getR());
|
||||
CTCell[] xcell = xrow[0].getCArray();
|
||||
assertEquals("D1", xcell[0].getR());
|
||||
assertEquals("A1", xcell[1].getR());
|
||||
assertEquals("C1", xcell[2].getR());
|
||||
assertEquals("F1", xcell[3].getR());
|
||||
|
||||
//re-creating a row does NOT add extra data to the parent
|
||||
row2 = sheet.createRow(1);
|
||||
@ -1015,25 +1015,25 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
sheet = workbook.getSheetAt(0);
|
||||
wsh = sheet.getCTWorksheet();
|
||||
xrow = sheetData.getRowList();
|
||||
assertEquals(3, xrow.size());
|
||||
xrow = sheetData.getRowArray();
|
||||
assertEquals(3, xrow.length);
|
||||
|
||||
//rows are sorted: {0, 1, 2}
|
||||
assertEquals(4, xrow.get(0).sizeOfCArray());
|
||||
assertEquals(1, xrow.get(0).getR());
|
||||
assertEquals(4, xrow[0].sizeOfCArray());
|
||||
assertEquals(1, xrow[0].getR());
|
||||
//cells are now sorted
|
||||
xcell = xrow.get(0).getCList();
|
||||
assertEquals("A1", xcell.get(0).getR());
|
||||
assertEquals("C1", xcell.get(1).getR());
|
||||
assertEquals("D1", xcell.get(2).getR());
|
||||
assertEquals("F1", xcell.get(3).getR());
|
||||
xcell = xrow[0].getCArray();
|
||||
assertEquals("A1", xcell[0].getR());
|
||||
assertEquals("C1", xcell[1].getR());
|
||||
assertEquals("D1", xcell[2].getR());
|
||||
assertEquals("F1", xcell[3].getR());
|
||||
|
||||
|
||||
assertEquals(0, xrow.get(1).sizeOfCArray());
|
||||
assertEquals(2, xrow.get(1).getR());
|
||||
assertEquals(0, xrow[1].sizeOfCArray());
|
||||
assertEquals(2, xrow[1].getR());
|
||||
|
||||
assertEquals(2, xrow.get(2).sizeOfCArray());
|
||||
assertEquals(3, xrow.get(2).getR());
|
||||
assertEquals(2, xrow[2].sizeOfCArray());
|
||||
assertEquals(3, xrow[2].getR());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -17,13 +17,8 @@
|
||||
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.junit.Test;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -32,8 +27,13 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
|
||||
|
||||
public final class TestXSSFTable {
|
||||
|
||||
@ -41,6 +41,7 @@ public final class TestXSSFTable {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void bug56274() throws IOException {
|
||||
// read sample file
|
||||
XSSFWorkbook inputWorkbook = XSSFTestDataSamples.openSampleWorkbook("56274.xlsx");
|
||||
@ -60,13 +61,13 @@ public final class TestXSSFTable {
|
||||
// re-read the saved file and make sure headers in the xml are in the original order
|
||||
inputWorkbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(new FileInputStream(outputFile));
|
||||
CTTable ctTable = inputWorkbook.getSheetAt(0).getTables().get(0).getCTTable();
|
||||
List<CTTableColumn> ctTableColumnList = ctTable.getTableColumns().getTableColumnList();
|
||||
CTTableColumn[] ctTableColumnArray = ctTable.getTableColumns().getTableColumnArray();
|
||||
|
||||
assertEquals("number of headers in xml table should match number of header cells in worksheet",
|
||||
headers.size(), ctTableColumnList.size());
|
||||
headers.size(), ctTableColumnArray.length);
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
assertEquals("header name in xml table should match number of header cells in worksheet",
|
||||
headers.get(i), ctTableColumnList.get(i).getName());
|
||||
headers.get(i), ctTableColumnArray[i].getName());
|
||||
}
|
||||
assertTrue(outputFile.delete());
|
||||
}
|
||||
|
||||
@ -704,7 +704,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
|
||||
CTPivotCache pivotCache = wb.addPivotCache("0");
|
||||
//Ensures that pivotCaches is initiated
|
||||
assertTrue(ctWb.isSetPivotCaches());
|
||||
assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheList().get(0));
|
||||
assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheArray(0));
|
||||
assertEquals("0", pivotCache.getId());
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ public final class TestColumnHelper extends TestCase {
|
||||
helper.addCleanColIntoCols(cols1, col9);
|
||||
|
||||
// TODO - assert something interesting
|
||||
assertEquals(12, cols1.getColList().size());
|
||||
assertEquals(12, cols1.sizeOfColArray());
|
||||
assertEquals(1, cols1.getColArray(0).getMin());
|
||||
assertEquals(16750, cols1.getColArray(11).getMax());
|
||||
}
|
||||
|
||||
@ -27,39 +27,37 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
|
||||
public final class TestCTColComparator extends TestCase {
|
||||
|
||||
public void testCompare() {
|
||||
CTColComparator comparator = new CTColComparator();
|
||||
CTCol o1 = CTCol.Factory.newInstance();
|
||||
o1.setMin(1);
|
||||
o1.setMax(10);
|
||||
CTCol o2 = CTCol.Factory.newInstance();
|
||||
o2.setMin(11);
|
||||
o2.setMax(12);
|
||||
assertEquals(-1, comparator.compare(o1, o2));
|
||||
assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2));
|
||||
CTCol o3 = CTCol.Factory.newInstance();
|
||||
o3.setMin(5);
|
||||
o3.setMax(8);
|
||||
CTCol o4 = CTCol.Factory.newInstance();
|
||||
o4.setMin(5);
|
||||
o4.setMax(80);
|
||||
assertEquals(-1, comparator.compare(o3, o4));
|
||||
assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o3, o4));
|
||||
}
|
||||
|
||||
public void testArraysSort() {
|
||||
CTColComparator comparator = new CTColComparator();
|
||||
CTCol o1 = CTCol.Factory.newInstance();
|
||||
o1.setMin(1);
|
||||
o1.setMax(10);
|
||||
CTCol o2 = CTCol.Factory.newInstance();
|
||||
o2.setMin(11);
|
||||
o2.setMax(12);
|
||||
assertEquals(-1, comparator.compare(o1, o2));
|
||||
assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2));
|
||||
CTCol o3 = CTCol.Factory.newInstance();
|
||||
o3.setMin(5);
|
||||
o3.setMax(80);
|
||||
CTCol o4 = CTCol.Factory.newInstance();
|
||||
o4.setMin(5);
|
||||
o4.setMax(8);
|
||||
assertEquals(1, comparator.compare(o3, o4));
|
||||
assertEquals(1, CTColComparator.BY_MIN_MAX.compare(o3, o4));
|
||||
CTCol[] cols = new CTCol[4];
|
||||
cols[0] = o1;
|
||||
cols[1] = o2;
|
||||
@ -67,7 +65,7 @@ public final class TestCTColComparator extends TestCase {
|
||||
cols[3] = o4;
|
||||
assertEquals(80, cols[2].getMax());
|
||||
assertEquals(8, cols[3].getMax());
|
||||
Arrays.sort(cols, comparator);
|
||||
Arrays.sort(cols, CTColComparator.BY_MIN_MAX);
|
||||
assertEquals(12, cols[3].getMax());
|
||||
assertEquals(8, cols[1].getMax());
|
||||
assertEquals(80, cols[2].getMax());
|
||||
|
||||
@ -234,7 +234,7 @@ public final class TestXWPFDocument extends TestCase {
|
||||
OutputStream os = newImagePart.getOutputStream();
|
||||
os.write(nature1);
|
||||
os.close();
|
||||
XWPFHeader xwpfHeader = doc.getHeaderList().get(0);
|
||||
XWPFHeader xwpfHeader = doc.getHeaderArray(0);
|
||||
PackageRelationship relationship = xwpfHeader.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, jpgRelation.getRelation());
|
||||
XWPFPictureData newPicData = new XWPFPictureData(newImagePart,relationship);
|
||||
/* new part is now ready to rumble */
|
||||
@ -317,13 +317,13 @@ public final class TestXWPFDocument extends TestCase {
|
||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_2.docx");
|
||||
assertEquals(1,doc.getAllPictures().size());
|
||||
assertEquals(1,doc.getAllPackagePictures().size());
|
||||
assertEquals(1,doc.getHeaderList().get(0).getAllPictures().size());
|
||||
assertEquals(1,doc.getHeaderArray(0).getAllPictures().size());
|
||||
doc.getPackage().revert();
|
||||
}
|
||||
|
||||
public void testPictureHandlingComplex() throws IOException, InvalidFormatException {
|
||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_3.docx");
|
||||
XWPFHeader xwpfHeader = doc.getHeaderList().get(0);
|
||||
XWPFHeader xwpfHeader = doc.getHeaderArray(0);
|
||||
|
||||
assertEquals(3,doc.getAllPictures().size());
|
||||
assertEquals(3,xwpfHeader.getAllPictures().size());
|
||||
|
||||
@ -24,6 +24,9 @@ import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.xwpf.XWPFTestDataSamples;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
|
||||
@ -39,9 +42,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl;
|
||||
|
||||
/**
|
||||
* Tests for XWPF Paragraphs
|
||||
@ -62,7 +62,7 @@ public final class TestXWPFParagraph extends TestCase {
|
||||
assertEquals(1, ps.size());
|
||||
XWPFParagraph p = ps.get(0);
|
||||
|
||||
assertEquals(5, p.getCTP().getRList().size());
|
||||
assertEquals(5, p.getCTP().sizeOfRArray());
|
||||
assertEquals("First header column!\tMid header\tRight header!", p
|
||||
.getText());
|
||||
}
|
||||
@ -234,6 +234,7 @@ public final class TestXWPFParagraph extends TestCase {
|
||||
assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testBookmarks() throws IOException {
|
||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx");
|
||||
XWPFParagraph paragraph = doc.getParagraphs().get(0);
|
||||
@ -242,7 +243,7 @@ public final class TestXWPFParagraph extends TestCase {
|
||||
assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray());
|
||||
CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0);
|
||||
assertEquals("poi", ctBookmark.getName());
|
||||
for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) {
|
||||
for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartArray()) {
|
||||
assertEquals("poi", bookmark.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public class TestXWPFRun extends TestCase {
|
||||
run.addCarriageReturn();
|
||||
run.setText("T2");
|
||||
run.addCarriageReturn();
|
||||
assertEquals(3, run.getCTR().getCrList().size());
|
||||
assertEquals(3, run.getCTR().sizeOfCrArray());
|
||||
|
||||
assertEquals("T1\n\nT2\n", run.toString());
|
||||
}
|
||||
@ -200,8 +200,8 @@ public class TestXWPFRun extends TestCase {
|
||||
run.setText("T2");
|
||||
run.addTab();
|
||||
run.setText("T3");
|
||||
assertEquals(1, run.getCTR().getCrList().size());
|
||||
assertEquals(1, run.getCTR().getTabList().size());
|
||||
assertEquals(1, run.getCTR().sizeOfCrArray());
|
||||
assertEquals(1, run.getCTR().sizeOfTabArray());
|
||||
|
||||
assertEquals("T1\nT2\tT3", run.toString());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user