remove deprecated o.a.p.hwpf.usermodel.Shapes (replaced by OfficeDrawing in POI 3.8 beta 4)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748788 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e28a8789f3
commit
bb43d1eb3c
@ -42,7 +42,6 @@ import org.apache.poi.hwpf.model.PicturesTable;
|
|||||||
import org.apache.poi.hwpf.model.RevisionMarkAuthorTable;
|
import org.apache.poi.hwpf.model.RevisionMarkAuthorTable;
|
||||||
import org.apache.poi.hwpf.model.SavedByTable;
|
import org.apache.poi.hwpf.model.SavedByTable;
|
||||||
import org.apache.poi.hwpf.model.SectionTable;
|
import org.apache.poi.hwpf.model.SectionTable;
|
||||||
import org.apache.poi.hwpf.model.ShapesTable;
|
|
||||||
import org.apache.poi.hwpf.model.SinglentonTextPiece;
|
import org.apache.poi.hwpf.model.SinglentonTextPiece;
|
||||||
import org.apache.poi.hwpf.model.StyleSheet;
|
import org.apache.poi.hwpf.model.StyleSheet;
|
||||||
import org.apache.poi.hwpf.model.SubdocumentType;
|
import org.apache.poi.hwpf.model.SubdocumentType;
|
||||||
@ -121,12 +120,6 @@ public final class HWPFDocument extends HWPFDocumentCore
|
|||||||
/** Holds pictures table */
|
/** Holds pictures table */
|
||||||
protected PicturesTable _pictures;
|
protected PicturesTable _pictures;
|
||||||
|
|
||||||
/** Holds Office Art objects
|
|
||||||
* @deprecated POI 3.8.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected ShapesTable _officeArts;
|
|
||||||
|
|
||||||
/** Holds Office Art objects */
|
/** Holds Office Art objects */
|
||||||
protected OfficeDrawingsImpl _officeDrawingsHeaders;
|
protected OfficeDrawingsImpl _officeDrawingsHeaders;
|
||||||
|
|
||||||
@ -318,8 +311,6 @@ public final class HWPFDocument extends HWPFDocumentCore
|
|||||||
|
|
||||||
// read in the pictures stream
|
// read in the pictures stream
|
||||||
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder);
|
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder);
|
||||||
// And the art shapes stream
|
|
||||||
_officeArts = new ShapesTable(_tableStream, _fib);
|
|
||||||
|
|
||||||
// And escher pictures
|
// And escher pictures
|
||||||
_officeDrawingsHeaders = new OfficeDrawingsImpl( _fspaHeaders, _escherRecordHolder, _mainStream );
|
_officeDrawingsHeaders = new OfficeDrawingsImpl( _fspaHeaders, _escherRecordHolder, _mainStream );
|
||||||
@ -535,18 +526,6 @@ public final class HWPFDocument extends HWPFDocumentCore
|
|||||||
return _escherRecordHolder;
|
return _escherRecordHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return ShapesTable object, that is able to extract office are shapes
|
|
||||||
* from this document
|
|
||||||
* @deprecated POI 3.8. Use {@link #getOfficeDrawingsMain()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Internal
|
|
||||||
public ShapesTable getShapesTable()
|
|
||||||
{
|
|
||||||
return _officeArts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OfficeDrawings getOfficeDrawingsHeaders()
|
public OfficeDrawings getOfficeDrawingsHeaders()
|
||||||
{
|
{
|
||||||
return _officeDrawingsHeaders;
|
return _officeDrawingsHeaders;
|
||||||
|
@ -1,57 +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.hwpf.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.poi.hwpf.usermodel.Shape;
|
|
||||||
import org.apache.poi.util.Internal;
|
|
||||||
|
|
||||||
@Internal
|
|
||||||
@Deprecated
|
|
||||||
public final class ShapesTable {
|
|
||||||
private List<Shape> _shapes;
|
|
||||||
private List<Shape> _shapesVisibili; //holds visible shapes
|
|
||||||
|
|
||||||
public ShapesTable(byte [] tblStream, FileInformationBlock fib) {
|
|
||||||
PlexOfCps binTable = new PlexOfCps(tblStream,
|
|
||||||
fib.getFcPlcspaMom(), fib.getLcbPlcspaMom(), 26);
|
|
||||||
|
|
||||||
_shapes = new ArrayList<Shape>();
|
|
||||||
_shapesVisibili = new ArrayList<Shape>();
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < binTable.length(); i++) {
|
|
||||||
GenericPropertyNode nodo = binTable.getProperty(i);
|
|
||||||
|
|
||||||
Shape sh = new Shape(nodo);
|
|
||||||
_shapes.add(sh);
|
|
||||||
if(sh.isWithinDocument())
|
|
||||||
_shapesVisibili.add(sh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Shape> getAllShapes() {
|
|
||||||
return _shapes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Shape> getVisibleShapes() {
|
|
||||||
return _shapesVisibili;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +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.hwpf.usermodel;
|
|
||||||
|
|
||||||
import org.apache.poi.hwpf.model.GenericPropertyNode;
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link OfficeDrawing} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public final class Shape {
|
|
||||||
int _id, _left, _right, _top, _bottom;
|
|
||||||
/**
|
|
||||||
* true if the Shape bounds are within document (for
|
|
||||||
* example, it's false if the image left corner is outside the doc, like for
|
|
||||||
* embedded documents)
|
|
||||||
*/
|
|
||||||
boolean _inDoc;
|
|
||||||
|
|
||||||
public Shape(GenericPropertyNode nodo) {
|
|
||||||
byte [] contenuto = nodo.getBytes();
|
|
||||||
_id = LittleEndian.getInt(contenuto);
|
|
||||||
_left = LittleEndian.getInt(contenuto, 4);
|
|
||||||
_top = LittleEndian.getInt(contenuto, 8);
|
|
||||||
_right = LittleEndian.getInt(contenuto, 12);
|
|
||||||
_bottom = LittleEndian.getInt(contenuto, 16);
|
|
||||||
_inDoc = (_left >= 0 && _right >= 0 && _top >= 0 && _bottom >=
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLeft() {
|
|
||||||
return _left;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRight() {
|
|
||||||
return _right;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTop() {
|
|
||||||
return _top;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBottom() {
|
|
||||||
return _bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return _right - _left + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return _bottom - _top + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWithinDocument() {
|
|
||||||
return _inDoc;
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,7 +54,6 @@ import org.apache.poi.hwpf.usermodel.TestRangeInsertion;
|
|||||||
import org.apache.poi.hwpf.usermodel.TestRangeProperties;
|
import org.apache.poi.hwpf.usermodel.TestRangeProperties;
|
||||||
import org.apache.poi.hwpf.usermodel.TestRangeReplacement;
|
import org.apache.poi.hwpf.usermodel.TestRangeReplacement;
|
||||||
import org.apache.poi.hwpf.usermodel.TestRangeSymbols;
|
import org.apache.poi.hwpf.usermodel.TestRangeSymbols;
|
||||||
import org.apache.poi.hwpf.usermodel.TestShapes;
|
|
||||||
import org.apache.poi.hwpf.usermodel.TestTableRow;
|
import org.apache.poi.hwpf.usermodel.TestTableRow;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
@ -113,7 +112,6 @@ import org.junit.runners.Suite;
|
|||||||
TestRangeProperties.class,
|
TestRangeProperties.class,
|
||||||
TestRangeReplacement.class,
|
TestRangeReplacement.class,
|
||||||
TestRangeSymbols.class,
|
TestRangeSymbols.class,
|
||||||
TestShapes.class,
|
|
||||||
TestTableRow.class
|
TestTableRow.class
|
||||||
})
|
})
|
||||||
public final class AllHWPFTests {
|
public final class AllHWPFTests {
|
||||||
|
@ -1,81 +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.hwpf.usermodel;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.apache.poi.hwpf.HWPFDocument;
|
|
||||||
import org.apache.poi.hwpf.HWPFTestDataSamples;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the shapes handling
|
|
||||||
*/
|
|
||||||
public final class TestShapes extends TestCase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* two shapes, second is a group
|
|
||||||
*/
|
|
||||||
public void testShapes() throws Exception {
|
|
||||||
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("WithArtShapes.doc");
|
|
||||||
|
|
||||||
List shapes = doc.getShapesTable().getAllShapes();
|
|
||||||
List vshapes = doc.getShapesTable().getVisibleShapes();
|
|
||||||
|
|
||||||
assertEquals(2, shapes.size());
|
|
||||||
assertEquals(2, vshapes.size());
|
|
||||||
|
|
||||||
Shape s1 = (Shape)shapes.get(0);
|
|
||||||
Shape s2 = (Shape)shapes.get(1);
|
|
||||||
|
|
||||||
assertEquals(3616, s1.getWidth());
|
|
||||||
assertEquals(1738, s1.getHeight());
|
|
||||||
assertEquals(true, s1.isWithinDocument());
|
|
||||||
|
|
||||||
assertEquals(4817, s2.getWidth());
|
|
||||||
assertEquals(2164, s2.getHeight());
|
|
||||||
assertEquals(true, s2.isWithinDocument());
|
|
||||||
|
|
||||||
|
|
||||||
// Re-serialisze, check still there
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
doc.write(baos);
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
|
||||||
doc = new HWPFDocument(bais);
|
|
||||||
|
|
||||||
shapes = doc.getShapesTable().getAllShapes();
|
|
||||||
vshapes = doc.getShapesTable().getVisibleShapes();
|
|
||||||
|
|
||||||
assertEquals(2, shapes.size());
|
|
||||||
assertEquals(2, vshapes.size());
|
|
||||||
|
|
||||||
s1 = (Shape)shapes.get(0);
|
|
||||||
s2 = (Shape)shapes.get(1);
|
|
||||||
|
|
||||||
assertEquals(3616, s1.getWidth());
|
|
||||||
assertEquals(1738, s1.getHeight());
|
|
||||||
assertEquals(true, s1.isWithinDocument());
|
|
||||||
|
|
||||||
assertEquals(4817, s2.getWidth());
|
|
||||||
assertEquals(2164, s2.getHeight());
|
|
||||||
assertEquals(true, s2.isWithinDocument());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user