ODPackage.RootElement
|
Method Summary |
Set<String> |
addBasicLibraries(Collection<? extends Library> libraries)
Add the passed libraries to this package. |
Set<String> |
addBasicLibraries(ODPackage pkg)
|
String |
checkStyles()
Verify that styles referenced by this document are indeed defined. |
void |
clear()
|
static ODPackage |
createFromDocuments(ContentTypeVersioned type,
org.jdom.Document content,
org.jdom.Document style,
org.jdom.Document meta,
org.jdom.Document settings)
|
static ODPackage |
createFromDocuments(org.jdom.Document content,
org.jdom.Document style)
Create a package from a collection of sub-documents. |
static ODPackage |
createFromFile(File f)
|
static ODPackage |
createFromStream(InputStream ins,
String name)
Read from the input stream into memory and close it. |
byte[] |
getBinaryFile(String entry)
|
ODXMLDocument |
getContent()
|
ContentTypeVersioned |
getContentType()
The type of this package, null if it cannot be found (eg this package is empty). |
protected Object |
getData(String entry)
|
org.jdom.Element |
getDefaultStyle(StyleStyleDesc<?> desc,
boolean create)
|
org.jdom.Document |
getDocument(String xmlEntry)
Return an XML document. |
Set<String> |
getEntries()
|
ODPackageEntry |
getEntry(String entry)
|
File |
getFile()
|
XMLFormatVersion |
getFormatVersion()
|
ODMeta |
getMeta()
|
ODMeta |
getMeta(boolean create)
|
String |
getMimeType()
|
ODDocument |
getODDocument()
|
static String |
getPageCount()
|
SpreadSheet |
getSpreadSheet()
|
org.jdom.Element |
getStyle(org.jdom.Document referent,
StyleDesc<?> desc,
String name)
Find the passed automatic or common style. |
org.jdom.Element |
getStyle(StyleDesc<?> desc,
String name)
Find the passed automatic or common style referenced from the content. |
ODXMLDocument |
getStyles()
The XML document where are located the common styles. |
TextDocument |
getTextDocument()
|
XMLVersion |
getVersion()
The version of this package, null if it cannot be found (eg this package is
empty, or contains no xml). |
ODXMLDocument |
getXMLFile(org.jdom.Document doc)
|
ODXMLDocument |
getXMLFile(String xmlEntry)
|
boolean |
hasODDocument()
|
boolean |
isSingle()
|
static boolean |
isStandardFile(String name)
Whether the passed entry is specific to a package. |
boolean |
isTemplate()
|
void |
putCopy(ODPackageEntry entry)
|
void |
putCopy(ODPackageEntry entry,
String entryName)
|
void |
putFile(String entry,
Object data)
|
void |
putFile(String entry,
Object data,
String mediaType)
|
void |
putFile(String entry,
Object data,
String mediaType,
boolean compress)
|
Map<String,Library> |
readBasicLibraries()
Parse BASIC libraries in this package. |
Map<String,EventListener> |
readEventListeners()
Parse events for the whole document. |
Set<String> |
removeBasicLibraries(Collection<String> libraries)
Remove the passed libraries. |
void |
rmFile(String entry)
|
void |
rmFiles(Collection<String> entries)
|
File |
save()
Save the content of this package to our file, overwriting it if it exists. |
void |
save(OutputStream out)
|
File |
saveAs(File fNoExt)
|
void |
setContentType(ContentTypeVersioned newType)
|
void |
setFile(File f)
|
static void |
setPageCount(int count)
Allow to specify a fixed number of pages for all text documents. |
void |
setTemplate(boolean b)
|
boolean |
split()
Split the ODPackage.RootElement.SINGLE_CONTENT. |
ODSingleXMLDocument |
toSingle()
Transform this to use a ODSingleXMLDocument. |
Map<String,String> |
validateSubDocuments()
Call Validator.isValid() on each XML subdocuments. |
Map<String,String> |
validateSubDocuments(boolean allowChangeToValidate)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ODPackage
public ODPackage()
ODPackage
public ODPackage(InputStream ins)
throws IOException
- Read from the input stream into memory and close it.
- Parameters:
ins - the package.
- Throws:
IOException - if ins couldn't be read.
ODPackage
public ODPackage(File f)
throws IOException
- Throws:
IOException
ODPackage
public ODPackage(ODPackage o)
setPageCount
public static final void setPageCount(int count)
- Allow to specify a fixed number of pages for all text documents. This provides a workaround
for LibreOffice 4.0.x on Ubuntu which takes a long time to open documents without statistics.
E.g. 40s for 35 pages but only 4s if the page count is 500 pages.
- Parameters:
count - page count, negative means remove.
getPageCount
public static final String getPageCount()
isStandardFile
public static final boolean isStandardFile(String name)
- Whether the passed entry is specific to a package.
- Parameters:
name - a entry name, eg "mimetype"
- Returns:
true if name is a standard file, eg true.
createFromDocuments
public static ODPackage createFromDocuments(org.jdom.Document content,
org.jdom.Document style)
- Create a package from a collection of sub-documents.
- Parameters:
content - the content.style - the styles, can be null.
- Returns:
- a package containing the XML documents.
createFromDocuments
public static ODPackage createFromDocuments(ContentTypeVersioned type,
org.jdom.Document content,
org.jdom.Document style,
org.jdom.Document meta,
org.jdom.Document settings)
createFromStream
public static ODPackage createFromStream(InputStream ins,
String name)
throws IOException
- Read from the input stream into memory and close it.
- Parameters:
ins - the package or flat XML.name - the name, can be null.
- Returns:
- a package containing the document.
- Throws:
IOException - if an error occurs.
createFromFile
public static ODPackage createFromFile(File f)
throws IOException
- Throws:
IOException
getFile
public final File getFile()
setFile
public final void setFile(File f)
getVersion
public final XMLVersion getVersion()
- The version of this package,
null if it cannot be found (eg this package is
empty, or contains no xml).
- Returns:
- the version of this package, can be
null.
getFormatVersion
public final XMLFormatVersion getFormatVersion()
getContentType
public final ContentTypeVersioned getContentType()
- The type of this package,
null if it cannot be found (eg this package is empty).
- Returns:
- the type of this package, can be
null.
setContentType
public final void setContentType(ContentTypeVersioned newType)
getMimeType
public final String getMimeType()
isTemplate
public final boolean isTemplate()
setTemplate
public final void setTemplate(boolean b)
validateSubDocuments
public final Map<String,String> validateSubDocuments()
- Call
Validator.isValid() on each XML subdocuments.
- Returns:
- all problems indexed by package entry names, i.e. empty if all OK,
null
if validation couldn't occur.
validateSubDocuments
public final Map<String,String> validateSubDocuments(boolean allowChangeToValidate)
getODDocument
public final ODDocument getODDocument()
hasODDocument
public final boolean hasODDocument()
getSpreadSheet
public final SpreadSheet getSpreadSheet()
getTextDocument
public final TextDocument getTextDocument()
getEntries
public final Set<String> getEntries()
getEntry
public final ODPackageEntry getEntry(String entry)
getData
protected final Object getData(String entry)
getBinaryFile
public final byte[] getBinaryFile(String entry)
getXMLFile
public final ODXMLDocument getXMLFile(String xmlEntry)
getXMLFile
public final ODXMLDocument getXMLFile(org.jdom.Document doc)
getStyles
public final ODXMLDocument getStyles()
- The XML document where are located the common styles.
- Returns:
- the document where are located styles.
getContent
public final ODXMLDocument getContent()
getMeta
public final ODMeta getMeta()
getMeta
public final ODMeta getMeta(boolean create)
readBasicLibraries
public final Map<String,Library> readBasicLibraries()
- Parse BASIC libraries in this package.
- Returns:
- the BASIC libraries by name.
addBasicLibraries
public final Set<String> addBasicLibraries(Collection<? extends Library> libraries)
- Add the passed libraries to this package. Passed libraries with the same content as existing
ones are ignored.
- Parameters:
libraries - what to add.
- Returns:
- the actually added libraries.
- Throws:
IllegalArgumentException - if libraries contains duplicates or if it
cannot be merged into this.- See Also:
Library.canBeMerged(Library)
addBasicLibraries
public final Set<String> addBasicLibraries(ODPackage pkg)
removeBasicLibraries
public final Set<String> removeBasicLibraries(Collection<String> libraries)
- Remove the passed libraries.
- Parameters:
libraries - which libraries to remove.
- Returns:
- the actually removed libraries.
readEventListeners
public final Map<String,EventListener> readEventListeners()
- Parse events for the whole document.
- Returns:
- event listeners by event name.
getDocument
public org.jdom.Document getDocument(String xmlEntry)
- Return an XML document.
- Parameters:
xmlEntry - the filename, eg "styles.xml".
- Returns:
- the matching document, or
null if there's none.
- Throws:
org.jdom.JDOMException - if error about the XML.
IOException - if an error occurs while reading the file.
getStyle
public final org.jdom.Element getStyle(StyleDesc<?> desc,
String name)
- Find the passed automatic or common style referenced from the content.
- Parameters:
desc - the family, eg StyleStyleDesc<ParagraphStyle>.name - the name, eg "P1".
- Returns:
- the corresponding XML element.
getStyle
public final org.jdom.Element getStyle(org.jdom.Document referent,
StyleDesc<?> desc,
String name)
- Find the passed automatic or common style. NOTE :
referent is needed because
there can exist automatic styles with the same name in both "content.xml" and "styles.xml".
- Parameters:
referent - the document referencing the style.desc - the family, eg StyleStyleDesc<ParagraphStyle>.name - the name, eg "P1".
- Returns:
- the corresponding XML element.
- See Also:
ODXMLDocument.getStyle(StyleDesc, String, Document)
getDefaultStyle
public final org.jdom.Element getDefaultStyle(StyleStyleDesc<?> desc,
boolean create)
checkStyles
public final String checkStyles()
- Verify that styles referenced by this document are indeed defined. NOTE this method is not
perfect : not all problems are detected.
- Returns:
null if no problem has been found, else a String describing it.
putFile
public void putFile(String entry,
Object data)
putFile
public void putFile(String entry,
Object data,
String mediaType)
putFile
public void putFile(String entry,
Object data,
String mediaType,
boolean compress)
putCopy
public final void putCopy(ODPackageEntry entry)
putCopy
public final void putCopy(ODPackageEntry entry,
String entryName)
rmFile
public void rmFile(String entry)
rmFiles
public final void rmFiles(Collection<String> entries)
clear
public void clear()
toSingle
public ODSingleXMLDocument toSingle()
- Transform this to use a
ODSingleXMLDocument. Ie after this method, only "content.xml"
remains and it's an instance of ODSingleXMLDocument.
- Returns:
- the created ODSingleXMLDocument.
isSingle
public final boolean isSingle()
split
public final boolean split()
- Split the
ODPackage.RootElement.SINGLE_CONTENT. If this was single the
former content won't be useable anymore, you can check it with
ODSingleXMLDocument.isDead().
- Returns:
true if this was modified.
save
public final void save(OutputStream out)
throws IOException
- Throws:
IOException
save
public File save()
throws IOException
- Save the content of this package to our file, overwriting it if it exists.
- Returns:
- the saved file.
- Throws:
IOException - if an error occurs while saving.
saveAs
public File saveAs(File fNoExt)
throws IOException
- Throws:
IOException
Copyright © 2010 jOpenDocument All Rights Reserved.
|