19package org.openoffice.xmerge.converter.xml.sxc;
21import java.io.IOException;
22import java.util.ArrayList;
23import java.util.Iterator;
32import org.w3c.dom.Element;
33import org.w3c.dom.NamedNodeMap;
34import org.w3c.dom.Node;
35import org.w3c.dom.NodeList;
114 if (node.hasChildNodes()) {
116 NodeList nodeList = node.getChildNodes();
117 int len = nodeList.getLength();
118 for (
int i = 0;
i < len;
i++) {
119 Node child = nodeList.item(
i);
121 if (child.getNodeType() == Node.ELEMENT_NODE) {
122 String nodeName = child.getNodeName();
166 org.w3c.dom.Document contentDom = sxcDoc.getContentDOM();
168 if (nl.getLength() != 0) {
169 styleCat.
add(nl.item(0), families, classes,
null,
false);
172 org.w3c.dom.Document stylesDom = sxcDoc.getStyleDOM();
174 if (nl.getLength() != 0) {
175 styleCat.
add(nl.item(0), families, classes,
null,
false);
191 if (node.hasChildNodes()) {
193 NodeList nodeList = node.getChildNodes();
194 int len = nodeList.getLength();
196 for (
int i = 0;
i < len;
i++) {
197 Node searchNode = nodeList.item(
i);
198 if (searchNode.getNodeType() == Node.ELEMENT_NODE) {
200 String nodeName = searchNode.getNodeName();
213 for (
int i = 0;
i < len;
i++) {
214 Node child = nodeList.item(
i);
216 if (child.getNodeType() == Node.ELEMENT_NODE) {
217 String nodeName = child.getNodeName();
245 if (node.hasChildNodes()) {
247 NodeList nodeList = node.getChildNodes();
248 int len = nodeList.getLength();
250 for (
int i = 0;
i < len;
i++) {
251 Node child = nodeList.item(
i);
253 if (child.getNodeType() == Node.ELEMENT_NODE) {
279 NamedNodeMap att = node.getAttributes();
288 if (node.hasChildNodes()) {
290 NodeList nodeList = node.getChildNodes();
291 int len = nodeList.getLength();
293 for (
int i = 0;
i < len;
i++) {
294 Node child = nodeList.item(
i);
296 if (child.getNodeType() == Node.ELEMENT_NODE) {
297 String nodeName = child.getNodeName();
337 NamedNodeMap cellAtt = node.getAttributes();
339 if (cellAtt !=
null) {
345 int repeatedRows = 1;
347 if(tableNumRowRepeatingNode!=
null) {
348 String repeatStr = tableNumRowRepeatingNode.getNodeValue();
350 repeatedRows =
Integer.parseInt(repeatStr);
355 if ( rowStyle !=
null) {
356 styleName = rowStyle.getNodeValue();
358 if(styleName.equalsIgnoreCase(
"Default") || styleName.length()==0) {
368 int rowHeight = rStyle !=
null ? rStyle.
getRowHeight() : 0;
379 Node rowsRepeatedNode =
383 if (rowsRepeatedNode !=
null) {
385 String rowsRepeatedString = rowsRepeatedNode.getNodeValue();
395 if (node.hasChildNodes()) {
397 NodeList nodeList = node.getChildNodes();
398 int len = nodeList.getLength();
400 for (
int i = 0;
i < len;
i++) {
401 Node child = nodeList.item(
i);
403 if (child.getNodeType() == Node.ELEMENT_NODE) {
404 String nodeName = child.getNodeName();
448 NamedNodeMap cellAtt = node.getAttributes();
453 int repeatedColumns = 1;
457 if(tableNumColRepeatingNode!=
null) {
458 Debug.
log(
Debug.
TRACE,
"traverseColumn() repeated-cols : " + tableNumColRepeatingNode.getNodeValue());
459 repeatedColumns =
Integer.parseInt(tableNumColRepeatingNode.getNodeValue());
460 col.setRepeated(repeatedColumns);
463 String cellStyleName =
"";
465 if(tableDefaultCellStyle!=
null) {
466 cellStyleName = tableDefaultCellStyle.getNodeValue();
473 if(cellStyleName.equalsIgnoreCase(
"Default") || cellStyleName.length()==0) {
484 if (cellStyle !=
null) {
486 col.setFormat(defaultFmt);
491 if(tableStyleNode!=
null) {
492 styleName = tableStyleNode.getNodeValue();
495 if(styleName.equalsIgnoreCase(
"Default") || styleName.length()==0) {
505 columnWidth = cStyle !=
null ? cStyle.
getColWidth() : 0;
506 col.setSize(columnWidth);
522 NamedNodeMap cellAtt = node.getAttributes();
527 Node tableValueTypeNode =
531 Node colsRepeatedNode =
535 Node tableStyleNode =
540 if(tableStyleNode!=
null) {
541 styleName = tableStyleNode.getNodeValue();
546 if(styleName.equalsIgnoreCase(
"Default")) {
550 }
else if(styleName.length()!=0) {
557 if (cStyle !=
null) {
563 if (colsRepeatedNode !=
null) {
565 String colsRepeatedString = colsRepeatedNode.getNodeValue();
589 if (tableValueTypeNode !=
null) {
592 tableValueTypeNode.getNodeValue();
600 if(tableStringValueNode !=
null) {
675 if(tableFormulaNode !=
null)
677 if(tableValueTypeNode ==
null) {
682 String cellFormula = tableFormulaNode.getNodeValue();
689 "TextNode, DateNode, TimeNode or BooleanNode\n");
691 if (node.hasChildNodes()) {
692 NodeList childList = node.getChildNodes();
693 int len = childList.getLength();
695 for (
int i = 0;
i < len;
i++) {
696 Node child = childList.item(
i);
697 if (child.getNodeType() == Node.ELEMENT_NODE) {
698 String childName = child.getNodeName();
728 NamedNodeMap cellAtt = node.getAttributes();
731 Node debug_attrib =
null;
732 if (cellAtt ==
null || cellAtt.item(0) ==
null) {
735 while ((debug_attrib = cellAtt.item(debug_i++)) !=
null) {
737 ": " + debug_attrib.getNodeName() +
" : " +
738 debug_attrib.getNodeValue() +
"\n");
742 if (node.hasChildNodes()) {
744 NodeList nodeList = node.getChildNodes();
746 int len = nodeList.getLength();
748 StringBuffer buffer =
new StringBuffer();
750 for (
int i = 0;
i < len;
i++) {
752 Node child = nodeList.item(
i);
755 short nodeType = child.getNodeType();
760 buffer.append(child.getNodeValue());
763 case Node.ENTITY_REFERENCE_NODE:
765 NodeList nodeList2 = child.getChildNodes();
766 int len2 = nodeList2.getLength();
768 for (
int j = 0; j < len2; j++) {
769 Node child2 = nodeList2.item(j);
771 if (child2.getNodeType() == Node.TEXT_NODE) {
772 buffer.append(child2.getNodeValue());
780 String s = buffer.toString();
798 protected void addCell(String cellValue)
throws IOException {
847 Element element =
null;
850 if (node instanceof Element) {
851 element = (Element) node;
859 if (list.getLength() != 1) {
866 NodeList nodeList =
paragraph.getChildNodes();
867 int len = nodeList.getLength();
868 for (
int j = 0; j < len; j++) {
870 Node child = nodeList.item(j);
871 if (child.getNodeType() == Node.TEXT_NODE) {
873 String s = child.getNodeValue();
874 int k = s.lastIndexOf(
'.');
876 s = s.substring(k+1);
877 decimals = s.length();
ConvertData is used as a container for passing Document objects in and out of the Convert class.
This Exception is thrown by convert algorithms.
A StyleCatalog holds a collection of Style objects.
Style lookup(String name, String family, String parent, Class<?> styleClass)
Return the first Style matching the specified names.
void add(Node node, String families[], Class<?> classes[], Class<?> defaultClass, boolean alwaysCreateDefault)
Parse the Document starting from node and working downward, and add all styles found,...
This is a class representing the different attributes for a worksheet contained in settings....
Represents a text Style in an OpenOffice document.
Format getFormat()
Returns the Format object for this particular style.
This is a class to define a table-column structure.
Format getFormat()
Get the current Format.
int getRepeated()
Get the repeat count for this item.
boolean isColumn()
Does this ColumnRowInfo represent a column?
Represents a text Style in an OpenOffice document.
int getColWidth()
Returns the width of this column.
This is a class to define a Name Definition structure.
Represents a text Style in an OpenOffice document.
int getRowHeight()
Returns the height of this row.
This class is an abstract class for encoding an SXC into an alternative spreadsheet format.
abstract void setColumnRows(ArrayList< ColumnRowInfo > columnRows)
Set the width of the columns in the WorkBook.
abstract void addCell(int row, int column, Format fmt, String cellContents)
Add a cell to the current WorkSheet.
abstract void setNameDefinition(NameDefinition nd)
Set the name definition of this spreadsheet.
abstract void createWorksheet(String sheetName)
Create a new WorkSheet within the WorkBook.
abstract void addSettings(BookSettings s)
Adds settings to the WorkBook.
General spreadsheet implementation of DocumentSerializer for the SxcPluginFactory.
void traverseTableColumn(Node node)
This method traverses the table:table-column Node.
void addCell(String cellValue)
This method will take the input cell value and add it to the spreadsheet Document we are currently en...
void traverseSettings(Node node)
This method traverses office:settings Element.
void traverseBody(Node node)
This method traverses office:body Element.
void traverseNamedExpressions(Node node)
This method traverses the table:table element Node.
SpreadsheetEncoder encoder
A SpreadsheetEncoder object for encoding to appropriate format.
void loadStyles(SxcDocument sxcDoc)
Handles the loading of defined styles from the style.xml file as well as automatic styles from the co...
void traverseCell(Node node)
This method traverses a table:table-cell element Node.
int colsRepeated
The number of times the current column is repeated.
Format fmt
Format object describing the cell.
void traverseTable(Node node)
This method traverses the table:table element Node.
int colID
The column number.
int rowsRepeated
The number of times the current row is repeated.
void traverseTableRow(Node node)
This method traverses the table:table-row element Node.
SxcDocumentSerializer()
Constructor.
int getDecimalPlaces(Node node)
This method takes a table:table-cell Node and traverses down to the text:p tag.
abstract ConvertData serialize()
Method to convert a DOM Document into "Device" Document objects.
void traverseParagraph(Node node)
This method traverses the text:p element Node.
StyleCatalog styleCat
The number of times the current column is repeated.
ArrayList< ColumnRowInfo > ColumnRowList
An array of column widths of the current worksheet.
This class is an implementation of OfficeDocument for the SXC format.
This class is used for logging debug messages.
static final int INFO
Informational messages.
static final int TRACE
Trace messages.
static void log(int flag, String msg)
Log message based on the flag type.
Class containing static utility methods for handling XML trees.
static String getNodeInfo(Node node)
Returns the name and type of an XML DOM Node.
A DocumentSerializer represents a converter that converts a "Office" Document to a "Device" Document ...
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String ATTRIBUTE_DEFAULT_CELL_STYLE
Attribute tag for table:default-cell-style-name of element table:table-column.
String TAG_TABLE_CELL
Element tag for table:table-cell.
String ATTRIBUTE_TABLE_VALUE
Attribute tag for table:value of element table:table-cell.
String ATTRIBUTE_TABLE_VALUE_TYPE
Attribute tag for table:value-type of element table:table-cell.
String ATTRIBUTE_TABLE_STYLE_NAME
Attribute tag for table:style-name of table elements.
String ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED
Attribute tag for table:number-columns-repeated of element table:table-cell.
String TAG_TABLE_COLUMN
Element tag for table:table-column.
String TAG_TABLE
Element tag for table:table.
String CELLTYPE_CURRENCY
The cell contains data of type currency.
String TAG_CONFIG_ITEM_MAP_ENTRY
Element tag for config:config-item-map-entry.
String TAG_PARAGRAPH
Element tag for text:p.
String CELLTYPE_BOOLEAN
The cell contains data of type boolean.
String TAG_TABLE_SCENARIO
Element tag for table:scenario.
String ATTRIBUTE_TABLE_BOOLEAN_VALUE
Attribute tag for table:time-boolean-value of element table:table-cell.
String TAG_OFFICE_AUTOMATIC_STYLES
Element tag for office:automatic-styles.
String CELLTYPE_DATE
The cell contains data of type date.
String TAG_TABLE_ROW
Element tag for table:table-row.
String CELLTYPE_TIME
The cell contains data of type time.
String CELLTYPE_STRING
The cell contains data of type string.
String TAG_OFFICE_STYLES
Element tag for office:styles.
String ATTRIBUTE_TABLE_STRING_VALUE
Attribute tag for table:string-value of element table:table-cell.
String ATTRIBUTE_TABLE_FORMULA
Attribute tag for table:formula of element table:table-cell.
String ATTRIBUTE_TABLE_DATE_VALUE
Attribute tag for table:date-value of element table:table-cell.
String TAG_CONFIG_ITEM_MAP_INDEXED
Element tag for config:config-item-map-indexed.
String CELLTYPE_FLOAT
The cell contains data of type float.
String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED
Attribute tag for table:number-rows-repeated of element table:table-row.
String TAG_CONFIG_ITEM_SET
Element tag for config:config-item-set.
String ATTRIBUTE_TABLE_TIME_VALUE
Attribute tag for table:time-value of element table:table-cell.
String TAG_NAMED_EXPRESSIONS
Element tag for table:named-expression.
String CELLTYPE_PERCENT
The cell contains data of type percent.
String ATTRIBUTE_TABLE_NAME
Attribute tag for table:name of element table:table.
Interface defining constants for Sxc attributes.
String COLUMN_STYLE_FAMILY
Family name for column styles.
String TABLE_CELL_STYLE_FAMILY
Family name for table-cell styles.
String ROW_STYLE_FAMILY
Family name for row styles.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
RttiCompleteObjectLocator col
Document and PluginFactory implementations for XML based formats.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...