diff options
author | PJ Fanning <fanningpj@apache.org> | 2020-07-16 15:30:08 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2020-07-16 15:30:08 +0000 |
commit | 05902bcd1186d24aeb9a8cdf43ee67bab517ed5f (patch) | |
tree | 26304118e1bfc7e0ee13bbb00d3762fd8f9d8f1c | |
parent | 38220f65b00801868a3c6942e5d3620a40380591 (diff) | |
download | poi-05902bcd1186d24aeb9a8cdf43ee67bab517ed5f.tar.gz poi-05902bcd1186d24aeb9a8cdf43ee67bab517ed5f.zip |
remove more deprecated code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879964 13f79535-47bb-0310-9956-ffa450edef68
9 files changed, 32 insertions, 261 deletions
diff --git a/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java b/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java index 212404bcb4..5d179397f4 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/ooxml/extractor/ExtractorFactory.java @@ -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)); } diff --git a/src/ooxml/java/org/apache/poi/xdgf/geom/Dimension2dDouble.java b/src/ooxml/java/org/apache/poi/xdgf/geom/Dimension2dDouble.java index a7d8210abc..11e6f3e98e 100644 --- a/src/ooxml/java/org/apache/poi/xdgf/geom/Dimension2dDouble.java +++ b/src/ooxml/java/org/apache/poi/xdgf/geom/Dimension2dDouble.java @@ -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) { diff --git a/src/ooxml/java/org/apache/poi/xdgf/usermodel/XDGFPage.java b/src/ooxml/java/org/apache/poi/xdgf/usermodel/XDGFPage.java index 20915460d5..f769dc474e 100644 --- a/src/ooxml/java/org/apache/poi/xdgf/usermodel/XDGFPage.java +++ b/src/ooxml/java/org/apache/poi/xdgf/usermodel/XDGFPage.java @@ -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"); @@ -86,6 +91,21 @@ public class XDGFPage { } /** + * @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 */ public Point2D.Double getPageOffset() { @@ -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(), diff --git a/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java b/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java index 815eaee826..bb4e1be577 100644 --- a/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java +++ b/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java @@ -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()); diff --git a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java deleted file mode 100644 index ffc943e0d8..0000000000 --- a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java +++ /dev/null @@ -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); - } -} diff --git a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java index fcc592333b..c31de3e345 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java @@ -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; @@ -172,25 +169,6 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments { } /** - * 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) * time rather than O(n) lookup time for List<CTComment> comments. diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java index fd4c54fbd2..3805eb95b3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java @@ -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; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFXmlColumnPr.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFXmlColumnPr.java index 47d34f4bb4..e0032219f5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFXmlColumnPr.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFXmlColumnPr.java @@ -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. * diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java index 37713dd1a9..0705bbe696 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java @@ -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 */ |