Specifies the location where the X.509 certificate that is used in signing is stored.
@author Julien Chable
The certificate is embedded in its own PackagePart.
The certificate is embedded in the SignaturePart that is created for the signature being added.
The certificate in not embedded in the package.
Storage class for configuration storage parameters.
TODO xml syntax checking is no longer done with DOM4j parser -> remove the schema or do it ?
@author CDubettier, Julen Chable
@version 1.0
Open Packaging Convention content types (see Annex F : Standard Namespaces
and Content Types).
@author CDubettier define some constants, Julien Chable
Core Properties part.
Digital Signature Certificate part.
Digital Signature Origin part.
Digital Signature XML Signature part.
Relationships part.
Custom XML part.
Plain old xml. Note - OOXML uses application/xml, and not text/xml!
TIFF image format.
@see
http://partners.adobe.com/public/developer/tiff/index.html#spec
Pict image format.
@see
http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html
XML file.
Specifies the encryption option for parts in a Package.
@author Julien Chable
@version 0.1
No encryption.
Type in Type/Subtype.
Subtype
Parameters
Media type compiled pattern for parameters.
Media type compiled pattern, with parameters.
Pattern to match on just the parameters part, to work
around the Java Regexp group capture behaviour
Constructor. Check the input with the RFC 2616 grammar.
@param contentType
The content type to store.
@throws InvalidFormatException
If the specified content type is not valid with RFC 2616.
Get the subtype.
@return The subtype of this content type.
Get the type.
@return The type of this content type.
Does this content type have any parameters associated with it?
Return the parameter keys
Gets the value associated to the specified key.
@param key
The key of the key/value pair.
@return The value associated to the specified key.
Manage package content types ([Content_Types].xml part).
@author Julien Chable
@version 1.0
Content type part name.
Content type namespace
Reference to the package using this content type manager.
Override content type tree.
Constructor. Parses the content of the specified input stream.
@param in
If different of null then the content types part is
retrieve and parse.
@throws InvalidFormatException
If the content types part content is not valid.
Build association extention-> content type (will be stored in
[Content_Types].xml) for example ContentType="image/png" Extension="png"
[M2.8]: When adding a new part to a package, the package implementer
shall ensure that a content type for that part is specified in the
Content Types stream; the package implementer shall perform the steps
described in §9.1.2.3:
1. Get the extension from the part name by taking the substring to the
right of the rightmost occurrence of the dot character (.) from the
rightmost segment.
2. If a part name has no extension, a corresponding Override element
shall be added to the Content Types stream.
3. Compare the resulting extension with the values specified for the
Extension attributes of the Default elements in the Content Types stream.
The comparison shall be case-insensitive ASCII.
4. If there is a Default element with a matching Extension attribute,
then the content type of the new part shall be compared with the value of
the ContentType attribute. The comparison might be case-sensitive and
include every character regardless of the role it plays in the
content-type grammar of RFC 2616, or it might follow the grammar of RFC
2616.
a. If the content types match, no further action is required.
b. If the content types do not match, a new Override element shall be
added to the Content Types stream. .
5. If there is no Default element with a matching Extension attribute, a
new Default element or Override element shall be added to the Content
Types stream.
Add an override content type for a specific part.
@param partName
Name of the part.
@param contentType
Content type of the part.
Add a content type associated with the specified extension.
@param extension
The part name extension to bind to a content type.
@param contentType
The content type associated with the specified extension.
Delete a content type based on the specified part name. If the specified
part name is register with an override content type, then this content
type is remove, else the content type is remove in the default content
type list if it exists and if no part is associated with it yet.
Check rule M2.4: The package implementer shall require that the Content
Types stream contain one of the following for every part in the package:
One matching Default element One matching Override element Both a
matching Default element and a matching Override element, in which case
the Override element takes precedence.
@param partName
The part URI associated with the override content type to
delete.
@exception InvalidOperationException
Throws if
Check if the specified content type is already register.
@param contentType
The content type to check.
@return true
if the specified content type is already
register, then false
.
Get the content type for the specified part, if any.
Rule [M2.9]: To get the content type of a part, the package implementer
shall perform the steps described in §9.1.2.4:
1. Compare the part name with the values specified for the PartName
attribute of the Override elements. The comparison shall be
case-insensitive ASCII.
2. If there is an Override element with a matching PartName attribute,
return the value of its ContentType attribute. No further action is
required.
3. If there is no Override element with a matching PartName attribute,
then a. Get the extension from the part name by taking the substring to
the right of the rightmost occurrence of the dot character (.) from the
rightmost segment. b. Check the Default elements of the Content Types
stream, comparing the extension with the value of the Extension
attribute. The comparison shall be case-insensitive ASCII.
4. If there is a Default element with a matching Extension attribute,
return the value of its ContentType attribute. No further action is
required.
5. If neither Override nor Default elements with matching attributes are
found for the specified part name, the implementation shall not map this
part name to a part.
@param partName
The URI part to check.
@return The content type associated with the URI (in case of an override
content type) or the extension (in case of default content type),
else null
.
@exception OpenXml4NetRuntimeException
Throws if the content type manager is not able to find the
content from an existing part.
Clear all content types.
Clear all override content types.
Parse the content types part.
@throws InvalidFormatException
Throws if the content type doesn't exist or the XML format is
invalid.
Save the contents type part.
@param outStream
The output stream use to save the XML content of the content
types part.
@return true if the operation success, else false.
Use to Append specific type XML elements, use by the save() method.
@param root
XML parent element use to Append this override type element.
@param entry
The values to Append.
@see #save(java.io.OutputStream)
Use to Append default types XML elements, use by the save() metid.
@param root
XML parent element use to Append this default type element.
@param entry
The values to Append.
@see #save(java.io.OutputStream)
Specific implementation of the save method. Call by the save() method,
call before exiting.
@param out
The output stream use to write the content type XML.
Provide useful method to manage file.
@author Julien Chable
@version 0.1
Get the directory part of the specified file path.
@param f
File to process.
@return The directory path from the specified
Copy a file.
@param in
The source file.
@param out
The target location.
@throws IOException
If an I/O error occur.
Get file name from the specified File object.
Default marshaller that specified that the part is responsible to marshall its content.
@author Julien Chable
@version 1.0
@see PartMarshaller
Save part in the output stream by using the save() method of the part.
@throws OpenXml4NetException
If any error occur.
Package properties marshaller.
@author CDubet, Julien Chable
Marshall package core properties to an XML document. Always return
true
.
Add category property element if needed.
Add content status property element if needed.
Add content type property element if needed.
Add created property element if needed.
Add creator property element if needed.
Add description property element if needed.
Add identifier property element if needed.
Add keywords property element if needed.
Add language property element if needed.
Add 'last modified by' property if needed.
Add 'last printed' property if needed.
Add modified property element if needed.
Add revision property if needed.
Add subject property if needed.
Add title property if needed.
Package core properties marshaller specialized for zipped package.
@author Julien Chable
Zip part marshaller. This marshaller is use to save any part in a zip stream.
@author Julien Chable
Save the specified part.
@throws OpenXml4NetException
Throws if an internal exception is thrown.
Save relationships into the part.
@param rels
The relationships collection to marshall.
@param relPartName
Part name of the relationship part to marshall.
@param zos
Zip output stream in which to save the XML content of the
relationships serialization.
Storage for the part data.
Constructor.
@param pack
The owner package.
@param partName
The part name.
@param contentType
The content type.
@throws InvalidFormatException
If the specified URI is not OPC compliant.
Constructor.
@param pack
The owner package.
@param partName
The part name.
@param contentType
The content type.
@param loadRelationships
Specify if the relationships will be loaded.
@throws InvalidFormatException
If the specified URI is not OPC compliant.
Close this stream and flush the content.
@see #flush()
Flush this output stream. This method is called by the close() method.
Warning : don't call this method for output consistency.
@see #close()
Represents the core properties part of a package.
@author Julien Chable
@version 1.0
Constructor.
@param pack
Container package.
@param partName
Name of this part.
@throws InvalidFormatException
Throws if the content is invalid.
A categorization of the content of this package.
[Example: Example values for this property might include: Resume, Letter,
Financial Forecast, Proposal, Technical Presentation, and so on. This
value might be used by an application's user interface to facilitate
navigation of a large Set of documents. end example]
The status of the content.
[Example: Values might include "Draft", "Reviewed", and "Final". end
example]
The type of content represented, generally defined by a specific use and
intended audience.
[Example: Values might include "Whitepaper", "Security Bulletin", and
"Exam". end example] [Note: This property is distinct from MIME content
types as defined in RFC 2616. end note]
Date of creation of the resource.
An entity primarily responsible for making the content of the resource.
An explanation of the content of the resource.
[Example: Values might include an abstract, table of contents, reference
to a graphical representation of content, and a free-text account of the
content. end example]
An unambiguous reference to the resource within a given context.
A delimited Set of keywords to support searching and indexing. This is
typically a list of terms that are not available elsewhere in the
properties.
The language of the intellectual content of the resource.
[Note: IETF RFC 3066 provides guidance on encoding to represent
languages. end note]
The user who performed the last modification. The identification is
environment-specific.
[Example: A name, email address, or employee ID. end example] It is
recommended that this value be as concise as possible.
The date and time of the last printing.
Date on which the resource was changed.
The revision number.
[Example: This value might indicate the number of saves or revisions,
provided the application updates it after each revision. end example]
The topic of the content of the resource.
The name given to the resource.
The version number. This value is Set by the user or by the application.
Get the category property.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getCategoryProperty()
Get content status.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getContentStatusProperty()
Get content type.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getContentTypeProperty()
Get created date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getCreatedProperty()
Get created date formated into a String.
@return A string representation of the created date.
Get creator.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getCreatorProperty()
Get description.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getDescriptionProperty()
Get identifier.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getIdentifierProperty()
Get keywords.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getKeywordsProperty()
Get the language.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getLanguageProperty()
Get the author of last modifications.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getLastModifiedByProperty()
Get last printed date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getLastPrintedProperty()
Get last printed date formated into a String.
@return A string representation of the last printed date.
Get modified date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getModifiedProperty()
Get modified date formated into a String.
@return A string representation of the modified date.
Get revision.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getRevisionProperty()
Get subject.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getSubjectProperty()
Get title.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getTitleProperty()
Get version.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#getVersionProperty()
Set the category.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setCategoryProperty(java.lang.String)
Set the content status.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setContentStatusProperty(java.lang.String)
Set the content type.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setContentTypeProperty(java.lang.String)
Set the created date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setCreatedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set the created date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setCreatedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set the creator.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setCreatorProperty(java.lang.String)
Set the description.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setDescriptionProperty(java.lang.String)
Set identifier.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setIdentifierProperty(java.lang.String)
Set keywords.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setKeywordsProperty(java.lang.String)
Set language.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setLanguageProperty(java.lang.String)
Set last modifications author.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setLastModifiedByProperty(java.lang.String)
Set last printed date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setLastPrintedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set last printed date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setLastPrintedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set last modification date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setModifiedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set last modification date.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setModifiedProperty(org.apache.poi.OpenXml4Net.util.Nullable)
Set revision.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setRevisionProperty(java.lang.String)
Set subject.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setSubjectProperty(java.lang.String)
Set title.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setTitleProperty(java.lang.String)
Set version.
@see org.apache.poi.OpenXml4Net.opc.PackageProperties#setVersionProperty(java.lang.String)
Convert a strig value into a String
Convert a string value represented a date into a DateTime?.
@throws InvalidFormatException
Throws if the date format isnot valid.
Convert a DateTime? into a String.
@param d
The Date to convert.
@return The formated date or null.
@see java.util.SimpleDateFormat
Object implemented this interface are considered as part marshaller. A part
marshaller is responsible to marshall a part in order to be save in a
package.
@author Julien Chable
@version 0.1
Save the content of the package in the stream
@param part
Part to marshall.
@param out
The output stream into which the part will be marshall.
@return false if any marshall error occurs, else true
@throws OpenXml4NetException
Throws only if any other exceptions are thrown by inner
methods.
Object implemented this interface are considered as part unmarshaller. A part
unmarshaller is responsible to unmarshall a part in order to load it from a
package.
@author Julien Chable
@version 0.1
Save the content of the package in the stream
@param in
The input stream from which the part will be unmarshall.
@return The part freshly unmarshall from the input stream.
@throws OpenXml4NetException
Throws only if any other exceptions are thrown by inner
methods.
Package properties unmarshaller.
@author Julien Chable
@version 1.0
Context needed for the unmarshall process of a part. This class is immutable.
@author Julien Chable
@version 1.0
Constructor.
@param targetPackage
Container.
@param partName
Name of the part to unmarshall.
@return the container
@return the partName
@return the zipEntry
Zip implementation of the ContentTypeManager.
@author Julien Chable
@version 1.0
@see ContentTypeManager
Delegate constructor to the super constructor.
@param in
The input stream to parse to fill internal content type
collections.
@throws InvalidFormatException
If the content types part content is not valid.
Forward slash use to convert part name between OPC and zip item naming
conventions.
Buffer to read data from file. Use big buffer to improve performaces. the
InputStream class is reading only 8192 bytes per read call (default value
set by sun)
Prevent this class to be instancied.
Retrieve the zip entry of the core properties part.
@throws OpenXml4NetException
Throws if internal error occurs.
Retrieve the Zip entry of the content types part.
Convert a zip name into an OPC name by adding a leading forward slash to
the specified item name.
@param zipItemName
Zip item name to convert.
@return An OPC compliant name.
Convert an OPC item name into a zip item name by removing any leading
forward slash if it exist.
@param opcItemName
The OPC item name to convert.
@return A zip item name without any leading slashes.
Convert an OPC item name into a zip URI by removing any leading forward
slash if it exist.
@param opcItemName
The OPC item name to convert.
@return A zip URI without any leading slashes.
Verifies that the given stream starts with a Zip structure.
Warning - this will consume the first few bytes of the stream,
you should push-back or reset the stream after use!
Opens the specified stream as a secure zip
@param stream
The stream to open.
@return The zip stream freshly open.
Opens the specified file as a zip, or returns null if no such file exists
@param file
The file to open.
@return The zip archive freshly open.
Retrieve and open a zip file with the specified path.
@param path
The file path.
@return The zip archive freshly open.
Represents a container that can store multiple data objects.
@author Julien Chable, CDubet
@version 0.1
Logger.
Default package access.
Package access.
Package parts collection.
Package relationships.
Part marshallers by content type.
Default part marshaller.
Part unmarshallers by content type.
Core package properties.
Manage parts content types of this package.
Flag if a modification is done to the document.
File path of this package.
Output stream for writing this package.
Constructor.
@param access
Package access.
Initialize the package instance.
Open a package with read/write permission.
@param path
The document path.
@return A Package object, else null.
@throws InvalidFormatException
If the specified file doesn't exist, and a parsing error
occur.
Open a package with read/write permission.
@param file
The file to open.
@return A Package object, else null.
@throws InvalidFormatException
If the specified file doesn't exist, and a parsing error
occur.
Open an user provided {@link ZipEntrySource} with read-only permission.
This method can be used to stream data into POI.
Opposed to other open variants, the data is read as-is, e.g. there aren't
any zip-bomb protection put in place.
@param zipEntry the custom source
@return A Package object
@ if a parsing error occur.
Open a package.
@param path
The document path.
@param access
PackageBase access.
@return A PackageBase object, else null.
@throws InvalidFormatException
If the specified file doesn't exist, and a parsing error
occur.
Open a package.
@param file
The file to open.
@param access
PackageBase access.
@return A PackageBase object, else null.
@throws InvalidFormatException
If the specified file doesn't exist, and a parsing error
occur.
Open a package.
Note - uses quite a bit more memory than {@link #open(String)}, which
doesn't need to hold the whole zip file in memory, and can take advantage
of native methods
@param in
The InputStream to read the package from
@return A PackageBase object
Opens a package if it exists, else it Creates one.
@param file
The file to open or to Create.
@return A newly Created package if the specified file does not exist,
else the package extract from the file.
@throws InvalidFormatException
Throws if the specified file exist and is not valid.
Creates a new package.
@param file
Path of the document.
@return A newly Created PackageBase ready to use.
Configure the package.
@param pkg
Flush the package : save all.
@see #close()
Close the package and save its content.
@throws IOException
If an IO exception occur during the saving process.
Close the package WITHOUT saving its content. Reinitialize this package
and cancel all changes done to it.
Add a thumbnail to the package. This method is provided to make easier
the addition of a thumbnail in a package. You can do the same work by
using the traditionnal relationship and part mechanism.
path The full path to the image file.
Add a thumbnail to the package. This method is provided to make easier
the addition of a thumbnail in a package. You can do the same work by
using the traditionnal relationship and part mechanism.
Throws an exception if the package access mode is in read only mode
(PackageAccess.Read).
@throws InvalidOperationException
Throws if a writing operation is done on a read only package.
@see org.apache.poi.OpenXml4Net.opc.PackageAccess
Throws an exception if the package access mode is in write only mode
(PackageAccess.Write). This method is call when other methods need write
right.
@throws InvalidOperationException
Throws if a read operation is done on a write only package.
@see org.apache.poi.OpenXml4Net.opc.PackageAccess
Retrieves or Creates if none exists, core package property part.
@return The PackageProperties part of this package.
Retrieve a part identified by its name.
@param PartName
Part name of the part to retrieve.
@return The part with the specified name, else null
.
Retrieve parts by content type.
@param contentType
The content type criteria.
@return All part associated to the specified content type.
Retrieve parts by relationship type.
@param relationshipType
Relationship type.
@return All parts which are the target of a relationship with the
specified type, if the method can't retrieve relationships from
the package, then return null
.
Retrieve parts by name
@param namePattern
The pattern for matching the names
@return All parts associated to the specified content type, sorted
in alphanumerically by the part-name
Get the target part from the specified relationship.
@param partRel
The part relationship uses to retrieve the part.
Load the parts of the archive if it has not been done yet. The
relationships of each part are not loaded.
Note - Rule M4.1 states that there may only ever be one Core
Properties Part, but Office produced files will sometimes
have multiple! As Office ignores all but the first, we relax
Compliance with Rule M4.1, and ignore all others silently too.
@return All this package's parts.
Create and Add a part, with the specified name and content type, to the
package.
@param PartName
Part name.
@param contentType
Part content type.
@return The newly Created part.
@throws InvalidFormatException
If rule M1.12 is not verified : Packages shall not contain
equivalent part names and package implementers shall neither
Create nor recognize packages with equivalent part names.
@see #CreatePartImpl(PackagePartName, String, bool)
Create and Add a part, with the specified name and content type, to the
package. For general purpose, prefer the overload version of this method
without the 'loadRelationships' parameter.
@param PartName
Part name.
@param contentType
Part content type.
@param loadRelationships
Specify if the existing relationship part, if any, logically
associated to the newly Created part will be loaded.
@return The newly Created part.
@throws InvalidFormatException
If rule M1.12 is not verified : Packages shall not contain
equivalent part names and package implementers shall neither
Create nor recognize packages with equivalent part names.
@see {@link#CreatePartImpl(URI, String)}
Add a part to the package.
@param PartName
Part name of the part to Create.
@param contentType
type associated with the file
@param content
the contents to Add. In order to have faster operation in
document merge, the data are stored in memory not on a hard
disk
@return The new part.
@see #CreatePart(PackagePartName, String)
Add the specified part to the package. If a part already exists in the
package with the same name as the one specified, then we replace the old
part by the specified part.
@param part
The part to Add (or replace).
@return The part Added to the package, the same as the one specified.
@throws InvalidFormatException
If rule M1.12 is not verified : Packages shall not contain
equivalent part names and package implementers shall neither
Create nor recognize packages with equivalent part names.
Remove the specified part in this package. If this part is relationship
part, then delete all relationships in the source part.
@param part
The part to Remove. If null
, skip the action.
@see #RemovePart(PackagePartName)
Remove a part in this package. If this part is relationship part, then
delete all relationships in the source part.
@param PartName
The part name of the part to Remove.
Remove a part from this package as well as its relationship part, if one
exists, and all parts listed in the relationship part. Be aware that this
do not delete relationships which target the specified part.
@param PartName
The name of the part to delete.
@throws InvalidFormatException
Throws if the associated relationship part of the specified
part is not valid.
Delete the part with the specified name and its associated relationships
part if one exists. Prefer the use of this method to delete a part in the
package, compare to the Remove() methods that don't Remove associated
relationships part.
@param PartName
Name of the part to delete
Delete the part with the specified name and all part listed in its
associated relationships part if one exists. This process is recursively
apply to all parts in the relationships part of the specified part.
Prefer the use of this method to delete a part in the package, compare to
the Remove() methods that don't Remove associated relationships part.
@param PartName
Name of the part to delete
Check if a part already exists in this package from its name.
@param PartName
Part name to check.
@return true if the part is logically Added to this package, else
false.
Add a relationship to the package (except relationships part).
Check rule M4.1 : The format designer shall specify and the format
producer shall Create at most one core properties relationship for a
package. A format consumer shall consider more than one core properties
relationship for a package to be an error. If present, the relationship
shall target the Core Properties part.
Check rule M1.25: The Relationships part shall not have relationships to
any other part. Package implementers shall enforce this requirement upon
the attempt to Create such a relationship and shall treat any such
relationship as invalid.
@param targetPartName
Target part name.
@param targetMode
Target mode, either Internal or External.
@param relationshipType
Relationship type.
@param relID
ID of the relationship.
@see PackageRelationshipTypes
Add a package relationship.
@param targetPartName
Target part name.
@param targetMode
Target mode, either Internal or External.
@param relationshipType
Relationship type.
@see PackageRelationshipTypes
Adds an external relationship to a part (except relationships part).
The targets of external relationships are not subject to the same
validity checks that internal ones are, as the contents is potentially
any file, URL or similar.
@param target
External target of the relationship
@param relationshipType
Type of relationship.
@return The newly Created and Added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddExternalRelationship(java.lang.String,
java.lang.String)
Adds an external relationship to a part (except relationships part).
The targets of external relationships are not subject to the same
validity checks that internal ones are, as the contents is potentially
any file, URL or similar.
@param target
External target of the relationship
@param relationshipType
Type of relationship.
@param id
Relationship unique id.
@return The newly Created and Added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddExternalRelationship(java.lang.String,
java.lang.String)
Delete a relationship from this package.
@param id
Id of the relationship to delete.
Retrieves all package relationships.
@return All package relationships of this package.
@throws OpenXml4NetException
@see #GetRelationshipsHelper(String)
Retrieves all relationships with the specified type.
@param relationshipType
The filter specifying the relationship type.
@return All relationships with the specified relationship type.
Retrieves all relationships with specified id (normally just ine because
a relationship id is supposed to be unique).
@param id
Id of the wanted relationship.
Clear package relationships.
Ensure that the relationships collection is not null.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#GetRelationship(java.lang.String)
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#hasRelationships()
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#isRelationshipExists(org.apache.poi.OpenXml4Net.opc.PackageRelationship)
Add a marshaller.
@param contentType
The content type to bind to the specified marshaller.
@param marshaller
The marshaller to register with the specified content type.
Add an unmarshaller.
@param contentType
The content type to bind to the specified unmarshaller.
@param unmarshaller
The unmarshaller to register with the specified content type.
Remove a marshaller by its content type.
@param contentType
The content type associated with the marshaller to Remove.
Remove an unmarshaller by its content type.
@param contentType
The content type associated with the unmarshaller to Remove.
Get the package access mode.
@return the packageAccess The current package access.
Validates the package compliance with the OPC specifications.
@return true if the package is valid else false
Save the document in the specified file.
@param targetFile
Destination file.
@throws IOException
Throws if an IO exception occur.
@see #save(OutputStream)
Save the document in the specified output stream.
@param outputStream
The stream to save the package.
@see #saveImpl(OutputStream)
Core method to Create a package part. This method must be implemented by
the subclass.
@param PartName
URI of the part to Create.
@param contentType
Content type of the part to Create.
@return The newly Created package part.
Core method to delete a package part. This method must be implemented by
the subclass.
@param PartName
The URI of the part to delete.
Flush the package but not save.
Close the package and cause a save of the package.
Close the package without saving the document. Discard all changes made
to this package.
Save the package into the specified output stream.
@param outputStream
The output stream use to save this package.
Get the package part mapped to the specified URI.
@param PartName
The URI of the part to retrieve.
@return The package part located by the specified URI, else null.
Get all parts link to the package.
@return A list of the part owned by the package.
Replace a content type in this package.
A typical scneario to call this method is to rename a template file to the main format, e.g.
".dotx" to ".docx"
".dotm" to ".docm"
".xltx" to ".xlsx"
".xltm" to ".xlsm"
".potx" to ".pptx"
".potm" to ".pptm"
For example, a code converting a .xlsm macro workbook to .xlsx would look as follows:
OPCPackage pkg = OPCPackage.open(new FileInputStream("macro-workbook.xlsm"));
pkg.replaceContentType(
"application/vnd.ms-excel.sheet.macroEnabled.main+xml",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
FileOutputStream out = new FileOutputStream("workbook.xlsx");
pkg.save(out);
out.close();
@param oldContentType the content type to be replaced
@param newContentType the replacement
@return whether replacement was succesfull
@since POI-3.8
Add the specified part, and register its content type with the content
type manager.
@param part
The part to add.
Remove the specified part, and clear its content type from the content
type manager.
@param partName
The part name of the part to remove.
Specifies package access.
@author Julien Chable
@version 1.0
Read only. Write not authorized.
Write only. Read not authorized.
Read and Write mode.
Open Packaging Convention namespaces URI.
@author Julien Chable
@version 1.0
Dublin Core Terms URI.
Dublin Core namespace URI.
Content Types.
Core Properties.
Digital Signatures.
Relationships.
Markup Compatibility.
Provides a base class for parts stored in a Package.
@author Julien Chable
@version 0.9
This part's container.
The part name. (required by the specification [M1.1])
The type of content of this part. (required by the specification [M1.2])
Flag to know if this part is a relationship.
Flag to know if this part has been logically deleted.
This part's relationships.
Constructor.
@param pack
Parent package.
@param partName
The part name, relative to the parent Package root.
@param contentType
The content type.
@throws InvalidFormatException
If the specified URI is not valid.
Constructor.
@param pack
Parent package.
@param partName
The part name, relative to the parent Package root.
@param contentType
The content type.
@param loadRelationships
Specify if the relationships will be loaded
@throws InvalidFormatException
If the specified URI is not valid.
Constructor.
@param pack
Parent package.
@param partName
The part name, relative to the parent Package root.
@param contentType
The Multipurpose Internet Mail Extensions (MIME) content type
of the part's data stream.
Check if the new part was already added before via PackagePart.addRelationship()
to find the relationship for
The existing relationship, or null if there isn't yet one
Adds an external relationship to a part (except relationships part).
The targets of external relationships are not subject to the same
validity checks that internal ones are, as the contents is potentially
any file, URL or similar.
@param target
External target of the relationship
@param relationshipType
Type of relationship.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#addExternalRelationship(java.lang.String,
java.lang.String)
Adds an external relationship to a part (except relationships part).
The targets of external relationships are not subject to the same
validity checks that internal ones are, as the contents is potentially
any file, URL or similar.
@param target
External target of the relationship
@param relationshipType
Type of relationship.
@param id
Relationship unique id.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#addExternalRelationship(java.lang.String,
java.lang.String)
Add a relationship to a part (except relationships part).
@param targetPartName
Name of the target part. This one must be relative to the
source root directory of the part.
@param targetMode
Mode [Internal|External].
@param relationshipType
Type of relationship.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
Add a relationship to a part (except relationships part).
Check rule M1.25: The Relationships part shall not have relationships to
any other part. Package implementers shall enforce this requirement upon
the attempt to create such a relationship and shall treat any such
relationship as invalid.
@param targetPartName
Name of the target part. This one must be relative to the
source root directory of the part.
@param targetMode
Mode [Internal|External].
@param relationshipType
Type of relationship.
@param id
Relationship unique id.
@return The newly created and added relationship
@throws InvalidFormatException
If the URI point to a relationship part URI.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String, java.lang.String)
Add a relationship to a part (except relationships part).
@param targetURI
URI the target part. Must be relative to the source root
directory of the part.
@param targetMode
Mode [Internal|External].
@param relationshipType
Type of relationship.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String)
Add a relationship to a part (except relationships part).
Check rule M1.25: The Relationships part shall not have relationships to
any other part. Package implementers shall enforce this requirement upon
the attempt to create such a relationship and shall treat any such
relationship as invalid.
@param targetURI
URI of the target part. Must be relative to the source root
directory of the part.
@param targetMode
Mode [Internal|External].
@param relationshipType
Type of relationship.
@param id
Relationship unique id.
@return The newly created and added relationship
@throws InvalidFormatException
If the URI point to a relationship part URI.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#AddRelationship(org.apache.poi.OpenXml4Net.opc.PackagePartName,
org.apache.poi.OpenXml4Net.opc.TargetMode, java.lang.String, java.lang.String)
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#clearRelationships()
Delete the relationship specified by its id.
@param id
The ID identified the part to delete.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#removeRelationship(java.lang.String)
Retrieve all the relationships attached to this part.
@return This part's relationships.
@throws OpenXml4NetException
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#getRelationships()
Retrieves a package relationship from its id.
@param id
ID of the package relationship to retrieve.
@return The package relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#getRelationship(java.lang.String)
Retrieve all relationships attached to this part which have the specified
type.
@param relationshipType
Relationship type filter.
@return All relationships from this part that have the specified type.
@throws InvalidFormatException
If an error occurs while parsing the part.
@throws InvalidOperationException
If the package is open in write only mode.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#getRelationshipsByType(java.lang.String)
Implementation of the getRelationships method().
@param filter
Relationship type filter. If null then the filter is
disabled and return all the relationships.
@return All relationships from this part that have the specified type.
@throws InvalidFormatException
Throws if an error occurs during parsing the relationships
part.
@throws InvalidOperationException
Throws if the package is open en write only mode.
@see #getRelationshipsByType(String)
Knows if the part have any relationships.
@return true if the part have at least one relationship else
false.
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#hasRelationships()
Checks if the specified relationship is part of this package part.
@param rel
The relationship to check.
@return true if the specified relationship exists in this part,
else returns false
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#isRelationshipExists(org.apache.poi.OpenXml4Net.opc.PackageRelationship)
Get the PackagePart that is the target of a relationship.
@param rel A relationship from this part to another one
@return The target part of the relationship
Get the input stream of this part to read its content.
@return The input stream of the content of this part, else
null
.
Get the output stream of this part. If the part is originally embedded in
Zip package, it'll be transform intot a MemoryPackagePart in
order to write inside (the standard Java API doesn't allow to write in
the file)
@see org.apache.poi.openxml4j.opc.internal.MemoryPackagePart
Throws an exception if this package part is a relationship part.
@throws InvalidOperationException
If this part is a relationship part.
Ensure the package relationships collection instance is built.
@throws InvalidFormatException
Throws if
@return the uri
@return the contentType
@return The Content Type, including parameters, of the part
@return true if this part is a relationship
@return true if this part has been logically deleted
@return The length of the part in bytes, or -1 if not known
Compare based on the package part name, using a natural sort order
Abtract method that get the input stream of this part.
@exception IOException
Throws if an IO Exception occur in the implementation
method.
Abstract method that get the output stream of this part.
Save the content of this part and the associated relationships part (if
this part own at least one relationship) into the specified output
stream.
@param zos
Output stream to save this part.
@throws OpenXml4NetException
If any exception occur.
Load the content of this part.
@param ios
The input stream of the content to load.
@return true if the content has been successfully loaded, else
false.
@throws InvalidFormatException
Throws if the content format is invalid.
Close this part : flush this part, close the input stream and output
stream. After this method call, the part must be available for packaging.
Flush the content of this part. If the input stream and/or output stream
as in a waiting state to read or write, the must to empty their
respective buffer.
Allows sub-classes to clean up before new data is added.
A package part collection.
@author Julien Chable
@version 0.1
Arraylist use to store this collection part names as string for rule
M1.11 optimized checking.
Check rule [M1.11]: a package implementer shall neither create nor
recognize a part with a part name derived from another part name by
Appending segments to it.
@exception InvalidOperationException
Throws if you try to add a part with a name derived from
another part name.
An immutable Open Packaging Convention compliant part name.
@author Julien Chable
@see http://www.ietf.org/rfc/rfc3986.txt
Part name stored as an URI.
Reserved characters for sub delimitations.
Authorized reserved characters for pChar.
Flag to know if this part name is from a relationship part name.
Constructor. Makes a ValidPartName object from a java.net.URI
@param uri
The URI to validate and to transform into ValidPartName.
@param checkConformance
Flag to specify if the contructor have to validate the OPC
conformance. Must be always true
except for
special URI like '/' which is needed for internal use by
OpenXml4Net but is not valid.
@throws InvalidFormatException
Throw if the specified part name is not conform to Open
Packaging Convention specifications.
@see java.net.URI
Constructor. Makes a ValidPartName object from a String part name.
@param partName
Part name to valid and to create.
@param checkConformance
Flag to specify if the contructor have to validate the OPC
conformance. Must be always true
except for
special URI like '/' which is needed for internal use by
OpenXml4Net but is not valid.
@throws InvalidFormatException
Throw if the specified part name is not conform to Open
Packaging Convention specifications.
Check if the specified part name is a relationship part name.
@param partUri
The URI to check.
@return true
if this part name respect the relationship
part naming convention else false
.
Know if this part name is a relationship part name.
@return true
if this part name respect the relationship
part naming convention else false
.
Throws an exception (of any kind) if the specified part name does not
follow the Open Packaging Convention specifications naming rules.
@param partUri
The part name to check.
@throws Exception
Throws if the part name is invalid.
Throws an exception if the specified URI is empty. [M1.1]
@param partURI
Part URI to check.
@throws InvalidFormatException
If the specified URI is empty.
Throws an exception if the part name has empty segments. [M1.3]
Throws an exception if a segment any characters other than pchar
characters. [M1.6]
Throws an exception if a segment contain percent-encoded forward slash
('/'), or backward slash ('\') characters. [M1.7]
Throws an exception if a segment contain percent-encoded unreserved
characters. [M1.8]
Throws an exception if the specified part name's segments end with a dot
('.') character. [M1.9]
Throws an exception if a segment doesn't include at least one non-dot
character. [M1.10]
@param partUri
The part name to check.
@throws InvalidFormatException
if the specified URI contain an empty segments or if one the
segments contained in the part name, ends with a dot ('.')
character.
Throws an exception if a segment any characters other than pchar
characters. [M1.6]
Throws an exception if a segment contain percent-encoded forward slash
('/'), or backward slash ('\') characters. [M1.7]
Throws an exception if a segment contain percent-encoded unreserved
characters. [M1.8]
@param segment
The segment to check
Throws an exception if the specified part name doesn't start with a
forward slash character '/'. [M1.4]
@param partUri
The part name to check.
@throws InvalidFormatException
If the specified part name doesn't start with a forward slash
character '/'.
Throws an exception if the specified part name ends with a forwar slash
character '/'. [M1.5]
@param partUri
The part name to check.
@throws InvalidFormatException
If the specified part name ends with a forwar slash character
'/'.
Throws an exception if the specified URI is absolute.
@param partUri
The URI to check.
@throws InvalidFormatException
Throws if the specified URI is absolute.
Compare two part name following the rule M1.12 :
Part name equivalence is determined by comparing part names as
case-insensitive ASCII strings. Packages shall not contain equivalent
part names and package implementers shall neither create nor recognize
packages with equivalent part names. [M1.12]
Retrieves the extension of the part name if any. If there is no extension
returns an empty String. Example : '/document/content.xml' => 'xml'
@return The extension of the part name.
Get this part name.
@return The name of this part name.
Part name equivalence is determined by comparing part names as
case-insensitive ASCII strings. Packages shall not contain equivalent
part names and package implementers shall neither create nor recognize
packages with equivalent part names. [M1.12]
Part name property getter.
@return This part name URI.
Represents the core properties of an OPC package.
@author Julien Chable
@version 1.0
@see org.apache.poi.OpenXml4Net.opc.OPCPackage
Set the category of the content of this package.
Set the category of the content of this package.
Set the status of the content.
Get the status of the content.
Get the type of content represented, generally defined by a specific use
and intended audience.
Set the type of content represented, generally defined by a specific use
and intended audience.
Get the date of creation of the resource.
Set the date of creation of the resource.
Set the date of creation of the resource.
Get the entity primarily responsible for making the content of the
resource.
Set the entity primarily responsible for making the content of the
resource.
Get the explanation of the content of the resource.
Set the explanation of the content of the resource.
Get an unambiguous reference to the resource within a given context.
Set an unambiguous reference to the resource within a given context.
Get a delimited Set of keywords to support searching and indexing. This
is typically a list of terms that are not available elsewhere in the
properties
Set a delimited Set of keywords to support searching and indexing. This
is typically a list of terms that are not available elsewhere in the
properties
Get the language of the intellectual content of the resource.
Set the language of the intellectual content of the resource.
Get the user who performed the last modification.
Set the user who performed the last modification.
Get the date and time of the last printing.
Set the date and time of the last printing.
Set the date and time of the last printing.
Get the date on which the resource was changed.
Set the date on which the resource was changed.
Set the date on which the resource was changed.
Get the revision number.
Set the revision number.
Get the topic of the content of the resource.
Set the topic of the content of the resource.
Get the name given to the resource.
Set the name given to the resource.
Get the version number.
Set the version number.
A part relationship.
@author Julien Chable
@version 1.0
Relation id.
Reference to the package.
Relationship type
Part of this relationship source
Targeting mode [Internal|External]
Target URI
Constructor.
@param pkg
@param sourcePart
@param targetUri
@param targetMode
@param relationshipType
@param id
@return the container
@return the id
@return the relationshipType
@return the source
@return URL of the source part of this relationship
public URI getSourceUri(){ }
@return the targetMode
@return the targetUri
Represents a collection of PackageRelationship elements that are owned by a
given PackagePart or the Package.
@author Julien Chable, CDubettier
@version 0.1
Package relationships ordered by ID.
Package relationships ordered by type.
A lookup of internal relationships to avoid
This relationshipPart.
Source part.
This part name.
Reference to the package.
The ID number of the next rID# to generate, or -1
if that is still to be determined.
Constructor.
Copy constructor.
This collection will contain only elements from the specified collection
for which the type is compatible with the specified relationship type
filter.
@param coll
Collection to import.
@param filter
Relationship type filter.
Constructor.
Constructor.
@throws InvalidFormatException
Throws if the format of the content part is invalid.
@throws InvalidOperationException
Throws if the specified part is a relationship part.
Constructor. Parse the existing package relationship part if one exists.
@param container
The parent package.
@param part
The part that own this relationships collection. If null
then this part is considered as the package root.
@throws InvalidFormatException
If an error occurs during the parsing of the relatinships
part fo the specified part.
Get the relationship part name of the specified part.
@param part
The part .
@return The relationship part name of the specified part. Be careful,
only the correct name is returned, this method does not check if
the part really exist in a package !
@throws InvalidOperationException
Throws if the specified part is a relationship part.
Add the specified relationship to the collection.
@param relPart
The relationship to add.
Add a relationship to the collection.
@param targetUri
Target URI.
@param targetMode
The target mode : INTERNAL or EXTERNAL
@param relationshipType
Relationship type.
@param id
Relationship ID.
@return The newly created relationship.
@see PackageAccess
Remove a relationship by its ID.
@param id
The relationship ID to Remove.
Remove a relationship by its reference.
@param rel
The relationship to delete.
Retrieves a relationship by its index in the collection.
@param index
Must be a value between [0-relationships_count-1]
Retrieves a package relationship based on its id.
@param id
ID of the package relationship to retrieve.
@return The package relationship identified by the specified id.
Get the numbe rof relationships in the collection.
Parse the relationship part and add all relationship in this collection.
@param relPart
The package part to parse.
@throws InvalidFormatException
Throws if the relationship part is invalid.
Retrieves all relations with the specified type.
@param typeFilter
Relationship type filter. If null then all
relationships are returned.
@return All relationships of the type specified by the filter.
Get this collection's iterator.
Get an iterator of a collection with all relationship with the specified
type.
@param typeFilter
Type filter.
@return An iterator to a collection containing all relationships with the
specified type contain in this collection.
Clear all relationships.
Relationship types.
@author Julien Chable
@version 0.2
Core properties relationship type.
The standard specifies a source relations ship for the Core File Properties part as follows:
http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties.
Office uses the following source relationship for the Core File Properties part:
http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties.
See 2.1.33 Part 1 Section 15.2.11.1, Core File Properties Part in [MS-OE376].pdf
Core properties relationship type as defiend in ECMA 376.
Digital signature relationship type.
Digital signature certificate relationship type.
Digital signature origin relationship type.
Thumbnail relationship type.
Extended properties relationship type.
Extended properties relationship type for strict ooxml.
Custom properties relationship type.
Core document relationship type.
Core document relationship type for strict ooxml.
Custom XML relationship type.
Image type.
Hyperlink type.
Style type.
External Link to another Document
Visio 2010 VSDX equivalent of package {@link #CORE_DOCUMENT}
Helper for part and pack Uri.
@author Julien Chable, CDubet, Kim Ung
@version 0.1
Package root Uri.
Extension name of a relationship part.
Segment name of a relationship part.
Segment name of the package properties folder.
Core package properties art name.
Forward slash Uri separator.
Forward slash Uri separator.
Package relationships part Uri
Package relationships part name.
Core properties part Uri.
Core properties partname.
Root package Uri.
Root package part name.
Gets the Uri for the package root.
@return Uri of the package root.
Know if the specified Uri is a relationship part name.
@param partUri
Uri to check.
@return true if the Uri false.
Get file name from the specified Uri.
Get the file name without the trailing extension.
Get the directory path from the specified Uri.
Combine two URIs.
@param prefix the prefix Uri
@param suffix the suffix Uri
@return the Combined Uri
Combine a string Uri with a prefix and a suffix.
Fully relativize the source part Uri against the target part Uri.
@param sourceURI
The source part Uri.
@param targetURI
The target part Uri.
@return A fully relativize part name Uri ('word/media/image1.gif',
'/word/document.xml' => 'media/image1.gif') else
null
.
Fully relativize the source part URI against the target part URI.
@param sourceURI
The source part URI.
@param targetURI
The target part URI.
@return A fully relativize part name URI ('word/media/image1.gif',
'/word/document.xml' => 'media/image1.gif') else
null
.
Resolve a source uri against a target.
@param sourcePartUri
The source Uri.
@param targetUri
The target Uri.
@return The resolved Uri.
Get Uri from a string path.
Get the source part Uri from a specified relationships part.
@param relationshipPartUri
The relationship part use to retrieve the source part.
@return The source part Uri from the specified relationships part.
Create an OPC compliant part name by throwing an exception if the Uri is
not valid.
@param partUri
The part name Uri to validate.
@return A valid part name object, else null
.
@throws InvalidFormatException
Throws if the specified Uri is not OPC compliant.
Create an OPC compliant part name.
@param partName
The part name to validate.
@return The correspondant part name if valid, else null
.
@throws InvalidFormatException
Throws if the specified part name is not OPC compliant.
@see #CreatePartName(Uri)
Create an OPC compliant part name by resolving it using a base part.
@param partName
The part name to validate.
@param relativePart
The relative base part.
@return The correspondant part name if valid, else null
.
@throws InvalidFormatException
Throws if the specified part name is not OPC compliant.
@see #CreatePartName(Uri)
Create an OPC compliant part name by resolving it using a base part.
@param partName
The part name Uri to validate.
@param relativePart
The relative base part.
@return The correspondant part name if valid, else null
.
@throws InvalidFormatException
Throws if the specified part name is not OPC compliant.
@see #CreatePartName(Uri)
Validate a part Uri by returning a bool.
([M1.1],[M1.3],[M1.4],[M1.5],[M1.6])
(OPC Specifications 8.1.1 Part names) :
Part Name Syntax
The part name grammar is defined as follows:
part_name = 1*( "/" segment )
segment = 1*( pchar )
(pchar is defined in RFC 3986)
@param partUri
The Uri to validate.
@return true if the Uri is valid to the OPC Specifications, else
false
@see #CreatePartName(Uri)
Decode a Uri by converting all percent encoded character into a String
character.
@param uri
The Uri to decode.
@return The specified Uri in a String with converted percent encoded
characters.
Build a part name where the relationship should be stored ((ex
/word/document.xml -> /word/_rels/document.xml.rels)
@param partName
Source part Uri
@return the full path (as Uri) of the relation file
@throws InvalidOperationException
Throws if the specified Uri is a relationshp part.
Add a relationship to a part (except relationships part).
@param targetPartName
Name of the target part. This one must be relative to the
source root directory of the part.
@param targetMode
Mode [Internal|External].
@param relationshipType
Type of relationship.
@return The newly created and added relationship
* Add a relationship to a part (except relationships part).
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
* relationship as invalid.
*
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
* @param targetMode
* Mode [Internal|External].
* @param relationshipType
* Type of relationship.
* @param id
* Relationship unique id.
* @return The newly created and added relationship
*
* @throws InvalidFormatException
* If the URI point to a relationship part URI.
Adds an external relationship to a part
(except relationships part).
The targets of external relationships are not
subject to the same validity checks that internal
ones are, as the contents is potentially
any file, URL or similar.
@param target External target of the relationship
@param relationshipType Type of relationship.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
Adds an external relationship to a part
(except relationships part).
The targets of external relationships are not
subject to the same validity checks that internal
ones are, as the contents is potentially
any file, URL or similar.
@param target External target of the relationship
@param relationshipType Type of relationship.
@param id Relationship unique id.
@return The newly created and added relationship
@see org.apache.poi.OpenXml4Net.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
Delete all the relationships attached to this.
Delete the relationship specified by its id.
@param id
The ID identified the part to delete.
Retrieve all the relationships attached to this.
@return This part's relationships.
@throws OpenXml4NetException
Retrieves a package relationship from its id.
@param id
ID of the package relationship to retrieve.
@return The package relationship
Retrieve all relationships attached to this part which have the specified
type.
@param relationshipType
Relationship type filter.
@return All relationships from this part that have the specified type.
@throws InvalidFormatException
If an error occurs while parsing the part.
@throws InvalidOperationException
If the package is open in write only mode.
Knows if the part have any relationships.
@return true if the part have at least one relationship else
false.
Checks if the specified relationship is part of this package part.
@param rel
The relationship to check.
@return true if the specified relationship exists in this part,
else returns false
Turning the DOM4j object in the specified output stream.
@param xmlContent
The XML document.
@param outStream
The Stream in which the XML document will be written.
@return true if the xml is successfully written in the stream,
else false.
Copy the input stream into the output stream.
@param inStream
The source stream.
@param outStream
The destination stream.
@return true if the operation succeed, else return false.
Specifies whether the target of a PackageRelationship is inside or outside a
Package.
@author Julien Chable
@version 1.0
The relationship references a resource that is external to the package.
The relationship references a part that is inside the package.
Physical zip package.
@author Julien Chable
Zip archive, as either a file on disk,
or a stream
Constructor. Creates a new ZipPackage.
Constructor. Operation not supported.
@param in
Zip input stream to load.
@param access
Constructor. Opens a Zip based Open XML document.
@param path
The path of the file to open or create.
@param access
The package access mode.
Constructor. Opens a Zip based Open XML document.
@param file
The file to open or create.
@param access
The package access mode.
Constructor. Opens a Zip based Open XML document from
a custom ZipEntrySource, typically an open archive
from another system
@param zipEntry
Zip data to load.
@param access
The package access mode.
Retrieves the parts from this package. We assume that the package has not
been yet inspect to retrieve all the parts, this method will open the
archive and look for all parts contain inside it. If the package part
list is not empty, it will be emptied.
@return All parts contain in this package.
@throws InvalidFormatException
Throws if the package is not valid.
Builds a PackagePartName for the given ZipEntry,
or null if it's the content types / invalid part
Create a new MemoryPackagePart from the specified URI and content type
aram partName The part URI.
@param contentType
The part content type.
@return The newly created zip package part, else null.
Delete a part from the package
@throws ArgumentException
Throws if the part URI is nulll or invalid.
Flush the package. Do nothing.
Close and save the package.
@see #close()
Create a unique identifier to be use as a temp file name.
@return A unique identifier use to be use as a temp file name.
Close the package without saving the document. Discard all the changes
made to this package.
Implement the getPart() method to retrieve a part from its URI in the
current package
@see #getPart(PackageRelationship)
Save this package into the specified stream
@param outputStream
The stream use to save this package.
@see #save(OutputStream)
Get the zip archive
@return The zip archive.
Zip implementation of a PackagePart.
@author Julien Chable
@version 1.0
@see PackagePart
The zip entry corresponding to this part.
Constructor.
@param container
The container package.
@param partName
Part name.
@param contentType
Content type.
@throws InvalidFormatException
Throws if the content of this part invalid.
Constructor.
@param container
The container package.
@param zipEntry
The zip entry corresponding to this part.
@param partName
The part name.
@param contentType
Content type.
@throws InvalidFormatException
Throws if the content of this part is invalid.
Get the zip entry of this part.
@return The zip entry in the zip structure coresponding to this part.
Implementation of the getInputStream() which return the inputStream of
this part zip entry.
@return Input stream of this part zip entry.
An Interface to make getting the different bits
of a Zip File easy.
Allows you to get at the ZipEntries, without
needing to worry about ZipFile vs ZipInputStream
being annoyingly very different.
Returns an Enumeration of all the Entries
Returns an InputStream of the decompressed
data that makes up the entry
Indicates we are done with reading, and
resources may be freed
Has close been called already?
A ZipEntrySource wrapper around a ZipFile.
Should be as low in terms of memory as a
normal ZipFile implementation is.
Provides a way to get at all the ZipEntries
from a ZipInputStream, as many times as required.
Allows a ZipInputStream to be treated much like
a ZipFile, for a price in terms of memory.
Be sure to call {@link #close()} as soon as you're
done, to free up that memory!
Reads all the entries from the ZipInputStream
into memory, and closes the source stream.
We'll then eat lots of memory, but be able to
work with the entries at-will.
Why oh why oh why are Iterator and Enumeration
still not compatible?
So we can close the real zip entry and still
effectively work with it.
Holds the (decompressed!) data in memory, so
close this as soon as you can!
Sets the ratio between de- and inflated bytes to detect zipbomb.
It defaults to 1% (= 0.01d), i.e. when the compression is better than
1% for any given read package part, the parsing will fail indicating a
Zip-Bomb.
@param ratio the ratio between de- and inflated bytes to detect zipbomb
Returns the current minimum compression rate that is used.
See setMinInflateRatio() for details.
@return The min accepted compression-ratio.
Sets the maximum file size of a single zip entry. It defaults to 4GB,
i.e. the 32-bit zip format maximum.
This can be used to limit memory consumption and protect against
security vulnerabilities when documents are provided by users.
@param maxEntrySize the max. file size of a single zip entry
Returns the current maximum allowed uncompressed file size.
See setMaxEntrySize() for details.
@return The max accepted uncompressed file size.
This exception is thrown when we try to open a file that doesn't
seem to actually be an OOXML (Office Open XML) file After all
This exception is thrown when we are given an ODF-based file
(eg OpenOffice .ods) instead of an actually OOXML (Office Open XML) file
This exception is thrown when we are given an OLE2-based file
(eg Excel .xls) instead of an actually OOXML (Office Open XML) file
Namespace URI to use to represent that there is no Namespace.
Defined by the Namespace specification to be "".
@see
Namespaces in XML, 5.2 Namespace Defaulting
Prefix to use to represent the default XML Namespace.
Defined by the XML specification to be "".
@see
Namespaces in XML, 3. Qualified Names
The official XML Namespace name URI.
Defined by the XML specification to be
"{@code http://www.w3.org/XML/1998/namespace}".
@see
Namespaces in XML, 3. Qualified Names
The official XML attribute used for specifying XML Namespace
declarations, {@link #XMLNS_ATTRIBUTE
XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.
Defined by the XML specification to be
"{@code http://www.w3.org/2000/xmlns/}".
@see
Namespaces in XML, 3. Qualified Names
@see
Namespaces in XML Errata
The official XML attribute used for specifying XML Namespace
declarations.
It is NOT valid to use as a
prefix. Defined by the XML specification to be
"{@code xmlns}".
@see
Namespaces in XML, 3. Qualified Names
W3C XML Schema Instance Namespace URI.
Defined to be "{@code http://www.w3.org/2001/XMLSchema-instance}".
@see
XML Schema Part 1:
Structures, 2.6 Schema-Related Markup in Documents Being Validated
W3C XPath Datatype Namespace URI.
Defined to be "{@code http://www.w3.org/2003/11/xpath-datatypes}".
@see XQuery 1.0 and XPath 2.0 Data Model
RELAX NG Namespace URI.
Defined to be "{@code http://relaxng.org/ns/structure/1.0}".
@see RELAX NG Specification