remove more deprecated code

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2020-07-16 15:30:08 +00:00
parent 38220f65b0
commit 05902bcd11
9 changed files with 32 additions and 261 deletions

View File

@ -51,7 +51,6 @@ import org.apache.poi.util.NotImplemented;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xdgf.extractor.XDGFVisioExtractor;
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFRelation;
import org.apache.poi.xssf.extractor.XSSFBEventBasedExcelExtractor;
@ -79,6 +78,12 @@ public final class ExtractorFactory {
private static final String VISIO_DOCUMENT_REL = PackageRelationshipTypes.VISIO_CORE_DOCUMENT;
private static final String STRICT_DOCUMENT_REL = PackageRelationshipTypes.STRICT_CORE_DOCUMENT;
private static final XSLFRelation[] SUPPORTED_XSLF_TYPES = new XSLFRelation[]{
XSLFRelation.MAIN, XSLFRelation.MACRO, XSLFRelation.MACRO_TEMPLATE,
XSLFRelation.PRESENTATIONML, XSLFRelation.PRESENTATIONML_TEMPLATE,
XSLFRelation.PRESENTATION_MACRO
};
private ExtractorFactory() {
}
@ -225,7 +230,7 @@ public final class ExtractorFactory {
}
// Is it XSLF?
for (XSLFRelation rel : XSLFPowerPointExtractor.SUPPORTED_TYPES) {
for (XSLFRelation rel : SUPPORTED_XSLF_TYPES) {
if ( rel.getContentType().equals( contentType ) ) {
return new SlideShowExtractor<>(new XMLSlideShow(pkg));
}

View File

@ -23,9 +23,10 @@ import org.apache.poi.util.Removal;
* @deprecated in 4.1.0 - use org.apache.poi.util.Dimension2DDouble
*/
@Deprecated
@Removal(version = "5.0.0")
@Removal(version = "6.0.0")
public class Dimension2dDouble extends org.apache.poi.util.Dimension2DDouble {
public Dimension2dDouble() {
super();
}
public Dimension2dDouble(double width, double height) {

View File

@ -22,7 +22,9 @@ import java.awt.geom.Rectangle2D;
import com.microsoft.schemas.office.visio.x2012.main.PageType;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.util.Dimension2DDouble;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
import org.apache.poi.xdgf.geom.Dimension2dDouble;
/**
@ -73,7 +75,10 @@ public class XDGFPage {
/**
* @return width/height of page
* @deprecated use {@link #getPageDimensions()}
*/
@Removal(version = "6.0.0")
@Deprecated
public Dimension2dDouble getPageSize() {
XDGFCell w = _pageSheet.getCell("PageWidth");
XDGFCell h = _pageSheet.getCell("PageHeight");
@ -85,6 +90,21 @@ public class XDGFPage {
Double.parseDouble(h.getValue()));
}
/**
* @return width/height of page
* @since POI 5.0.0
*/
public Dimension2DDouble getPageDimensions() {
XDGFCell w = _pageSheet.getCell("PageWidth");
XDGFCell h = _pageSheet.getCell("PageHeight");
if (w == null || h == null)
throw new POIXMLException("Cannot determine page size");
return new Dimension2DDouble(Double.parseDouble(w.getValue()),
Double.parseDouble(h.getValue()));
}
/**
* @return origin of coordinate system
*/
@ -108,7 +128,7 @@ public class XDGFPage {
* @return bounding box of page
*/
public Rectangle2D getBoundingBox() {
Dimension2dDouble sz = getPageSize();
Dimension2DDouble sz = getPageDimensions();
Point2D.Double offset = getPageOffset();
return new Rectangle2D.Double(-offset.getX(), -offset.getY(),

View File

@ -28,7 +28,7 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.poi.xdgf.geom.Dimension2dDouble;
import org.apache.poi.util.Dimension2DDouble;
import org.apache.poi.xdgf.usermodel.XDGFPage;
import org.apache.poi.xdgf.usermodel.XmlVisioDocument;
import org.apache.poi.xdgf.usermodel.shape.ShapeDebuggerRenderer;
@ -61,7 +61,7 @@ public class VsdxToPng {
public static void renderToPng(XDGFPage page, File outFile, double scale,
ShapeRenderer renderer) throws IOException {
Dimension2dDouble sz = page.getPageSize();
Dimension2DDouble sz = page.getPageDimensions();
int width = (int) (scale * sz.getWidth());
int height = (int) (scale * sz.getHeight());

View File

@ -1,208 +0,0 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xslf.extractor;
import java.io.IOException;
import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.sl.extractor.SlideShowExtractor;
import org.apache.poi.util.Removal;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFRelation;
import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFSlideShow;
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.xmlbeans.XmlException;
/**
* Extractor for XSLF SlideShows
*
* @deprecated use {@link SlideShowExtractor}
*/
@Deprecated
@Removal(version="5.0.0")
public class XSLFPowerPointExtractor extends POIXMLTextExtractor {
public static final XSLFRelation[] SUPPORTED_TYPES = new XSLFRelation[]{
XSLFRelation.MAIN, XSLFRelation.MACRO, XSLFRelation.MACRO_TEMPLATE,
XSLFRelation.PRESENTATIONML, XSLFRelation.PRESENTATIONML_TEMPLATE,
XSLFRelation.PRESENTATION_MACRO
};
private final SlideShowExtractor<XSLFShape, XSLFTextParagraph> delegate;
private boolean slidesByDefault = true;
private boolean notesByDefault;
private boolean commentsByDefault;
private boolean masterByDefault;
@SuppressWarnings("WeakerAccess")
public XSLFPowerPointExtractor(XMLSlideShow slideShow) {
super(slideShow);
delegate = new SlideShowExtractor<>(slideShow);
}
public XSLFPowerPointExtractor(XSLFSlideShow slideShow) {
this(new XMLSlideShow(slideShow.getPackage()));
}
public XSLFPowerPointExtractor(OPCPackage container) throws XmlException, OpenXML4JException, IOException {
this(new XSLFSlideShow(container));
}
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.err.println("Use:");
System.err.println(" XSLFPowerPointExtractor <filename.pptx>");
System.exit(1);
}
POIXMLTextExtractor extractor =
new XSLFPowerPointExtractor(
new XSLFSlideShow(args[0]));
System.out.println(extractor.getText());
extractor.close();
}
/**
* Should a call to getText() return slide text?
* Default is yes
*/
@SuppressWarnings("WeakerAccess")
public void setSlidesByDefault(final boolean slidesByDefault) {
this.slidesByDefault = slidesByDefault;
delegate.setSlidesByDefault(slidesByDefault);
}
/**
* Should a call to getText() return notes text?
* Default is no
*/
@SuppressWarnings("WeakerAccess")
public void setNotesByDefault(final boolean notesByDefault) {
this.notesByDefault = notesByDefault;
delegate.setNotesByDefault(notesByDefault);
}
/**
* Should a call to getText() return comments text? Default is no
*/
@SuppressWarnings({"WeakerAccess", "unused"})
public void setCommentsByDefault(final boolean commentsByDefault) {
this.commentsByDefault = commentsByDefault;
delegate.setCommentsByDefault(commentsByDefault);
}
/**
* Should a call to getText() return text from master? Default is no
*/
@SuppressWarnings("WeakerAccess")
public void setMasterByDefault(final boolean masterByDefault) {
this.masterByDefault = masterByDefault;
delegate.setMasterByDefault(masterByDefault);
}
/**
* Gets the slide text, but not the notes text
*/
@Override
public String getText() {
return delegate.getText();
}
/**
* Gets the requested text from the file
*
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
*/
public String getText(final boolean slideText, final boolean notesText) {
return getText(slideText, notesText, commentsByDefault, masterByDefault);
}
/**
* Gets the requested text from the file
*
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
* @param masterText Should we retrieve text from master slides?
* @return the extracted text
*/
public String getText(boolean slideText, boolean notesText, boolean masterText) {
return getText(slideText, notesText, commentsByDefault, masterText);
}
/**
* Gets the requested text from the file
*
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
* @param commentText Should we retrieve text from comments?
* @param masterText Should we retrieve text from master slides?
* @return the extracted text
*/
@SuppressWarnings("Duplicates")
public String getText(boolean slideText, boolean notesText, boolean commentText, boolean masterText) {
delegate.setSlidesByDefault(slideText);
delegate.setNotesByDefault(notesText);
delegate.setCommentsByDefault(commentText);
delegate.setMasterByDefault(masterText);
try {
return delegate.getText();
} finally {
delegate.setSlidesByDefault(slidesByDefault);
delegate.setNotesByDefault(notesByDefault);
delegate.setCommentsByDefault(commentsByDefault);
delegate.setMasterByDefault(masterByDefault);
}
}
/**
* Gets the requested text from the slide
*
* @param slide the slide to retrieve the text from
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
* @param masterText Should we retrieve text from master slides?
* @return the extracted text
*/
public static String getText(XSLFSlide slide, boolean slideText, boolean notesText, boolean masterText) {
return getText(slide, slideText, notesText, false, masterText);
}
/**
* Gets the requested text from the slide
*
* @param slide the slide to retrieve the text from
* @param slideText Should we retrieve text from slides?
* @param notesText Should we retrieve text from notes?
* @param commentText Should we retrieve text from comments?
* @param masterText Should we retrieve text from master slides?
* @return the extracted text
*/
public static String getText(XSLFSlide slide, boolean slideText, boolean notesText, boolean commentText, boolean masterText) {
final SlideShowExtractor<XSLFShape, XSLFTextParagraph> ex = new SlideShowExtractor<>(slide.getSlideShow());
ex.setSlidesByDefault(slideText);
ex.setNotesByDefault(notesText);
ex.setCommentsByDefault(commentText);
ex.setMasterByDefault(masterText);
return ex.getText(slide);
}
}

View File

@ -24,14 +24,11 @@ import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
@ -171,25 +168,6 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
return commentRefs.keySet().iterator();
}
/**
* Returns all cell comments on this sheet.
* @return A map of each Comment in this sheet, keyed on the cell address where
* the comment is located.
* @deprecated use <code>getCellAddresses</code> instead
*/
@Removal(version = "4.2")
@Deprecated
public Map<CellAddress, XSSFComment> getCellComments() {
prepareCTCommentCache();
final TreeMap<CellAddress, XSSFComment> map = new TreeMap<>();
for (final Entry<CellAddress, CTComment> e : commentRefs.entrySet()) {
map.put(e.getKey(), new XSSFComment(this, e.getValue(), null));
}
return map;
}
/**
* Refresh Map<CellAddress, CTComment> commentRefs cache,
* Calls that use the commentRefs cache will perform in O(1)

View File

@ -34,7 +34,6 @@ import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;

View File

@ -21,7 +21,6 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
import org.apache.poi.xssf.usermodel.XSSFTable;
import org.apache.poi.xssf.usermodel.XSSFTableColumn;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXmlColumnPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STXmlDataType.Enum;
@ -55,14 +54,6 @@ public class XSSFXmlColumnPr {
this.ctXmlColumnPr = ctXmlColumnPr;
}
@Deprecated
@Removal(version="4.2")
public XSSFXmlColumnPr(XSSFTable table, CTTableColumn ctTableColum, CTXmlColumnPr ctXmlColumnPr) {
this.table = table;
this.tableColumn = table.getColumns().get(table.findColumnIndex(ctTableColum.getName()));
this.ctXmlColumnPr = ctXmlColumnPr;
}
/**
* Get the column for which these XML column properties are set.
*

View File

@ -27,8 +27,6 @@ import java.util.function.Function;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.util.Internal;
import org.apache.poi.util.NotImplemented;
import org.apache.poi.util.Removal;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
@ -234,19 +232,6 @@ public class XWPFTable implements IBodyElement, ISDTContents {
return text.toString();
}
/**
* This method has existed since 2008 without an implementation.
* It will be removed unless an implementation is provided.
* @deprecated 4.0.0 due to lack of implementation.
*/
@Deprecated
@Removal
@NotImplemented
public void addNewRowBetween(int start, int end) {
throw new UnsupportedOperationException("XWPFTable#addNewRowBetween(int, int) not implemented");
}
/**
* add a new column for each row in this table
*/