19 package org.openoffice.xmerge.converter.xml.sxc;
21 import java.io.IOException;
22 import java.util.Iterator;
32 import org.w3c.dom.Element;
33 import org.w3c.dom.Node;
34 import org.w3c.dom.NodeList;
59 private org.w3c.dom.Document
doc = null;
143 sxcDoc.initContentDOM();
144 sxcDoc.initSettingsDOM();
149 doc = sxcDoc.getContentDOM();
161 decoder =
createDecoder(workbookName, worksheetNames,
"password");
180 String fontTable[]=
new String[] {
"Tahoma",
"Tahoma",
"swiss",
"variable",
181 "Courier New",
"'Courier New'",
186 Node root = list.item(0);
188 for(
int i=0;
i<fontTable.length;) {
198 root.appendChild(tableElement);
208 protected void decode() throws IOException {
215 System.err.println(
"Error decoding invalid Input stream");
222 Node node = list.item(0);
224 for (
int i = 0;
i < numSheets;
i++) {
229 int len = list.getLength();
240 if(nameDefinitionTable.hasNext()) {
246 Node settingsNode = settingsList.item(0);
268 configItemMapIndexed.appendChild(configItemMapEntry);
269 configItemSetEntry.appendChild(configItemMapIndexed);
270 root.appendChild(configItemSetEntry);
289 while(eNameDefinitions.hasNext()) {
295 root.appendChild(namedExpressionsElement);
330 root.appendChild(tableElement);
366 if(result.length==0) {
368 cStyle.
setName(
"co" + colStyles++);
371 styleCat.
add(cStyle);
374 styleName = existingStyle.
getName();
385 root.appendChild(colElement);
405 Element rowElement = null;
408 Element cellElement = null;
421 Node autoStylesNode = null;
434 if (col <= lastColumn && rowElement != null) {
435 int numSkippedCells = lastColumn - col + 1;
445 int deltaRows = newRow - row;
468 if(result.length==0) {
470 rStyle.
setName(
"ro" + rowStyles++);
473 styleCat.
add(rStyle);
476 styleName = existingStyle.
getName();
485 root.appendChild(rowElement);
493 if (rowElement == null) {
505 int numColsSkipped = newCol - col;
532 autoStylesNode =
doc.getElementsByTagName(
535 if (autoStylesNode == null) {
537 doc.insertBefore(autoStylesNode, bodyNode);
545 if(result.length==0) {
547 tStyle.
setName(
"ce" + textStyles++);
550 styleCat.
add(tStyle);
553 styleName = existingStyle.
getName();
563 rowElement.appendChild(cellElement);
567 cellElement.appendChild(textElement);
568 textElement.appendChild(
doc.createTextNode(cellContents));
578 if (col <= lastColumn && rowElement != null) {
579 int numSkippedCells = lastColumn - col + 1;
584 if(autoStylesNode!=null) {
586 NodeList nl = styleCat.
writeNode(
doc,
"dummy").getChildNodes();
587 int nlLen = nl.getLength();
588 for (
int i = 0;
i < nlLen;
i++) {
589 autoStylesNode.appendChild(nl.item(0));
613 protected void addEmptyRows(
int numEmptyRows, Node root,
int numEmptyCells) {
624 Integer.toString(numEmptyRows));
627 root.appendChild(rowElement);
633 for (
int i = 0;
i < numEmptyRows;
i++) {
663 if (numColsSkipped > 1) {
667 Integer.toString(numColsSkipped));
671 row.appendChild(cellElement);
674 for (
int i = 0;
i < numColsSkipped;
i++) {
696 if (contents.startsWith(
"=")) {
723 contents.toLowerCase());
abstract String getCellContents()
Return the contents of the active cell.
void addEmptyRows(int numEmptyRows, Node root, int numEmptyCells)
This method will add empty rows to the.
abstract Format getCellFormat()
Return a.
void addEmptyCells(int numColsSkipped, Node row)
This method will add empty cells to the.
String CELLTYPE_STRING
The cell contains data of type string.
String ATTRIBUTE_TABLE_VALUE_TYPE
Attribute tag for table:value-type of element table:table-cell.
abstract int getNumberOfColumns()
Returns the number of populated columns in the current WorkSheet.
void setName(String newName)
Sets the name of this.
String TAG_TABLE
Element tag for table:table.
abstract Iterator< ColumnRowInfo > getColumnRowInfos()
Returns an Enumeration to a Vector of.
SpreadsheetDecoder decoder
A.
String ATTRIBUTE_TABLE_DATE_VALUE
Attribute tag for table:date-value of element table:table-cell.
String TAG_TABLE_ROW
Element tag for table:table-row.
String TAG_CONFIG_ITEM_MAP_INDEXED
Element tag for config:config-item-map-indexed.
abstract String[] getWorksheetNames(ConvertData cd)
This method will return the name of the WorkSheet from the.
abstract Iterator< NameDefinition > getNameDefinitions()
Returns an Enumeration to a Vector of.
Provides general purpose utilities.
void initFontTable()
This initializes a font table so we can include some basic font support for spreadsheets.
org.w3c.dom.Document doc
A w3c.
String TAG_STYLE_FONT_DECL
Element tag for style:font-decl.
void processCellData(Element cellElement, String type, String contents)
This method process the data in a cell and sets the appropriate attributes on the cell...
String ATTRIBUTE_TABLE_CURRENCY
Attribute tag for table:currency of element table:table-cell.
static void log(int flag, String msg)
Log message based on the flag type.
SxcDocumentDeserializer(ConvertData cd)
Constructor.
void processTable(Node root)
This method process a WorkSheet and generates a portion of the.
String TAG_CONFIG_ITEM_SET
Element tag for config:config-item-set.
org.w3c.dom.Document settings
A w3c.
String ATTRIBUTE_TABLE_STYLE_NAME
Attribute tag for table:style-name of table elements.
This is a class representing the different attributes for a worksheet contained in settings...
String ATTRIBUTE_STYLE_NAME
Attribute tag for style:name of element style:name.
int getSize()
Get the height (for rows) or width (for columns).
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types...
void decode()
Outer level method used to decode a WorkBook into a.
abstract String getWorkbookName(ConvertData cd)
This method will return the name of the WorkBook from the.
String ATTRIBUTE_TABLE_TIME_VALUE
Attribute tag for table:time-value of element table:table-cell.
String DEFAULT_STYLE
Name of the default style.
String TAG_TABLE_COLUMN
Element tag for table:table-column.
abstract void addDeviceContent(ConvertData cd)
Add the contents of a.
This is a class to define a Name Definition structure.
static final int TRACE
Trace messages.
Interface defining constants for Sxc attributes.
String TAG_OFFICE_FONT_DECLS
Element tag for office:font-decls.
String ATTRIBUTE_TABLE_NAME
Attribute tag for table:name of element table:table.
String CELLTYPE_BOOLEAN
The cell contains data of type boolean.
String ATTRIBUTE_TABLE_BOOLEAN_VALUE
Attribute tag for table:time-boolean-value of element table:table-cell.
String TAG_TABLE_CELL
Element tag for table:table-cell.
exports com.sun.star. java
abstract String getCellValue()
Return the value of the active cell.
abstract String getCellDataType()
Return the data type of the active cell.
String ATTRIBUTE_FO_FONT_FAMILY_GENERIC
Attribute tag for fo:font-family of element fo:font-family.
void add(Node node, String families[], Class<?> classes[], Class<?> defaultClass, boolean alwaysCreateDefault)
Parse the.
String TAG_PARAGRAPH
Element tag for text:p.
General spreadsheet implementation of.
String CELLTYPE_DATE
The cell contains data of type date.
String TAG_CONFIG_ITEM_MAP_ENTRY
Element tag for config:config-item-map-entry.
String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED
Attribute tag for table:number-rows-repeated of element table:table-row.
Document deserialize()
Method to convert a set of "Device".
abstract BookSettings getSettings()
Returns the.
String ATTRIBUTE_FO_FONT_FAMILY
Attribute tag for fo:font-family of element fo:font-family.
abstract SpreadsheetDecoder createDecoder(String workbook, String[] worksheetNames, String password)
This.
String TAG_OFFICE_AUTOMATIC_STYLES
Element tag for office:automatic-styles.
abstract String getSheetName()
Returns the name of the current WorkSheet.
String COLUMN_STYLE_FAMILY
Family name for column styles.
void writeNode(org.w3c.dom.Document doc, Node root)
Writes out a content.xml entry for this NameDefinition object.
String ATTRIBUTE_TABLE_VALUE
Attribute tag for table:value of element table:table-cell.
String TABLE_CELL_STYLE_FAMILY
Family name for table-cell styles.
This is a class to define a table-column structure.
String ROW_STYLE_FAMILY
Family name for row styles.
void processSettings(Node root)
This method process the settings portion of the.
void processNameDefinition(Node root, Iterator< NameDefinition > eNameDefinitions)
This method process a Name Definition Table and generates a portion of the.
String TAG_NAMED_EXPRESSIONS
Element tag for table:named-expression.
abstract int getRowNumber()
Returns the number of the active row.
String ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED
Attribute tag for table:number-columns-repeated of element table:table-cell.
String ATTRIBUTE_TABLE_FORMULA
Attribute tag for table:formula of element table:table-cell.
String ATTRIBUTE_CONFIG_NAME
Attribute tag for config:name of element config:config-item.
String CELLTYPE_PERCENT
The cell contains data of type percent.
String ATTRIBUTE_STYLE_FONT_PITCH
Attribute tag for style:font-pitch of element style:font-pitch.
boolean isColumn()
Does this.
String CELLTYPE_TIME
The cell contains data of type time.
boolean isRow()
Does this.
Provides interfaces for converting between two.
This class is used for logging debug messages.
void processCells(Node root)
This method process the cells in a.
int getRepeated()
Get the repeat count for this item.
void processColumns(Node root)
This method process the cells in a.
abstract int getNumberOfSheets()
Returns the total number of sheets in the WorkBook.
String TAG_OFFICE_BODY
Element tag for office:body.
Style[] getMatching(Style s)
Given a.
Element writeNode(org.w3c.dom.Document parentDoc, String name)
Create a.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a.
abstract int getColNumber()
Returns the number of the active column.
This class is an implementation of.
String CELLTYPE_CURRENCY
The cell contains data of type currency.
String TAG_OFFICE_SETTINGS
Element tag for office:settings.
abstract boolean goToNextCell()
Move on the next populated cell in the current WorkSheet.
abstract void setWorksheet(int sheetIndex)
Sets the active WorkSheet.
void writeNode(org.w3c.dom.Document settings, Node root)
Writes out a settings.xml entry for this.
String getName()
Returns the name of this.