|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.odftoolkit.odfdom.pkg.OdfPackageDocument
org.odftoolkit.odfdom.dom.OdfSchemaDocument
org.odftoolkit.simple.Document
org.odftoolkit.simple.TextDocument
public class TextDocument
This class represents an empty ODF text document.
Nested Class Summary | |
---|---|
static class |
TextDocument.OdfMediaType
This enum contains all possible media types of SpreadsheetDocument documents. |
Nested classes/interfaces inherited from class org.odftoolkit.simple.Document |
---|
Document.ScriptType |
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument |
---|
OdfSchemaDocument.OdfXMLFile |
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument |
---|
OdfPackageDocument.Resource |
Field Summary |
---|
Fields inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument |
---|
mContentDom, mDocumentStyles, mMetaDom, mSettingsDom, mStylesDom |
Fields inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument |
---|
mDocumentMediaType, mDocumentPathInPackage, mPackage, ROOT_DOCUMENT_PATH |
Constructor Summary | |
---|---|
protected |
TextDocument(OdfPackage pkg,
String internalPath,
TextDocument.OdfMediaType odfMediaType)
To avoid data duplication a new document is only created, if not already opened. |
Method Summary | |
---|---|
void |
addColumnBreak()
Appends a new column break to this document. |
void |
addColumnBreak(Paragraph refParagraph)
Appends a new column break to this document after the reference paragraph. |
List |
addList()
Add a new List to this container. |
List |
addList(ListDecorator decorator)
Add a List with specified ListDecorator to this container. |
void |
addPageBreak()
Appends a new page break to this document. |
void |
addPageBreak(Paragraph refParagraph)
Appends a new page break to this document after the reference paragraph. |
Paragraph |
addParagraph(String text)
Creates a new paragraph and append text. |
OdfTextParagraph |
addText(String text)
Deprecated. As of Simple version 0.5, replaced by Paragraph.appendTextContent(String content) |
Section |
appendSection(Section section,
boolean isResourceCopied)
Copy a section and append it at the end of the text document, whether the section is in this document or in a different document. |
void |
changeMode(TextDocument.OdfMediaType mediaType)
Changes the document to the given mediatype. |
void |
clearList()
Remove all Lists from this container. |
Chart |
createChart(String title,
DataSet dataset,
Rectangle rect)
Creates a new Chart for this container. |
Chart |
createChart(String title,
SpreadsheetDocument document,
CellRangeAddressList cellRangeAddr,
boolean firstRowAsLabel,
boolean firstColumnAsLabel,
boolean rowAsDataSeries,
Rectangle rect)
Creates a new Chart for this container. |
Chart |
createChart(String title,
String[] labels,
String[] legends,
double[][] data,
Rectangle rect)
Creates a new Chart for this container. |
VariableField |
declareVariable(String name,
VariableField.VariableType type)
Declare a new variable field to this container. |
void |
deleteChartById(String chartId)
Deletes chart by chart id. |
void |
deleteChartByTitle(String title)
Deletes chart(s) by chart title. |
Chart |
getChartById(String chartId)
Gets chart with specified id. |
List<Chart> |
getChartByTitle(String title)
Gets chart list with specified title. |
int |
getChartCount()
Returns the chart count of this container |
OfficeTextElement |
getContentRoot()
Get the content root of a text document. |
Footer |
getFooter()
Get the Standard Page footer of this text document. |
Footer |
getFooter(boolean isFirstPage)
Get the footer of this text document. |
Header |
getHeader()
Get the Standard Page header of this text document. |
Header |
getHeader(boolean isFirstPage)
Get the header of this text document. |
OdfElement |
getListContainerElement()
Get the ODF element which can have |
Iterator<List> |
getListIterator()
Return an Iterator of the Lists in this ListContainer. |
Paragraph |
getParagraphByIndex(int index,
boolean isEmptyParagraphSkipped)
Return a paragraph with a given index. |
Paragraph |
getParagraphByReverseIndex(int reverseIndex,
boolean isEmptyParagraphSkipped)
Return a paragraph with a given index. |
OdfElement |
getParagraphContainerElement()
Get the ODF element which can have |
Iterator<Paragraph> |
getParagraphIterator()
Return an Iterator of the paragraph in this container. |
OdfElement |
getTableContainerElement()
Get the ODF element which can have |
OdfElement |
getVariableContainerElement()
Get the ODF element which can have variable declare section as child element directly according to ODF specification. |
VariableField |
getVariableFieldByName(String name)
Return the declared variable by name. |
static TextDocument |
loadDocument(File file)
Creates an TextDocument from the OpenDocument provided by a File. |
static TextDocument |
loadDocument(InputStream inputStream)
Creates an TextDocument from the OpenDocument provided by a resource Stream. |
static TextDocument |
loadDocument(String documentPath)
Loads an TextDocument from the provided path. |
OdfTextParagraph |
newParagraph()
Deprecated. As of Simple version 0.5, replaced by Paragraph.newParagraph(ParagraphContainer) |
OdfTextParagraph |
newParagraph(String text)
Deprecated. As of Simple version 0.5, replaced by addParagraph(String text) |
static TextDocument |
newTextDocument()
Creates an empty text document. |
static TextDocument |
newTextDocument(TextDocument.OdfMediaType mimeType)
Creates an empty text document. |
static TextDocument |
newTextMasterDocument()
Creates an empty text master document. |
static TextDocument |
newTextTemplateDocument()
Creates an empty text template. |
static TextDocument |
newTextWebDocument()
Creates an empty text web. |
boolean |
removeList(List list)
Remove the existing List from this container. |
boolean |
removeParagraph(Paragraph para)
Remove paragraph from this document |
void |
setPageColumns(int columnsNumber,
double spacing)
Defines several columns to the page whose style is specified. |
Methods inherited from class org.odftoolkit.simple.Document |
---|
addTable, addTable, close, getComponentMap, getContentRoot, getEmbeddedDocument, getEmbeddedDocuments, getEmbeddedDocuments, getLocale, getOdfMediaType, getOfficeMetadata, getScriptType, getSectionByName, getSectionIterator, getTableBuilder, getTableByName, getTableContainerImpl, getTableList, insertDocument, loadDocument, loadDocument, loadTemplate, newImage, removeElementLinkedResource, save, save, setLocale, setLocale, setOdfMediaType, toString |
Methods inherited from class org.odftoolkit.odfdom.dom.OdfSchemaDocument |
---|
getBaseURI, getContentDom, getContentStream, getDocumentStyles, getFileDom, getMasterPages, getMetaDom, getMetaStream, getOfficeMasterStyles, getOrCreateDocumentStyles, getSettingsDom, getSettingsStream, getStylesDom, getStylesStream, getTables, getXMLFilePath |
Methods inherited from class org.odftoolkit.odfdom.pkg.OdfPackageDocument |
---|
flushDoms, getDocumentPath, getFileDom, getMediaTypeString, getPackage, isExternalReference, isRootDocument, loadSubDocument, normalizeDocumentPath, removeDocument, save, setMediaTypeString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected TextDocument(OdfPackage pkg, String internalPath, TextDocument.OdfMediaType odfMediaType)
Method Detail |
---|
public static TextDocument newTextDocument() throws Exception
Exception
- - if the document could not be createdpublic static TextDocument newTextDocument(TextDocument.OdfMediaType mimeType) throws Exception
Exception
- - if the document could not be createdpublic static TextDocument newTextTemplateDocument() throws Exception
Exception
- - if the template could not be createdpublic static TextDocument newTextMasterDocument() throws Exception
Exception
- - if the document could not be createdpublic static TextDocument newTextWebDocument() throws Exception
Exception
- - if the document could not be createdpublic static TextDocument loadDocument(InputStream inputStream) throws Exception
Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by TextDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.
If the resource stream is not a ODF text document, ClassCastException might be thrown.
inputStream
- - the InputStream of the ODF text document.
Exception
- - if the document could not be created.public static TextDocument loadDocument(String documentPath) throws Exception
TextDocument relies on the file being available for read access over the whole lifecycle of TextDocument.
If the resource stream is not a ODF text document, ClassCastException might be thrown.
documentPath
- - the path from where the document can be loaded
Exception
- - if the document could not be created.public static TextDocument loadDocument(File file) throws Exception
TextDocument relies on the file being available for read access over the whole lifecycle of TextDocument.
If the resource stream is not a ODF text document, ClassCastException might be thrown.
file
- - a file representing the ODF text document.
Exception
- - if the document could not be created.public OfficeTextElement getContentRoot() throws Exception
getContentRoot
in class Document
Exception
- if the file DOM could not be created.public OdfTextParagraph newParagraph(String text) throws Exception
addParagraph(String text)
text
-
Exception
- if the file DOM could not be created.addParagraph(String)
public OdfTextParagraph newParagraph() throws Exception
Paragraph.newParagraph(ParagraphContainer)
Exception
- if the file DOM could not be created.Paragraph.newParagraph(ParagraphContainer)
,
addParagraph(String)
public OdfTextParagraph addText(String text) throws Exception
Paragraph.appendTextContent(String content)
text
- initial text for the paragraph.
Exception
- if the file DOM could not be created.Paragraph.appendTextContent(String)
,
Paragraph.appendTextContentNotCollapsed(String)
,
getParagraphByIndex(int, boolean)
,
getParagraphByReverseIndex(int, boolean)
public void changeMode(TextDocument.OdfMediaType mediaType)
mediaType
- the related ODF mimetypepublic Section appendSection(Section section, boolean isResourceCopied)
The IDs and names in this section would be changed to ensure unique.
If the section contains a linked resource, isResourceCopied
would specify whether the linked resource would be copied or not, when
the copy and append happens within a same document.
section
- - the section objectisResourceCopied
- - whether the linked resource is copied or not.public Header getHeader()
public Header getHeader(boolean isFirstPage)
isFirstPage
- if isFirstPage
is true, return the First Page
header, otherwise return Standard Page header.
public Footer getFooter()
public Footer getFooter(boolean isFirstPage)
isFirstPage
- if isFirstPage
is true, return the First Page
footer, otherwise return Standard Page footer.
public OdfElement getTableContainerElement()
TableContainer
getTableContainerElement
in interface TableContainer
public OdfElement getListContainerElement()
ListContainer
getListContainerElement
in interface ListContainer
public List addList()
ListContainer
addList
in interface ListContainer
public List addList(ListDecorator decorator)
ListContainer
addList
in interface ListContainer
decorator
- the specified ListDecorator
public void clearList()
ListContainer
clearList
in interface ListContainer
public Iterator<List> getListIterator()
ListContainer
getListIterator
in interface ListContainer
Iterator
public boolean removeList(List list)
ListContainer
removeList
in interface ListContainer
public void addPageBreak()
public void addPageBreak(Paragraph refParagraph)
refParagraph
- the reference paragraph after where the page break inserted.public void setPageColumns(int columnsNumber, double spacing)
columnsNumber
- the number of columns (are of width identical)spacing
- column spacing in cm (ex. 2.40 for 2,4 cm)public void addColumnBreak()
public void addColumnBreak(Paragraph refParagraph)
refParagraph
- the reference paragraph after where the column break inserted.public Paragraph addParagraph(String text)
addParagraph
in interface ParagraphContainer
text
- the text content of this paragraph
public boolean removeParagraph(Paragraph para)
removeParagraph
in interface ParagraphContainer
para
- the instance of paragraph
public OdfElement getParagraphContainerElement()
ParagraphContainer
getParagraphContainerElement
in interface ParagraphContainer
public Paragraph getParagraphByIndex(int index, boolean isEmptyParagraphSkipped)
ParagraphContainer
An index of zero represents the first paragraph.
If empty paragraph is skipped, the empty paragraph won't be counted.
getParagraphByIndex
in interface ParagraphContainer
index
- - the index started from 0.isEmptyParagraphSkipped
- - whether the empty paragraph is skipped or not
public Paragraph getParagraphByReverseIndex(int reverseIndex, boolean isEmptyParagraphSkipped)
ParagraphContainer
An index of zero represents the last paragraph.
If empty paragraph is skipped, the empty paragraph won't be counted.
getParagraphByReverseIndex
in interface ParagraphContainer
reverseIndex
- - the index started from 0 in reverse order.isEmptyParagraphSkipped
- - whether the empty paragraph is skipped or not
public Iterator<Paragraph> getParagraphIterator()
ParagraphContainer
getParagraphIterator
in interface ParagraphContainer
public VariableField declareVariable(String name, VariableField.VariableType type)
VariableContainer
declareVariable
in interface VariableContainer
name
- the unique name of this variable field.type
- the type of this variable field.
public VariableField getVariableFieldByName(String name)
VariableContainer
getVariableFieldByName
in interface VariableContainer
name
- the unique name of this variable field.
public OdfElement getVariableContainerElement()
VariableContainer
The variable declare section may be
getVariableContainerElement
in interface VariableContainer
public Chart createChart(String title, DataSet dataset, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart title.dataset
- chart data set.rect
- chart rectangle.
public Chart createChart(String title, SpreadsheetDocument document, CellRangeAddressList cellRangeAddr, boolean firstRowAsLabel, boolean firstColumnAsLabel, boolean rowAsDataSeries, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart title.document
- the data source spreadsheet document.cellRangeAddr
- the cell range address list which is used as chart data set.firstRowAsLabel
- whether uses first row as label.firstColumnAsLabel
- whether uses first column as label.rowAsDataSeries
- whether uses data as series.rect
- chart rectangle.
public Chart createChart(String title, String[] labels, String[] legends, double[][] data, Rectangle rect)
ChartContainer
createChart
in interface ChartContainer
title
- chart rectangle.labels
- label stringslegends
- legend stringsdata
- chart data set.rect
- chart rectangle.
public void deleteChartById(String chartId)
ChartContainer
deleteChartById
in interface ChartContainer
chartId
- the id of specified chart.public void deleteChartByTitle(String title)
ChartContainer
deleteChartByTitle
in interface ChartContainer
title
- the title of specified chart(s).public Chart getChartById(String chartId)
ChartContainer
getChartById
in interface ChartContainer
chartId
- the id of this chart.
public List<Chart> getChartByTitle(String title)
ChartContainer
getChartByTitle
in interface ChartContainer
title
- the title of specified chart(s).
public int getChartCount()
ChartContainer
getChartCount
in interface ChartContainer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |