package org.apache.poi.openxml4j.opc;
+import static org.apache.poi.openxml4j.opc.ContentTypes.EXTENSION_XML;
+import static org.apache.poi.openxml4j.opc.ContentTypes.PLAIN_OLD_XML;
+import static org.apache.poi.openxml4j.opc.ContentTypes.RELATIONSHIPS_PART;
+import static org.apache.poi.openxml4j.opc.PackagingURIHelper.RELATIONSHIP_PART_EXTENSION_NAME;
+
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.poi.ooxml.util.PackageHelper;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
pkg.contentTypeManager.addContentType(
PackagingURIHelper.createPartName(
PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_URI),
- ContentTypes.RELATIONSHIPS_PART);
+ RELATIONSHIPS_PART);
pkg.contentTypeManager.addContentType(
PackagingURIHelper.createPartName("/default.xml"),
- ContentTypes.PLAIN_OLD_XML);
+ PLAIN_OLD_XML);
// Initialise some PackageBase properties
pkg.packageProperties = new PackagePropertiesPart(pkg,
PackagePart part = this.createPartImpl(partName, contentType,
loadRelationships);
+
+ /* check/create default entries - for bug54803 */
+ try {
+ PackagePartName ppn = PackagingURIHelper.createPartName("/."+EXTENSION_XML);
+ contentTypeManager.addContentType(ppn, PLAIN_OLD_XML);
+ ppn = PackagingURIHelper.createPartName("/"+RELATIONSHIP_PART_EXTENSION_NAME);
+ contentTypeManager.addContentType(ppn, RELATIONSHIPS_PART);
+ } catch (InvalidFormatException e) {
+ throw new InvalidOperationException("unable to create default content-type entries.", e);
+ }
+
this.contentTypeManager.addContentType(partName, contentType);
this.partList.put(partName, part);
this.isDirty = true;
import org.apache.poi.ss.usermodel.FontUnderline;
import org.apache.poi.ss.usermodel.ShapeTypes;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.Units;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.Test;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.*;
public class TestXSSFDrawing {
+ @Test
+ public void bug54803() throws Exception {
+ try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("bug54803.xlsx")) {
+ XSSFSheet sheet = wb.getSheetAt(0);
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFTestDataSamples.writeOutAndReadBack(wb).close();
+ }
+ }
+
@Test
public void testRead() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithDrawing.xlsx");