mirror of https://github.com/apache/poi.git
Add a bit more XSSFDrawing testing, not all of which works properly yet...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1179461 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a234740a3b
commit
fc6029fca4
|
@ -85,6 +85,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
|
||||||
protected XSSFDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
|
protected XSSFDrawing(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
|
||||||
super(part, rel);
|
super(part, rel);
|
||||||
drawing = CTDrawing.Factory.parse(part.getInputStream());
|
drawing = CTDrawing.Factory.parse(part.getInputStream());
|
||||||
|
isNew = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +117,13 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing {
|
||||||
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||||
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
|
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
|
||||||
*/
|
*/
|
||||||
if(isNew) xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr"));
|
if(isNew) {
|
||||||
|
// Have it wrapped in a <xdr:wsDr> tag
|
||||||
|
xmlOptions.setSaveSyntheticDocumentElement(
|
||||||
|
new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")
|
||||||
|
);
|
||||||
|
isNew = false;
|
||||||
|
}
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put(NAMESPACE_A, "a");
|
map.put(NAMESPACE_A, "a");
|
||||||
map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
|
map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
|
||||||
|
|
|
@ -23,6 +23,7 @@ import junit.framework.TestCase;
|
||||||
import org.apache.poi.POIXMLDocumentPart;
|
import org.apache.poi.POIXMLDocumentPart;
|
||||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
|
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
|
@ -44,7 +45,6 @@ public class TestXSSFDrawing extends TestCase {
|
||||||
//there should be a relation to this drawing in the worksheet
|
//there should be a relation to this drawing in the worksheet
|
||||||
assertTrue(sheet.getCTWorksheet().isSetDrawing());
|
assertTrue(sheet.getCTWorksheet().isSetDrawing());
|
||||||
assertEquals(drawingId, sheet.getCTWorksheet().getDrawing().getId());
|
assertEquals(drawingId, sheet.getCTWorksheet().getDrawing().getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNew(){
|
public void testNew(){
|
||||||
|
@ -85,7 +85,27 @@ public class TestXSSFDrawing extends TestCase {
|
||||||
c4.setText(rt);
|
c4.setText(rt);
|
||||||
|
|
||||||
c4.setNoFill(true);
|
c4.setNoFill(true);
|
||||||
|
|
||||||
|
|
||||||
|
// Save and re-load it
|
||||||
|
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
|
sheet = wb.getSheetAt(0);
|
||||||
|
|
||||||
|
// Check
|
||||||
|
dr1 = sheet.createDrawingPatriarch();
|
||||||
|
CTDrawing ctDrawing = dr1.getCTDrawing();
|
||||||
|
|
||||||
|
// Connector, shapes and text boxes are all two cell anchors
|
||||||
|
assertEquals(0, ctDrawing.sizeOfAbsoluteAnchorArray());
|
||||||
|
assertEquals(0, ctDrawing.sizeOfOneCellAnchorArray());
|
||||||
|
// TODO Fix this!
|
||||||
|
// assertEquals(4, ctDrawing.sizeOfTwoCellAnchorArray());
|
||||||
|
|
||||||
|
// Ensure it got the right namespaces
|
||||||
|
String xml = ctDrawing.toString();
|
||||||
|
assertEquals("<xdr:wsDr", xml.substring(0, 9));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultipleDrawings(){
|
public void testMultipleDrawings(){
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|
Loading…
Reference in New Issue