remove some deprecated code slated for removal in 3.18
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ed85b0484
commit
0b7774a452
@ -1,195 +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.hpsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.LittleEndianConsts;
|
||||
import org.apache.poi.util.Removal;
|
||||
|
||||
/**
|
||||
* Class for writing little-endian data and more.
|
||||
* @deprecated POI 3.16 beta 2 - use LittleEndian instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Removal(version="3.18")
|
||||
public class TypeWriter
|
||||
{
|
||||
|
||||
/**
|
||||
* <p>Writes a two-byte value (short) to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to.
|
||||
* @param n The value to write.
|
||||
* @return The number of bytes that have been written.
|
||||
* @exception IOException if an I/O error occurs
|
||||
*/
|
||||
public static int writeToStream( final OutputStream out, final short n )
|
||||
throws IOException
|
||||
{
|
||||
LittleEndian.putShort( out, n ); // FIXME: unsigned
|
||||
return LittleEndianConsts.SHORT_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes a four-byte value to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to.
|
||||
* @param n The value to write.
|
||||
* @exception IOException if an I/O error occurs
|
||||
* @return The number of bytes written to the output stream.
|
||||
*/
|
||||
public static int writeToStream( final OutputStream out, final int n )
|
||||
throws IOException
|
||||
{
|
||||
LittleEndian.putInt( n, out );
|
||||
return LittleEndianConsts.INT_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes a eight-byte value to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to.
|
||||
* @param n The value to write.
|
||||
* @exception IOException if an I/O error occurs
|
||||
* @return The number of bytes written to the output stream.
|
||||
*/
|
||||
public static int writeToStream( final OutputStream out, final long n )
|
||||
throws IOException
|
||||
{
|
||||
LittleEndian.putLong( n, out );
|
||||
return LittleEndianConsts.LONG_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes an unsigned two-byte value to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to
|
||||
* @param n The value to write
|
||||
* @exception IOException if an I/O error occurs
|
||||
*/
|
||||
public static void writeUShortToStream( final OutputStream out, final int n )
|
||||
throws IOException
|
||||
{
|
||||
int high = n & 0xFFFF0000;
|
||||
if ( high != 0 ) {
|
||||
throw new IllegalPropertySetDataException( "Value " + n
|
||||
+ " cannot be represented by 2 bytes." );
|
||||
}
|
||||
LittleEndian.putUShort( n, out );
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes an unsigned four-byte value to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to.
|
||||
* @param n The value to write.
|
||||
* @return The number of bytes that have been written to the output stream.
|
||||
* @exception IOException if an I/O error occurs
|
||||
*/
|
||||
public static int writeUIntToStream( final OutputStream out, final long n )
|
||||
throws IOException
|
||||
{
|
||||
long high = n & 0xFFFFFFFF00000000L;
|
||||
if ( high != 0 && high != 0xFFFFFFFF00000000L ) {
|
||||
throw new IllegalPropertySetDataException( "Value " + n
|
||||
+ " cannot be represented by 4 bytes." );
|
||||
}
|
||||
LittleEndian.putUInt( n, out );
|
||||
return LittleEndianConsts.INT_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes a 16-byte {@link ClassID} to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to
|
||||
* @param n The value to write
|
||||
* @return The number of bytes written
|
||||
* @exception IOException if an I/O error occurs
|
||||
*/
|
||||
public static int writeToStream(final OutputStream out, final ClassID n)
|
||||
throws IOException
|
||||
{
|
||||
byte[] b = new byte[16];
|
||||
n.write(b, 0);
|
||||
out.write(b, 0, b.length);
|
||||
return b.length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Writes an array of {@link Property} instances to an output stream
|
||||
* according to the Horrible Property Stream Format.</p>
|
||||
*
|
||||
* @param out The stream to write to
|
||||
* @param properties The array to write to the stream
|
||||
* @param codepage The codepage number to use for writing strings
|
||||
* @exception IOException if an I/O error occurs
|
||||
* @throws UnsupportedVariantTypeException if HPSF does not support some
|
||||
* variant type.
|
||||
*/
|
||||
public static void writeToStream(final OutputStream out,
|
||||
final Property[] properties,
|
||||
final int codepage)
|
||||
throws IOException, UnsupportedVariantTypeException
|
||||
{
|
||||
/* If there are no properties don't write anything. */
|
||||
if (properties == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write the property list. This is a list containing pairs of property
|
||||
* ID and offset into the stream. */
|
||||
for (int i = 0; i < properties.length; i++)
|
||||
{
|
||||
final Property p = properties[i];
|
||||
writeUIntToStream(out, p.getID());
|
||||
writeUIntToStream(out, p.getSize(codepage));
|
||||
}
|
||||
|
||||
/* Write the properties themselves. */
|
||||
for (int i = 0; i < properties.length; i++)
|
||||
{
|
||||
final Property p = properties[i];
|
||||
long type = p.getType();
|
||||
writeUIntToStream(out, type);
|
||||
VariantSupport.write(out, (int) type, p.getValue(), codepage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Writes a double value value to an output stream.</p>
|
||||
*
|
||||
* @param out The stream to write to.
|
||||
* @param n The value to write.
|
||||
* @exception IOException if an I/O error occurs
|
||||
* @return The number of bytes written to the output stream.
|
||||
*/
|
||||
public static int writeToStream( final OutputStream out, final double n )
|
||||
throws IOException
|
||||
{
|
||||
LittleEndian.putDouble( n, out );
|
||||
return LittleEndianConsts.DOUBLE_SIZE;
|
||||
}
|
||||
|
||||
}
|
@ -1,45 +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.usermodel;
|
||||
|
||||
import org.apache.poi.util.Removal;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
|
||||
|
||||
/*
|
||||
* @deprecated POI 3.16 beta 1. use {@link XSLFTable} instead
|
||||
*/
|
||||
@Removal(version="3.18")
|
||||
public class DrawingTable {
|
||||
private final CTTable table;
|
||||
|
||||
public DrawingTable(CTTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public DrawingTableRow[] getRows() {
|
||||
CTTableRow[] ctTableRows = table.getTrArray();
|
||||
DrawingTableRow[] o = new DrawingTableRow[ctTableRows.length];
|
||||
|
||||
for (int i=0; i<o.length; i++) {
|
||||
o[i] = new DrawingTableRow(ctTableRows[i]);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
@ -1,125 +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.usermodel;
|
||||
|
||||
import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
|
||||
|
||||
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.poi.util.Removal;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
|
||||
/*
|
||||
* @deprecated POI 3.16 beta 1. - iterate over the shapes of a slide instead
|
||||
*/
|
||||
@Removal(version="3.18")
|
||||
@Beta
|
||||
public class XSLFCommonSlideData {
|
||||
private final CTCommonSlideData data;
|
||||
|
||||
public XSLFCommonSlideData(CTCommonSlideData data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public List<DrawingTextBody> getDrawingText() {
|
||||
CTGroupShape gs = data.getSpTree();
|
||||
|
||||
List<DrawingTextBody> out = new ArrayList<>();
|
||||
|
||||
processShape(gs, out);
|
||||
|
||||
for (CTGroupShape shape : gs.getGrpSpArray()) {
|
||||
processShape(shape, out);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
while (c.toNextSelection()) {
|
||||
XmlObject o = c.getObject();
|
||||
|
||||
if (o instanceof XmlAnyTypeImpl) {
|
||||
// Pesky XmlBeans bug - see Bugzilla #49934
|
||||
try {
|
||||
o = CTTable.Factory.parse(o.toString(), DEFAULT_XML_OPTIONS);
|
||||
} catch (XmlException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (o instanceof CTTable) {
|
||||
DrawingTable table = new DrawingTable((CTTable) o);
|
||||
|
||||
for (DrawingTableRow row : table.getRows()) {
|
||||
for (DrawingTableCell cell : row.getCells()) {
|
||||
DrawingTextBody textBody = cell.getTextBody();
|
||||
out.add(textBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.dispose();
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
public List<DrawingParagraph> getText() {
|
||||
List<DrawingParagraph> paragraphs = new ArrayList<>();
|
||||
for(DrawingTextBody textBody : getDrawingText()) {
|
||||
paragraphs.addAll(Arrays.asList(textBody.getParagraphs()));
|
||||
}
|
||||
return paragraphs;
|
||||
}
|
||||
|
||||
private void processShape(CTGroupShape gs, List<DrawingTextBody> out) {
|
||||
for (CTShape shape : gs.getSpArray()) {
|
||||
CTTextBody ctTextBody = shape.getTxBody();
|
||||
if (ctTextBody==null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DrawingTextBody textBody;
|
||||
CTApplicationNonVisualDrawingProps nvpr = shape.getNvSpPr().getNvPr();
|
||||
if(nvpr.isSetPh()) {
|
||||
textBody = new DrawingTextPlaceholder(ctTextBody, nvpr.getPh());
|
||||
} else {
|
||||
textBody = new DrawingTextBody(ctTextBody);
|
||||
}
|
||||
|
||||
out.add(textBody);
|
||||
}
|
||||
}
|
||||
}
|
@ -42,7 +42,6 @@ implements Notes<XSLFShape,XSLFTextParagraph> {
|
||||
XSLFNotes() {
|
||||
super();
|
||||
_notes = prototype();
|
||||
setCommonSlideData(_notes.getCSld());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +60,6 @@ implements Notes<XSLFShape,XSLFTextParagraph> {
|
||||
NotesDocument doc =
|
||||
NotesDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
|
||||
_notes = doc.getNotes();
|
||||
setCommonSlideData(_notes.getCSld());
|
||||
}
|
||||
|
||||
private static CTNotesSlide prototype(){
|
||||
|
@ -66,7 +66,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
|
||||
NotesMasterDocument doc =
|
||||
NotesMasterDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
|
||||
_slide = doc.getNotesMaster();
|
||||
setCommonSlideData(_slide.getCSld());
|
||||
}
|
||||
|
||||
private static CTNotesMaster prototype() {
|
||||
|
@ -58,7 +58,6 @@ public abstract class XSLFSheet extends POIXMLDocumentPart
|
||||
implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
|
||||
private static POILogger LOG = POILogFactory.getLogger(XSLFSheet.class);
|
||||
|
||||
private XSLFCommonSlideData _commonSlideData;
|
||||
private XSLFDrawing _drawing;
|
||||
private List<XSLFShape> _shapes;
|
||||
private CTGroupShape _spTree;
|
||||
@ -141,18 +140,6 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
|
||||
*/
|
||||
public abstract XmlObject getXmlObject();
|
||||
|
||||
/*
|
||||
* @deprecated POI 3.16 beta 1. use {@link XSLFTable} instead
|
||||
*/
|
||||
@Removal(version="3.18")
|
||||
protected void setCommonSlideData(CTCommonSlideData data) {
|
||||
if(data == null) {
|
||||
_commonSlideData = null;
|
||||
} else {
|
||||
_commonSlideData = new XSLFCommonSlideData(data);
|
||||
}
|
||||
}
|
||||
|
||||
private XSLFDrawing getDrawing(){
|
||||
initDrawingAndShapes();
|
||||
return _drawing;
|
||||
|
@ -60,7 +60,6 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
|
||||
XSLFSlide() {
|
||||
super();
|
||||
_slide = prototype();
|
||||
setCommonSlideData(_slide.getCSld());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +82,6 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
|
||||
|
||||
SldDocument doc = SldDocument.Factory.parse(_doc, DEFAULT_XML_OPTIONS);
|
||||
_slide = doc.getSld();
|
||||
setCommonSlideData(_slide.getCSld());
|
||||
}
|
||||
|
||||
private static CTSlide prototype(){
|
||||
|
@ -51,7 +51,6 @@ implements MasterSheet<XSLFShape,XSLFTextParagraph> {
|
||||
SldLayoutDocument doc =
|
||||
SldLayoutDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
|
||||
_layout = doc.getSldLayout();
|
||||
setCommonSlideData(_layout.getCSld());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -76,7 +76,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
|
||||
SldMasterDocument doc =
|
||||
SldMasterDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
|
||||
_slide = doc.getSldMaster();
|
||||
setCommonSlideData(_slide.getCSld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user