Package com.independentsoft.office.odf
Class Document
java.lang.Object
com.independentsoft.office.odf.Document
- Direct Known Subclasses:
Chart,Spreadsheet,TextDocument
Represents a document in OpenDocument format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CommonStylesprotected FileTableprotected FileTableprotected booleanprotected Manifestprotected MetaDataprotected Stringprotected ZipOutputStreamprotected Settingsprotected Charset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidaddManifestEntry(Manifest currentManifest, Manifest originalManifest, String path)Adds a manifest:file-entry for a package part written from the in-memory model (image, OLE object, embedded document).protected voidaddMimeTypeFile(String mimeTypeValue)protected voidaddPreservedEmbeddedObjectManifestEntries(Manifest manifest, SharedObjects sharedObjects)Returns all occurrences of the specified text in the whole document, including tables, headers, footers, notes, annotations, text boxes and shapes.find(String text, FindOptions options)Returns all occurrences of the specified text.<T> List<T>findElements(Class<T> type)Returns all content elements of the specified type, for example all images or all tables, from the whole document.<T> List<T>findElements(Class<T> type, Predicate<T> match)Returns all content elements of the specified type which match the specified condition.<T> List<T>findElements(Class<T> type, Predicate<T> match, int scope)Returns all content elements of the specified type which match the specified condition.Returns the first occurrence of the specified text or null if the text was not found.findFirst(String text, FindOptions options)Returns the first occurrence of the specified text or null if the text was not found.Gets the attributed texts.abstract byte[]getBytes()Gets the bytes.Gets the common styles.Gets the configurations.abstract List<IContentElement>Gets the content elements.Gets the creation date.Gets the creator.Gets the custom file table.Gets the description.intGets the editing cycles.Gets the editing duration.Gets the fields.Gets the file input table.Gets the generator.Gets the headings.abstract StringgetHtml()Converts the document to HTML format.Gets the images.Gets the initial creator.Gets the input file table.abstract InputStreamGets the input stream.Gets the keywords.Gets the language.Gets the last modified.getLists()Gets the lists.Gets the manifest.Gets the meta data.Gets the mime type.Gets the paragraphs.getPreservedPackageParts(SharedObjects sharedObjects)Returns the paths of original package parts that this writer does NOT regenerate (thumbnails, layout-cache, manifest.rdf, unreferenced pictures, ...) so they can be carried over into the saved package instead of being dropped.Gets the prints the date.Gets the printed by.Gets the sections.Gets the statistic.Gets the subject.Gets the tables.Gets the template.getText()Returns the plain text of the whole document.getTexts()Gets the texts.getTitle()Gets the title.Gets the user defined metadata elements.booleanChecks if is template.abstract voidopen(InputStream stream)Open.abstract voidOpen.protected voidopenImplementation(InputStream stream)booleanremove(IContentElement element)Removes the specified content element from the document.booleanReplaces the image of the specified image element.booleanReplaces the image of the specified image element.booleanreplace(IContentElement oldElement, IContentElement newElement)Replaces the specified content element, for example a span, a paragraph or a table, with another content element.booleanreplace(IContentElement oldElement, IContentElement newElement, FindOptions options)Replaces the specified content element with another content element.intreplace(String text, AttributedText attributedText)Replaces all occurrences of the specified text with a copy of the specified span.intreplace(String text, AttributedText attributedText, FindOptions options)Replaces all occurrences of the specified text with a copy of the specified span.intreplace(String text, IParagraphContent content)Replaces all occurrences of the specified text with a copy of the specified content, for example an image, a tab, a line break, a field or a hyperlink.intreplace(String text, IParagraphContent content, FindOptions options)Replaces all occurrences of the specified text with a copy of the specified content.intReplaces all occurrences of the specified oldText with newText in the whole document.intreplace(String oldText, String newText, FindOptions options)Replaces all occurrences of the specified oldText with newText.intreplace(String text, List<AttributedText> attributedTexts, FindOptions options)Replaces all occurrences of the specified text with copies of the specified spans.intReplaces all occurrences of the specified oldText with newText.intReplaces all occurrences of the specified oldText with newText.intreplaceContent(String text, List<IParagraphContent> content, FindOptions options)Replaces all occurrences of the specified text with copies of the specified content.abstract voidsave(OutputStream stream)Save.abstract voidSave.abstract voidSave.abstract voidsaveAsHtml(OutputStream stream)Saves the document in HTML format.abstract voidsaveAsHtml(String file)Saves the document in HTML format.abstract voidsaveAsHtml(String file, boolean overwrite)Saves the document in HTML format.voidsetCreationDate(Date creationDate)Sets the creation date.voidsetCreator(String creator)Sets the creator.voidsetDescription(String description)Sets the description.voidsetEditingCycles(int editingCycles)Sets the editing cycles.voidsetEditingDuration(String editingDuration)Sets the editing duration.voidsetInitialCreator(String initialCreator)Sets the initial creator.voidsetKeywords(String keywords)Sets the keywords.voidsetLanguage(String language)Sets the language.voidsetLastModified(Date lastModified)Sets the last modified.voidsetMimeType(String mimeType)Sets the mime type.voidsetPrintDate(Date printDate)Sets the prints the date.voidsetPrintedBy(String printedBy)Sets the printed by.voidsetStatistic(DocumentStatistic statistic)Sets the statistic.voidsetSubject(String subject)Sets the subject.voidsetTemplate(boolean isTemplate)Sets the template.voidsetTemplate(Template template)Sets the template.voidSets the title.
-
Field Details
-
utf8
-
outputStream
-
inputFileTable
-
customFileTable
-
mimeType
-
isTemplate
protected boolean isTemplate -
manifest
-
metaData
-
commonStyles
-
settings
-
-
Constructor Details
-
Document
public Document()
-
-
Method Details
-
open
Open.- Parameters:
file- the file- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
open
Open.- Parameters:
stream- the stream- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
save
Save.- Parameters:
file- the file- Throws:
IOException- Signals that an I/O exception has occurred.
-
save
Save.- Parameters:
file- the fileoverwrite- the overwrite- Throws:
IOException- Signals that an I/O exception has occurred.
-
save
Save.- Parameters:
stream- the stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
getBytes
Gets the bytes.- Returns:
- the bytes
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getInputStream
Gets the input stream.- Returns:
- the input stream
- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Saves the document in HTML format.- Parameters:
file- The path of the file to save.- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Saves the document in HTML format.- Parameters:
file- The path of the file to save.overwrite- If true, overwrites an existing file.- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Saves the document in HTML format.- Parameters:
stream- The stream to save to.- Throws:
IOException- Signals that an I/O exception has occurred.
-
getHtml
Converts the document to HTML format.- Returns:
- The HTML representation of the document.
- Throws:
IOException- Signals that an I/O exception has occurred.
-
openImplementation
- Throws:
IOExceptionXMLStreamException
-
addFile
- Throws:
IOException
-
addManifestEntry
Adds a manifest:file-entry for a package part written from the in-memory model (image, OLE object, embedded document). Without it the part is unlisted and the package can be reported as corrupt. The original manifest (if any) supplies the exact media-type; otherwise it is derived from the file extension. -
addMimeTypeFile
- Throws:
IOException
-
addFile
- Throws:
IOException
-
getAttributedTexts
Gets the attributed texts.- Returns:
- the attributed texts
-
getTexts
Gets the texts.- Returns:
- the texts
-
getText
Returns the plain text of the whole document.- Returns:
- the plain text of the document or an empty string if the document does not contain text
-
getParagraphs
Gets the paragraphs.- Returns:
- the paragraphs
-
getHeadings
Gets the headings.- Returns:
- the headings
-
getFields
Gets the fields.- Returns:
- the fields
-
getLists
Gets the lists.- Returns:
- the lists
-
getSections
Gets the sections.- Returns:
- the sections
-
getTables
Gets the tables.- Returns:
- the tables
-
getImages
Gets the images.- Returns:
- the images
-
find
Returns all occurrences of the specified text in the whole document, including tables, headers, footers, notes, annotations, text boxes and shapes.- Parameters:
text- the text to find.- Returns:
- A list of FindResult objects.
-
find
Returns all occurrences of the specified text.- Parameters:
text- the text to find.options- the options of the search.- Returns:
- A list of FindResult objects.
-
findFirst
Returns the first occurrence of the specified text or null if the text was not found.- Parameters:
text- the text to find.- Returns:
- A FindResult object or null.
-
findFirst
Returns the first occurrence of the specified text or null if the text was not found.- Parameters:
text- the text to find.options- the options of the search.- Returns:
- A FindResult object or null.
-
findElements
Returns all content elements of the specified type, for example all images or all tables, from the whole document.- Type Parameters:
T- the type of the content elements.- Parameters:
type- the type of the content elements.- Returns:
- A list of content elements.
-
findElements
Returns all content elements of the specified type which match the specified condition.- Type Parameters:
T- the type of the content elements.- Parameters:
type- the type of the content elements.match- the condition the content elements have to match.- Returns:
- A list of content elements.
-
findElements
Returns all content elements of the specified type which match the specified condition.- Type Parameters:
T- the type of the content elements.- Parameters:
type- the type of the content elements.match- the condition the content elements have to match.scope- the parts of the document to search.- Returns:
- A list of content elements.
-
replace
Replaces all occurrences of the specified oldText with newText in the whole document. The paragraphs, their styles and all other content of the paragraphs remain unchanged.- Parameters:
oldText- the string to replace.newText- the string that replaces oldText.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified oldText with newText.- Parameters:
oldText- the string to replace.newText- the string that replaces oldText.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified oldText with newText.- Parameters:
oldText- a list of strings to replace.newText- a list of strings that replaces oldText.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified oldText with newText.- Parameters:
oldText- a list of strings to replace.newText- a list of strings that replaces oldText.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified text with a copy of the specified span. The text before and after the replaced text keeps its formatting.- Parameters:
text- the text to replace.attributedText- the AttributedText that replaces the text.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified text with a copy of the specified span.- Parameters:
text- the text to replace.attributedText- the AttributedText that replaces the text.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified text with copies of the specified spans.- Parameters:
text- the text to replace.attributedTexts- the AttributedText objects that replace the text.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified text with a copy of the specified content, for example an image, a tab, a line break, a field or a hyperlink.- Parameters:
text- the text to replace.content- the content that replaces the text.- Returns:
- The number of replaced occurrences.
-
replace
Replaces all occurrences of the specified text with a copy of the specified content.- Parameters:
text- the text to replace.content- the content that replaces the text.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replaceContent
Replaces all occurrences of the specified text with copies of the specified content.- Parameters:
text- the text to replace.content- the content that replaces the text.options- the options of the search.- Returns:
- The number of replaced occurrences.
-
replace
Replaces the specified content element, for example a span, a paragraph or a table, with another content element. The properties of the replaced element are preserved if the new element has no own properties.- Parameters:
oldElement- the content element to replace.newElement- the content element that replaces oldElement.- Returns:
- true if the content element was replaced.
-
replace
public boolean replace(IContentElement oldElement, IContentElement newElement, FindOptions options)Replaces the specified content element with another content element.- Parameters:
oldElement- the content element to replace.newElement- the content element that replaces oldElement.options- the options of the replacement.- Returns:
- true if the content element was replaced.
-
replace
Replaces the image of the specified image element. The size, the position and all other properties of the frame remain unchanged.- Parameters:
image- the image to replace.filePath- the path of the new image file.- Returns:
- true if the image was replaced.
- Throws:
IOException- Signals that an I/O exception has occurred.
-
replace
Replaces the image of the specified image element. The size, the position and all other properties of the frame remain unchanged.- Parameters:
image- the image to replace.fileName- the file name of the new image.buffer- the new image.- Returns:
- true if the image was replaced.
-
remove
Removes the specified content element from the document.- Parameters:
element- the content element to remove.- Returns:
- true if the content element was removed.
-
getContentElements
Gets the content elements.- Returns:
- the content elements
-
getInputFileTable
Gets the input file table.- Returns:
- the input file table
-
getCustomFileTable
Gets the custom file table.- Returns:
- the custom file table
-
getCommonStyles
Gets the common styles.- Returns:
- the common styles
-
getGenerator
Gets the generator.- Returns:
- the generator
-
getTitle
Gets the title.- Returns:
- the title
-
setTitle
Sets the title.- Parameters:
title- the new title
-
getDescription
Gets the description.- Returns:
- the description
-
setDescription
Sets the description.- Parameters:
description- the new description
-
getSubject
Gets the subject.- Returns:
- the subject
-
setSubject
Sets the subject.- Parameters:
subject- the new subject
-
getLanguage
Gets the language.- Returns:
- the language
-
setLanguage
Sets the language.- Parameters:
language- the new language
-
getKeywords
Gets the keywords.- Returns:
- the keywords
-
setKeywords
Sets the keywords.- Parameters:
keywords- the new keywords
-
getCreator
Gets the creator.- Returns:
- the creator
-
setCreator
Sets the creator.- Parameters:
creator- the new creator
-
getCreationDate
Gets the creation date.- Returns:
- the creation date
-
setCreationDate
Sets the creation date.- Parameters:
creationDate- the new creation date
-
getLastModified
Gets the last modified.- Returns:
- the last modified
-
setLastModified
Sets the last modified.- Parameters:
lastModified- the new last modified
-
getEditingCycles
public int getEditingCycles()Gets the editing cycles.- Returns:
- the editing cycles
-
setEditingCycles
public void setEditingCycles(int editingCycles)Sets the editing cycles.- Parameters:
editingCycles- the new editing cycles
-
getEditingDuration
Gets the editing duration.- Returns:
- the editing duration
-
setEditingDuration
Sets the editing duration.- Parameters:
editingDuration- the new editing duration
-
getInitialCreator
Gets the initial creator.- Returns:
- the initial creator
-
setInitialCreator
Sets the initial creator.- Parameters:
initialCreator- the new initial creator
-
getPrintDate
Gets the prints the date.- Returns:
- the prints the date
-
setPrintDate
Sets the prints the date.- Parameters:
printDate- the new prints the date
-
getPrintedBy
Gets the printed by.- Returns:
- the printed by
-
setPrintedBy
Sets the printed by.- Parameters:
printedBy- the new printed by
-
getUserDefinedMetadataElements
Gets the user defined metadata elements.- Returns:
- the user defined metadata elements
-
getTemplate
Gets the template.- Returns:
- the template
-
setTemplate
Sets the template.- Parameters:
template- the new template
-
getStatistic
Gets the statistic.- Returns:
- the statistic
-
setStatistic
Sets the statistic.- Parameters:
statistic- the new statistic
-
getConfigurations
Gets the configurations.- Returns:
- the configurations
-
isTemplate
public boolean isTemplate()Checks if is template.- Returns:
- true, if is template
-
setTemplate
public void setTemplate(boolean isTemplate)Sets the template.- Parameters:
isTemplate- the new template
-
getFileInputTable
Gets the file input table.- Returns:
- the file input table
-
getManifest
Gets the manifest.- Returns:
- the manifest
-
getMetaData
Gets the meta data.- Returns:
- the meta data
-
getMimeType
Gets the mime type.- Returns:
- the mime type
-
setMimeType
Sets the mime type.- Parameters:
mimeType- the new mime type
-