==================================================================== */
package org.apache.poi.ooxml;
-import java.lang.reflect.InvocationTargetException;
+import java.io.IOException;
+import org.apache.poi.ooxml.POIXMLRelation.PackagePartConstructor;
+import org.apache.poi.ooxml.POIXMLRelation.ParentPartConstructor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import org.apache.xmlbeans.XmlException;
/**
* Defines a factory API that enables sub-classes to create instances of <code>POIXMLDocumentPart</code>
public abstract class POIXMLFactory {
private static final POILogger LOGGER = POILogFactory.getLogger(POIXMLFactory.class);
- private static final Class<?>[] PARENT_PART = {POIXMLDocumentPart.class, PackagePart.class};
- private static final Class<?>[] ORPHAN_PART = {PackagePart.class};
-
/**
* Create a POIXMLDocumentPart from existing package part and relation. This method is called
* from {@link POIXMLDocument#load(POIXMLFactory)} when parsing a document
* @param parent parent part
* @param part the PackagePart representing the created instance
* @return A new instance of a POIXMLDocumentPart.
- *
+ *
* @since by POI 3.14-Beta1
*/
public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackagePart part) {
// don't parse the document parts, if its class can't be determined
// or if it's a package relation of another embedded resource
- if (descriptor == null || descriptor.getRelationClass() == null || POIXMLDocument.PACK_OBJECT_REL_TYPE.equals(relType)) {
- LOGGER.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType());
- return new POIXMLDocumentPart(parent, part);
- }
-
- Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
try {
- try {
- return createDocumentPart(cls, PARENT_PART, new Object[]{parent, part});
- } catch (NoSuchMethodException e) {
- return createDocumentPart(cls, ORPHAN_PART, new Object[]{part});
+ if (descriptor != null && !POIXMLDocument.PACK_OBJECT_REL_TYPE.equals(relType)) {
+ ParentPartConstructor parentPartConstructor = descriptor.getParentPartConstructor();
+ if (parentPartConstructor != null) {
+ return parentPartConstructor.init(parent, part);
+ }
+ PackagePartConstructor packagePartConstructor = descriptor.getPackagePartConstructor();
+ if (packagePartConstructor != null) {
+ return packagePartConstructor.init(part);
+ }
}
- } catch (Exception e) {
- throw new POIXMLException((e.getCause() != null ? e.getCause() : e).getMessage(), e);
+
+ LOGGER.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType());
+ return new POIXMLDocumentPart(parent, part);
+ } catch (IOException | XmlException e) {
+ throw new POIXMLException(e.getMessage(), e);
}
}
-
- /**
- * Need to delegate instantiation to sub class because of constructor visibility
- *
- * @param cls the document class to be instantiated
- * @param classes the classes of the constructor arguments
- * @param values the values of the constructor arguments
- * @return the new document / part
- * @throws SecurityException thrown if the object can't be instantiated
- * @throws NoSuchMethodException thrown if there is no constructor found for the given arguments
- * @throws InstantiationException thrown if the object can't be instantiated
- * @throws IllegalAccessException thrown if the object can't be instantiated
- * @throws InvocationTargetException thrown if the object can't be instantiated
- *
- * @since POI 3.14-Beta1
- */
- protected abstract POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException;
-
+
/**
- * returns the descriptor for the given relationship type
+ * returns the descriptor for the given relationship type
*
* @param relationshipType the relationship type of the descriptor
* @return the descriptor or null if type is unknown
- *
+ *
* @since POI 3.14-Beta1
*/
protected abstract POIXMLRelation getDescriptor(String relationshipType);
* @return A new instance of a POIXMLDocumentPart.
*/
public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor) {
- Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass();
- try {
- return createDocumentPart(cls, null, null);
- } catch (Exception e) {
- throw new POIXMLException(e);
+ if (descriptor == null || descriptor.getNoArgConstructor() == null) {
+ throw new POIXMLException("can't initialize POIXMLDocumentPart");
}
+
+ return descriptor.getNoArgConstructor().init();
}
/**
* Retrieves the package relationship of the child part within the parent
- *
+ *
* @param parent the parent to search for the part
* @param part the part to look for
- *
+ *
* @return the relationship
- *
+ *
* @throws POIXMLException if the relations are erroneous or the part is not related
- *
+ *
* @since POI 3.14-Beta1
*/
protected PackageRelationship getPackageRelationship(POIXMLDocumentPart parent, PackagePart part) {
} catch (InvalidFormatException e) {
throw new POIXMLException("error while determining package relations", e);
}
-
+
throw new POIXMLException("package part isn't a child of the parent document.");
}
}
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import org.apache.xmlbeans.XmlException;
/**
* Represents a descriptor of a OOXML relation.
*/
public abstract class POIXMLRelation {
+ @Internal
+ public interface NoArgConstructor {
+ POIXMLDocumentPart init();
+ }
+
+ @Internal
+ public interface PackagePartConstructor {
+ POIXMLDocumentPart init(PackagePart part) throws IOException, XmlException;
+ }
+
+ @Internal
+ public interface ParentPartConstructor {
+ POIXMLDocumentPart init(POIXMLDocumentPart parent, PackagePart part) throws IOException, XmlException;
+ }
+
private static final POILogger log = POILogFactory.getLogger(POIXMLRelation.class);
/**
private String _defaultName;
/**
- * Defines what object is used to construct instances of this relationship
+ * Constructors or factory method to construct instances of this relationship
*/
- private Class<? extends POIXMLDocumentPart> _cls;
+ private final NoArgConstructor noArgConstructor;
+ private final PackagePartConstructor packagePartConstructor;
+ private final ParentPartConstructor parentPartConstructor;
/**
* Instantiates a POIXMLRelation.
* @param type content type
* @param rel relationship
* @param defaultName default item name
- * @param cls defines what object is used to construct instances of this relationship
+ * @param noArgConstructor method used to construct instances of this relationship from scratch
+ * @param packagePartConstructor method used to construct instances of this relationship with a package part
*/
- public POIXMLRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
+ protected POIXMLRelation(String type, String rel, String defaultName,
+ NoArgConstructor noArgConstructor,
+ PackagePartConstructor packagePartConstructor,
+ ParentPartConstructor parentPartConstructor) {
_type = type;
_relation = rel;
_defaultName = defaultName;
- _cls = cls;
+ this.noArgConstructor = noArgConstructor;
+ this.packagePartConstructor = packagePartConstructor;
+ this.parentPartConstructor = parentPartConstructor;
}
/**
* @param rel relationship
* @param defaultName default item name
*/
- public POIXMLRelation(String type, String rel, String defaultName) {
- this(type, rel, defaultName, null);
+ protected POIXMLRelation(String type, String rel, String defaultName) {
+ this(type, rel, defaultName, null, null, null);
}
/**
* Return the content type. Content types define a media type, a subtype, and an
/**
* Returns the filename for the nth one of these, e.g. /xl/comments4.xml
- *
+ *
* @param index the suffix for the document type
* @return the filename including the suffix
*/
}
return _defaultName.replace("#", Integer.toString(index));
}
-
+
/**
* Returns the index of the filename within the package for the given part.
* e.g. 4 for /xl/comments4.xml
- *
+ *
* @param part the part to read the suffix from
* @return the suffix
*/
String regex = _defaultName.replace("#", "(\\d+)");
return Integer.valueOf(part.getPackagePart().getPartName().getName().replaceAll(regex, "$1"));
}
-
+
+ /**
+ * @return the constructor method used to construct instances of this relationship from scratch
+ *
+ * @since 4.1.2
+ */
+ public NoArgConstructor getNoArgConstructor() {
+ return noArgConstructor;
+ }
+
+ /**
+ * @return the constructor method used to construct instances of this relationship with a package part
+ *
+ * @since 4.1.2
+ */
+ public PackagePartConstructor getPackagePartConstructor() {
+ return packagePartConstructor;
+ }
+
/**
- * Return type of the object used to construct instances of this relationship
+ * @return the constructor method used to construct instances of this relationship with a package part
*
- * @return the class of the object used to construct instances of this relation
+ * @since 4.1.2
*/
- public Class<? extends POIXMLDocumentPart> getRelationClass(){
- return _cls;
+ public ParentPartConstructor getParentPartConstructor() {
+ return parentPartConstructor;
}
/**
import java.util.HashMap;
import java.util.Map;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.ContentTypes;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
private static final Map<String, DSigRelation> _table = new HashMap<>();
public static final DSigRelation ORIGIN_SIGS = new DSigRelation(
- ContentTypes.DIGITAL_SIGNATURE_ORIGIN_PART,
- PackageRelationshipTypes.DIGITAL_SIGNATURE_ORIGIN,
- "/_xmlsignatures/origin.sigs", null
+ ContentTypes.DIGITAL_SIGNATURE_ORIGIN_PART,
+ PackageRelationshipTypes.DIGITAL_SIGNATURE_ORIGIN,
+ "/_xmlsignatures/origin.sigs"
);
public static final DSigRelation SIG = new DSigRelation(
ContentTypes.DIGITAL_SIGNATURE_XML_SIGNATURE_PART,
PackageRelationshipTypes.DIGITAL_SIGNATURE,
- "/_xmlsignatures/sig#.xml", null
+ "/_xmlsignatures/sig#.xml"
);
- private DSigRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+ private DSigRelation(String type, String rel, String defaultName) {
+ super(type, rel, defaultName);
_table.put(rel, this);
}
import java.util.List;
import java.util.Map;
+import com.microsoft.schemas.office.visio.x2012.main.ConnectType;
+import com.microsoft.schemas.office.visio.x2012.main.PageContentsType;
+import com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Internal;
import org.apache.poi.xdgf.usermodel.shape.exceptions.StopVisiting;
import org.apache.poi.xdgf.xml.XDGFXMLDocumentPart;
-import com.microsoft.schemas.office.visio.x2012.main.ConnectType;
-import com.microsoft.schemas.office.visio.x2012.main.PageContentsType;
-import com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType;
-
/**
* Container of shapes for a page in a Visio diagram. Shapes are not
* necessarily literal shapes in the diagram, but is the term that is
/**
* @since POI 3.14-Beta1
*/
- public XDGFBaseContents(PackagePart part, XDGFDocument document) {
- super(part, document);
+ public XDGFBaseContents(PackagePart part) {
+ super(part);
}
-
+
@Internal
public PageContentsType getXmlObject() {
return _pageContents;
public List<XDGFShape> getTopLevelShapes() {
return Collections.unmodifiableList(_toplevelShapes);
}
-
+
public List<XDGFConnection> getConnections() {
return Collections.unmodifiableList(_connections);
}
package org.apache.poi.xdgf.usermodel;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.xdgf.xml.XDGFXMLDocumentPart;
/**
* Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
return XDGFRelation.getInstance(relationshipType);
}
- /**
- * @since POI 3.14-Beta1
- */
@Override
- protected POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
- Class<?>[] cl;
- Object[] vals;
- if (classes == null) {
- cl = new Class<?>[]{XDGFDocument.class};
- vals = new Object[]{document};
- } else {
- cl = new Class<?>[classes.length+1];
- System.arraycopy(classes, 0, cl, 0, classes.length);
- cl[classes.length] = XDGFDocument.class;
- vals = new Object[values.length+1];
- System.arraycopy(values, 0, vals, 0, values.length);
- vals[values.length] = document;
+ public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackagePart part) {
+ POIXMLDocumentPart newPart = super.createDocumentPart(parent, part);
+ if (newPart instanceof XDGFXMLDocumentPart) {
+ ((XDGFXMLDocumentPart)newPart).setDocument(document);
+ }
+ return newPart;
+ }
+
+ @Override
+ public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor) {
+ POIXMLDocumentPart newPart = super.newDocumentPart(descriptor);
+ if (newPart instanceof XDGFXMLDocumentPart) {
+ ((XDGFXMLDocumentPart)newPart).setDocument(document);
}
-
- Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(cl);
- return constructor.newInstance(vals);
+ return newPart;
}
}
import java.io.IOException;
+import com.microsoft.schemas.office.visio.x2012.main.MasterContentsDocument;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xdgf.exceptions.XDGFException;
import org.apache.xmlbeans.XmlException;
-import com.microsoft.schemas.office.visio.x2012.main.MasterContentsDocument;
-
/**
* Contains the actual contents of the master/stencil
*/
/**
* @since POI 3.14-Beta1
*/
- public XDGFMasterContents(PackagePart part, XDGFDocument document) {
- super(part, document);
+ public XDGFMasterContents(PackagePart part) {
+ super(part);
}
-
+
@Override
protected void onDocumentRead() {
import java.util.HashMap;
import java.util.Map;
+import com.microsoft.schemas.office.visio.x2012.main.MasterType;
+import com.microsoft.schemas.office.visio.x2012.main.MastersDocument;
+import com.microsoft.schemas.office.visio.x2012.main.MastersType;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xdgf.xml.XDGFXMLDocumentPart;
import org.apache.xmlbeans.XmlException;
-import com.microsoft.schemas.office.visio.x2012.main.MasterType;
-import com.microsoft.schemas.office.visio.x2012.main.MastersDocument;
-import com.microsoft.schemas.office.visio.x2012.main.MastersType;
-
/**
* A collection of masters (typically stencils) in a Visio document
*/
/**
* @since POI 3.14-Beta1
*/
- public XDGFMasters(PackagePart part, XDGFDocument document) {
- super(part, document);
+ public XDGFMasters(PackagePart part) {
+ super(part);
}
-
+
@Internal
protected MastersType getXmlObject() {
return _mastersObject;
import java.util.HashMap;
import java.util.Map;
+import com.microsoft.schemas.office.visio.x2012.main.PageContentsDocument;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xdgf.exceptions.XDGFException;
import org.apache.xmlbeans.XmlException;
-import com.microsoft.schemas.office.visio.x2012.main.PageContentsDocument;
-
public class XDGFPageContents extends XDGFBaseContents {
protected Map<Long, XDGFMaster> _masters = new HashMap<>();
/**
* @since POI 3.14-Beta1
*/
- public XDGFPageContents(PackagePart part, XDGFDocument document) {
- super(part, document);
+ public XDGFPageContents(PackagePart part) {
+ super(part);
}
-
+
@Override
protected void onDocumentRead() {
try {
import java.util.Collections;
import java.util.List;
+import com.microsoft.schemas.office.visio.x2012.main.PageType;
+import com.microsoft.schemas.office.visio.x2012.main.PagesDocument;
+import com.microsoft.schemas.office.visio.x2012.main.PagesType;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xdgf.xml.XDGFXMLDocumentPart;
import org.apache.xmlbeans.XmlException;
-import com.microsoft.schemas.office.visio.x2012.main.PageType;
-import com.microsoft.schemas.office.visio.x2012.main.PagesDocument;
-import com.microsoft.schemas.office.visio.x2012.main.PagesType;
-
/**
* Contains a list of Page objects (not page content!)
/**
* @since POI 3.14-Beta1
*/
- public XDGFPages(PackagePart part, XDGFDocument document) {
- super(part, document);
+ public XDGFPages(PackagePart part) {
+ super(part);
}
-
+
@Internal
PagesType getXmlObject() {
return _pagesObject;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
-import org.apache.poi.xdgf.xml.XDGFXMLDocumentPart;
public class XDGFRelation extends POIXMLRelation {
private static final Map<String, XDGFRelation> _table = new HashMap<>();
public static final XDGFRelation DOCUMENT = new XDGFRelation(
- "application/vnd.ms-visio.drawing.main+xml",
- PackageRelationshipTypes.VISIO_CORE_DOCUMENT,
- "/visio/document.xml", null);
+ "application/vnd.ms-visio.drawing.main+xml",
+ PackageRelationshipTypes.VISIO_CORE_DOCUMENT,
+ "/visio/document.xml", null);
public static final XDGFRelation MASTERS = new XDGFRelation(
- "application/vnd.ms-visio.masters+xml",
- "http://schemas.microsoft.com/visio/2010/relationships/masters",
- "/visio/masters/masters.xml", XDGFMasters.class);
+ "application/vnd.ms-visio.masters+xml",
+ "http://schemas.microsoft.com/visio/2010/relationships/masters",
+ "/visio/masters/masters.xml", XDGFMasters::new);
public static final XDGFRelation MASTER = new XDGFRelation(
- "application/vnd.ms-visio.master+xml",
- "http://schemas.microsoft.com/visio/2010/relationships/master",
- "/visio/masters/master#.xml", XDGFMasterContents.class);
+ "application/vnd.ms-visio.master+xml",
+ "http://schemas.microsoft.com/visio/2010/relationships/master",
+ "/visio/masters/master#.xml", XDGFMasterContents::new);
public static final XDGFRelation IMAGES = new XDGFRelation(null,
- PackageRelationshipTypes.IMAGE_PART, null, null // XSSFPictureData.class
- );
+ PackageRelationshipTypes.IMAGE_PART, null, null // XSSFPictureData.class
+ );
public static final XDGFRelation PAGES = new XDGFRelation(
- "application/vnd.ms-visio.pages+xml",
- "http://schemas.microsoft.com/visio/2010/relationships/pages",
- "/visio/pages/pages.xml", XDGFPages.class);
+ "application/vnd.ms-visio.pages+xml",
+ "http://schemas.microsoft.com/visio/2010/relationships/pages",
+ "/visio/pages/pages.xml", XDGFPages::new);
public static final XDGFRelation PAGE = new XDGFRelation(
- "application/vnd.ms-visio.page+xml",
- "http://schemas.microsoft.com/visio/2010/relationships/page",
- "/visio/pages/page#.xml", XDGFPageContents.class);
+ "application/vnd.ms-visio.page+xml",
+ "http://schemas.microsoft.com/visio/2010/relationships/page",
+ "/visio/pages/page#.xml", XDGFPageContents::new);
public static final XDGFRelation WINDOW = new XDGFRelation(
- "application/vnd.ms-visio.windows+xml",
- "http://schemas.microsoft.com/visio/2010/relationships/windows",
- "/visio/windows.xml", null);
+ "application/vnd.ms-visio.windows+xml",
+ "http://schemas.microsoft.com/visio/2010/relationships/windows",
+ "/visio/windows.xml", null);
- private XDGFRelation(String type, String rel, String defaultName, Class<? extends XDGFXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+ private XDGFRelation(String type, String rel, String defaultName,
+ PackagePartConstructor packagePartConstructor) {
+ super(type, rel, defaultName, null, packagePartConstructor, null);
_table.put(rel, this);
}
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.util.Internal;
import org.apache.poi.xdgf.usermodel.XDGFDocument;
public class XDGFXMLDocumentPart extends POIXMLDocumentPart {
protected XDGFDocument _document;
-
+
/**
* @since POI 3.14-Beta1
*/
- public XDGFXMLDocumentPart(PackagePart part, XDGFDocument document) {
+ public XDGFXMLDocumentPart(PackagePart part) {
super(part);
+ }
+
+ /**
+ * @since POI 4.1.2
+ */
+ @Internal
+ public void setDocument(XDGFDocument document) {
_document = document;
}
}
package org.apache.poi.xslf.usermodel;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
* Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
*/
public final class XSLFFactory extends POIXMLFactory {
- private XSLFFactory(){
-
- }
-
private static final XSLFFactory inst = new XSLFFactory();
public static XSLFFactory getInstance(){
return inst;
}
+ private XSLFFactory() {}
+
/**
* @since POI 3.14-Beta1
*/
protected POIXMLRelation getDescriptor(String relationshipType) {
return XSLFRelation.getInstance(relationshipType);
}
-
- /**
- * @since POI 3.14-Beta1
- */
- @Override
- protected POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
- Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(classes);
- return constructor.newInstance(values);
- }
}
import java.util.Map;
import org.apache.poi.ooxml.POIXMLDocument;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.util.Beta;
private static final Map<String, XSLFRelation> _table = new HashMap<>();
public static final XSLFRelation MAIN = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml",
- null, null, null
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
);
public static final XSLFRelation MACRO = new XSLFRelation(
- "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml",
- null, null, null
+ "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml"
);
public static final XSLFRelation MACRO_TEMPLATE = new XSLFRelation(
- "application/vnd.ms-powerpoint.template.macroEnabled.main+xml",
- null, null, null
+ "application/vnd.ms-powerpoint.template.macroEnabled.main+xml"
);
public static final XSLFRelation PRESENTATIONML = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml",
- null, null, null
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"
);
public static final XSLFRelation PRESENTATIONML_TEMPLATE = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml",
- null, null, null
+ "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml"
);
public static final XSLFRelation PRESENTATION_MACRO = new XSLFRelation(
- "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml",
- null, null, null
+ "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml"
);
public static final XSLFRelation THEME_MANAGER = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.themeManager+xml",
- null, null, null
+ "application/vnd.openxmlformats-officedocument.themeManager+xml"
);
public static final XSLFRelation NOTES = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
- "/ppt/notesSlides/notesSlide#.xml",
- XSLFNotes.class
+ "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
+ "/ppt/notesSlides/notesSlide#.xml",
+ XSLFNotes::new, XSLFNotes::new
);
public static final XSLFRelation SLIDE = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.slide+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
- "/ppt/slides/slide#.xml",
- XSLFSlide.class
+ "application/vnd.openxmlformats-officedocument.presentationml.slide+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
+ "/ppt/slides/slide#.xml",
+ XSLFSlide::new, XSLFSlide::new
);
public static final XSLFRelation SLIDE_LAYOUT = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
- "/ppt/slideLayouts/slideLayout#.xml",
- XSLFSlideLayout.class
+ "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
+ "/ppt/slideLayouts/slideLayout#.xml",
+ null, XSLFSlideLayout::new
);
public static final XSLFRelation SLIDE_MASTER = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
- "/ppt/slideMasters/slideMaster#.xml",
- XSLFSlideMaster.class
+ "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
+ "/ppt/slideMasters/slideMaster#.xml",
+ null, XSLFSlideMaster::new
);
public static final XSLFRelation NOTES_MASTER = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
- "/ppt/notesMasters/notesMaster#.xml",
- XSLFNotesMaster.class
+ "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
+ "/ppt/notesMasters/notesMaster#.xml",
+ XSLFNotesMaster::new, XSLFNotesMaster::new
);
public static final XSLFRelation COMMENTS = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.comments+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
- "/ppt/comments/comment#.xml",
- XSLFComments.class
+ "application/vnd.openxmlformats-officedocument.presentationml.comments+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
+ "/ppt/comments/comment#.xml",
+ XSLFComments::new, XSLFComments::new
);
public static final XSLFRelation COMMENT_AUTHORS = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
- "/ppt/commentAuthors.xml",
- XSLFCommentAuthors.class
+ "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
+ "/ppt/commentAuthors.xml",
+ XSLFCommentAuthors::new, XSLFCommentAuthors::new
);
public static final XSLFRelation HYPERLINK = new XSLFRelation(
- null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
- null,
- null
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
+ null
);
public static final XSLFRelation THEME = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.theme+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
- "/ppt/theme/theme#.xml",
- XSLFTheme.class
+ "application/vnd.openxmlformats-officedocument.theme+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
+ "/ppt/theme/theme#.xml",
+ XSLFTheme::new, XSLFTheme::new
);
public static final XSLFRelation VML_DRAWING = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.vmlDrawing",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
- "/ppt/drawings/vmlDrawing#.vml",
- null
+ "application/vnd.openxmlformats-officedocument.vmlDrawing",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
+ "/ppt/drawings/vmlDrawing#.vml"
);
// this is not the same as in XSSFRelation.WORKBOOK, as it is usually used by embedded charts
// referencing the original embedded excel workbook
public static final XSLFRelation WORKBOOK = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- POIXMLDocument.PACK_OBJECT_REL_TYPE,
- "/ppt/embeddings/Microsoft_Excel_Worksheet#.xlsx",
- XSSFWorkbook.class
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ POIXMLDocument.PACK_OBJECT_REL_TYPE,
+ "/ppt/embeddings/Microsoft_Excel_Worksheet#.xlsx",
+ XSSFWorkbook::new, XSSFWorkbook::new
);
public static final XSLFRelation CHART = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
- "/ppt/charts/chart#.xml",
- XSLFChart.class
+ "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
+ "/ppt/charts/chart#.xml",
+ XSLFChart::new, XSLFChart::new
);
public static final XSLFRelation IMAGE_EMF = new XSLFRelation(
- PictureType.EMF.contentType,
- IMAGE_PART,
- "/ppt/media/image#.emf",
- XSLFPictureData.class
+ PictureType.EMF.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.emf",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_WMF = new XSLFRelation(
- PictureType.WMF.contentType,
- IMAGE_PART,
- "/ppt/media/image#.wmf",
- XSLFPictureData.class
+ PictureType.WMF.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.wmf",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_PICT = new XSLFRelation(
- PictureType.PICT.contentType,
- IMAGE_PART,
- "/ppt/media/image#.pict",
- XSLFPictureData.class
+ PictureType.PICT.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.pict",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_JPEG = new XSLFRelation(
- PictureType.JPEG.contentType,
- IMAGE_PART,
- "/ppt/media/image#.jpeg",
- XSLFPictureData.class
+ PictureType.JPEG.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.jpeg",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_PNG = new XSLFRelation(
- PictureType.PNG.contentType,
- IMAGE_PART,
- "/ppt/media/image#.png",
- XSLFPictureData.class
+ PictureType.PNG.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.png",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_DIB = new XSLFRelation(
- PictureType.DIB.contentType,
- IMAGE_PART,
- "/ppt/media/image#.dib",
- XSLFPictureData.class
+ PictureType.DIB.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.dib",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_GIF = new XSLFRelation(
- PictureType.GIF.contentType,
- IMAGE_PART,
- "/ppt/media/image#.gif",
- XSLFPictureData.class
+ PictureType.GIF.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.gif",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_TIFF = new XSLFRelation(
- PictureType.TIFF.contentType,
- IMAGE_PART,
- "/ppt/media/image#.tiff",
- XSLFPictureData.class
+ PictureType.TIFF.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.tiff",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_EPS = new XSLFRelation(
- PictureType.EPS.contentType,
- IMAGE_PART,
- "/ppt/media/image#.eps",
- XSLFPictureData.class
+ PictureType.EPS.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.eps",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_BMP = new XSLFRelation(
- PictureType.BMP.contentType,
- IMAGE_PART,
- "/ppt/media/image#.bmp",
- XSLFPictureData.class
+ PictureType.BMP.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.bmp",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_WPG = new XSLFRelation(
- PictureType.WPG.contentType,
- IMAGE_PART,
- "/ppt/media/image#.wpg",
- XSLFPictureData.class
+ PictureType.WPG.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.wpg",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_WDP = new XSLFRelation(
- PictureType.WDP.contentType,
- IMAGE_PART,
- "/ppt/media/image#.wdp",
- XSLFPictureData.class
+ PictureType.WDP.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.wdp",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGE_SVG = new XSLFRelation(
- PictureType.SVG.contentType,
- IMAGE_PART,
- "/ppt/media/image#.svg",
- XSLFPictureData.class
+ PictureType.SVG.contentType,
+ IMAGE_PART,
+ "/ppt/media/image#.svg",
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation IMAGES = new XSLFRelation(
- null,
- IMAGE_PART,
- null,
- XSLFPictureData.class
+ null,
+ IMAGE_PART,
+ null,
+ XSLFPictureData::new, XSLFPictureData::new
);
public static final XSLFRelation TABLE_STYLES = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles",
- "/ppt/tableStyles.xml",
- XSLFTableStyles.class
+ "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles",
+ "/ppt/tableStyles.xml",
+ XSLFTableStyles::new, XSLFTableStyles::new
);
public static final XSLFRelation OLE_OBJECT = new XSLFRelation(
- "application/vnd.openxmlformats-officedocument.oleObject",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
- "/ppt/embeddings/oleObject#.bin",
- XSLFObjectData.class
+ "application/vnd.openxmlformats-officedocument.oleObject",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
+ "/ppt/embeddings/oleObject#.bin",
+ XSLFObjectData::new, XSLFObjectData::new
);
public static final XSLFRelation FONT = new XSLFRelation(
- "application/x-fontdata",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",
- "/ppt/fonts/font#.fntdata",
- XSLFFontData.class
+ "application/x-fontdata",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",
+ "/ppt/fonts/font#.fntdata",
+ XSLFFontData::new, XSLFFontData::new
);
- private XSLFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+ private XSLFRelation(String type) {
+ this(type, null, null, null, null);
+ }
+
+ private XSLFRelation(String type, String rel, String defaultName) {
+ this(type, rel, defaultName, null, null);
+ }
+
+ private XSLFRelation(String type, String rel, String defaultName,
+ NoArgConstructor noArgConstructor,
+ PackagePartConstructor packagePartConstructor) {
+ super(type, rel, defaultName, noArgConstructor, packagePartConstructor, null);
_table.put(rel, this);
}
public XSLFTableStyles(PackagePart part) throws IOException, XmlException {
super(part);
- InputStream is = getPackagePart().getInputStream();
- TblStyleLstDocument styleDoc = TblStyleLstDocument.Factory.parse(is);
- is.close();
+ TblStyleLstDocument styleDoc;
+ try (InputStream is = getPackagePart().getInputStream()) {
+ styleDoc = TblStyleLstDocument.Factory.parse(is);
+ }
_tblStyleLst = styleDoc.getTblStyleLst();
List<CTTableStyle> tblStyles = _tblStyleLst.getTblStyleList();
_styles = new ArrayList<>(tblStyles.size());
_styles.add(new XSLFTableStyle(c));
}
}
-
+
public CTTableStyleList getXmlObject(){
return _tblStyleLst;
}
package org.apache.poi.xssf.binary;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.util.Internal;
static final XSSFBRelation SHARED_STRINGS_BINARY = new XSSFBRelation(
"application/vnd.ms-excel.sharedStrings",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
- "/xl/sharedStrings.bin",
- null
+ "/xl/sharedStrings.bin"
);
public static final XSSFBRelation STYLES_BINARY = new XSSFBRelation(
"application/vnd.ms-excel.styles",
PackageRelationshipTypes.STYLE_PART,
- "/xl/styles.bin",
- null
+ "/xl/styles.bin"
);
- private XSSFBRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+ private XSSFBRelation(String type, String rel, String defaultName) {
+ super(type, rel, defaultName);
}
}
package org.apache.poi.xssf.usermodel;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
* Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
*/
public class XSSFFactory extends POIXMLFactory {
- protected XSSFFactory() {
- }
-
private static final XSSFFactory inst = new XSSFFactory();
public static XSSFFactory getInstance(){
return inst;
}
+ protected XSSFFactory() {}
+
/**
* @since POI 3.14-Beta1
*/
protected POIXMLRelation getDescriptor(String relationshipType) {
return XSSFRelation.getInstance(relationshipType);
}
-
- /**
- * @since POI 3.14-Beta1
- */
- @Override
- protected POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
- Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(classes);
- return constructor.newInstance(values);
- }
}
import java.util.Map;
import org.apache.poi.ooxml.POIXMLDocument;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.xssf.model.CalculationChain;
/**
* Defines namespaces, content types and normal file names / naming
- * patterns, for the well-known XSSF format parts.
+ * patterns, for the well-known XSSF format parts.
*/
public final class XSSFRelation extends POIXMLRelation {
public static final XSSFRelation WORKBOOK = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/workbook",
- "/xl/workbook.xml",
- null
+ "/xl/workbook.xml"
);
+
public static final XSSFRelation MACROS_WORKBOOK = new XSSFRelation(
"application/vnd.ms-excel.sheet.macroEnabled.main+xml",
PackageRelationshipTypes.CORE_DOCUMENT,
- "/xl/workbook.xml",
- null
+ "/xl/workbook.xml"
);
+
public static final XSSFRelation TEMPLATE_WORKBOOK = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml",
PackageRelationshipTypes.CORE_DOCUMENT,
- "/xl/workbook.xml",
- null
+ "/xl/workbook.xml"
);
public static final XSSFRelation MACRO_TEMPLATE_WORKBOOK = new XSSFRelation(
"application/vnd.ms-excel.template.macroEnabled.main+xml",
PackageRelationshipTypes.CORE_DOCUMENT,
- "/xl/workbook.xml",
- null
+ "/xl/workbook.xml"
);
+
public static final XSSFRelation MACRO_ADDIN_WORKBOOK = new XSSFRelation(
"application/vnd.ms-excel.addin.macroEnabled.main+xml",
PackageRelationshipTypes.CORE_DOCUMENT,
- "/xl/workbook.xml",
- null
+ "/xl/workbook.xml"
);
public static final XSSFRelation XLSB_BINARY_WORKBOOK = new XSSFRelation(
- "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
- PackageRelationshipTypes.CORE_DOCUMENT,
- "/xl/workbook.bin",
- null
- );
+ "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
+ PackageRelationshipTypes.CORE_DOCUMENT,
+ "/xl/workbook.bin"
+ );
public static final XSSFRelation WORKSHEET = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
"/xl/worksheets/sheet#.xml",
- XSSFSheet.class
+ XSSFSheet::new, XSSFSheet::new
);
public static final XSSFRelation CHARTSHEET = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
"/xl/chartsheets/sheet#.xml",
- XSSFChartSheet.class
+ null, XSSFChartSheet::new
);
public static final XSSFRelation SHARED_STRINGS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
"/xl/sharedStrings.xml",
- SharedStringsTable.class
+ SharedStringsTable::new, SharedStringsTable::new
);
public static final XSSFRelation STYLES = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
PackageRelationshipTypes.STYLE_PART,
"/xl/styles.xml",
- StylesTable.class
+ StylesTable::new, StylesTable::new
);
public static final XSSFRelation DRAWINGS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.drawing+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
"/xl/drawings/drawing#.xml",
- XSSFDrawing.class
+ XSSFDrawing::new, XSSFDrawing::new
);
public static final XSSFRelation VML_DRAWINGS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.vmlDrawing",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
"/xl/drawings/vmlDrawing#.vml",
- XSSFVMLDrawing.class
+ XSSFVMLDrawing::new, XSSFVMLDrawing::new
);
public static final XSSFRelation CHART = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
"/xl/charts/chart#.xml",
- XSSFChart.class
+ XSSFChart::new, XSSFChart::new
);
public static final XSSFRelation CUSTOM_XML_MAPPINGS = new XSSFRelation(
"application/xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/xmlMaps",
"/xl/xmlMaps.xml",
- MapInfo.class
+ MapInfo::new, MapInfo::new
);
public static final XSSFRelation SINGLE_XML_CELLS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells",
"/xl/tables/tableSingleCells#.xml",
- SingleXmlCells.class
+ SingleXmlCells::new, SingleXmlCells::new
);
public static final XSSFRelation TABLE = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",
"/xl/tables/table#.xml",
- XSSFTable.class
+ XSSFTable::new, XSSFTable::new
);
public static final XSSFRelation IMAGES = new XSSFRelation(
null,
PackageRelationshipTypes.IMAGE_PART,
null,
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_EMF = new XSSFRelation(
"image/x-emf",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.emf",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_WMF = new XSSFRelation(
"image/x-wmf",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.wmf",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_PICT = new XSSFRelation(
"image/pict",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.pict",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_JPEG = new XSSFRelation(
"image/jpeg",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.jpeg",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_PNG = new XSSFRelation(
"image/png",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.png",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_DIB = new XSSFRelation(
"image/dib",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.dib",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_GIF = new XSSFRelation(
"image/gif",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.gif",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_TIFF = new XSSFRelation(
"image/tiff",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.tiff",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_EPS = new XSSFRelation(
"image/x-eps",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.eps",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_BMP = new XSSFRelation(
"image/x-ms-bmp",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.bmp",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation IMAGE_WPG = new XSSFRelation(
"image/x-wpg",
PackageRelationshipTypes.IMAGE_PART,
"/xl/media/image#.wpg",
- XSSFPictureData.class
+ XSSFPictureData::new, XSSFPictureData::new
);
public static final XSSFRelation SHEET_COMMENTS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
"/xl/comments#.xml",
- CommentsTable.class
+ CommentsTable::new, CommentsTable::new
);
public static final XSSFRelation SHEET_HYPERLINKS = new XSSFRelation(
null,
PackageRelationshipTypes.HYPERLINK_PART,
- null,
null
);
public static final XSSFRelation OLEEMBEDDINGS = new XSSFRelation(
null,
POIXMLDocument.OLE_OBJECT_REL_TYPE,
- null,
null
);
public static final XSSFRelation PACKEMBEDDINGS = new XSSFRelation(
null,
POIXMLDocument.PACK_OBJECT_REL_TYPE,
- null,
null
);
"application/vnd.ms-office.vbaProject",
"http://schemas.microsoft.com/office/2006/relationships/vbaProject",
"/xl/vbaProject.bin",
- XSSFVBAPart.class
+ XSSFVBAPart::new, XSSFVBAPart::new
);
public static final XSSFRelation ACTIVEX_CONTROLS = new XSSFRelation(
"application/vnd.ms-office.activeX+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control",
- "/xl/activeX/activeX#.xml",
- null
+ "/xl/activeX/activeX#.xml"
);
public static final XSSFRelation ACTIVEX_BINS = new XSSFRelation(
"application/vnd.ms-office.activeX",
"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary",
- "/xl/activeX/activeX#.bin",
- null
+ "/xl/activeX/activeX#.bin"
);
public static final XSSFRelation MACRO_SHEET_BIN = new XSSFRelation(
- null,//TODO: figure out what this should be?
- "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet",
- "/xl/macroSheets/sheet#.bin",
- null
+ null,//TODO: figure out what this should be?
+ "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet",
+ "/xl/macroSheets/sheet#.bin"
);
public static final XSSFRelation INTL_MACRO_SHEET_BIN = new XSSFRelation(
- null,//TODO: figure out what this should be?
- "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet",
- "/xl/macroSheets/sheet#.bin",
- null
+ null,//TODO: figure out what this should be?
+ "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet",
+ "/xl/macroSheets/sheet#.bin"
);
public static final XSSFRelation DIALOG_SHEET_BIN = new XSSFRelation(
- null,//TODO: figure out what this should be?
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",
- "/xl/dialogSheets/sheet#.bin",
- null
+ null,//TODO: figure out what this should be?
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",
+ "/xl/dialogSheets/sheet#.bin"
);
public static final XSSFRelation THEME = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.theme+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
"/xl/theme/theme#.xml",
- ThemesTable.class
+ ThemesTable::new, ThemesTable::new
);
public static final XSSFRelation CALC_CHAIN = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",
"/xl/calcChain.xml",
- CalculationChain.class
+ CalculationChain::new, CalculationChain::new
);
public static final XSSFRelation EXTERNAL_LINKS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",
"/xl/externalLinks/externalLink#.xmll",
- ExternalLinksTable.class
+ ExternalLinksTable::new, ExternalLinksTable::new
);
public static final XSSFRelation PRINTER_SETTINGS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings",
- "/xl/printerSettings/printerSettings#.bin",
- null
+ "/xl/printerSettings/printerSettings#.bin"
);
public static final XSSFRelation PIVOT_TABLE = new XSSFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
- "/xl/pivotTables/pivotTable#.xml",
- XSSFPivotTable.class
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
+ "/xl/pivotTables/pivotTable#.xml",
+ XSSFPivotTable::new, XSSFPivotTable::new
);
public static final XSSFRelation PIVOT_CACHE_DEFINITION = new XSSFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
- "/xl/pivotCache/pivotCacheDefinition#.xml",
- XSSFPivotCacheDefinition.class
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
+ "/xl/pivotCache/pivotCacheDefinition#.xml",
+ XSSFPivotCacheDefinition::new, XSSFPivotCacheDefinition::new
);
public static final XSSFRelation PIVOT_CACHE_RECORDS = new XSSFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
- "/xl/pivotCache/pivotCacheRecords#.xml",
- XSSFPivotCacheRecords.class
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
+ "/xl/pivotCache/pivotCacheRecords#.xml",
+ XSSFPivotCacheRecords::new, XSSFPivotCacheRecords::new
);
public static final XSSFRelation CTRL_PROP_RECORDS = new XSSFRelation(
- null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp",
- "/xl/ctrlProps/ctrlProp#.xml",
- null
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp",
+ "/xl/ctrlProps/ctrlProp#.xml"
);
public static final XSSFRelation CUSTOM_PROPERTIES = new XSSFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty",
- "/xl/customProperty#.bin",
- null
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty",
+ "/xl/customProperty#.bin"
);
public static final String NS_SPREADSHEETML = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
public static final String NS_DRAWINGML = "http://schemas.openxmlformats.org/drawingml/2006/main";
public static final String NS_CHART = "http://schemas.openxmlformats.org/drawingml/2006/chart";
- private XSSFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+
+ private XSSFRelation(String type, String rel, String defaultName) {
+ this(type,rel, defaultName, null, null);
+ }
+
+ private XSSFRelation(String type, String rel, String defaultName,
+ NoArgConstructor noArgConstructor,
+ PackagePartConstructor packagePartConstructor) {
+ super(type, rel, defaultName, noArgConstructor, packagePartConstructor, null);
_table.put(rel, this);
}
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlException;
* Construct XWPFEndnotes from a package part
*
* @param part the package part holding the data of the footnotes,
- *
+ *
* @since POI 3.14-Beta1
*/
- public XWPFEndnotes(PackagePart part) throws IOException, OpenXML4JException {
+ public XWPFEndnotes(PackagePart part) {
super(part);
}
-
+
/**
* Set the end notes for this part.
*
}
/**
- * Create a new end note and add it to the document.
+ * Create a new end note and add it to the document.
*
* @return New XWPFEndnote
* @since 4.0.0
*/
public XWPFEndnote createEndnote() {
- CTFtnEdn newNote = CTFtnEdn.Factory.newInstance();
+ CTFtnEdn newNote = CTFtnEdn.Factory.newInstance();
newNote.setType(STFtnEdn.NORMAL);
XWPFEndnote footnote = addEndnote(newNote);
footnote.getCTFtnEdn().setId(getIdManager().nextId());
return footnote;
-
+
}
/**
* Remove the specified footnote if present.
*
- * @param pos
+ * @param pos
* @return True if the footnote was removed.
* @since 4.0.0
*/
} catch (XmlException e) {
throw new POIXMLException();
}
-
+
for (CTFtnEdn note : ctEndnotes.getEndnoteList()) {
listFootnote.add(new XWPFEndnote(note, this));
}
}
}
-
+
}
package org.apache.poi.xwpf.usermodel;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
* Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
*/
public final class XWPFFactory extends POIXMLFactory {
- private XWPFFactory() {
-
- }
-
private static final XWPFFactory inst = new XWPFFactory();
public static XWPFFactory getInstance() {
return inst;
}
+ private XWPFFactory() {}
+
/**
* @since POI 3.14-Beta1
*/
protected POIXMLRelation getDescriptor(String relationshipType) {
return XWPFRelation.getInstance(relationshipType);
}
-
- /**
- * @since POI 3.14-Beta1
- */
- @Override
- protected POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
- Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(classes);
- return constructor.newInstance(values);
- }
}
\ No newline at end of file
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlException;
* Construct XWPFFootnotes from a package part
*
* @param part the package part holding the data of the footnotes,
- *
+ *
* @since POI 3.14-Beta1
*/
- public XWPFFootnotes(PackagePart part) throws IOException, OpenXML4JException {
+ public XWPFFootnotes(PackagePart part) {
super(part);
}
-
+
/**
* Construct XWPFFootnotes from scratch for a new document.
*/
}
/**
- * Create a new footnote and add it to the document.
+ * Create a new footnote and add it to the document.
*
* @return New {@link XWPFFootnote}
* @since 4.0.0
*/
public XWPFFootnote createFootnote() {
- CTFtnEdn newNote = CTFtnEdn.Factory.newInstance();
+ CTFtnEdn newNote = CTFtnEdn.Factory.newInstance();
newNote.setType(STFtnEdn.NORMAL);
XWPFFootnote footnote = addFootnote(newNote);
footnote.getCTFtnEdn().setId(getIdManager().nextId());
return footnote;
-
+
}
/**
} catch (XmlException e) {
throw new POIXMLException();
}
-
+
for (CTFtnEdn note : ctFootnotes.getFootnoteList()) {
listFootnote.add(new XWPFFootnote(note, this));
}
}
return resultList;
}
-
-
+
+
}
/**
* @since by POI 3.14-Beta1
*/
- public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) throws IOException {
+ public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) {
super(parent, part);
this.document = (XWPFDocument) getParent();
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
*
* @since POI 3.14-Beta1
*/
- public XWPFNumbering(PackagePart part) throws IOException, OpenXML4JException {
+ public XWPFNumbering(PackagePart part) {
super(part);
isNew = true;
}
import java.util.Map;
import org.apache.poi.ooxml.POIXMLDocument;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public static final XWPFRelation DOCUMENT = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
PackageRelationshipTypes.CORE_DOCUMENT,
- "/word/document.xml",
- null
+ "/word/document.xml"
);
+
public static final XWPFRelation TEMPLATE = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml",
- PackageRelationshipTypes.CORE_DOCUMENT,
- "/word/document.xml",
- null
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml",
+ PackageRelationshipTypes.CORE_DOCUMENT,
+ "/word/document.xml"
);
+
public static final XWPFRelation MACRO_DOCUMENT = new XWPFRelation(
- "application/vnd.ms-word.document.macroEnabled.main+xml",
- PackageRelationshipTypes.CORE_DOCUMENT,
- "/word/document.xml",
- null
+ "application/vnd.ms-word.document.macroEnabled.main+xml",
+ PackageRelationshipTypes.CORE_DOCUMENT,
+ "/word/document.xml"
);
+
public static final XWPFRelation MACRO_TEMPLATE_DOCUMENT = new XWPFRelation(
- "application/vnd.ms-word.template.macroEnabledTemplate.main+xml",
- PackageRelationshipTypes.CORE_DOCUMENT,
- "/word/document.xml",
- null
+ "application/vnd.ms-word.template.macroEnabledTemplate.main+xml",
+ PackageRelationshipTypes.CORE_DOCUMENT,
+ "/word/document.xml"
);
+
public static final XWPFRelation GLOSSARY_DOCUMENT = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument",
- "/word/glossary/document.xml",
- null
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument",
+ "/word/glossary/document.xml"
);
+
public static final XWPFRelation NUMBERING = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
- "/word/numbering.xml",
- XWPFNumbering.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
+ "/word/numbering.xml",
+ XWPFNumbering::new, XWPFNumbering::new
);
+
public static final XWPFRelation FONT_TABLE = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
- "/word/fontTable.xml",
- null
+ "/word/fontTable.xml"
);
+
public static final XWPFRelation SETTINGS = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
- "/word/settings.xml",
- XWPFSettings.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
+ "/word/settings.xml",
+ XWPFSettings::new, XWPFSettings::new
);
+
public static final XWPFRelation STYLES = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
- "/word/styles.xml",
- XWPFStyles.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
+ "/word/styles.xml",
+ XWPFStyles::new, XWPFStyles::new
);
+
public static final XWPFRelation WEB_SETTINGS = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
- "/word/webSettings.xml",
- null
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
+ "/word/webSettings.xml"
);
+
public static final XWPFRelation HEADER = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
- "/word/header#.xml",
- XWPFHeader.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
+ "/word/header#.xml",
+ XWPFHeader::new, XWPFHeader::new
);
+
public static final XWPFRelation FOOTER = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
- "/word/footer#.xml",
- XWPFFooter.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
+ "/word/footer#.xml",
+ XWPFFooter::new, XWPFFooter::new
);
+
public static final XWPFRelation THEME = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.theme+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
- "/word/theme/theme#.xml",
- null
+ "application/vnd.openxmlformats-officedocument.theme+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
+ "/word/theme/theme#.xml"
);
public static final XWPFRelation WORKBOOK = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- POIXMLDocument.PACK_OBJECT_REL_TYPE,
- "/word/embeddings/Microsoft_Excel_Worksheet#.xlsx",
- XSSFWorkbook.class
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ POIXMLDocument.PACK_OBJECT_REL_TYPE,
+ "/word/embeddings/Microsoft_Excel_Worksheet#.xlsx",
+ XSSFWorkbook::new, (PackagePartConstructor)XSSFWorkbook::new
);
public static final XWPFRelation CHART = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
- "/word/charts/chart#.xml",
- XWPFChart.class
+ "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
+ "/word/charts/chart#.xml",
+ XWPFChart::new, XWPFChart::new
);
public static final XWPFRelation HYPERLINK = new XWPFRelation(
- null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
- null,
- null
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
+ null
);
public static final XWPFRelation COMMENT = new XWPFRelation(
- null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
- null,
- null
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
+ null
);
public static final XWPFRelation FOOTNOTE = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
- "/word/footnotes.xml",
- XWPFFootnotes.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
+ "/word/footnotes.xml",
+ XWPFFootnotes::new, XWPFFootnotes::new
);
public static final XWPFRelation ENDNOTE = new XWPFRelation(
- "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
- "/word/endnotes.xml",
- XWPFEndnotes.class
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
+ "/word/endnotes.xml",
+ XWPFEndnotes::new, XWPFEndnotes::new
);
/**
* Supported image formats
*/
public static final XWPFRelation IMAGE_EMF = new XWPFRelation(
- "image/x-emf",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.emf",
- XWPFPictureData.class
+ "image/x-emf",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.emf",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_WMF = new XWPFRelation(
- "image/x-wmf",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.wmf",
- XWPFPictureData.class
+ "image/x-wmf",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.wmf",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_PICT = new XWPFRelation(
- "image/pict",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.pict",
- XWPFPictureData.class
+ "image/pict",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.pict",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_JPEG = new XWPFRelation(
- "image/jpeg",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.jpeg",
- XWPFPictureData.class
+ "image/jpeg",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.jpeg",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_PNG = new XWPFRelation(
- "image/png",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.png",
- XWPFPictureData.class
+ "image/png",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.png",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_DIB = new XWPFRelation(
- "image/dib",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.dib",
- XWPFPictureData.class
+ "image/dib",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.dib",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_GIF = new XWPFRelation(
- "image/gif",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.gif",
- XWPFPictureData.class
+ "image/gif",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.gif",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_TIFF = new XWPFRelation(
- "image/tiff",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.tiff",
- XWPFPictureData.class
+ "image/tiff",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.tiff",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_EPS = new XWPFRelation(
- "image/x-eps",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.eps",
- XWPFPictureData.class
+ "image/x-eps",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.eps",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_BMP = new XWPFRelation(
- "image/x-ms-bmp",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.bmp",
- XWPFPictureData.class
+ "image/x-ms-bmp",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.bmp",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGE_WPG = new XWPFRelation(
- "image/x-wpg",
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- "/word/media/image#.wpg",
- XWPFPictureData.class
+ "image/x-wpg",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ "/word/media/image#.wpg",
+ XWPFPictureData::new, XWPFPictureData::new
);
public static final XWPFRelation IMAGES = new XWPFRelation(
- null,
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
- null,
- XWPFPictureData.class
+ null,
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+ null,
+ XWPFPictureData::new, XWPFPictureData::new
);
- private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
- super(type, rel, defaultName, cls);
+ private XWPFRelation(String type, String rel, String defaultName) {
+ super(type, rel, defaultName);
+ _table.put(rel, this);
+ }
+
+ private XWPFRelation(String type, String rel, String defaultName,
+ NoArgConstructor noArgConstructor,
+ PackagePartConstructor packagePartConstructor) {
+ super(type, rel, defaultName, noArgConstructor, packagePartConstructor, null);
+ _table.put(rel, this);
+ }
+
+ private XWPFRelation(String type, String rel, String defaultName,
+ NoArgConstructor noArgConstructor,
+ ParentPartConstructor parentPartConstructor) {
+ super(type, rel, defaultName, noArgConstructor, null, parentPartConstructor);
_table.put(rel, this);
}
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
* Construct XWPFStyles from a package part
*
* @param part the package part holding the data of the styles,
- *
+ *
* @since POI 3.14-Beta1
*/
- public XWPFStyles(PackagePart part) throws IOException, OpenXML4JException {
+ public XWPFStyles(PackagePart part) {
super(part);
}
-
+
/**
* Construct XWPFStyles from scratch for a new document.
*/
import java.io.IOException;
import java.io.InputStream;
import java.lang.Thread.UncaughtExceptionHandler;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart;
+import org.apache.poi.ooxml.util.PackageHelper;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.NullOutputStream;
-import org.apache.poi.ooxml.util.PackageHelper;
import org.apache.poi.util.TempFile;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xssf.usermodel.XSSFRelation;
public OPCParser(OPCPackage pkg) {
super(pkg);
}
-
+
public OPCParser(OPCPackage pkg, String coreDocumentRel) {
super(pkg, coreDocumentRel);
}
protected POIXMLRelation getDescriptor(String relationshipType) {
return null;
}
-
- /**
- * @since POI 3.14-Beta1
- */
- @Override
- protected POIXMLDocumentPart createDocumentPart
- (Class<? extends POIXMLDocumentPart> cls, Class<?>[] classes, Object[] values)
- throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
- return null;
- }
}
private static void traverse(POIXMLDocument doc) throws IOException{
traverse(p, context);
}
}
-
+
/**
* Recursively traverse a OOXML document and assert that same logical parts have the same physical instances
*/
private static void traverse(RelationPart rp, HashMap<String,POIXMLDocumentPart> context) throws IOException{
POIXMLDocumentPart dp = rp.getDocumentPart();
assertEquals(rp.getRelationship().getTargetURI().toString(), dp.getPackagePart().getPartName().getName());
-
+
context.put(dp.getPackagePart().getPartName().getName(), dp);
for(RelationPart p : dp.getRelationParts()){
assertNotNull(p.getRelationship().toString());
-
+
String uri = p.getDocumentPart().getPackagePart().getPartName().getURI().toString();
assertEquals(uri, p.getRelationship().getTargetURI().toString());
if (!context.containsKey(uri)) {
FileOutputStream out = new FileOutputStream(tmp);
doc.write(out);
out.close();
-
+
// Should not be able to write to an output stream that has been closed
try {
doc.write(out);
throw e;
}
}
-
+
// Should be able to close a document multiple times, though subsequent closes will have no effect.
doc.close();
try {
doc.parse(new TestFactory());
traverse(doc);
-
+
assertEquals(pkg1.getRelationships().size(), pkg2.getRelationships().size());
-
+
ArrayList<PackagePart> l1 = pkg1.getParts();
ArrayList<PackagePart> l2 = pkg2.getParts();
-
+
assertEquals(l1.size(), l2.size());
for (int i=0; i < l1.size(); i++){
PackagePart p1 = l1.get(i);
PackagePart p2 = l2.get(i);
-
+
assertEquals(p1.getContentType(), p2.getContentType());
assertEquals(p1.hasRelationships(), p2.hasRelationships());
if(p1.hasRelationships()){
}
}
}
-
+
@Test
public void testGetNextPartNumber() throws Exception {
POIDataSamples pds = POIDataSamples.getDocumentInstance();
part.onDocumentCreate();
//part.getTargetPart(null);
}
-
+
@Test
public void testVSDX() throws Exception {
POIDataSamples pds = POIDataSamples.getDiagramInstance();
@SuppressWarnings("resource")
OPCPackage open = PackageHelper.open(pds.openResourceAsStream("test.vsdx"));
POIXMLDocument part = new OPCParser(open, PackageRelationshipTypes.VISIO_CORE_DOCUMENT);
-
+
assertNotNull(part);
assertEquals(0, part.getRelationCounter());
part.close();
}
-
+
@Test
public void testVSDXPart() throws IOException {
POIDataSamples pds = POIDataSamples.getDiagramInstance();
OPCPackage open = PackageHelper.open(pds.openResourceAsStream("test.vsdx"));
-
+
POIXMLDocumentPart part = new POIXMLDocumentPart(open, PackageRelationshipTypes.VISIO_CORE_DOCUMENT);
-
+
assertNotNull(part);
assertEquals(0, part.getRelationCounter());
-
+
open.close();
}
-
+
@Test(expected=POIXMLException.class)
public void testInvalidCoreRel() throws IOException {
POIDataSamples pds = POIDataSamples.getDiagramInstance();
ClassLoader cl = getClass().getClassLoader();
UncaughtHandler uh = new UncaughtHandler();
-
+
// check schema type loading and check if we could run in an OOM
Thread[] ta = new Thread[30];
for (int j=0; j<10; j++) {
private static class UncaughtHandler implements UncaughtExceptionHandler {
Throwable e;
-
+
public synchronized void uncaughtException(Thread t, Throwable e) {
this.e = e;
-
+
}
-
+
public synchronized boolean hasException() {
return e != null;
}