diff options
Diffstat (limited to 'xmerge/source/xmerge/java/org/openoffice/xmerge/converter')
43 files changed, 2030 insertions, 2697 deletions
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java index c7088a6f3a51..a2e67c08f4cf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java @@ -24,7 +24,6 @@ import java.io.StringWriter; import java.io.ByteArrayOutputStream; import java.io.IOException; - import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; @@ -41,17 +40,16 @@ import org.xml.sax.SAXException; import org.openoffice.xmerge.util.Debug; /** - * An implementation of <code>Document</code> for - * StarOffice documents. + * An implementation of {@code Document} for StarOffice documents. */ public class DOMDocument implements org.openoffice.xmerge.Document { - /** Factory for <code>DocumentBuilder</code> objects. */ + /** Factory for {@code DocumentBuilder} objects. */ private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - /** DOM <code>Document</code> of content.xml. */ + /** DOM {@code Document} of content.xml. */ private Document contentDoc = null; private String documentName = null; @@ -59,54 +57,50 @@ public class DOMDocument private String fileExt = null; /** - * Default constructor. + * Default constructor. * - * @param name <code>Document</code> name. - * @param ext <code>Document</code> extension. + * @param name {@code Document} name. + * @param ext {@code Document} extension. */ - public DOMDocument(String name,String ext) - { - this(name,ext,true, false); + public DOMDocument(String name,String ext) { + this(name,ext,true, false); } - /** - * Returns the file extension of the <code>Document</code> - * represented. + /** + * Returns the file extension of the {@code Document} represented. * - * @return file extension of the <code>Document</code>. + * @return file extension of the {@code Document}. */ private String getFileExtension() { return fileExt; } - /** - * Constructor with arguments to set <code>namespaceAware</code> - * and <code>validating</code> flags. + * Constructor with arguments to set {@code namespaceAware} and + * {@code validating} flags. * - * @param name <code>Document</code> name (may or may not - * contain extension). - * @param ext <code>Document</code> extension. - * @param namespaceAware Value for <code>namespaceAware</code> flag. - * @param validating Value for <code>validating</code> flag. + * @param name {@code Document} name (may or may not contain + * extension). + * @param ext {@code Document} extension. + * @param namespaceAware Value for {@code namespaceAware} flag. + * @param validating Value for {@code validating} flag. */ - private DOMDocument(String name, String ext,boolean namespaceAware, boolean validating) { + private DOMDocument(String name, String ext,boolean namespaceAware, + boolean validating) { factory.setValidating(validating); factory.setNamespaceAware(namespaceAware); this.fileExt = ext; - this.documentName = trimDocumentName(name); + this.documentName = trimDocumentName(name); this.fileName = documentName + getFileExtension(); } - /** - * Removes the file extension from the <code>Document</code> - * name. + * Removes the file extension from the {@code Document} name. * - * @param name Full <code>Document</code> name with extension. + * @param name Full {@code Document} name with extension. * - * @return Name of <code>Document</code> without the extension. + * @return Name of {@code Document} without the extension. */ private String trimDocumentName(String name) { String temp = name.toLowerCase(); @@ -122,15 +116,15 @@ public class DOMDocument return name; } - /** - * Return a DOM <code>Document</code> object of the document content - * file. Note that a content DOM is not created when the constructor - * is called. So, either the <code>read</code> method or the - * <code>initContentDOM</code> method will need to be called ahead - * on this object before calling this method. + * Return a DOM {@code Document} object of the document content file. + * + * <p>Note that a content DOM is not created when the constructor is called. + * So, either the {@code read} method or the {@code initContentDOM} method + * will need to be called ahead on this object before calling this method. + * </p> * - * @return DOM <code>Document</code> object. + * @return DOM {@code Document} object. */ public Document getContentDOM() { @@ -138,46 +132,42 @@ public class DOMDocument } /** - * Sets the Content of the <code>Document</code> to the contents of the - * supplied <code>Node</code> list. + * Sets the Content of the {@code Document} to the contents of the supplied + * {@code Node} list. * - * @param newDom DOM <code>Document</code> object. + * @param newDom DOM {@code Document} object. */ public void setContentDOM( Node newDom) { contentDoc=(Document)newDom; } - /** - * Return the name of the <code>Document</code>. + * Return the name of the {@code Document}. * - * @return The name of <code>Document</code>. + * @return The name of {@code Document}. */ public String getName() { return documentName; } - /** - * Return the file name of the <code>Document</code>, possibly - * with the standard extension. + * Return the file name of the {@code Document}, possibly with the standard + * extension. * - * @return The file name of <code>Document</code>. + * @return The file name of {@code Document}. */ public String getFileName() { return fileName; } - /** - * Read the Office <code>Document</code> from the specified - * <code>InputStream</code>. + * Read the Office {@code Document} from the specified {@code InputStream}. * - * @param is Office document <code>InputStream</code>. + * @param is Office document {@code InputStream}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void read(InputStream is) throws IOException { Debug.log(Debug.INFO, "reading file"); @@ -185,19 +175,18 @@ public class DOMDocument DocumentBuilder builder = factory.newDocumentBuilder(); contentDoc = builder.parse(is); } catch (ParserConfigurationException ex) { - System.out.println("Error:"+ ex); + System.out.println("Error:"+ ex); } catch (SAXException ex) { - System.out.println("Error:"+ ex); + System.out.println("Error:"+ ex); } } - /** - * Write out content to the supplied <code>OutputStream</code>. + * Write out content to the supplied {@code OutputStream}. * - * @param os XML <code>OutputStream</code>. + * @param os XML {@code OutputStream}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(OutputStream os) throws IOException { @@ -207,20 +196,17 @@ public class DOMDocument os.write(contentBytes); } - /** - * <p>Write out a <code>org.w3c.dom.Document</code> object into a - * <code>byte</code> array.</p> + * Write out a {@code org.w3c.dom.Document} object into a {@code byte} array. * - * <p>TODO: remove dependency on com.sun.xml.tree.XmlDocument - * package!</p> + * <p>TODO: remove dependency on {@code com.sun.xml.tree.XmlDocument} package! + * </p> * - * @param doc DOM <code>Document</code> object. + * @param doc DOM {@code Document} object. * - * @return <code>byte</code> array of DOM <code>Document</code> - * object. + * @return {@code byte} array of DOM {@code Document} object. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ private byte[] docToBytes(Document doc) throws IOException { @@ -248,83 +234,71 @@ public class DOMDocument // The method is in the XMLDocument class itself, not a helper meth = jaxpDoc.getMethod("write", - new Class[] { Class.forName("java.io.OutputStream") } ); + new Class[]{Class.forName("java.io.OutputStream")}); - meth.invoke(doc, new Object [] { baos } ); - } - else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) - { - System.out.println("Using Crimson"); - Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); - // The method is in the XMLDocument class itself, not a helper + meth.invoke(doc, new Object[]{baos}); + } else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) { + System.out.println("Using Crimson"); + Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); + // The method is in the XMLDocument class itself, not a helper meth = crimsonDoc.getMethod("write", - new Class[] { Class.forName("java.io.OutputStream") } ); + new Class[]{Class.forName("java.io.OutputStream")}); - meth.invoke(doc, new Object [] { baos } ); - } - else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") - || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { + meth.invoke(doc, new Object[]{baos}); + } else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") + || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { System.out.println("Using Xerces"); // Try for Xerces - Class<?> xercesSer = - Class.forName("org.apache.xml.serialize.XMLSerializer"); + Class<?> xercesSer + = Class.forName("org.apache.xml.serialize.XMLSerializer"); // Get the OutputStream constructor // May want to use the OutputFormat parameter at some stage too - con = xercesSer.getConstructor(new Class [] - { Class.forName("java.io.OutputStream"), - Class.forName("org.apache.xml.serialize.OutputFormat") } ); - + con = xercesSer.getConstructor(new Class[]{Class.forName("java.io.OutputStream"), + Class.forName("org.apache.xml.serialize.OutputFormat")}); // Get the serialize method meth = xercesSer.getMethod("serialize", - new Class [] { Class.forName("org.w3c.dom.Document") } ); - + new Class[]{Class.forName("org.w3c.dom.Document")}); // Get an instance - Object serializer = con.newInstance(new Object [] { baos, null } ); - + Object serializer = con.newInstance(new Object[]{baos, null}); // Now call serialize to write the document - meth.invoke(serializer, new Object [] { doc } ); - } - else if (domImpl.equals("gnu.xml.dom.DomDocument")) { + meth.invoke(serializer, new Object[]{doc}); + } else if (domImpl.equals("gnu.xml.dom.DomDocument")) { System.out.println("Using GNU"); Class<?> gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); // Get the serialize method meth = gnuSer.getMethod("serialize", - new Class [] { Class.forName("org.w3c.dom.Node"), - Class.forName("java.io.OutputStream") } ); + new Class[]{Class.forName("org.w3c.dom.Node"), + Class.forName("java.io.OutputStream")}); // Get an instance Object serializer = gnuSer.newInstance(); // Now call serialize to write the document - meth.invoke(serializer, new Object [] { doc, baos } ); - } - else { + meth.invoke(serializer, new Object[]{doc, baos}); + } else { // We dont have another parser try { - DOMSource domSource = new DOMSource(doc); - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.transform(domSource, result); - return writer.toString().getBytes(); - } - catch (Exception e) { + DOMSource domSource = new DOMSource(doc); + StringWriter writer = new StringWriter(); + StreamResult result = new StreamResult(writer); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.transform(domSource, result); + return writer.toString().getBytes(); + } catch (Exception e) { // We don't have another parser throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); } } - } - catch (ClassNotFoundException cnfe) { + } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe.toString()); - } - catch (Exception e) { + } catch (Exception e) { // We may get some other errors, but the bottom line is that // the steps being executed no longer work throw new IOException(e.toString()); @@ -334,9 +308,4 @@ public class DOMDocument return bytes; } - -} - - - - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java index 643cd64bcdd7..765c6f86569c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java @@ -21,139 +21,130 @@ package org.openoffice.xmerge.converter.palm; import java.io.UnsupportedEncodingException; /** - * <p>This class contains data for a single Palm database for use during - * a conversion process.</p> + * This class contains data for a single Palm database for use during a + * conversion process. * - * <p>It contains zero or more <code>Record</code> objects stored in an - * array. The index of the <code>Record</code> object in the array is - * the <code>Record</code> id or number for that specific <code>Record</code> object. - * Note that this class does not check for maximum number of Records - * allowable in an actual PDB.</p> + * <p>It contains zero or more {@code Record} objects stored in an array. The + * index of the {@code Record} object in the array is the {@code Record} id or + * number for that specific {@code Record} object. Note that this class does + * not check for maximum number of Records allowable in an actual PDB.</p> * - * <p>This class also contains the PDB name associated with the Palm - * database it represents. A PDB name consists of 32 bytes of a - * certain encoding (extended ASCII in this case).</p> + * <p>This class also contains the PDB name associated with the Palm database + * it represents. A PDB name consists of 32 bytes of a certain encoding + * (extended ASCII in this case).</p> * - * <p>The non default constructors take in a name parameter which may not - * be the exact PDB name to be used. The name parameter in - * <code>String</code> or <code>byte</code> array are converted to an exact - * <code>NAME_LENGTH</code> byte array. If the length of the name is less - * than <code>NAME_LENGTH</code>, it is padded with '\0' characters. If it - * is more, it gets truncated. The last character in the resulting byte - * array is always a '\0' character. The resulting byte array is stored in - * <code>bName</code>, and a corresponding String object <code>sName</code> - * that contains characters without the '\0' characters.</p> + * <p>The non default constructors take in a name parameter which may not be + * the exact PDB name to be used. The name parameter in {@code String} or + * {@code byte} array are converted to an exact {@code NAME_LENGTH} byte array. + * If the length of the name is less than {@code NAME_LENGTH}, it is padded + * with {@code '\0'} characters. If it is more, it gets truncated. The last + * character in the resulting byte array is always a {@code '\0'} character. + * The resulting byte array is stored in {@code bName}, and a corresponding + * {@code String} object {@code sName} that contains characters without the + * {@code '\0'} characters.</p> * - * <p>The <code>write</code> method is called within the - * {@link org.openoffice.xmerge.converter.palm.PalmDocument#write - * PalmDocument.write} method for writing out its data to the <code>OutputStream</code> - * object.</p> + * <p>The {@code write} method is called within the {@link + * org.openoffice.xmerge.converter.palm.PalmDocument#write + * PalmDocument.write} method for writing out its data to the + * {@code OutputStream} object.</p> * - * <p>The <code>read</code> method is called within the - * {@link org.openoffice.xmerge.converter.palm.PalmDocument#read - * PalmDocument.read} method for reading in its data from the <code>InputStream</code> - * object.</p> + * <p>The {@code read} method is called within the {@link + * org.openoffice.xmerge.converter.palm.PalmDocument#read PalmDocument.read} + * method for reading in its data from the {@code InputStream} object.</p> * - * @see PalmDocument - * @see Record + * @see PalmDocument + * @see Record */ public final class PalmDB { - - - /** Number of bytes for the name field in the PDB. */ + /** Number of bytes for the name field in the PDB. */ public final static int NAME_LENGTH = 32; - /** List of <code>Record</code> objects. */ + /** List of {@code Record} objects. */ private Record[] records; - /** PDB name in bytes. */ + /** PDB name in bytes. */ private byte[] bName = null; - /** PDB name in String. */ + /** PDB name in String. */ private String sName = null; - /** Creator ID. */ + /** Creator ID. */ private int creatorID = 0; - /** Type ID */ + /** Type ID */ private int typeID = 0; /** - * PDB version. Palm UInt16. - * It is treated as a number here, since there is no unsigned 16 bit - * in Java, int is used instead, but only 2 bytes are written out or - * read in. + * PDB version. Palm UInt16. + * It is treated as a number here, since there is no unsigned 16 bit in Java, + * {@code int} is used instead, but only 2 bytes are written out or read in. */ private int version = 0; /** - * PDB attribute - flags for the database. - * Palm UInt16. Unsignedness should be irrelevant. + * PDB attribute - flags for the database. + * Palm UInt16. Unsignedness should be irrelevant. */ private short attribute = 0; - /** - * Default constructor. + * Default constructor. * - * @param creatorID The PDB Creator ID. - * @param typeID The PDB Type ID. - * @param version The PDB header version. - * @param attribute The PDB header attribute. + * @param creatorID The PDB Creator ID. + * @param typeID The PDB Type ID. + * @param version The PDB header version. + * @param attribute The PDB header attribute. */ public PalmDB(int creatorID, int typeID, int version, short attribute) { - records = new Record[0]; setAttributes(creatorID, typeID, version, attribute); } - /** - * Constructor to create <code>PalmDB</code> object with - * <code>Record</code> objects. <code>recs.length</code> - * can be zero for an empty PDB. + * Constructor to create {@code PalmDB} object with {@code Record} objects. + * + * <p>{@code recs.length} can be zero for an empty PDB.</p> * - * @param name Suggested PDB name in a <code>String</code>. - * @param creatorID The PDB Creator ID. - * @param typeID The PDB Type ID. - * @param version The PDB header version. - * @param attribute The PDB header attribute. - * @param recs Array of <code>Record</code> objects. + * @param name Suggested PDB name in a {@code String}. + * @param creatorID The PDB Creator ID. + * @param typeID The PDB Type ID. + * @param version The PDB header version. + * @param attribute The PDB header attribute. + * @param recs Array of {@code Record} objects. * - * @throws UnsupportedEncodingException If <code>name</code> is - * not properly encoded. - * @throws NullPointerException If <code>recs</code> is null. + * @throws UnsupportedEncodingException If {@code name} is not properly + * encoded. + * @throws NullPointerException If {@code recs} is {@code null}. */ public PalmDB(String name, int creatorID, int typeID, int version, - short attribute, Record[] recs) - throws UnsupportedEncodingException { + short attribute, Record[] recs) + throws UnsupportedEncodingException { this(name.getBytes(PdbUtil.ENCODING), creatorID, typeID, version, attribute, recs); } - /** - * Constructor to create object with <code>Record</code> - * objects. <code>recs.length</code> can be zero for an - * empty PDB. + * Constructor to create object with {@code Record} objects. + * + * <p>{@code recs.length} can be zero for an empty PDB.</p> * - * @param name Suggested PDB name in a <code>byte</code> - * array. - * @param creatorID The PDB Creator ID. - * @param typeID The PDB Type ID. - * @param version The PDB header version. - * @param attribute The PDB header attribute. - * @param recs Array of <code>Record</code> objects. + * @param name Suggested PDB name in a {@code byte} array. + * @param creatorID The PDB Creator ID. + * @param typeID The PDB Type ID. + * @param version The PDB header version. + * @param attribute The PDB header attribute. + * @param recs Array of {@code Record} objects. * - * @throws UnsupportedEncodingException If <code>name</code> is - * not properly encoded. - * @throws NullPointerException If recs is null. + * @throws UnsupportedEncodingException If {@code name} is not properly + * encoded. + * @throws NullPointerException If {@code recs} is {@code null}. */ public PalmDB(byte[] name, int creatorID, int typeID, int version, - short attribute, Record[] recs) throws UnsupportedEncodingException { + short attribute, Record[] recs) + throws UnsupportedEncodingException { store(name); @@ -162,36 +153,35 @@ public final class PalmDB { setAttributes(creatorID, typeID, version, attribute); } - /** - * Set the attributes for the <code>PalmDB</code> object. + * Set the attributes for the {@code PalmDB} object. * - * @param creatorID The PDB Creator ID. - * @param typeID The PDB Type ID. - * @param version The PDB header version. - * @param attribute The PDB header attribute. + * @param creatorID The PDB Creator ID. + * @param typeID The PDB Type ID. + * @param version The PDB header version. + * @param attribute The PDB header attribute. */ - private void setAttributes (int creatorID, int typeID, int version, short attribute) { + private void setAttributes (int creatorID, int typeID, int version, + short attribute) { this.creatorID = creatorID; this.typeID = typeID; this.version = version; this.attribute = attribute; } - /** - * This private method is mainly used by the constructors above. - * to store bytes into name and also create a <code>String</code> - * representation. and also by the <code>read</code> method. + * This private method is mainly used by the constructors above. + * + * <p>to store bytes into name and also create a {@code String} + * representation, and also by the {@code read} method.</p> * - * TODO: Note that this method assumes that the <code>byte</code> - * array parameter contains one character per <code>byte</code>, - * else it would truncate improperly. + * <p>TODO: Note that this method assumes that the {@code byte} array + * parameter contains one character per {@code byte}, else it would + * truncate improperly.</p> * - * @param bytes PDB name in <code>byte</code> array. + * @param bytes PDB name in {@code byte<} array. * - * @throws UnsupportedEncodingException If ENCODING is - * not supported. + * @throws UnsupportedEncodingException If ENCODING is not supported. */ private void store(byte[] bytes) throws UnsupportedEncodingException { @@ -202,11 +192,9 @@ public final class PalmDB { // Note that the last byte in bName has to be '\0'. int lastIndex = NAME_LENGTH - 1; - int len = (bytes.length < lastIndex)? bytes.length: lastIndex; int i; - for (i = 0; i < len; i++) { if (bytes[i] == 0) { @@ -220,130 +208,105 @@ public final class PalmDB { sName = new String(bName, 0, i, PdbUtil.ENCODING); } - /** - * Returns creator ID. + * Returns creator ID. * - * @return The creator ID. + * @return The creator ID. */ public int getCreatorID() { - return creatorID; } - /** - * Returns type ID. + * Returns type ID. * - * @return The type ID. + * @return The type ID. */ public int getTypeID() { - return typeID; } - /** - * Returns attribute flag. + * Returns attribute flag. * - * @return The attribute flag. + * @return The attribute flag. */ public short getAttribute() { - return attribute; } - /** - * Returns version. + * Returns version. * - * @return The version. + * @return The version. */ public int getVersion() { - return version; } - /** - * Return the number of Records contained in this - * PDB <code>PalmDB</code> object. + * Return the number of Records contained in this PDB {@code PalmDB} object. * - * @return Number of <code>Record</code> objects. + * @return Number of {@code Record} objects. */ public int getRecordCount() { - return records.length; } - /** - * Return the specific <code>Record</code> object associated - * with the <code>Record</code> number. + * Return the specific {@code Record} object associated with the + * {@code Record} number. * - * @param index <code>Record</code> index number. + * @param index {@code Record} index number. * - * @return The <code>Record</code> object in the specified index + * @return The {@code Record} object in the specified index * - * @throws ArrayIndexOutOfBoundsException If index is out of bounds. + * @throws ArrayIndexOutOfBoundsException If index is out of bounds. */ public Record getRecord(int index) { - return records[index]; } - /** - * Return the list of <code>Record</code> objects. + * Return the list of {@code Record} objects. * - * @return The array of <code>Record</code> objects. + * @return The array of {@code Record} objects. */ public Record[] getRecords() { - return records; } /** - * Return the PDB name associated with this object. + * Return the PDB name associated with this object. * - * @return The PDB name. + * @return The PDB name. */ public String getPDBNameString() { - return sName; } - /** - * Return the PDB name associated with this object in - * <code>byte</code> array of exact length of 32 bytes. + * Return the PDB name associated with this object in {@code byte} array of + * exact length of 32 bytes. * - * @return The PDB name in <code>byte</code> array of - * length 32. + * @return The PDB name in {@code byte} array of length 32. */ public byte[] getPDBNameBytes() { - return bName; } - - - - - /** - * Override equals method of <code>Object</code>. + * Override equals method of {@code Object}. * - * Two <code>PalmDB</code> objects are equal if they contain - * the same information, i.e. PDB name and Records. + * <p>Two {@code PalmDB} objects are equal if they contain the same + * information, i.e. PDB name and Records.</p> * - * This is used primarily for testing purposes only for now. + * <p>This is used primarily for testing purposes only for now.</p> * - * @param obj A <code>PalmDB</code> <code>Object</code> to - * compare. + * @param obj A {@code PalmDB} {@code Object} to compare. * - * @return true if <code>obj</code> is equal to this, otherwise - * false. + * @return {@code true} if {@code obj} is equal to this, otherwise + * {@code false}. */ @Override public boolean equals(Object obj) { @@ -357,38 +320,26 @@ public final class PalmDB { checkLabel: { // compare sName - if (!sName.equals(pdb.sName)) { - break checkLabel; } // compare bName - if (bName.length != pdb.bName.length) { - break checkLabel; } - for (int i = 0; i < bName.length; i++) { - if (bName[i] != pdb.bName[i]) { - break checkLabel; } } // compare each Record - if (records.length != pdb.records.length) { - break checkLabel; } - for (int i = 0; i < records.length; i++) { - if (!records[i].equals(pdb.records[i])) { - break checkLabel; } } @@ -400,5 +351,4 @@ public final class PalmDB { return bool; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java index 82977ea21ee3..b7fb67bcf886 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDocument.java @@ -28,54 +28,45 @@ import java.io.UnsupportedEncodingException; import org.openoffice.xmerge.Document; /** - * <p> A <code>PalmDocument</code> is palm implementaion of the - * <code>Document</code> interface.</p> - * - * <p>This implementation allows the Palm device format to be - * read via an <code>InputStream</code> and written via an - * <code>OutputStream</code>.</p> + * A {@code PalmDocument} is palm implementation of the {@code Document} + * interface. * + * <p>This implementation allows the Palm device format to be read via an + * {@code InputStream} and written via an {@code OutputStream}.</p> */ - public class PalmDocument implements Document { - /** - * The internal representation of a pdb. - */ + /** The internal representation of a pdb. */ private PalmDB pdb; - /** - * The file name. - */ + /** The file name. */ private String fileName; /** - * Constructor to create a <code>PalmDocument</code> - * from an <code>InputStream</code>. + * Constructor to create a {@code PalmDocument} from an {@code InputStream}. * - * @param is <code>InputStream</code> containing a PDB. + * @param is {@code InputStream} containing a PDB. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public PalmDocument(InputStream is) throws IOException { read(is); } - /** - * Constructor to create a <code>PalmDocument</code> with - * <code>Record</code> objects. <code>recs.length</code> - * can be zero for an empty PDB. + * Constructor to create a {@code PalmDocument} with {@code Record} objects. + * + * <p>{@code recs.length} can be zero for an empty PDB.</p> * - * @param name Suggested PDB name in <code>String</code>. - * @param creatorID The PDB Creator ID. - * @param typeID The PDB Type ID. - * @param version The PDB header version. - * @param attribute The PDB header attribute. - * @param recs Array of <code>Record</code> objects. + * @param name Suggested PDB name in {@code String}. + * @param creatorID The PDB Creator ID. + * @param typeID The PDB Type ID. + * @param version The PDB header version. + * @param attribute The PDB header attribute. + * @param recs Array of {@code Record} objects. * - * @throws NullPointerException If <code>recs</code> is null. + * @throws NullPointerException If {@code recs} is {@code null}. */ public PalmDocument(String name, int creatorID, int typeID, int version, short attribute, Record[] recs) @@ -84,15 +75,13 @@ public class PalmDocument fileName = pdb.getPDBNameString(); } - /** - * Reads in a file from the <code>InputStream</code>. + * Reads in a file from the {@code InputStream}. * - * @param is <code>InputStream</code> to read in its content. + * @param is {@code InputStream} to read in its content. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ - public void read(InputStream is) throws IOException { PdbDecoder decoder = new PdbDecoder(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -106,35 +95,31 @@ public class PalmDocument fileName = pdb.getPDBNameString(); } - /** - * Writes the <code>PalmDocument</code> to an <code>OutputStream</code>. + * Writes the {@code PalmDocument} to an {@code OutputStream}. * - * @param os The <code>OutputStream</code> to write the content. + * @param os The {@code OutputStream} to write the content. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(OutputStream os) throws IOException { PdbEncoder encoder = new PdbEncoder(pdb); encoder.write(os); } - /** - * Returns the <code>PalmDB</code> contained in this object. + * Returns the {@code PalmDB} contained in this object. * - * @return The <code>PalmDB</code>. + * @return The {@code PalmDB}. */ public PalmDB getPdb() { return pdb; } - /** - * Sets the <code>PalmDocument</code> to a new <code>PalmDB</code> - * value. + * Sets the {@code PalmDocument} to a new {@code PalmDB} value. * - * @param pdb The new <code>PalmDB</code> value. + * @param pdb The new {@code PalmDB} value. */ public void setPdb(PalmDB pdb) { this.pdb = pdb; @@ -143,25 +128,21 @@ public class PalmDocument fileName = name; } - /** - * Returns the name of the file. + * Returns the name of the file. * - * @return The name of the file represented in the - * <code>PalmDocument</code>. + * @return The name of the file represented in the {@code PalmDocument}. */ public String getFileName() { return fileName + ".pdb"; } - /** - * Returns the <code>Document</code> name. + * Returns the {@code Document} name. * - * @return The <code>Document</code> name. + * @return The {@code Document} name. */ public String getName() { return fileName; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java index 02143e789cb5..bbd892a2f2d2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java @@ -23,63 +23,53 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; /** - * <p>Provides functionality to decode a PDB formatted file into - * a <code>PalmDB</code> object given an <code>InputStream</code>. - * This class is only used by the <code>PalmDB</code> object.</p> + * Provides functionality to decode a PDB formatted file into a {@code PalmDB} + * object given an {@code InputStream}. * - * <p>Sample usage:</p> + * <p>This class is only used by the {@code PalmDB} object.</p> * - * <blockquote><pre><code> - * PdbDecoder decoder = new PdbDecoder("sample.pdb"); - * PalmDB palmDB = decoder.parse(); - * </code></pre></blockquote> + * <p>Sample usage:</p> + * <blockquote><pre>{@code PdbDecoder decoder = new PdbDecoder("sample.pdb"); + * PalmDB palmDB = decoder.parse();}</pre></blockquote> * - * <p>This decoder has the following assumptions on the PDB file:</p> + * <p>This decoder has the following assumptions on the PDB file:</p> + * <ol> + * <li>There is only one RecordList section in the PDB.</li> + * <li>The {@code Record} indices in the RecordList are sorted in order, i.e. + * the first {@code Record} index refers to {@code Record} 0, and so + * forth.</li> + * <li>The raw {@code Record} in the {@code Record} section are sorted as + * well in order, i.e. first {@code Record} comes ahead of second + * {@code Record}, etc.</li> + * </ol> * - * <ol> - * <li>There is only one RecordList section in the PDB.</li> - * <li>The <code>Record</code> indices in the RecordList are sorted in - * order, i.e. the first <code>Record</code> index refers to - * <code>Record</code> 0, and so forth.</li> - * <li>The raw <code>Record</code> in the <code>Record</code> section - * are sorted as well in order, i.e. first <code>Record</code> - * comes ahead of second <code>Record</code>, etc.</li> - * </ol> + * <p>Other decoders assume these as well.</p> * - * <p>Other decoders assume these as well.</p> - * - * @see PalmDB - * @see Record + * @see PalmDB + * @see Record */ public final class PdbDecoder { - - - /** - * <p>This method decodes a PDB file into a <code>PalmDB</code> - * object.</p> + * This method decodes a PDB file into a {@code PalmDB} object. * - * <p>First, the header data is read using the <code>PdbHeader</code> - * <code>read</code> method. Next, the RecordList section is - * read and the <code>Record</code> offsets are stored for use when - * parsing the Records. Based on these offsets, the bytes - * corresponding to each <code>Record</code> are read and each is - * stored in a <code>Record</code> object. Lastly, the data is - * used to create a <code>PalmDB</code> object.</p> + * <p>First, the header data is read using the {@code PdbHeader.read} + * method. Next, the RecordList section is read and the {@code Record} + * offsets are stored for use when parsing the Records. Based on these + * offsets, the bytes corresponding to each {@code Record} are read and + * each is stored in a {@code Record} object. Lastly, the data is used + * to create a {@code PalmDB} object.</p> * - * @param b <code>byte[]</code> containing PDB. + * @param b {@code byte[]} containing PDB. * - * @throws IOException If I/O error occurs. + * @throws IOException If I/O error occurs. */ - public PalmDB parse(byte[] b) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(b); DataInputStream dis = new DataInputStream(bais); // read the PDB header - PdbHeader header = new PdbHeader(); header.read(dis); @@ -87,7 +77,6 @@ public final class PdbDecoder { if (header.numRecords != 0) { // read in the record indices + offsets - int recOffset[] = new int[header.numRecords]; byte recAttrs[] = new byte[header.numRecords]; @@ -97,20 +86,18 @@ public final class PdbDecoder { // read in attributes (1 byte) + unique id (3 bytes) // take away the unique id, store the attributes - int attr = dis.readInt(); recAttrs[i] = (byte) (attr >>> 24); } // read the records - int lastIndex = header.numRecords - 1; for (int i = 0; i < lastIndex; i++) { //dis.seek(recOffset[i]); - dis.reset(); - dis.skip(recOffset[i]); + dis.reset(); + dis.skip(recOffset[i]); int len = recOffset[i+1] - recOffset[i]; byte[] bytes = new byte[len]; dis.readFully(bytes); @@ -118,26 +105,18 @@ public final class PdbDecoder { } // last record - dis.reset(); - int len = dis.available() - recOffset[lastIndex]; - dis.skip(recOffset[lastIndex]); - byte[] bytes = new byte[len]; + int len = dis.available() - recOffset[lastIndex]; + dis.skip(recOffset[lastIndex]); + byte[] bytes = new byte[len]; dis.readFully(bytes); recArray[lastIndex] = new Record(bytes, recAttrs[lastIndex]); } - - // create PalmDB and return it - PalmDB pdb = new PalmDB(header.pdbName, header.creatorID, header.typeID, header.version, header.attribute, recArray); return pdb; } - - - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java index 83f8a27f423d..f3f68045afe4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java @@ -25,48 +25,43 @@ import java.io.IOException; import java.util.Date; /** - * <p>Provides functionality to encode a <code>PalmDB</code> object - * into a PDB formatted file given a file <code>OutputStream</code>. - * This class is only used by the <code>PalmDB</code> object.</p> + * Provides functionality to encode a {@code PalmDB} object into a PDB + * formatted file given a file {@code OutputStream}. * - * <p>One needs to create one <code>PdbEncoder</code> object per - * <code>PalmDB</code> object to be encoded. This class keeps - * the PDB header data and functionality in the <code>PdbHeader</code> - * class.</p> + * <p>This class is only used by the {@code PalmDB} object.</p> * - * <p>Sample usage:</p> + * <p>One needs to create one {@code PdbEncoder} object per {@code PalmDB} + * object to be encoded. This class keeps the PDB header data and functionality + * in the {@code PdbHeader} class.</p> * - * <blockquote><pre><code> - * PdbEncoder encoder = new PdbEncoder(palmDB, "STRW", "data"); - * encoder.write(new FileOutputStream("sample.pdb")); - * </code></pre></blockquote> + * <p>Sample usage:</p> + * <blockquote><pre>{@code PdbEncoder encoder = new PdbEncoder(palmDB, "STRW", "data"); + * encoder.write(new FileOutputStream("sample.pdb"));}</pre></blockquote> * - * @see PalmDB - * @see Record + * @see PalmDB + * @see Record */ public final class PdbEncoder { - /** PDB header. */ + /** PDB header. */ private PdbHeader header = null; - /** the PalmDB object. */ + /** the PalmDB object. */ private PalmDB db = null; - /** - * The pattern for unique_id=0x00BABE(start). - */ + /** The pattern for unique_id=0x00BABE(start). */ private final static int START_UNIQUE_ID = 0x00BABE; /** - * Constructor. + * Constructor. * - * @param db The <code>PalmDB</code> to be encoded. + * @param db The {@code PalmDB} to be encoded. */ public PdbEncoder(PalmDB db) { header = new PdbHeader(); - header.version = db.getVersion(); + header.version = db.getVersion(); header.attribute = db.getAttribute(); @@ -84,33 +79,29 @@ public final class PdbEncoder { header.numRecords = db.getRecordCount(); } - /** - * Write out a PDB into the given <code>OutputStream</code>. + * Write out a PDB into the given {@code OutputStream}. * - * <p>First, write out the header data by using the - * <code>PdbHeader</code> <code>write</code> method. Next, - * calculate the RecordList section and write it out. - * Lastly, write out the bytes corresponding to each - * <code>Record</code>.</p> + * <p>First, write out the header data by using the {@code PdbHeader.write} + * method. Next, calculate the RecordList section and write it out. Lastly, + * write out the bytes corresponding to each {@code Record}.</p> * - * <p>The RecordList section contains a list of - * <code>Record</code> index info, where each <code>Record</code> - * index info contains:</p> + * <p>The RecordList section contains a list of {@code Record} index info, + * where each {@code Record} index info contains:</p> * - * <ul> - * <li>4 bytes local offset of the <code>Record</code> from the - * top of the PDB.</li> - * <li>1 byte of <code>Record</code> attribute.</li> - * <li>3 bytes unique <code>Record</code> ID.</li> - * </ul> + * <ul> + * <li>4 bytes local offset of the {@code Record} from the top of the + * PDB.</li> + * <li>1 byte of {@code Record} attribute.</li> + * <li>3 bytes unique {@code Record} ID.</li> + * </ul> * - * <p>There should be a total of <code>header.numRecords</code> - * of <code>Record</code> index info</p>. + * <p>There should be a total of {@code header.numRecords} of {@code Record} + * index info.</p> * - * @param os <code>OutputStream</code> to write out PDB. + * @param os {@code OutputStream} to write out PDB. * - * @throws IOException If I/O error occurs. + * @throws IOException If I/O error occurs. */ public void write(OutputStream os) throws IOException { @@ -123,7 +114,6 @@ public final class PdbEncoder { if (header.numRecords > 0) { // compute for recOffset[] - int recOffset[] = new int[header.numRecords]; byte recAttr[] = new byte[header.numRecords]; @@ -132,7 +122,6 @@ public final class PdbEncoder { recOffset[0] = PdbUtil.HEADER_SIZE + (header.numRecords * 8); int lastIndex = header.numRecords - 1; - for (int i = 0; i < lastIndex; i++) { Record rec = db.getRecord(i); @@ -143,13 +132,10 @@ public final class PdbEncoder { } // grab the last record's attribute. - Record lastRec = db.getRecord(lastIndex); recAttr[lastIndex] = lastRec.getAttributes(); - int uid = START_UNIQUE_ID; - for (int i = 0; i < header.numRecords; i++) { // write out each record offset @@ -166,21 +152,17 @@ public final class PdbEncoder { } // write out the raw records - for (int i = 0; i < header.numRecords; i++) { Record rec = db.getRecord(i); byte bytes[] = rec.getBytes(); dos.write(bytes); } - } else { - // placeholder bytes if there are no records in the list. dos.writeShort(0); } dos.flush(); } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java index fc8303111557..280c6e3dbcf5 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java @@ -23,89 +23,85 @@ import java.io.DataOutput; import java.io.IOException; /** - * <p>Class used only internally by <code>PdbEncoder</code> and - * <code>PdbDecoder</code> to store, read and write a PDB header.</p> + * Class used only internally by {@code PdbEncoder} and {@code PdbDecoder} to + * store, read and write a PDB header. * - * <p>Note that fields are intended to be accessible only at the - * package level.</p> + * <p>Note that fields are intended to be accessible only at the package + * level.</p> * - * <p>Some of the fields are internally represented using a - * larger type since Java does not have unsigned types. - * Some are not since they are not relevant for now. - * The <code>read</code> and <code>write</code> methods should - * handle them properly.</p> + * <p>Some of the fields are internally represented using a larger type since + * Java does not have unsigned types. Some are not since they are not relevant + * for now. The {@code read} and {@code write} methods should handle them + * properly.</p> * - * @see PalmDB - * @see Record + * @see PalmDB + * @see Record */ final class PdbHeader { - - /** Name of the database. 32 bytes. */ + /** Name of the database. 32 bytes. */ byte[] pdbName = null; /** - * Flags for the database. Palm UInt16. Unsignedness should be - * irrelevant. + * Flags for the database. Palm UInt16. Unsignedness should be irrelevant. */ short attribute = 0; - /** Application-specific version for the database. Palm UInt16. */ + /** Application-specific version for the database. Palm UInt16. */ int version = 0; - /** Date created. Palm UInt32. */ + /** Date created. Palm UInt32. */ long creationDate = 0; - /** Date last modified. Palm UInt32. */ + /** Date last modified. Palm UInt32. */ long modificationDate = 0; - /** Date last backup. Palm UInt32. */ + /** Date last backup. Palm UInt32. */ private long lastBackupDate = 0; /** - * Incremented every time a <code>Record</code> is - * added, deleted or modified. Palm UInt32. + * Incremented every time a {@code Record} is added, deleted or modified. + * Palm UInt32. */ private long modificationNumber = 0; - /** Optional field. Palm UInt32. Unsignedness should be irrelevant. */ + /** Optional field. Palm UInt32. Unsignedness should be irrelevant. */ private int appInfoID = 0; - /** Optional field. Palm UInt32. Unsignedness should be irrelevant. */ + /** Optional field. Palm UInt32. Unsignedness should be irrelevant. */ private int sortInfoID = 0; - /** Database type ID. Palm UInt32. Unsignedness should be irrelevant. */ + /** Database type ID. Palm UInt32. Unsignedness should be irrelevant. */ int typeID = 0; - /** Database creator ID. Palm UInt32. Unsignedness should be irrelevant. */ + /** Database creator ID. Palm UInt32. Unsignedness should be irrelevant. */ int creatorID = 0; - /** ??? */ + /** ??? */ private int uniqueIDSeed = 0; - /** See numRecords. 4 bytes. */ + /** See numRecords. 4 bytes. */ private int nextRecordListID = 0; /** - * Number of Records stored in the database header. - * If all the <code>Record</code> entries cannot fit in the header, - * then <code>nextRecordList</code> has the local ID of a - * RecordList that contains the next set of <code>Record</code>. - * Palm UInt16. + * Number of Records stored in the database header. + * If all the {@code Record} entries cannot fit in the header, then + * {@code nextRecordList} has the local ID of a RecordList that contains + * the next set of {@code Record}. + * Palm UInt16. */ int numRecords = 0; - /** - * Read in the data for the PDB header. Need to - * preserve the unsigned value for some of the fields. + * Read in the data for the PDB header. * - * @param in A <code>DataInput</code> object. + * <p>Need to preserve the unsigned value for some of the fields.</p> * - * @throws IOException If any I/O error occurs. + * @param in A {@code DataInput} object. + * + * @throws IOException If any I/O error occurs. */ public void read(DataInput in) throws IOException { - pdbName = new byte[PalmDB.NAME_LENGTH]; in.readFully(pdbName); attribute = in.readShort(); @@ -123,16 +119,14 @@ final class PdbHeader { numRecords = in.readUnsignedShort(); } - /** - * Write out PDB header data. + * Write out PDB header data. * - * @param out A <code>DataOutput</code> object. + * @param out A {@code DataOutput} object. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(DataOutput out) throws IOException { - out.write(pdbName); out.writeShort(attribute); out.writeShort(version); @@ -148,5 +142,4 @@ final class PdbHeader { out.writeInt(nextRecordListID); out.writeShort(numRecords); } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java index 85147c7980e2..dd8068d63134 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java @@ -19,22 +19,17 @@ package org.openoffice.xmerge.converter.palm; /** - * Contains common static methods and constants for use within the package. + * Contains common static methods and constants for use within the package. */ public final class PdbUtil { - /** Difference in seconds from Jan 01, 1904 to Jan 01, 1970. */ + /** Difference in seconds from Jan 01, 1904 to Jan 01, 1970. */ final static long TIME_DIFF = 2082844800; - /** Encoding scheme used. */ + /** Encoding scheme used. */ final static String ENCODING = "8859_1"; - /** Size of a PDB header in bytes. */ + /** Size of a PDB header in bytes. */ final static int HEADER_SIZE = 78; - - - - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java index b66d1cab6303..ac7ba521884b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/Record.java @@ -25,133 +25,111 @@ import java.io.DataInputStream; import java.io.IOException; /** - * <p>Contains the raw bytes for a <code>Record</code> in a PDB.</p> + * Contains the raw bytes for a {@code Record} in a PDB. * - * <p>Note that it is not associated with a <code>Record</code> number - * or ID.</p> + * <p>Note that it is not associated with a {@code Record} number or ID.</p> * - * @see PalmDocument - * @see PalmDB + * @see PalmDocument + * @see PalmDB */ public final class Record { - /** <code>Record</code> <code>byte</code> array. */ + /** {@code Record} {@code byte} array. */ private byte[] data; - /** <code>Record</code> attributes. */ + /** {@code Record} attributes. */ private byte attributes = 0; - /** - * Default constructor. + * Default constructor. */ public Record() { - data = new byte[0]; } - /** - * <p>Constructor to create a <code>Record</code> filled with - * bytes.</p> + * Constructor to create a {@code Record} filled with bytes. * - * <p>Note that this does not check for 64k <code>Record</code> - * sizes. User of this class must check for that.</p> + * <p>Note that this does not check for 64k {@code Record} sizes. User of + * this class must check for that.</p> * - * @param d <code>byte</code> array contents for this object. + * @param d {@code byte} array contents for this object. */ public Record(byte[] d) { - this(d, (byte) 0); } - /** - * <p>Constructor to create a <code>Record</code> filled with - * bytes and assign <code>Record</code> attributes.</p> + * Constructor to create a {@code Record} filled with bytes and assign + * {@code Record} attributes. * - * <p>Note that this does not check for 64k <code>Record</code> - * sizes. User of this class must check for that.</p> + * <p>Note that this does not check for 64k {@code Record} sizes. User of + * this class must check for that.</p> * - * @param d <code>byte</code> array contents for this object. - * @param attrs <code>Record</code> attributes. + * @param d {@code byte} array contents for this object. + * @param attrs {@code Record} attributes. */ public Record(byte[] d, byte attrs) { - data = new byte[d.length]; attributes = attrs; System.arraycopy(d, 0, data, 0, d.length); } - /** - * This method returns the number of bytes in this object. + * This method returns the number of bytes in this object. * - * @return Number of bytes in this object. + * @return Number of bytes in this object. */ public int getSize() { - return data.length; } - /** - * This method returns the contents of this <code>Object</code>. + * This method returns the contents of this {@code Object}. * - * @return Contents in <code>byte</code> array + * @return Contents in {@code byte} array */ public byte[] getBytes() { - return data; } - /** - * <p>This method returns the <code>Record</code> attributes.</p> + * <p>This method returns the {@code Record} attributes.</p> * - * <blockquote><pre> - * <code>Record</code> attributes consists of (from high to low bit) + * <blockquote><pre>{@code Record} attributes consists of (from high to low bit) * - * delete (1) - dirty (1) - busy (1) - secret (1) - category (4) - * </pre></blockquote> + * delete (1) - dirty (1) - busy (1) - secret (1) - category (4)</pre></blockquote> * - * @return <code>Record</code> attribute. + * @return {@code Record} attribute. */ public byte getAttributes() { - return attributes; } - /** - * Write out the <code>Record</code> attributes and - * <code>Record</code> length followed by the data in this - * <code>Record</code> object. + * Write out the {@code Record} attributes and {@code Record} length + * followed by the data in this {@code Record} object. * - * @param outs The <code>OutputStream</code> to write the object. + * @param outs The {@code OutputStream} to write the object. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(OutputStream outs) throws IOException { - DataOutputStream out = new DataOutputStream(outs); out.writeByte(attributes); out.writeShort(data.length); out.write(data); } - /** - * Read the necessary data to create a PDB from - * the <code>InputStream</code>. + * Read the necessary data to create a PDB from the {@code InputStream}. * - * @param ins The <code>InputStream</code> to read data from - * in order to restore the <code>object</code>. + * @param ins The {@code InputStream} to read data from in order to + * restore the {@code object}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void read(InputStream ins) throws IOException { - DataInputStream in = new DataInputStream(ins); attributes = in.readByte(); int len = in.readUnsignedShort(); @@ -159,18 +137,17 @@ public final class Record { in.readFully(data); } - /** - * <p>Override equals method of <code>Object</code>.</p> + * Override equals method of {@code Object}. * - * <p>Two <code>Record</code> objects are equal if they contain - * the same bytes in the array and the same attributes.</p> + * <p>Two {@code Record} objects are equal if they contain the same bytes + * in the array and the same attributes.</p> * - * <p>This is used primarily for testing purposes only for now.</p> + * <p>This is used primarily for testing purposes only for now.</p> * - * @param obj A <code>Record</code> object to compare with + * @param obj A {@code Record} object to compare with * - * @return true if obj is equal, otherwise false. + * @return {@code true} if {@code obj} is equal, otherwise {@code false}. */ @Override public boolean equals(Object obj) { @@ -184,24 +161,18 @@ public final class Record { checkLabel: { if (rec.getAttributes() != attributes) { - break checkLabel; } - if (rec.getSize() == data.length) { - for (int i = 0; i < data.length; i++) { - if (data[i] != rec.data[i]) { break checkLabel; } } - bool = true; } } } return bool; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java index d3b10bf256f9..212e07ee891a 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java @@ -22,7 +22,6 @@ import org.w3c.dom.Document; import org.w3c.dom.DOMException; import org.w3c.dom.Element; - /** * This class represents embedded object's in an OpenOffice.org document that * have a binary representation. @@ -42,7 +41,6 @@ public class EmbeddedBinaryObject extends EmbeddedObject { super(name, type); } - /** * Package private constructor for use when reading an object from a * compressed SX? file. @@ -56,11 +54,10 @@ public class EmbeddedBinaryObject extends EmbeddedObject { super(name, type, source); } - /** * This method returns the data for this object. * - * @return A <code>byte</code> array containing the object's data. + * @return A {@code byte} array containing the object's data. */ public byte[] getBinaryData() { @@ -74,11 +71,10 @@ public class EmbeddedBinaryObject extends EmbeddedObject { return objData; } - /** * Sets the data for this object. * - * @param data A <code>byte</code> array containing data for the object. + * @param data A {@code byte} array containing data for the object. */ public void setBinaryData(byte[] data) { objData = data; @@ -89,8 +85,8 @@ public class EmbeddedBinaryObject extends EmbeddedObject { * Package private method for writing the data of the EmbeddedObject to a * SX? file. * - * @param zip An <code>OfficeZip</code> instance representing the file - * the data is to be written to. + * @param zip An {@code OfficeZip} instance representing the file the + * data is to be written to. */ @Override void write(OfficeZip zip) { @@ -99,7 +95,6 @@ public class EmbeddedBinaryObject extends EmbeddedObject { } } - /** * Package private method that constructs the manifest.xml entries for this * embedded object. @@ -113,6 +108,4 @@ public class EmbeddedBinaryObject extends EmbeddedObject { manifestDoc.getDocumentElement().appendChild(objNode); } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java index cdc3d51d88fc..fc05447b28d9 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedObject.java @@ -23,7 +23,6 @@ import java.io.IOException; import org.w3c.dom.Document; import org.w3c.dom.DOMException; - public abstract class EmbeddedObject { protected String objName; protected String objType; @@ -47,7 +46,6 @@ public abstract class EmbeddedObject { hasChanged = true; } - /** * Package private constructor for use when reading an object from a * compressed SX? file. @@ -62,13 +60,12 @@ public abstract class EmbeddedObject { zipFile = source; } - /** * Retrieves the name of the embedded object represented by an instance of * this class. * * <b>N.B.</b>The name refers to the name as found in the - * <code>META-INF/manifest.xml</code> file. + * {@code META-INF/manifest.xml} file. * * @return The name of the object. */ @@ -76,13 +73,12 @@ public abstract class EmbeddedObject { return objName; } - /** * Retrieves the type of the embedded object represented by an instance of * this class. * - * The <code>META-INF/manifest.xml</code> file currently represents the - * type of an object using MIME types. + * The {@code META-INF/manifest.xml} file currently represents the type of + * an object using MIME types. */ public final String getType() { return objType; @@ -92,8 +88,8 @@ public abstract class EmbeddedObject { * Package private method for writing the data of the EmbeddedObject to a * SX? file. * - * @param zip An <code>OfficeZip</code> instance representing the file - * the data is to be written to. + * @param zip An {@code OfficeZip} instance representing the file the + * data is to be written to. */ abstract void write(OfficeZip zip) throws IOException; @@ -102,4 +98,4 @@ public abstract class EmbeddedObject { * embedded object. */ abstract void writeManifestData(Document manifestDoc) throws DOMException; -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java index bbf0128b0dee..b081d6fa13aa 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedXMLObject.java @@ -33,18 +33,32 @@ import org.xml.sax.SAXException; /** * This class represents those embedded objects in an OpenOffice.org document - * that have an XML representation. Currently, according to the OpenOffice.org - * File Format 1.0 document, there are 6 such objects: + * that have an XML representation. * - * Formulae created with Math (application/vnd.sun.xml.math) - * Charts created with Chart (application/vnd.sun.xml.chart) - * Spreadsheets created with Calc (application/vnd.sun.xml.calc) - * Text created with Writer (application/vnd.sun.xml.writer) - * Drawings created with Draw (application/vnd.sun.xml.draw) - * Presentations created with Impress (application/vnd.sun.xml.impress) + * <p>Currently, according to the OpenOffice.org File Format 1.0 document, + * there are 6 such objects:</p> + * <blockquote><table summary="" border="1" cellpadding="3" cellspacing="0"> + * <tr> + * <th>Description</th><th>Object</th> + * </tr><tr> + * <td>Formula created with Math</td><td>application/vnd.sun.xml.math</td> + * </tr><tr> + * <td>Charts created with Chart</td><td>application/vnd.sun.xml.chart</td> + * </tr><tr> + * <td>Spreadsheets created with Calc</td> + * <td>application/vnd.sun.xml.calc</td> + * </tr><tr> + * <td>Text created with Writer</td><td>application/vnd.sun.xml.writer</td> + * </tr><tr> + * <td>Drawings created with Draw</td><td>application/vnd.sun.xml.draw</td> + * </tr><tr> + * <td>Presentations created with Impress</td> + * <td>application/vnd.sun.xml.impress</td> + * </tr> + * </table></blockquote> * - * These object types are stored using a combination of content, settings and styles - * XML files. + * <p>These object types are stored using a combination of content, settings and + * styles XML files.</p> */ public class EmbeddedXMLObject extends EmbeddedObject { @@ -58,8 +72,8 @@ public class EmbeddedXMLObject extends EmbeddedObject { /** * Constructor for an embedded object stored using an XML representation. * - * @param name The name of the object. - * @param type The mime-type of the object. See the class summary. + * @param name The name of the object. + * @param type The mime-type of the object. See the class summary. */ public EmbeddedXMLObject(String name, String type) { super(name, type); @@ -69,23 +83,22 @@ public class EmbeddedXMLObject extends EmbeddedObject { * Package private constructor for use when reading an object from a * compressed SX? file. * - * @param name The name of the object. - * @param type The mime-type of the object. See the class summary. - * @param source The OfficeZip representation of the SX? file that stores - * the object. + * @param name The name of the object. + * @param type The mime-type of the object. See the class summary. + * @param source The OfficeZip representation of the SX? file that stores + * the object. */ EmbeddedXMLObject(String name, String type, OfficeZip source) { super(name, type, source); } - /** * Returns the content data for this embedded object. * - * @return DOM representation of "content.xml" + * @return DOM representation of "content.xml". * - * @throws SAXException If any parser error occurs - * @throws IOException If any IO error occurs + * @throws SAXException If any parser error occurs. + * @throws IOException If any IO error occurs. */ public Document getContentDOM() throws SAXException, IOException { @@ -96,25 +109,23 @@ public class EmbeddedXMLObject extends EmbeddedObject { return contentDOM; } - /** * Sets the content data for the embedded object. * - * @param content DOM representation of the object's content. + * @param content DOM representation of the object's content. */ public void setContentDOM(Document content) { contentDOM = content; hasChanged = true; } - /** * Returns the settings data for this embedded object. * - * @return DOM representation of "settings.xml" + * @return DOM representation of "settings.xml" * - * @throws SAXException If any parser error occurs - * @throws IOException If any IO error occurs + * @throws SAXException If any parser error occurs. + * @throws IOException If any IO error occurs. */ public Document getSettingsDOM() throws SAXException, IOException { @@ -125,25 +136,23 @@ public class EmbeddedXMLObject extends EmbeddedObject { return settingsDOM; } - /** * Sets the settings data for the embedded object. * - * @param settings DOM representation of the object's styles. + * @param settings DOM representation of the object's styles. */ public void setSettingsDOM(Document settings) { settingsDOM = settings; hasChanged = true; } - /** * Returns the style data for this embedded object. * - * @return DOM representation of "styles.xml" + * @return DOM representation of "styles.xml". * - * @throws SAXException If any parser error occurs - * @throws IOException If any IO error occurs + * @throws SAXException If any parser error occurs. + * @throws IOException If any IO error occurs. */ public Document getStylesDOM() throws SAXException, IOException { @@ -154,29 +163,27 @@ public class EmbeddedXMLObject extends EmbeddedObject { return stylesDOM; } - /** * Sets the styles data for the embedded object. * - * @param styles DOM representation of the object's styles. + * @param styles DOM representation of the object's styles. */ public void setStylesDOM(Document styles) { stylesDOM = styles; hasChanged = true; } - /** * This method extracts the data for the given XML file from the SX? file * and creates a DOM representation of it. * - * @param name The name of the XML file to retrieve. It is paired with - * the object name to access the SX? file. + * @param name The name of the XML file to retrieve. It is paired with + * the object name to access the SX? file. * * @return DOM representation of the named XML file. * - * @throws SAXException If any parser error occurs - * @throws IOException If any IO error occurs + * @throws SAXException If any parser error occurs. + * @throws IOException If any IO error occurs. */ private Document getNamedDOM(String name) throws SAXException, IOException { if (zipFile == null) { @@ -194,24 +201,21 @@ public class EmbeddedXMLObject extends EmbeddedObject { byte[] data = zipFile.getNamedBytes((objName + "/" + name)); if (data != null) { return OfficeDocument.parse(builder, data); - } - else { + } else { return null; } - } - catch (ParserConfigurationException pce) { + } catch (ParserConfigurationException pce) { throw new SAXException(pce); } } - /** * Package private method for writing the data of the EmbeddedObject to a * SX? file. * - * @param zip An <code>OfficeZip</code> instance representing the file - * the data is to be written to. + * @param zip An {@code OfficeZip} instance representing the file the data + * is to be written to. */ @Override void write(OfficeZip zip) throws IOException { @@ -235,7 +239,7 @@ public class EmbeddedXMLObject extends EmbeddedObject { * Package private method that constructs the manifest.xml entries for this * embedded object. * - * @param manifestDoc <code>Document</code> containing the manifest entries. + * @param manifestDoc {@code Document} containing the manifest entries. */ @Override void writeManifestData(Document manifestDoc) throws DOMException { @@ -266,7 +270,6 @@ public class EmbeddedXMLObject extends EmbeddedObject { stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, (objName + "/styles.xml")); } - Element objectNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE); objectNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE, objType); @@ -274,5 +277,4 @@ public class EmbeddedXMLObject extends EmbeddedObject { root.appendChild(objectNode); } - -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java index 452869ce3cef..8605c6ad63ee 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeConstants.java @@ -19,9 +19,8 @@ package org.openoffice.xmerge.converter.xml; /** - * This interface contains constants for StarOffice XML tags, - * attributes (StarCalc cell types, etc.). - * + * This interface contains constants for StarOffice XML tags, attributes + * (StarCalc cell types, etc.). */ public interface OfficeConstants { @@ -29,31 +28,29 @@ public interface OfficeConstants { String TAG_OFFICE_DOCUMENT = "office:document"; /** - * Element tag for <i>office:document-content</i>, this is the root - * tag in content.xml. + * Element tag for <i>office:document-content</i>, this is the root tag in + * content.xml. */ String TAG_OFFICE_DOCUMENT_CONTENT = "office:document-content"; /** - * Element tag for <i>office:document-settings</i>, this is the root - * tag in content.xml. + * Element tag for <i>office:document-settings</i>, this is the root tag in + * content.xml. */ String TAG_OFFICE_DOCUMENT_SETTINGS= "office:document-settings"; - /** - * Element tag for <i>office:document-meta</i>, this is the root - * tag in content.xml. + /** + * Element tag for <i>office:document-meta</i>, this is the root tag in + * content.xml. */ String TAG_OFFICE_DOCUMENT_META= "office:document-meta"; /** - * Element tag for <i>office:document-styles</i>, this is the root tag - * in styles.xml. + * Element tag for <i>office:document-styles</i>, this is the root tag in + * styles.xml. */ String TAG_OFFICE_DOCUMENT_STYLES = "office:document-styles"; - - /** Element tag for <i>office:styles</i>. */ String TAG_OFFICE_STYLES = "office:styles"; @@ -82,20 +79,20 @@ public interface OfficeConstants { String ATTRIBUTE_STYLE_NAME = "style:name"; /** - * Attribute tag for <i>style:font-pitch</i> of element - * <i>style:font-pitch</i>. + * Attribute tag for <i>style:font-pitch</i> of element + * <i>style:font-pitch</i>. */ String ATTRIBUTE_STYLE_FONT_PITCH = "style:font-pitch"; /** - * Attribute tag for <i>fo:font-family</i> of element - * <i>fo:font-family</i>. + * Attribute tag for <i>fo:font-family</i> of element + * <i>fo:font-family</i>. */ String ATTRIBUTE_FO_FONT_FAMILY = "fo:font-family"; /** - * Attribute tag for <i>fo:font-family</i> of element - * <i>fo:font-family</i>. + * Attribute tag for <i>fo:font-family</i> of element + * <i>fo:font-family</i>. */ String ATTRIBUTE_FO_FONT_FAMILY_GENERIC = "fo:font-family-generic"; @@ -147,27 +144,24 @@ public interface OfficeConstants { /** Element tag for <i>table:named-expression</i>. */ String TAG_TABLE_NAMED_EXPRESSION= "table:named-expression"; - /** - * Attribute tag for <i>table:name</i> of element - * <i>table:table</i>. - */ + /** Attribute tag for <i>table:name</i> of element <i>table:table</i>. */ String ATTRIBUTE_TABLE_NAME = "table:name"; /** - * Attribute tag for <i>table:expression</i> of element - * <i>table:named-range</i>. + * Attribute tag for <i>table:expression</i> of element + * <i>table:named-range</i>. */ String ATTRIBUTE_TABLE_EXPRESSION = "table:expression"; /** - * Attribute tag for <i>table:base-cell-address</i> of element - * <i>table:named-range</i>. + * Attribute tag for <i>table:base-cell-address</i> of element + * <i>table:named-range</i>. */ String ATTRIBUTE_TABLE_BASE_CELL_ADDRESS = "table:base-cell-address"; /** - * Attribute tag for <i>table:cell-range-address</i> of element - * <i>table:named-range</i>. + * Attribute tag for <i>table:cell-range-address</i> of element + * <i>table:named-range</i>. */ String ATTRIBUTE_TABLE_CELL_RANGE_ADDRESS = "table:cell-range-address"; @@ -177,9 +171,9 @@ public interface OfficeConstants { /** Element tag for <i>table:table-column</i>. */ String TAG_TABLE_COLUMN = "table:table-column"; - /** - * Attribute tag for <i>table:default-cell-style-name</i> - * of element <i>table:table-column</i>. + /** + * Attribute tag for <i>table:default-cell-style-name</i> of element + * <i>table:table-column</i>. */ String ATTRIBUTE_DEFAULT_CELL_STYLE = "table:default-cell-style-name"; @@ -190,69 +184,65 @@ public interface OfficeConstants { String TAG_TABLE_CELL = "table:table-cell"; /** - * Attribute tag for <i>table:value-type</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:value-type</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_VALUE_TYPE = "table:value-type"; /** - * Attribute tag for <i>table:number-columns-repeated</i> - * of element <i>table:table-cell</i>. + * Attribute tag for <i>table:number-columns-repeated</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED = "table:number-columns-repeated"; /** - * Attribute tag for <i>table:number-rows-repeated</i> - * of element <i>table:table-row</i>. + * Attribute tag for <i>table:number-rows-repeated</i> of element + * <i>table:table-row</i>. */ - String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED = - "table:number-rows-repeated"; + String ATTRIBUTE_TABLE_NUM_ROWS_REPEATED = "table:number-rows-repeated"; /** - * Attribute tag for <i>table:formula</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:formula</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_FORMULA = "table:formula"; /** - * Attribute tag for <i>table:value</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:value</i> of element <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_VALUE = "table:value"; /** - * Attribute tag for <i>table:date-value</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:date-value</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_DATE_VALUE = "table:date-value"; /** - * Attribute tag for <i>table:time-value</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:time-value</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_TIME_VALUE = "table:time-value"; /** - * Attribute tag for <i>table:string-value</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:string-value</i> of element + * <i>table:table-cell</i>. */ - String ATTRIBUTE_TABLE_STRING_VALUE = - "table:string-value"; + String ATTRIBUTE_TABLE_STRING_VALUE = "table:string-value"; /** - * Attribute tag for <i>table:time-boolean-value</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:time-boolean-value</i> of element + * <i>table:table-cell</i>. */ - String ATTRIBUTE_TABLE_BOOLEAN_VALUE = - "table:boolean-value"; + String ATTRIBUTE_TABLE_BOOLEAN_VALUE = "table:boolean-value"; /** Attribute tag for <i>table:style-name</i> of table elements. */ String ATTRIBUTE_TABLE_STYLE_NAME = "table:style-name"; /** - * Attribute tag for <i>table:currency</i> of element - * <i>table:table-cell</i>. + * Attribute tag for <i>table:currency</i> of element + * <i>table:table-cell</i>. */ String ATTRIBUTE_TABLE_CURRENCY = "table:currency"; @@ -325,22 +315,19 @@ public interface OfficeConstants { String TAG_CONFIG_ITEM_MAP_ENTRY= "config:config-item-map-entry"; /** - * Attribute tag for <i>config:name</i> of element - * <i>config:config-item</i>. + * Attribute tag for <i>config:name</i> of element <i>config:config-item</i>. */ String ATTRIBUTE_CONFIG_NAME = "config:name"; /** - * Attribute tag for <i>config:type</i> of element - * <i>config:config-item</i>. + * Attribute tag for <i>config:type</i> of element <i>config:config-item</i>. */ String ATTRIBUTE_CONFIG_TYPE = "config:type"; - /** StarWriter XML MIME type. */ String SXW_MIME_TYPE = "application/vnd.sun.xml.writer"; /** StarCalc XML MIME type. */ String SXC_MIME_TYPE = "application/vnd.sun.xml.calc"; -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java index b90a285938ce..df3fec9660b1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java @@ -53,41 +53,39 @@ import javax.xml.transform.stream.*; import org.openoffice.xmerge.util.Debug; /** - * An implementation of <code>Document</code> for - * StarOffice documents. + * An implementation of {@code Document} for StarOffice documents. */ public abstract class OfficeDocument - implements org.openoffice.xmerge.Document, - OfficeConstants { + implements org.openoffice.xmerge.Document, OfficeConstants { - /** Factory for <code>DocumentBuilder</code> objects. */ + /** Factory for {@code DocumentBuilder} objects. */ private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - /** DOM <code>Document</code> of content.xml. */ + /** DOM {@code Document} of content.xml. */ private Document contentDoc = null; - /** DOM <code>Document</code> of meta.xml. */ + /** DOM {@code Document} of meta.xml. */ private Document metaDoc = null; - /** DOM <code>Document</code> of settings.xml. */ + /** DOM {@code Document} of settings.xml. */ private Document settingsDoc = null; - /** DOM <code>Document</code> of content.xml. */ + /** DOM {@code Document} of content.xml. */ private Document styleDoc = null; - /** DOM <code>Docuemtn</code> of META-INF/manifest.xml. */ + /** DOM {@code Document} of @code META-INF/manifest.xml. */ private Document manifestDoc = null; private String documentName = null; private String fileName = null; /** - * <code>OfficeZip</code> object to store zip contents from - * read <code>InputStream</code>. Note that this member - * will still be null if it was initialized using a template - * file instead of reading from a StarOffice zipped - * XML file. + * {@code OfficeZip} object to store zip contents from read + * {@code InputStream}. + * + * <p>Note that this member will still be null if it was initialized using + * a template file instead of reading from a StarOffice zipped XML file.</p> */ private OfficeZip zip = null; @@ -95,24 +93,22 @@ public abstract class OfficeDocument private Map<String, EmbeddedObject> embeddedObjects = null; /** - * Default constructor. + * Default constructor. * - * @param name <code>Document</code> name. + * @param name {@code Document} name. */ - public OfficeDocument(String name) - { + public OfficeDocument(String name) { this(name, true, false); } - /** - * Constructor with arguments to set <code>namespaceAware</code> - * and <code>validating</code> flags. + * Constructor with arguments to set {@code namespaceAware} and + * {@code validating} flags. * - * @param name <code>Document</code> name (may or may not - * contain extension). - * @param namespaceAware Value for <code>namespaceAware</code> flag. - * @param validating Value for <code>validating</code> flag. + * @param name {@code Document} name (may or may not contain + * extension). + * @param namespaceAware Value for {@code namespaceAware} flag. + * @param validating Value for {@code validating} flag. */ public OfficeDocument(String name, boolean namespaceAware, boolean validating) { factory.setValidating(validating); @@ -121,14 +117,12 @@ public abstract class OfficeDocument this.fileName = documentName + getFileExtension(); } - /** - * Removes the file extension from the <code>Document</code> - * name. + * Removes the file extension from the {@code Document} name. * - * @param name Full <code>Document</code> name with extension. + * @param name Full {@code Document} name with extension. * - * @return Name of <code>Document</code> without the extension. + * @return Name of {@code Document} without the extension. */ private String trimDocumentName(String name) { String temp = name.toLowerCase(); @@ -144,145 +138,133 @@ public abstract class OfficeDocument return name; } - /** - * Return a DOM <code>Document</code> object of the content.xml - * file. Note that a content DOM is not created when the constructor - * is called. So, either the <code>read</code> method or the - * <code>initContentDOM</code> method will need to be called ahead - * on this object before calling this method. + * Return a DOM {@code Document} object of the content.xml file. * - * @return DOM <code>Document</code> object. + * <p>Note that a content DOM is not created when the constructor is called. + * So, either the {@code read} method or the {@code initContentDOM} method + * will need to be called ahead on this object before calling this method.</p> + * + * @return DOM {@code Document} object. */ public Document getContentDOM() { return contentDoc; } - /** - * Return a DOM <code>Document</code> object of the meta.xml - * file. Note that a content DOM is not created when the constructor - * is called. So, either the <code>read</code> method or the - * <code>initContentDOM</code> method will need to be called ahead - * on this object before calling this method. + /** + * Return a DOM {@code Document} object of the meta.xml file. + * + * <p>Note that a content DOM is not created when the constructor is called. + * So, either the {@code read} method or the {@code initContentDOM} method + * will need to be called ahead on this object before calling this method.</p> * - * @return DOM <code>Document</code> object. + * @return DOM <code>Document</code> object. */ public Document getMetaDOM() { return metaDoc; } - - /** - * Return a DOM <code>Document</code> object of the settings.xml - * file. Note that a content DOM is not created when the constructor - * is called. So, either the <code>read</code> method or the - * <code>initContentDOM</code> method will need to be called ahead - * on this object before calling this method. + /** + * Return a DOM {@code Document} object of the settings.xml file. + * + * <p>Note that a content DOM is not created when the constructor is called. + * So, either the {@code read} method or the {@code initContentDOM} method + * will need to be called ahead on this object before calling this method.</p> * - * @return DOM <code>Document</code> object. + * @return DOM {@code Document} object. */ public Document getSettingsDOM() { return settingsDoc; } - /** * Sets the content tree of the document. * - * @param newDom <code>Node</code> containing the new content tree. + * @param newDom {@code Node} containing the new content tree. */ public void setContentDOM( Node newDom) { contentDoc = (Document)newDom; } - /** * Sets the meta tree of the document. * - * @param newDom <code>Node</code> containing the new meta tree. + * @param newDom {@code Node} containing the new meta tree. */ public void setMetaDOM (Node newDom) { metaDoc = (Document)newDom; } - /** * Sets the settings tree of the document. * - * @param newDom <code>Node</code> containing the new settings tree. + * @param newDom {@code Node} containing the new settings tree. */ public void setSettingsDOM (Node newDom) { settingsDoc = (Document)newDom; } - /** * Sets the style tree of the document. * - * @param newDom <code>Node</code> containing the new style tree. + * @param newDom {@code Node} containing the new style tree. */ public void setStyleDOM (Node newDom) { styleDoc = (Document)newDom; } - /** - * Return a DOM <code>Document</code> object of the style.xml file. - * Note that this may return null if there is no style DOM. - * Note that a style DOM is not created when the constructor - * is called. Depending on the <code>InputStream</code>, a - * <code>read</code> method may or may not build a style DOM. When - * creating a new style DOM, call the <code>initStyleDOM</code> method - * first. + * Return a DOM {@code Document} object of the style.xml file. * - * @return DOM <code>Document</code> object. + * <p>Note that this may return {@code null} if there is no style DOM.</p> + * <p>Note that a style DOM is not created when the constructor is called. + * Depending on the {@code InputStream}, a {@code read} method may or may + * not build a style DOM. When creating a new style DOM, call the + * {@code initStyleDOM} method first.</p> + * + * @return DOM {@code Document} object. */ public Document getStyleDOM() { return styleDoc; } - /** - * Return the name of the <code>Document</code>. + * Return the name of the {@code Document}. * - * @return The name of <code>Document</code>. + * @return The name of {@code Document}. */ public String getName() { return documentName; } - /** - * Return the file name of the <code>Document</code>, possibly - * with the standard extension. + * Return the file name of the {@code Document}, possibly with the standard + * extension. * - * @return The file name of <code>Document</code>. + * @return The file name of {@code Document}. */ public String getFileName() { return fileName; } - /** - * Returns the file extension for this type of - * <code>Document</code>. + * Returns the file extension for this type of {@code Document}. * - * @return The file extension of <code>Document</code>. + * @return The file extension of {@code Document}. */ protected abstract String getFileExtension(); - /** * Returns all the embedded objects (graphics, formulae, etc.) present in * this document. * - * @return An <code>Iterator</code> of <code>EmbeddedObject</code> objects. + * @return An {@code Iterator} of {@code EmbeddedObject} objects. */ public Iterator<EmbeddedObject> getEmbeddedObjects() { @@ -302,7 +284,6 @@ public abstract class OfficeDocument String type = attrs.getNamedItem(ATTRIBUTE_MANIFEST_FILE_TYPE).getNodeValue(); String path = attrs.getNamedItem(ATTRIBUTE_MANIFEST_FILE_PATH).getNodeValue(); - /* * According to OpenOffice.org XML File Format document (ver. 1) * there are only two types of embedded object: @@ -338,17 +319,15 @@ public abstract class OfficeDocument } /** - * Read the Office <code>Document</code> from the given - * <code>InputStream</code>. + * Read the Office {@code Document} from the given {@code InputStream}. * - * @param is Office document <code>InputStream</code>. + * @param is Office document {@code InputStream}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void read(InputStream is) throws IOException { Debug.log(Debug.INFO, "reading Office file"); - DocumentBuilder builder = null; try { @@ -358,99 +337,69 @@ public abstract class OfficeDocument } // read in Office zip file format - zip = new OfficeZip(); zip.read(is); // grab the content.xml and // parse it into contentDoc. - byte contentBytes[] = zip.getContentXMLBytes(); - if (contentBytes == null) { - throw new OfficeDocumentException("Entry content.xml not found in file"); } - try { - contentDoc = parse(builder, contentBytes); - } catch (SAXException ex) { - throw new OfficeDocumentException(ex); } // if style.xml exists, grab the style.xml // parse it into styleDoc. - byte styleBytes[] = zip.getStyleXMLBytes(); - if (styleBytes != null) { - try { - styleDoc = parse(builder, styleBytes); - } catch (SAXException ex) { - throw new OfficeDocumentException(ex); } } - byte metaBytes[] = zip.getMetaXMLBytes(); - + byte metaBytes[] = zip.getMetaXMLBytes(); if (metaBytes != null) { - try { - metaDoc = parse(builder, metaBytes); - } catch (SAXException ex) { - throw new OfficeDocumentException(ex); } } - byte settingsBytes[] = zip.getSettingsXMLBytes(); - + byte settingsBytes[] = zip.getSettingsXMLBytes(); if (settingsBytes != null) { - try { - settingsDoc = parse(builder, settingsBytes); } catch (SAXException ex) { - throw new OfficeDocumentException(ex); } } - // Read in the META-INF/manifest.xml file byte manifestBytes[] = zip.getManifestXMLBytes(); - if (manifestBytes != null) { - try { manifestDoc = parse(builder, manifestBytes); } catch (SAXException ex) { throw new OfficeDocumentException(ex); } } - } - /** - * Read the Office <code>Document</code> from the given - * <code>InputStream</code>. + * Read the Office {@code Document} from the given {@code InputStream}. * - * @param is Office document <code>InputStream</code>. - * @param isZip <code>boolean</code> Identifies whether - * a file is zipped or not + * @param is Office document {@code InputStream}. + * @param isZip {@code boolean} Identifies whether a file is zipped or not. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void read(InputStream is, boolean isZip) throws IOException { @@ -564,18 +513,16 @@ public abstract class OfficeDocument } - /** - * Parse given <code>byte</code> array into a DOM - * <code>Document</code> object using the - * <code>DocumentBuilder</code> object. + * Parse given {@code byte} array into a DOM {@code Document} object using + * the {@code DocumentBuilder} object. * - * @param builder <code>DocumentBuilder</code> object for parsing. - * @param bytes <code>byte</code> array for parsing. + * @param builder {@code DocumentBuilder} object for parsing. + * @param bytes {@code byte} array for parsing. * - * @return Resulting DOM <code>Document</code> object. + * @return Resulting DOM {@code Document} object. * - * @throws SAXException If any parsing error occurs. + * @throws SAXException If any parsing error occurs. */ static Document parse(DocumentBuilder builder, byte bytes[]) throws SAXException, IOException { @@ -593,7 +540,6 @@ public abstract class OfficeDocument return doc; } - /** * Method to return the MIME type of the document. * @@ -601,13 +547,12 @@ public abstract class OfficeDocument */ protected abstract String getDocumentMimeType(); - /** - * Write out Office ZIP file format. + * Write out Office ZIP file format. * - * @param os XML <code>OutputStream</code>. + * @param os XML {@code OutputStream}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(OutputStream os) throws IOException { if (zip == null) { @@ -634,9 +579,9 @@ public abstract class OfficeDocument domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_TYPE, ""); manifestRoot.appendChild(domEntry); - // Write content to the Zip file and then write any of the optional + // Write content to the Zip file and then write any of the optional // data, if it exists. - zip.setContentXMLBytes(docToBytes(contentDoc)); + zip.setContentXMLBytes(docToBytes(contentDoc)); domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); domEntry.setAttribute(ATTRIBUTE_MANIFEST_FILE_PATH, "content.xml"); @@ -644,7 +589,7 @@ public abstract class OfficeDocument manifestRoot.appendChild(domEntry); - if (styleDoc != null) { + if (styleDoc != null) { zip.setStyleXMLBytes(docToBytes(styleDoc)); domEntry = manifestDoc.createElement(TAG_MANIFEST_FILE); @@ -676,30 +621,27 @@ public abstract class OfficeDocument zip.write(os); } - - /** - * Write out Office ZIP file format. + /** + * Write out Office ZIP file format. * - * @param os XML <code>OutputStream</code>. - * @param isZip <code>boolean</code> + * @param os XML {@code OutputStream}. + * @param isZip {@code boolean} * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void write(OutputStream os, boolean isZip) throws IOException { // Create an OfficeZip object if one does not exist. if (isZip){ write(os); - } - else{ - try{ + } else { + try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder= builderFactory.newDocumentBuilder(); DOMImplementation domImpl = builder.getDOMImplementation(); domImpl.createDocumentType("office:document","-//OpenOffice.org//DTD OfficeDocument 1.0//EN",null); org.w3c.dom.Document newDoc = domImpl.createDocument("http://openoffice.org/2000/office","office:document",null); - Element rootElement=newDoc.getDocumentElement(); rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); @@ -726,37 +668,33 @@ public abstract class OfficeDocument rootElement.setAttribute("office:class","text" ); rootElement.setAttribute("office:version","1.0"); - NodeList nodeList; Node tmpNode; Node rootNode = rootElement; - if (metaDoc !=null){ + if (metaDoc !=null) { nodeList= metaDoc.getElementsByTagName(TAG_OFFICE_META); - if (nodeList.getLength()>0){ + if (nodeList.getLength()>0) { tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - }if (styleDoc !=null){ + } if (styleDoc !=null) { nodeList= styleDoc.getElementsByTagName(TAG_OFFICE_STYLES); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); - } - - }if (settingsDoc !=null){ + } + } if (settingsDoc !=null) { nodeList= settingsDoc.getElementsByTagName(TAG_OFFICE_SETTINGS); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); rootNode.appendChild(tmpNode); } - } - if (contentDoc !=null){ + } if (contentDoc !=null) { nodeList= contentDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); - rootNode.appendChild(tmpNode); + rootNode.appendChild(tmpNode); } - nodeList= contentDoc.getElementsByTagName(TAG_OFFICE_BODY); if (nodeList.getLength()>0){ tmpNode = newDoc.importNode(nodeList.item(0),true); @@ -766,27 +704,25 @@ public abstract class OfficeDocument byte contentBytes[] = docToBytes(newDoc); os.write(contentBytes); - } - catch(Exception exc){ - System.out.println("\nException in OfficeDocument.write():" +exc); - } - } + } catch(Exception exc){ + System.out.println("\nException in OfficeDocument.write():" +exc); + } + } } /** - * <p>Write out a <code>org.w3c.dom.Document</code> object into a - * <code>byte</code> array.</p> + * Write out a {@code org.w3c.dom.Document} object into a {@code byte} + * array. * - * <p>TODO: remove dependency on com.sun.xml.tree.XmlDocument - * package!</p> + * <p>TODO: remove dependency on {@code com.sun.xml.tree.XmlDocument} + * package!</p> * - * @param doc DOM <code>Document</code> object. + * @param doc DOM {@code Document} object. * - * @return <code>byte</code> array of DOM <code>Document</code> - * object. + * @return {@code byte} array of DOM {@code Document} object. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ static byte[] docToBytes(Document doc) throws IOException { @@ -818,20 +754,17 @@ public abstract class OfficeDocument new Class[] { Class.forName("java.io.OutputStream") } ); meth.invoke(doc, new Object [] { baos } ); - } - else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) - { + } else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) { Debug.log(Debug.INFO, "Using Crimson"); - Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); - // The method is in the XMLDocument class itself, not a helper + Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); + // The method is in the XMLDocument class itself, not a helper meth = crimsonDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); meth.invoke(doc, new Object [] { baos } ); - } - else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") - || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { + } else if (domImpl.equals("org.apache.xerces.dom.DocumentImpl") + || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { Debug.log(Debug.INFO, "Using Xerces"); @@ -845,20 +778,16 @@ public abstract class OfficeDocument { Class.forName("java.io.OutputStream"), Class.forName("org.apache.xml.serialize.OutputFormat") } ); - // Get the serialize method meth = xercesSer.getMethod("serialize", new Class [] { Class.forName("org.w3c.dom.Document") } ); - // Get an instance Object serializer = con.newInstance(new Object [] { baos, null } ); - // Now call serialize to write the document meth.invoke(serializer, new Object [] { doc } ); - } - else if (domImpl.equals("gnu.xml.dom.DomDocument")) { + } else if (domImpl.equals("gnu.xml.dom.DomDocument")) { Debug.log(Debug.INFO, "Using GNU"); Class<?> gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); @@ -873,18 +802,16 @@ public abstract class OfficeDocument // Now call serialize to write the document meth.invoke(serializer, new Object [] { doc, baos } ); - } - else { - try { - DOMSource domSource = new DOMSource(doc); - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.transform(domSource, result); - return writer.toString().getBytes(); - } - catch (Exception e) { + } else { + try { + DOMSource domSource = new DOMSource(doc); + StringWriter writer = new StringWriter(); + StreamResult result = new StreamResult(writer); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.transform(domSource, result); + return writer.toString().getBytes(); + } catch (Exception e) { // We don't have another parser throw new IOException("No appropriate API (JAXP/Xerces) to serialize XML document: " + domImpl); } @@ -904,12 +831,11 @@ public abstract class OfficeDocument return bytes; } - /** - * Initializes a new DOM <code>Document</code> with the content - * containing minimum OpenOffice XML tags. + * Initializes a new DOM {@code Document} with the content containing + * minimum OpenOffice XML tags. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public final void initContentDOM() throws IOException { @@ -930,10 +856,10 @@ public abstract class OfficeDocument } /** - * Initializes a new DOM <code>Document</code> with the content - * containing minimum OpenOffice XML tags. + * Initializes a new DOM {@code Document} with the content containing + * minimum OpenOffice XML tags. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public final void initSettingsDOM() throws IOException { @@ -948,10 +874,10 @@ public abstract class OfficeDocument } /** - * Initializes a new DOM Document with styles - * containing minimum OpenOffice XML tags. + * Initializes a new DOM Document with styles containing minimum OpenOffice + * XML tags. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public final void initStyleDOM() throws IOException { @@ -959,30 +885,24 @@ public abstract class OfficeDocument } /** - * <p>Creates a new DOM <code>Document</code> containing minimum - * OpenOffice XML tags.</p> + * Creates a new DOM {@code Document} containing minimum OpenOffice XML tags. * - * <p>This method uses the subclass - * <code>getOfficeClassAttribute</code> method to get the - * attribute for <i>office:class</i>.</p> + * <p>This method uses the subclass {@code getOfficeClassAttribute} method + * to get the attribute for <i>office:class</i>.</p> * - * @param rootName root name of <code>Document</code>. + * @param rootName root name of {@code Document}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ private final Document createSettingsDOM(String rootName) throws IOException { Document doc = null; try { - DocumentBuilder builder = factory.newDocumentBuilder(); doc = builder.newDocument(); - } catch (ParserConfigurationException ex) { - throw new OfficeDocumentException(ex); - } Element root = doc.createElement(rootName); @@ -996,32 +916,25 @@ public abstract class OfficeDocument return doc; } - /** - * <p>Creates a new DOM <code>Document</code> containing minimum - * OpenOffice XML tags.</p> + * Creates a new DOM {@code Document} containing minimum OpenOffice XML tags. * - * <p>This method uses the subclass - * <code>getOfficeClassAttribute</code> method to get the - * attribute for <i>office:class</i>.</p> + * <p>This method uses the subclass {@code getOfficeClassAttribute} method + * to get the attribute for <i>office:class</i>.</p> * - * @param rootName root name of <code>Document</code>. + * @param rootName root name of <code>Document</code>. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ private final Document createDOM(String rootName) throws IOException { Document doc = null; try { - DocumentBuilder builder = factory.newDocumentBuilder(); doc = builder.newDocument(); - } catch (ParserConfigurationException ex) { - throw new OfficeDocumentException(ex); - } Element root = doc.createElement(rootName); @@ -1047,7 +960,6 @@ public abstract class OfficeDocument return doc; } - /** * Return the <i>office:class</i> attribute value. * @@ -1055,30 +967,29 @@ public abstract class OfficeDocument */ protected abstract String getOfficeClassAttribute(); - /** - * <p>Hacked code to filter <!DOCTYPE> tag before - * sending stream to parser.</p> + * Hacked code to filter {@literal <!DOCTYPE>} tag before sending stream to + * parser. * - * <p>This hacked code needs to be changed later on.</p> + * <p>This hacked code needs to be changed later on.</p> * - * <p>Issue: using current jaxp1.0 parser, there is no way - * to turn off processing of dtds. Current set of dtds - * have bugs, processing them will throw exceptions.</p> + * <p>Issue: using current jaxp1.0 parser, there is no way to turn off + * processing of dtds. Current set of dtds have bugs, processing them will + * throw exceptions.</p> * - * <p>This is a simple hack that assumes the whole <!DOCTYPE> - * tag are all in the same line. This is sufficient for - * current StarOffice 6.0 generated XML files. Since this - * hack really needs to go away, I don't want to spend - * too much time in making it a perfect hack.</p> - * FIX (HJ): Removed requirement for DOCTYPE to be in one line - * FIX (HJ): No longer removes newlines + * <p>This is a simple hack that assumes the whole {@literal <!DOCTYPE>} tag + * are all in the same line. This is sufficient for current StarOffice 6.0 + * generated XML files. Since this hack really needs to go away, I don't + * want to spend too much time in making it a perfect hack.</p> * - * @param is <code>InputStream</code> to be filtered. + * FIX (HJ): Removed requirement for DOCTYPE to be in one line + * FIX (HJ): No longer removes newlines * - * @return Reader value without the <!DOCTYPE> tag. + * @param is {@code InputStream} to be filtered. * - * @throws IOException If any I/O error occurs. + * @return Reader value without the {@literal <!DOCTYPE>} tag. + * + * @throws IOException If any I/O error occurs. */ private static Reader hack(InputStream is) throws IOException { @@ -1086,17 +997,14 @@ public abstract class OfficeDocument StringBuffer buffer = new StringBuffer(); String str; - while ((str = br.readLine()) != null) { int sIndex = str.indexOf("<!DOCTYPE"); - if (sIndex > -1) { buffer.append(str.substring(0, sIndex)); int eIndex = str.indexOf('>', sIndex + 8 ); - if (eIndex > -1) { buffer.append(str.substring(eIndex + 1, str.length())); @@ -1134,18 +1042,18 @@ public abstract class OfficeDocument } /** - * <p>Transform the InputStream to a Reader Stream.</p> + * Transform the {@code InputStream} to a Reader Stream. * - * <p>This hacked code needs to be changed later on.</p> + * <p>This hacked code needs to be changed later on.</p> * - * <p>Issue: the new oasis input file stream means - * that the old input stream fails. see #i33702# </p> + * <p>Issue: the new oasis input file stream means that the old input stream + * fails. see #i33702# </p> * - * @param is <code>InputStream</code> to be filtered. + * @param is {@code InputStream} to be filtered. * - * @return Reader value of the InputStream(). + * @return Reader value of the {@code InputStream()}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ private static Reader secondHack(InputStream is) throws IOException { @@ -1164,7 +1072,6 @@ public abstract class OfficeDocument return r; } - /** * Method to create the initial entries in the manifest.xml file stored * in an SX? file. @@ -1178,7 +1085,7 @@ public abstract class OfficeDocument DocumentType docType = domImpl.createDocumentType(TAG_MANIFEST_ROOT, "-//OpenOffice.org//DTD Manifest 1.0//EN", "Manifest.dtd"); - manifestDoc = domImpl.createDocument("manifest", TAG_MANIFEST_ROOT, docType); + manifestDoc = domImpl.createDocument("manifest", TAG_MANIFEST_ROOT, docType); } catch (ParserConfigurationException ex) { throw new OfficeDocumentException(ex); } @@ -1196,4 +1103,3 @@ public abstract class OfficeDocument manifestRoot.appendChild(docRoot); } } - diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java index 815c2b4a8b50..89f91499caaf 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocumentException.java @@ -26,21 +26,19 @@ import org.xml.sax.SAXParseException; import org.openoffice.xmerge.util.Resources; /** - * Used by OfficeDocument to encapsulate exceptions. It will add - * more details to the message string if it is of type - * <code>SAXParseException</code>. + * Used by OfficeDocument to encapsulate exceptions. + * + * <p>It will add more details to the message string if it is of type + * {@code SAXParseException}.</p> */ - public final class OfficeDocumentException extends IOException { private StringBuffer message = null; - /** - * Constructor, capturing additional information from the - * <code>SAXException</code>. + * Constructor, capturing additional information from the {@code SAXException}. * - * @param e The <code>SAXException</code>. + * @param e The {@code SAXException}. */ public OfficeDocumentException(SAXException e) { super(e.toString()); @@ -84,37 +82,32 @@ public final class OfficeDocumentException extends IOException { } } - /** - * Constructor, creates exception with provided message. + * Constructor, creates exception with provided message. * - * @param s Message value for the exception. + * @param s Message value for the exception. */ public OfficeDocumentException(String s) { super(s); } - /** - * Constructor, creates exception with the message - * corresponding to the message value of the provided - * exception. + * Constructor, creates exception with the message corresponding to the + * message value of the provided exception. * - * @param e The Exception. + * @param e The {@code Exception}. */ public OfficeDocumentException(Exception e) { super(e.getMessage()); } - /** - * Returns the message value for the <code>Exception</code>. + * Returns the message value for the {@code Exception}. * - * @return The message value for the <code>Exception</code>. + * @return The message value for the {@code Exception}. */ @Override public String getMessage() { return message.toString() + super.getMessage(); } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java index 1938a4e884d4..3bfaf3cb8404 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java @@ -33,11 +33,9 @@ import java.io.ByteArrayOutputStream; import org.openoffice.xmerge.util.Debug; /** - * Class used by {@link - * org.openoffice.xmerge.converter.xml.OfficeDocument - * OfficeDocument} to handle reading and writing - * from a ZIP file, as well as storing ZIP entries. - * + * Class used by {@link org.openoffice.xmerge.converter.xml.OfficeDocument + * OfficeDocument} to handle reading and writing from a ZIP file, as well as + * storing ZIP entries. */ class OfficeZip { @@ -65,20 +63,20 @@ class OfficeZip { entryList = new LinkedList<Entry>(); } - /** - * <p>Read each zip entry in the <code>InputStream</code> object - * and store in entryList both the <code>ZipEntry</code> object - * as well as the bits of each entry. Call this method before - * calling the <code>getContentXMLBytes</code> method or the - * <code>getStyleXMLBytes</code> method.</p> + * Read each zip entry in the {@code InputStream} object and store in + * entryList both the {@code ZipEntry} object as well as the bits of each + * entry. * - * <p>Keep track of the CONTENTXML and STYLEXML using - * contentIndex and styleIndex, respectively.</p> + * <p>Call this method before calling the {@code getContentXMLBytes} method + * or the {@code getStyleXMLBytes} method.</p> * - * @param is <code>InputStream</code> object to read. + * <p>Keep track of the {@code CONTENTXML} and {@code STYLEXML} using + * {@code contentIndex} and {@code styleIndex}, respectively.</p> * - * @throws IOException If any I/O error occurs. + * @param is {@code InputStream} object to read. + * + * @throws IOException If any I/O error occurs. */ void read(InputStream is) throws IOException { @@ -129,47 +127,48 @@ class OfficeZip { zis.close(); } - /** - * This method returns the CONTENTXML file in a - * <code>byte</code> array. It returns null if there is no - * CONTENTXML in this zip file. + * This method returns the CONTENTXML file in a {@code byte} array. * - * @return CONTENTXML in a <code>byte</code> array. + * <p>It returns null if there is no {@code CONTENTXML} in this zip file.</p> + * + * @return CONTENTXML in a {@code byte} array. */ byte[] getContentXMLBytes() { return getEntryBytes(contentIndex); } - /** - * This method returns the STYLEXML file in a - * <code>byte</code> array. It returns null if there is - * no STYLEXML in this zip file. + * This method returns the {@code STYLEXML} file in a {@code byte} array. * - * @return STYLEXML in a <code>byte</code> array. + * <p>It returns {@code null} if there is no {@code STYLEXML} in this zip + * file.</p> + * + * @return STYLEXML in a {@code byte} array. */ byte[] getStyleXMLBytes() { return getEntryBytes(styleIndex); } - /** - * This method returns the METAXML file in a - * <code>byte</code> array. It returns null if there is - * no METAXML in this zip file. + /** + * This method returns the METAXML file in a {@code byte} array. * - * @return METAXML in a <code>byte</code> array. + * <p>It returns {@code null} if there is no {@code METAXML} in this zip + * file.</p> + * + * @return METAXML in a {@code byte} array. */ byte[] getMetaXMLBytes() { return getEntryBytes(metaIndex); } - /** - * This method returns the SETTINGSXML file in a - * <code>byte</code> array. It returns null if there is - * no SETTINGSXML in this zip file. + /** + * This method returns the {@code SETTINGSXML} file in a {@code byte} array. + * + * <p>It returns {@code null} if there is no {@code SETTINGSXML} in this zip + * file.</p> * * @return SETTINGSXML in a <code>byte</code> array. */ @@ -178,10 +177,12 @@ class OfficeZip { } /** - * This method returns the MANIFESTXML file in a <code>byte</code> array. - * It returns null if there is no MANIFESTXML in this zip file. + * This method returns the {@code MANIFESTXML} file in a {@code byte} array. + * + * <p>It returns {@code null} if there is no {@code MANIFESTXML} in this zip + * file.</p> * - * @return MANIFESTXML in a <code>byte</code> array. + * @return MANIFESTXML in a {@code byte} array. */ byte[] getManifestXMLBytes() { return getEntryBytes(manifestIndex); @@ -193,8 +194,8 @@ class OfficeZip { * * @param name The name of the entry in the Zip file to retrieve. * - * @return The data for the named entry in a <code>byte</code> array or - * <code>null</code> if no entry is found. + * @return The data for the named entry in a {@code byte} array or + * {@code null} if no entry is found. */ byte[] getNamedBytes(String name) { @@ -214,13 +215,13 @@ class OfficeZip { return null; } - /** - * This method sets the bytes for the named entry. It searches for a - * matching entry in the LinkedList. If no entry is found, a new one is - * created. + * This method sets the bytes for the named entry. + * + * <p>It searches for a matching entry in the LinkedList. If no entry is + * found, a new one is created.</p> * - * Writing of data is defferred to setEntryBytes(). + * <p>Writing of data is deferred to {@code setEntryBytes()}.</p> * * @param name The name of the entry to search for. * @param bytes The new data to write. @@ -241,17 +242,14 @@ class OfficeZip { } /** - * Used by the <code>getContentXMLBytes</code> method and the - * <code>getStyleXMLBytes</code> method to return the - * <code>byte</code> array from the corresponding - * <code>entry</code> in the <code>entryList</code>. + * Used by the {@code getContentXMLBytes} method and the + * {@code getStyleXMLBytes} method to return the {@code byte} array from the + * corresponding {@code Entry} in the {@code entryList}. * - * @param index Index of <code>Entry</code> object in - * <code>entryList</code>. + * @param index Index of {@code Entry} object in {@code entryList}. * - * @return <code>byte</code> array associated in that - * <code>Entry</code> object or null, if there is - * not such <code>Entry</code>. + * @return {@code byte} array associated in that {@code Entry} object or + * {@code null}, if there is not such {@code Entry}. */ private byte[] getEntryBytes(int index) { @@ -264,90 +262,73 @@ class OfficeZip { return bytes; } - /** - * Set or replace the <code>byte</code> array for the - * CONTENTXML file. + * Set or replace the <code>byte</code> array for the {@code CONTENTXML} file. * - * @param bytes <code>byte</code> array for the - * CONTENTXML file. + * @param bytes {@code byte} array for the {@code CONTENTXML} file. */ void setContentXMLBytes(byte bytes[]) { contentIndex = setEntryBytes(contentIndex, bytes, CONTENTXML); } - /** - * Set or replace the <code>byte</code> array for the - * STYLEXML file. + * Set or replace the {@code byte} array for the {@code STYLEXML} file. * - * @param bytes <code>byte</code> array for the - * STYLEXML file. + * @param bytes {@code byte} array for the {@code STYLEXML} file. */ void setStyleXMLBytes(byte bytes[]) { styleIndex = setEntryBytes(styleIndex, bytes, STYLEXML); } - - /** - * Set or replace the <code>byte</code> array for the - * METAXML file. + /** + * Set or replace the {@code byte} array for the {@code METAXML} file. * - * @param bytes <code>byte</code> array for the - * METAXML file. + * @param bytes {@code byte} array for the {@code METAXML} file. */ void setMetaXMLBytes(byte bytes[]) { metaIndex = setEntryBytes(metaIndex, bytes, METAXML); } - - /** - * Set or replace the <code>byte</code> array for the - * SETTINGSXML file. + /** + * Set or replace the {@code byte} array for the {@code SETTINGSXML} file. * - * @param bytes <code>byte</code> array for the - * SETTINGSXML file. + * @param bytes {@code byte} array for the {@code SETTINGSXML} file. */ void setSettingsXMLBytes(byte bytes[]) { settingsIndex = setEntryBytes(settingsIndex, bytes, SETTINGSXML); } - /** - * Set or replace the <code>byte</code> array for the MANIFESTXML file. + * Set or replace the {@code byte} array for the {@code MANIFESTXML} file. * - * @param bytes <code>byte</code> array for the MANIFESTXML file. + * @param bytes {@code byte} array for the {@code MANIFESTXML} file. */ void setManifestXMLBytes(byte bytes[]) { manifestIndex = setEntryBytes(manifestIndex, bytes, MANIFESTXML); } /** - * <p>Used by the <code>setContentXMLBytes</code> method and - * the <code>setStyleXMLBytes</code> to either replace an - * existing <code>Entry</code>, or create a new entry in - * <code>entryList</code>.</p> + * Used by the {@code setContentXMLBytes} method and the + * {@code setStyleXMLBytes} to either replace an existing {@code Entry}, or + * create a new entry in {@code entryList}. * - * <p>If there is an <code>Entry</code> object within - * entryList that corresponds to the index, replace the - * <code>ZipEntry</code> info.</p> + * <p>If there is an {@code Entry} object within {@code entryList} that + * corresponds to the index, replace the {@code ZipEntry} info.</p> * - * @param index Index of <code>Entry</code> to modify. - * @param bytes <code>Entry</code> value. - * @param name Name of <code>Entry</code>. + * @param index Index of <code>Entry</code> to modify. + * @param bytes <code>Entry</code> value. + * @param name Name of <code>Entry</code>. * - * @return Index of value added or modified in entryList + * @return Index of value added or modified in entryList */ private int setEntryBytes(int index, byte bytes[], String name) { if (index > -1) { - // replace existing entry in entryList - Entry entry = entryList.get(index); name = entry.zipEntry.getName(); int method = entry.zipEntry.getMethod(); @@ -358,7 +339,6 @@ class OfficeZip { entry.bytes= bytes; } else { - // add a new entry into entryList ZipEntry ze = createZipEntry(name, bytes, ZipEntry.DEFLATED); Entry entry = new Entry(ze, bytes); @@ -369,14 +349,12 @@ class OfficeZip { return index; } - /** - * Write out the ZIP entries into the <code>OutputStream</code> - * object. + * Write out the ZIP entries into the {@code OutputStream} object. * - * @param os <code>OutputStream</code> object to write ZIP. + * @param os <code>OutputStream</code> object to write ZIP. * - * @throws IOException If any ZIP I/O error occurs. + * @throws IOException If any ZIP I/O error occurs. */ void write(OutputStream os) throws IOException { @@ -385,7 +363,6 @@ class OfficeZip { ZipOutputStream zos = new ZipOutputStream(os); ListIterator<Entry> iterator = entryList.listIterator(); - while (iterator.hasNext()) { Entry entry = iterator.next(); @@ -402,15 +379,14 @@ class OfficeZip { zos.close(); } - /** - * Creates a <code>ZipEntry</code> object based on the given params. + * Creates a {@code ZipEntry} object based on the given parameters. * - * @param name Name for the <code>ZipEntry</code>. - * @param bytes <code>byte</code> array for <code>ZipEntry</code>. - * @param method ZIP method to be used for <code>ZipEntry</code>. + * @param name Name for the {@code ZipEntry}. + * @param bytes {@code byte} array for {@code ZipEntry}. + * @param method ZIP method to be used for {@code ZipEntry}. * - * @return A <code>ZipEntry</code> object. + * @return A {@code ZipEntry} object. */ private ZipEntry createZipEntry(String name, byte bytes[], int method) { @@ -430,9 +406,10 @@ class OfficeZip { } /** - * This inner class is used as a data structure for holding - * a <code>ZipEntry</code> info and its corresponding bytes. - * These are stored in entryList. + * This inner class is used as a data structure for holding a {@code ZipEntry} + * info and its corresponding bytes. + * + * <p>These are stored in {@code entryList}.</p> */ private class Entry { @@ -444,5 +421,4 @@ class OfficeZip { this.bytes = bytes; } } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java index 8cafc8c985d3..3faeb876fd14 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java @@ -25,13 +25,12 @@ import org.w3c.dom.Element; import org.openoffice.xmerge.util.Debug; - abstract class conversionAlgorithm { abstract int I(String val); } /** - * This algorithm expects only values in millimeters, e.g. "20.3mm". + * This algorithm expects only values in millimeters, e.g. {@literal "20.3mm"}. */ class horizSize extends conversionAlgorithm { @Override @@ -54,10 +53,9 @@ class horizSize extends conversionAlgorithm { } } - -/* - * This algorithm does line height - can be either millimeters or - * a percentage. +/** + * This algorithm does line height {@literal -} can be either millimeters or a + * percentage. */ class lineHeight extends conversionAlgorithm { @Override @@ -88,9 +86,8 @@ class lineHeight extends conversionAlgorithm { } } - /** - * This class converts alignment values. + * This class converts alignment values. */ class alignment extends conversionAlgorithm { @Override @@ -115,52 +112,50 @@ class alignment extends conversionAlgorithm { } } - /** - * This class represents a paragraph <code>Style</code>. + * This class represents a paragraph {@code Style}. * - * <table summary="Paragraph style attributes and their values" border="1" cellpadding="1"> - * <caption>Table with all paragraph style attributes and their values</caption> - * <tr><td>Attribute</td><td>Value</td></tr> - * <tr><td>MARGIN_LEFT</td><td>mm * 100</td></tr> - * <tr><td>MARGIN_RIGHT</td><td>mm * 100</td></tr> - * <tr><td>MARGIN_TOP</td><td>mm * 100 (space on top of paragraph)</td></tr> - * <tr><td>MARGIN_BOTTOM</td><td>mm * 100</td></tr> - * <tr><td>TEXT_INDENT</td><td>mm * 100 (first line indent)</td></tr> - * <tr> - * <td>LINE_HEIGHT</td> - * <td>mm * 100, unless or'ed with LH_PCT, in which - * case it is a percentage (e.g. 200% for double spacing) - * Can also be or'ed with LH_ATLEAST. Value is stored - * in bits indicated by LH_VALUEMASK.</td> - * </tr> - * <tr><td>TEXT_ALIGN</td><td>ALIGN_RIGHT, ALIGN_CENTER, ALIGN_JUST, ALIGN_LEFT</td></tr> - * </table> + * <blockquote><table summary="Paragraph style attributes and their values" + * border="1" cellpadding="3" cellspacing="0"> + * <caption>Table with all paragraph style attributes and their values</caption> + * <tr><th>Attribute</th><th>Value</th></tr> + * <tr><td>MARGIN_LEFT</td><td>mm * 100</td></tr> + * <tr><td>MARGIN_RIGHT</td><td>mm * 100</td></tr> + * <tr><td>MARGIN_TOP</td><td>mm * 100 (space on top of paragraph)</td></tr> + * <tr><td>MARGIN_BOTTOM</td><td>mm * 100</td></tr> + * <tr><td>TEXT_INDENT</td><td>mm * 100 (first line indent)</td></tr> + * <tr> + * <td>LINE_HEIGHT</td> + * <td>mm * 100, unless or'ed with LH_PCT, in which case it is a percentage + * (e.g. 200% for double spacing) Can also be or'ed with LH_ATLEAST. + * Value is stored in bits indicated by LH_VALUEMASK.</td> + * </tr> + * <tr> + * <td>TEXT_ALIGN</td> + * <td>ALIGN_RIGHT, ALIGN_CENTER, ALIGN_JUST, ALIGN_LEFT</td> + * </tr> + * </table></blockquote> */ public class ParaStyle extends Style implements Cloneable { - - - - - /** Indent left property. */ + /** Indent left property. */ private static final int TEXT_INDENT = 4; - /** Indent right property. */ + /** Indent right property. */ private static final int LINE_HEIGHT = 5; - /** Align text property. */ + /** Align text property. */ private static final int TEXT_ALIGN = 6; // This must always be one more than highest property - /** Total number of properties. */ + /** Total number of properties. */ private static final int NR_PROPERTIES = 7; /** - * Array of flags indicating which attributes are set for this - * paragraph <code>Style</code>. + * Array of flags indicating which attributes are set for this paragraph + * {@code Style}. */ private boolean isSet[] = new boolean[NR_PROPERTIES]; - /** Array of attribute values for this paragraph <code>tyle</code>. */ + /** Array of attribute values for this paragraph {@code Style}. */ private int value[] = new int[NR_PROPERTIES]; - /** Array of attribute names for this paragraph <code>Style</code>. */ + /** Array of attribute names for this paragraph {@code Style}. */ private String attrName[] = { "fo:margin-left", "fo:margin-right", @@ -171,7 +166,7 @@ public class ParaStyle extends Style implements Cloneable { "fo:text-align" }; - /** Array of attribute structures for this paragraph <code>Style</code>. */ + /** Array of attribute structures for this paragraph {@code Style}. */ private Class<?> algor[] = { horizSize.class, horizSize.class, @@ -182,22 +177,22 @@ public class ParaStyle extends Style implements Cloneable { alignment.class }; - /** Align right. */ + /** Align right. */ public static final int ALIGN_RIGHT = 1; - /** Align center. */ + /** Align center. */ public static final int ALIGN_CENTER = 2; - /** Align justified. */ + /** Align justified. */ public static final int ALIGN_JUST = 3; - /** Align left. */ + /** Align left. */ public static final int ALIGN_LEFT = 4; - /** Line height percentage. */ + /** Line height percentage. */ public static final int LH_PCT = 0x40000000; - /** Line height mask. */ - private static final int LH_VALUEMASK = 0x00FFFFFF; + /** Line height mask. */ + private static final int LH_VALUEMASK = 0x00FFFFFF; - /** Ignored tags. */ + /** Ignored tags. */ private static String[] ignored = { "style:font-name", "fo:font-size", "fo:font-weight", "fo:color", "fo:language", "fo:country", "style:font-name-asian", @@ -209,15 +204,13 @@ public class ParaStyle extends Style implements Cloneable { "text:number-lines", "text:line-number" }; - /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node A <i>style:style</i> <code>Node</code> which, which - * is assumed to have <i>family</i> attribute of - * <i>paragraph</i>. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node A <i>style:style</i> {@code Node} which, which is assumed + * to have <i>family</i> attribute of <i>paragraph</i>. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public ParaStyle(Node node, StyleCatalog sc) { @@ -247,19 +240,18 @@ public class ParaStyle extends Style implements Cloneable { } } - /** - * Constructor for use when going from client device format to DOM. + * Constructor for use when going from client device format to DOM. * - * @param name Name of the <code>Style</code>. Can be null. - * @param familyName Family of the <code>Style</code> - usually - * <i>paragraph</i>, <i>text</i>, etc. Can be null. - * @param parentName Name of the parent <code>Style</code>, or null - * if none. - * @param attribs Array of attributes to set. - * @param values Array of values to set. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of the {@code Style}. Can be {@code null}. + * @param familyName Family of the {@code Style} {@literal -} usually + * <i>paragraph</i>, <i>text</i>, etc. Can be {@code null}. + * @param parentName Name of the parent {@code Style}, or {@code null} + * if none. + * @param attribs Array of attributes to set. + * @param values Array of values to set. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public ParaStyle(String name, String familyName, String parentName, String attribs[], String values[], StyleCatalog sc) { @@ -269,20 +261,17 @@ public class ParaStyle extends Style implements Cloneable { setAttribute(attribs[i], values[i]); } - /** - * Alternate constructor for use when going from client device - * format to DOM. + * Alternate constructor for use when going from client device format to DOM. * - * @param name Name of the <code>Style</code>. Can be null. - * @param familyName Family of the <code>Style</code> - usually - * <i>paragraph</i>, <i>text</i>, etc. Can be null. - * @param parentName Name of the parent <code>Style</code>, or - * null if none. - * @param attribs Array of attributes indices to set. - * @param values Array of values to set. - * @param lookup The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of the {@code Style}. Can be {@code null}. + * @param familyName Family of the {@code Style} {@literal -} usually + * <i>paragraph</i>, <i>text</i>, etc. Can be {@code null}. + * @param parentName Name of the parent {@code Style}, or null if none. + * @param attribs Array of attributes indices to set. + * @param values Array of values to set. + * @param lookup The {@code StyleCatalog}, which is used for looking + * up ancestor {@code Style} objects. */ public ParaStyle(String name, String familyName, String parentName, int attribs[], String values[], StyleCatalog lookup) { @@ -292,14 +281,12 @@ public class ParaStyle extends Style implements Cloneable { setAttribute(attribs[i], values[i]); } - /** - * This code checks whether an attribute is one that we - * intentionally ignore. + * This code checks whether an attribute is one that we intentionally ignore. * - * @param attribute The attribute to check. + * @param attribute The attribute to check. * - * @return true if attribute can be ignored, false otherwise. + * @return {@code true} if attribute can be ignored, {@code false} otherwise. */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { @@ -309,12 +296,11 @@ public class ParaStyle extends Style implements Cloneable { return false; } - /** - * Set an attribute for this paragraph <code>Style</code>. + * Set an attribute for this paragraph {@code Style}. * - * @param attr The attribute to set. - * @param value The attribute value to set. + * @param attr The attribute to set. + * @param value The attribute value to set. */ private void setAttribute(String attr, String value) { for (int i = 0; i < NR_PROPERTIES; i++) { @@ -327,18 +313,11 @@ public class ParaStyle extends Style implements Cloneable { Debug.log(Debug.INFO, "ParaStyle Unhandled: " + attr + "=" + value); } - - - - - - - /** - * Set an attribute for this paragraph <code>Style</code>. + * Set an attribute for this paragraph {@code Style}. * - * @param attr The attribute index to set. - * @param value The attribute value to set. + * @param attr The attribute index to set. + * @param value The attribute value to set. */ private void setAttribute(int attr, String value) { isSet[attr] = true; @@ -349,11 +328,10 @@ public class ParaStyle extends Style implements Cloneable { } } - /** - * Return the <code>Style</code> in use. + * Return the {@code Style} in use. * - * @return The fully-resolved copy of the <code>Style</code> in use. + * @return The fully-resolved copy of the {@code Style} in use. */ @Override public Style getResolved() { @@ -396,14 +374,13 @@ public class ParaStyle extends Style implements Cloneable { return resolved; } - /** - * Private function to return the value as an element in - * a Comma Separated Value (CSV) format. + * Private function to return the value as an element in a Comma Separated + * Value (CSV) format. * - * @param value The value to format. + * @param value The value to format. * - * @return The formatted value. + * @return The formatted value. */ private static String toCSV(String value) { if (value != null) @@ -412,14 +389,13 @@ public class ParaStyle extends Style implements Cloneable { return "\"\","; } - /** - * Private function to return the value as a last element in - * a Comma Separated Value (CSV) format. + * Private function to return the value as a last element in a Comma + * Separated Value (CSV) format. * - * @param value The value to format. + * @param value The value to format. * - * @return The formatted value. + * @return The formatted value. */ private static String toLastCSV(String value) { if (value != null) @@ -428,10 +404,8 @@ public class ParaStyle extends Style implements Cloneable { return "\"\""; } - /** - * Print a Comma Separated Value (CSV) header line for the - * spreadsheet dump. + * Print a Comma Separated Value (CSV) header line for the spreadsheet dump. */ public static void dumpHdr() { System.out.println(toCSV("Name") + toCSV("Family") + toCSV("parent") @@ -440,10 +414,8 @@ public class ParaStyle extends Style implements Cloneable { + toCSV("line height") + toLastCSV("txt align")); } - /** - * Dump this <code>Style</code> as a Comma Separated Value (CSV) - * line. + * Dump this {@code Style} as a Comma Separated Value (CSV) line. */ public void dumpCSV() { String attributes = ""; @@ -458,15 +430,13 @@ public class ParaStyle extends Style implements Cloneable { + attributes + toLastCSV(null)); } - /** - * Create the <code>Node</code> with the specified elements. + * Create the {@code Node} with the specified elements. * - * @param parentDoc Parent <code>Document</code> of the - * <code>Node</code> to create. - * @param name Name of the <code>Node</code>. + * @param parentDoc Parent {@code Document} of the {@code Node} to create. + * @param name Name of the {@code Node}. * - * @return The created <code>Node</code>. + * @return The created {@code Node}. */ @Override public Node createNode(org.w3c.dom.Document parentDoc, String name) { @@ -475,15 +445,13 @@ public class ParaStyle extends Style implements Cloneable { return node; } - /** - * Return true if <code>style</code> is a subset of the - * <code>Style</code>. + * Return {@code true} if {@code style} is a subset of the {@code Style}. * - * @param style <code>Style</code> to check. + * @param style {@code Style} to check. * - * @return true if <code>style</code> is a subset, false - * otherwise. + * @return {@code true} if <code>style</code> is a subset, {@code false} + * otherwise. */ @Override public boolean isSubset(Style style) { @@ -518,14 +486,12 @@ public class ParaStyle extends Style implements Cloneable { return true; } - /** - * Add <code>Style</code> attributes to the given - * <code>Node</code>. This may involve writing child - * <code>Node</code> objects as well. + * Add {@code Style} attributes to the given {@code Node}. + * + * <p>This may involve writing child {@code Node} objects as well.</p> * - * @param node The <code>Node</code> to add <code>Style</code> - * attributes. + * @param node The {@code Node} to add {@code Style} attributes. */ private void writeAttributes(Element node) { for (int i = 0; i <= TEXT_INDENT; i++) { @@ -559,5 +525,4 @@ public class ParaStyle extends Style implements Cloneable { node.setAttribute(attrName[TEXT_ALIGN], val); } } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java index 1f5bcd5ce44c..d28d6a45fd1d 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/Style.java @@ -22,40 +22,39 @@ import org.w3c.dom.Node; import org.w3c.dom.NamedNodeMap; /** - * An object of class <code>Style</code> represents a <i>style</i> - * in an OpenOffice document. In practice subclasses of this - * <code>Style</code>, such as <code>TextStyle</code>, - * <code>ParaStyle</code> are used. + * An object of class {@code Style} represents a <i>style</i> in an OpenOffice + * document. * - * @see <a href="TextStyle.html">TextStyle</a> - * @see <a href="ParaStyle.html">ParaStyle</a> + * <p>In practice subclasses of this {@code Style}, such as {@code TextStyle}, + * {@code ParaStyle} are used.</p> + * + * @see <a href="TextStyle.html">TextStyle</a> + * @see <a href="ParaStyle.html">ParaStyle</a> */ public class Style { - /** Name of the <code>Style</code>. */ + /** Name of the {@code Style}. */ protected String name = null; - /** Family of the <code>Style</code>. */ + /** Family of the {@code Style}. */ protected String family = null; - /** Parent of the <code>Style</code>. */ + /** Parent of the {@code Style}. */ protected String parent = null; /** - * A reference to the <code>StyleCatalog</code> to be used for - * looking up ancestor <code>Style</code> objects. + * A reference to the {@code StyleCatalog} to be used for looking up ancestor + * {@code Style} objects. */ protected StyleCatalog sc; - /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node A <i>style:style</i> or <i>style:default-style</i> - * <code>Node</code> from the document being parsed. - * No checking of <code>Node</code> is done, so if it - * is not of the proper type the results will be - * unpredictable. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node A <i>style:style</i> or <i>style:default-style</i> + * {@code Node} from the document being parsed. No checking of + * {@code Node} is done, so if it is not of the proper type + * the results will be unpredictable. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public Style(Node node, StyleCatalog sc) { @@ -81,16 +80,15 @@ public class Style { } } - /** - * Constructor for use when going from client device format to DOM. + * Constructor for use when going from client device format to DOM. * - * @param name Name of the <code>Style</code>. Can be null. - * @param family Family of the <code>Style</code> - usually - * <i>paragraph</i>, <i>text</i>, etc. Can be null. - * @param parent Name of the parent <code>Style</code>, or null if none. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of the {@code Style}. Can be {@code null}. + * @param family Family of the {@code Style} {@literal -} usually + * <i>paragraph</i>, <i>text</i>, etc. Can be {@code null}. + * @param parent Name of the parent {@code Style}, or {@code null} if none. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public Style(String name, String family, String parent, StyleCatalog sc) { this.sc = sc; @@ -99,107 +97,95 @@ public class Style { this.parent = parent; } - /** - * Set the <code>StyleCatalog</code> to be used when looking up the - * <code>Style</code> parent. + * Set the {@code StyleCatalog} to be used when looking up the {@code Style} + * parent. * - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public void setCatalog(StyleCatalog sc) { this.sc = sc; } - /** - * Returns the name of this <code>Style</code>. + * Returns the name of this {@code Style}. * - * @return The name of this <code>Style</code>. + * @return The name of this {@code Style}. */ public String getName() { return name; } - /** - * Sets the name of this <code>Style</code>. + * Sets the name of this {@code Style}. * - * @param newName The new name of this <code>Style</code>. + * @param newName The new name of this {@code Style}. */ public void setName(String newName) { name = newName; } - /** - * Return the family of this <code>Style</code>. + * Return the family of this {@code Style}. * - * @return The family of this <code>Style</code>. + * @return The family of this {@code Style}. */ public String getFamily() { return family; } /** - * Return the name of the parent of this <code>Style</code>. + * Return the name of the parent of this {@code Style}. * - * @return The parent of this <code>Style</code>. + * @return The parent of this {@code Style}. */ public String getParent() { return parent; } - /** - * Return a <code>Style</code> object corresponding to this one, but with - * all of the inherited information from parent <code>Style</code> - * objects filled in. The object returned will be a new object, not a - * reference to this object, even if it does not need any information - * added. + * Return a {@code Style} object corresponding to this one, but with all of + * the inherited information from parent {@code Style} objects filled in. + * + * <p>The object returned will be a new object, not a reference to this + * object, even if it does not need any information added.</p> * - * @return A resolved <code>Style</code> object in which to look up - * ancestors. + * @return A resolved {@code Style} object in which to look up ancestors. */ public Style getResolved() { return new Style(name, family, parent, sc); } - /** - * Write a <code>Node</code> in <code>parentDoc</code> - * representing this <code>Style</code>. Note that the - * <code>Node</code> is returned unconnected. + * Write a {@code Node} in {@code parentDoc} representing this {@code Style}. + * + * <p>Note that the {@code Node} is returned unconnected.</p> * - * @param parentDoc Document to which new <code>Node</code> will - * belong. - * @param name Name to use for new <code>Node</code>. + * @param parentDoc Document to which new {@code Node} will belong. + * @param name Name to use for new {@code Node}. */ public Node createNode(org.w3c.dom.Document parentDoc, String name) { // DJP: write this! Should call writeAttributes() return null; } - - - - /** - * Return true if <code>Style</code> is a subset of this one. Note - * that this will return true even if <code>Style</code> is less - * specific than this <code>Style</code>, so long as it does not - * contradict this <code>Style</code> in any way. + * Return {@code true} if {@code Style} is a subset of this one. * - * This always returns true since only subclasses of - * <code>Style</code> contain any actual <code>Style</code> - * information. + * <p>Note that this will return true even if {@code Style} is less specific + * than this {@code Style}, so long as it does not contradict this + * {@code Style} in any way.</p> * - * @param style The <code>Style</code> to check + * <p>This always returns true since only subclasses of {@code Style} + * contain any actual {@code Style} information.</p> * - * @return true if the <code>Style</code> is a subset, false otherwise. + * @param style The {@code Style} to check. + * + * @return {@code true} if the {@code Style} is a subset, {@code false} + * otherwise. */ public boolean isSubset(Style style) { return true; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java index 70ac5cebfd35..ac66285b4e45 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java @@ -27,67 +27,61 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - /** - * A <code>StyleCatalog</code> holds a collection of <code>Style</code> - * objects. It is intended for use when parsing or building a DOM - * document. + * A {@code StyleCatalog} holds a collection of {@code Style} objects. + * + * <p>It is intended for use when parsing or building a DOM document.</p> * - * Each entry in the <code>StyleCatalog</code> represents a - * <code>Style</code>, and is an object which is a subclass of - * <code>Style</code>. + * <p>Each entry in the {@code StyleCatalog} represents a {@code Style}, and is + * an object which is a subclass of {@code Style}.</p> * - * @see <a href="Style.html">Style</a> + * @see <a href="Style.html">Style</a> */ public class StyleCatalog { private ArrayList<Style> styles; // The actual styles /** - * Constructor + * Constructor. * - * @param initialEntries Expected number of entries to set - * for efficiency purposes. + * @param initialEntries Expected number of entries to set for efficiency + * purposes. */ public StyleCatalog(int initialEntries) { styles = new ArrayList<Style>(initialEntries); } - /** - * <p>Parse the <code>Document</code> starting from <code>node</code> - * and working downward, and add all styles found, so long as their - * family name is listed in <code>families</code>. For each - * family name in <code>families</code> there must be a corresponding - * element in <code>classes</code>, which specifies the class type - * to use for that family. All of these classes must be - * subclasses of <code>Style</code>. There can be multiple - * classes specified for a particular family.</p> + * Parse the {@code Document} starting from {@code node} and working downward, + * and add all styles found, so long as their family name is listed in + * {@code families}. * - * <p>If <code>defaultClass</code> is non-null, then all styles that - * are found will be added. Any <code>Style</code> whose family is - * not listed in <code>families</code> will be added using defaultClass, - * which, of course, must be a subclass of <code>Style</code>. - * If <code>alwaysCreateDefault</code> is true, then a class - * of type <code>defaultClass</code> will always be created, - * regardless of whether there was also a match in - * <code>families</code>.</p> + * <p>For each family name in {@code families} there must be a corresponding + * element in {@code classes}, which specifies the class type to use for that + * family. All of these classes must be subclasses of {@code Style}. There + * can be multiple classes specified for a particular family.</p> * - * <p>DJP Todo: make it recursive so that <code>node</code> can be - * higher up in the <code>Document</code> tree.</p> + * <p>If {@code defaultClass} is non-null, then all styles that are found + * will be added. Any {@code Style} whose family is not listed in + * {@code families} will be added using defaultClass, which, of course, must + * be a subclass of {@code Style}. If {@code alwaysCreateDefault} is + * {@code true}, then a class of type {@code defaultClass} will always be + * created, regardless of whether there was also a match in {@code families}. + * </p> * - * @param node The node to be searched for - * <code>Style</code> objects. - * @param families An array of <code>Style</code> families - * to add. - * @param classes An array of class types corresponding - * to the families array. - * @param defaultClass All <code>Style</code> objects that are - * found are added to this class. - * @param alwaysCreateDefault A class of type <code>defaultClass</code> - * will always be created, regardless of - * whether there is a match in the - * families array. + * <p>DJP ToDo: make it recursive so that {@code node} can be higher up in + * the {@code Document} tree.</p> + * + * @param node The node to be searched for {@code Style} + * objects. + * @param families An array of {@code Style} families to add. + * @param classes An array of class types corresponding to the + * families array. + * @param defaultClass All {@code Style} objects that are found are + * added to this class. + * @param alwaysCreateDefault A class of type {@code defaultClass} will + * always be created, regardless of whether + * there is a match in the families array. */ public void add(Node node, String families[], Class<?> classes[], Class<?> defaultClass, boolean alwaysCreateDefault) { @@ -127,14 +121,12 @@ public class StyleCatalog { } } - /** - * Call the constructor of class <code>cls</code> with parameters - * <code>node</code>, and add the resulting <code>Style</code> to - * the catalog. + * Call the constructor of class {@code cls} with parameters {@code node}, + * and add the resulting {@code Style} to the catalog. * - * @param cls The class whose constructor will be called. - * @param node The constructed class will be added to this node. + * @param cls The class whose constructor will be called. + * @param node The constructed class will be added to this node. */ private void callConstructor(Class<?> cls, Node node) { Class<?> params[] = new Class[2]; @@ -151,31 +143,29 @@ public class StyleCatalog { } } - /** - * Add a <code>Style</code> to the catalog. + * Add a {@code Style} to the catalog. * - * @param s The <code>Style</code> to add. + * @param s The {@code Style} to add. */ public void add(Style s) { styles.add(s); } - /** - * Return the first <code>Style</code> matching the specified names. + * Return the first {@code Style} matching the specified names. * - * @param name Name to match, null is considered + * @param name Name to match, {@code null} is considered * <i>always match</i>. - * @param family Family to match, null is considered + * @param family Family to match, {@code null} is considered * <i>always match</i>. - * @param parent Parent to match, null is considered + * @param parent Parent to match, {@code null} is considered * <i>always match</i>. - * @param styleClass styleClass to match, null is considered + * @param styleClass styleClass to match, {@code null} is considered * <i>always match</i>. * - * @return <code>Style</code> value if all parameters match, - * null otherwise + * @return {@code Style} value if all parameters match, {@code null} + * otherwise. */ public Style lookup(String name, String family, String parent, Class<?> styleClass) { @@ -199,15 +189,13 @@ public class StyleCatalog { return null; // none found } - /** - * Given a <code>Style</code> <code>s</code> return all - * <code>Style</code> objects that match. + * Given a {@code Style s} return all {@code Style} objects that match. * - * @param s <code>Style</code> to match. + * @param s {@code Style} to match. * - * @return An array of <code>Style</code> objects that match, an - * empty array if none match. + * @return An array of {@code Style} objects that match, an empty array if + * none match. */ public Style[] getMatching(Style s) { @@ -230,24 +218,18 @@ public class StyleCatalog { return matchArray; } - - - - /** - * <p>Create a <code>Node</code> named <code>name</code> in - * <code>Document</code> <code>parentDoc</code>, and write the - * entire <code>StyleCatalog</code> to it.</p> + * Create a {@code Node} named {@code name} in {@code Document parentDoc}, + * and write the entire {@code StyleCatalog} to it. * - * <p>Note that the resulting node is returned, but is not connected - * into the document. Placing the output node in the document is - * left to the caller.</p> + * <p>Note that the resulting node is returned, but is not connected into the + * document. Placing the output node in the document is left to the caller. + * </p> * - * @param parentDoc The <code>Document</code> to add the - * <code>Node</code>. - * @param name The name of the <code>Node</code> to add. + * @param parentDoc The {@code Document} to add the {@code Node}. + * @param name The name of the {@code Node} to add. * - * @return The <code>Element</code> that was created. + * @return The {@code Element} that was created. */ public Element writeNode(org.w3c.dom.Document parentDoc, String name) { Element rootNode = parentDoc.createElement(name); @@ -276,17 +258,12 @@ public class StyleCatalog { return rootNode; } - - - - /** - * Find the family attribute of a <code>Style</code> <code>Node</code>. + * Find the family attribute of a {@code Style Node}. * - * @param node The <code>Node</code> to check. + * @param node The {@code Node} to check. * - * @return The family attribute, or null if one does not - * exist. + * @return The family attribute, or {@code null} if one does not exist. */ private String getFamilyName(Node node) { NamedNodeMap attributes = node.getAttributes(); @@ -301,5 +278,4 @@ public class StyleCatalog { } return null; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java index c752f1e1fb4f..41fb07014a4c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java @@ -30,12 +30,10 @@ import org.w3c.dom.Element; import org.openoffice.xmerge.util.Debug; /** - * Represents a text <code>Style</code> in an OpenOffice document. - * + * Represents a text {@code Style} in an OpenOffice document. */ public class TextStyle extends Style implements Cloneable { - /** Indicates <i>bold</i> text. */ final private static int BOLD = 0x01; /** Indicates <i>italic</i> text. */ @@ -49,7 +47,6 @@ public class TextStyle extends Style implements Cloneable { /** Indicates <i>subscripted</i> text. */ final private static int SUBSCRIPT = 0x20; - /** Values of text attributes. */ private int values = 0; /** Bitwise mask of text attributes. */ @@ -59,19 +56,19 @@ public class TextStyle extends Style implements Cloneable { private int sizeInPoints = 0; /** Font name. */ private String fontName = null; - /** Font <code>Color</code>. */ + /** Font {@code Color}. */ private Color fontColor = null; - /** Background <code>Color</code>. */ + /** Background {@code Color}. */ private Color bgColor = null; /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node The <i>style:style</i> <code>Node</code> containing - * the <code>Style</code>. (This <code>Node</code> is - * assumed have a <i>family</i> attribute of <i>text</i>). - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node The <i>style:style</i> {@code Node} containing the + * {@code Style}. (This {@code Node} is assumed have a + * <i>family</i> attribute of <i>text</i>). + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public TextStyle(Node node, StyleCatalog sc) { super(node, sc); @@ -111,35 +108,31 @@ public class TextStyle extends Style implements Cloneable { } } - /** - * Constructor for use when going from client device format to DOM + * Constructor for use when going from client device format to DOM * - * @param name Name of text <code>Style</code>. Can be null. - * @param family Family of text <code>Style</code> (usually - * <i>text</i>). Can be null. - * @param parent Name of parent text <code>Style</code>, or null - * for none. - * @param mask Bitwise mask of text attributes that this text - * <code>Style</code> will specify. Can be any - * combination of the following, or'ed together: - * {@link #BOLD}, {@link #ITALIC}, {@link #UNDERLINE}, - * {@link #STRIKETHRU}, {@link #SUPERSCRIPT}, - * {@link #SUBSCRIPT}. This parameter determines what - * attributes this <code>Style</code> will specify. - * When an attribute is specified in a - * <code>Style</code>, its value can be either - * <i>on</i> or <i>off</i>. The on/off value for - * each attribute is controlled by the - * <code>values</code> parameter. - * @param values Values of text attributes that this text - * <code>Style</code> will be setting. Any of the - * attributes ({@link #BOLD}, etc) listed for - * <code>mask</code> can be used for this. - * @param fontSize Font size in points. - * @param fontName Name of font. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of text {@code Style}. Can be {@code null}. + * @param family Family of text {@code Style} (usually <i>text</i>). + * Can be {@code null}. + * @param parent Name of parent text {@code Style}, or {@code null} for + * none. + * @param mask Bitwise mask of text attributes that this text + * {@code Style} will specify. Can be any combination of + * the following, or'ed together: {@link #BOLD}, + * {@link #ITALIC}, {@link #UNDERLINE}, {@link #STRIKETHRU}, + * {@link #SUPERSCRIPT}, {@link #SUBSCRIPT}. This parameter + * determines what attributes this {@code Style} will + * specify. When an attribute is specified in a + * {@code Style}, its value can be either <i>on</i> or + * <i>off</i>. The on/off value for each attribute is + * controlled by the {@code values} parameter. + * @param values Values of text attributes that this text {@code Style} + * will be setting. Any of the attributes ({@link #BOLD}, + * etc) listed for {@code mask} can be used for this. + * @param fontSize Font size in points. + * @param fontName Name of font. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public TextStyle(String name, String family, String parent, int mask, int values, int fontSize, String fontName, StyleCatalog sc) { @@ -150,13 +143,12 @@ public class TextStyle extends Style implements Cloneable { this.fontName = fontName; } - /** - * Parse a color specification of the form <i>#rrggbb</i> + * Parse a color specification of the form <i>#rrggbb</i> * - * @param value <code>Color</code> specification to parse. + * @param value {@code Color} specification to parse. * - * @return The <code>Color</code> associated the value. + * @return The {@code Color} associated the value. */ private Color parseColorString(String value) { // Assume color value is of form #rrggbb @@ -176,12 +168,11 @@ public class TextStyle extends Style implements Cloneable { return new Color(red, green, blue); } - /** - * Set an attribute. + * Set an attribute. * - * @param attr The attribute to set. - * @param value The attribute value to set. + * @param attr The attribute to set. + * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { @@ -257,70 +248,56 @@ public class TextStyle extends Style implements Cloneable { } } - - - - - - - /** - * Return the font size for this <code>Style</code>. + * Return the font size for this {@code Style}. * - * @return The font size in points + * @return The font size in points */ public int getFontSize() { return sizeInPoints; } - /** - * Return the name of the font for this <code>Style</code>. + * Return the name of the font for this {@code Style}. * - * @return Name of font, or null if no font is specified by - * this <code>Style</code>. + * @return Name of font, or null if no font is specified by this + * {@code Style}. */ public String getFontName() { return fontName; } - /** - * Return the font <code>Color</code> for this <code>Style</code>. - * Can be null if none was specified. + * Return the font {@code Color} for this {@code Style}. * - * @return <code>Color</code> value for this <code>Style</code>. - * Can be null. + * <p>Can be {@code null} if none was specified.</p> + * + * @return {@code Color} value for this {@code Style}. Can be {@code null}. */ public Color getFontColor() { return fontColor; } - /** - * Return the background <code>Color</code> for this - * <code>Style</code>. Can be null if none was specified. + * Return the background {@code Color} for this {@code Style}. * - * @return Background <code>Color</code> value for this - * <code>Style</code>. Can be null. + * <p>Can be {@code null} if none was specified.</p> + * + * @return Background {@code Color} value for this {@code Style}. Can be + * {@code null}. */ public Color getBackgroundColor() { return bgColor; } - - - - /** - * Return a <code>Style</code> object corresponding to this one, - * but with all of the inherited information from parent - * <code>Style</code> objects filled in. The object returned will - * be a new object, not a reference to this object, even if it does - * not need any information added. + * Return a {@code Style} object corresponding to this one, but with all of + * the inherited information from parent {@code Style} objects filled in. * - * @return The <code>StyleCatalog</code> in which to look up - * ancestors. + * <p>The object returned will be a new object, not a reference to this + * object, even if it does not need any information added.</p> + * + * @return The {@code StyleCatalog} in which to look up ancestors. */ @Override public Style getResolved() { @@ -375,36 +352,33 @@ public class TextStyle extends Style implements Cloneable { return resolved; } - /** - * Set one or more text attributes to <i>on</i>. + * Set one or more text attributes to <i>on</i>. * - * @param flags Flag values to set <i>on</i>. + * @param flags Flag values to set <i>on</i>. */ private void turnAttributesOn(int flags) { mask |= flags; values |= flags; } - /** - * Set one or more text attributes to <i>off</i>. + * Set one or more text attributes to <i>off</i>. * - * @param flags The flag values to set <i>off</i>. + * @param flags The flag values to set <i>off</i>. */ private void turnAttributesOff(int flags) { mask |= flags; values &= ~flags; } - /** - * Private function to return the value as an element in - * a Comma Separated Value (CSV) format. + * Private function to return the value as an element in a Comma Separated + * Value (CSV) format. * - * @param value The value to format. + * @param value The value to format. * - * @return The formatted value. + * @return The formatted value. */ private static String toCSV(String value) { if (value != null) @@ -413,14 +387,13 @@ public class TextStyle extends Style implements Cloneable { return "\"\","; } - /** - * Private function to return the value as a last element in - * a Comma Separated Value (CSV) format. + * Private function to return the value as a last element in a Comma + * Separated Value (CSV) format. * - * @param value The value to format. + * @param value The value to format. * - * @return The formatted value. + * @return The formatted value. */ private static String toLastCSV(String value) { if (value != null) @@ -429,10 +402,8 @@ public class TextStyle extends Style implements Cloneable { return "\"\""; } - /** - * Print a Comma Separated Value (CSV) header line for the - * spreadsheet dump. + * Print a Comma Separated Value (CSV) header line for the spreadsheet dump. */ public static void dumpHdr() { System.out.println(toCSV("Name") + toCSV("Family") + toCSV("parent") @@ -441,9 +412,8 @@ public class TextStyle extends Style implements Cloneable { + toCSV("Strikethru") + toCSV("Superscript") + toLastCSV("Subscript")); } - /** - * Dump this <code>Style</code> as a Comma Separated Value (CSV) line. + * Dump this {@code Style} as a Comma Separated Value (CSV) line. */ public void dumpCSV() { String attributes = ""; @@ -456,17 +426,15 @@ public class TextStyle extends Style implements Cloneable { + toCSV(fontName) + toCSV("" + sizeInPoints) + attributes + toLastCSV(null)); } - /** - * Create a new <code>Node</code> in the <code>Document</code>, and - * write this <code>Style</code> to it. + * Create a new {@code Node} in the {@code Document}, and write this + * {@code Style} to it. * - * @param parentDoc Parent <code>Document</code> of the - * <code>Node</code> to create. - * @param name Name to use for the new <code>Node</code> (e.g. - * <i>style:style</i>) + * @param parentDoc Parent {@code Document} of the {@code Node} to create. + * @param name Name to use for the new {@code Node} (e.g. + * <i>style:style</i>) * - * @return Created <code>Node</code>. + * @return Created {@code Node}. */ @Override public Node createNode(org.w3c.dom.Document parentDoc, String name) { @@ -475,16 +443,14 @@ public class TextStyle extends Style implements Cloneable { return node; } - /** - * Return true if <code>style</code> specifies as much or less - * than this <code>Style</code>, and nothing it specifies - * contradicts this <code>Style</code>. + * Return {@code true} if {@code style} specifies as much or less than this + * {@code Style}, and nothing it specifies contradicts this {@code Style}. * - * @param style The <code>Style</code> to check. + * @param style The {@code Style} to check. * - * @return true if <code>style</code> is a subset, false - * otherwise. + * @return {@code true} if {@code style} is a subset, {@code false} + * otherwise. */ @Override public boolean isSubset(Style style) { @@ -524,13 +490,11 @@ public class TextStyle extends Style implements Cloneable { return true; } - /** - * Write this <code>Style</code> object's attributes to a - * <code>Node</code> in the <code>Document</code>. + * Write this {@code Style} object's attributes to a {@code Node} in the + * {@code Document}. * - * @param node The <code>Node</code> to add <code>Style</code> - * attributes. + * @param node The {@code Node} to add {@code Style} attributes. */ private void writeAttributes(Element node) { @@ -573,14 +537,12 @@ public class TextStyle extends Style implements Cloneable { buildColorString(bgColor)); } - /** - * Given a <code>Color</code>, return a string of the form - * <i>#rrggbb</i>. + * Given a {@code Color}, return a string of the form <i>{@literal #rrggbb}</i>. * - * @param c The <code>Color</code> value. + * @param c The {@code Color} value. * - * @return The <code>Color</code> value in the form <i>#rrggbb</i>. + * @return The {@code Color} value in the form <i>{@literal #rrggbb}</i>. */ private String buildColorString(Color c) { int v[] = new int[3]; @@ -597,7 +559,6 @@ public class TextStyle extends Style implements Cloneable { return colorString; } - private static String[] ignored = { "style:text-autospace", "style:text-underline-color", "fo:margin-left", "fo:margin-right", "fo:text-indent", @@ -611,15 +572,13 @@ public class TextStyle extends Style implements Cloneable { "style:line-break", "fo:keep-with-next" }; - - /* - * This code checks whether an attribute is one that we - * intentionally ignore. + /** + * This code checks whether an attribute is one that we intentionally ignore. * - * @param attribute The attribute to check. + * @param attribute The attribute to check. * - * @return true if <code>attribute</code> can be ignored, - * otherwise false. + * @return {@code true} if {@code attribute} can be ignored, otherwise + * {@code false}. */ private boolean isIgnored(String attribute) { for (String ignored1 : ignored) { @@ -629,5 +588,4 @@ public class TextStyle extends Style implements Cloneable { } return false; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java index fd47549359a1..2b1a48f7d657 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java @@ -34,27 +34,29 @@ import org.w3c.dom.NodeList; */ public class BookSettings implements OfficeConstants { - /** A w3c <code>Document</code>. */ + /** A w3c {@code Document}. */ private org.w3c.dom.Document settings = null; - private boolean hasColumnRowHeaders = true; - private String activeSheet = ""; - private ArrayList<SheetSettings> worksheetSettings = new ArrayList<SheetSettings>(); + private boolean hasColumnRowHeaders = true; + private String activeSheet = ""; + private ArrayList<SheetSettings> worksheetSettings + = new ArrayList<SheetSettings>(); /** - * Constructor for a <code>BookSettings</code>. Reads document settings - * from xml and inits SheetSettings variables. + * Constructor for a {@code BookSettings}. * - * @param root The root XML node to read from. + * <p>Reads document settings from xml and inits SheetSettings variables.</p> + * + * @param root The root XML node to read from. */ public BookSettings(Node root) { readNode(root); } /** - * Constructor for a <code>BookSettings</code> + * Constructor for a {@code BookSettings}. * - * @param worksheetSettings If it's a row the height, a column the width + * @param worksheetSettings If it's a row the height, a column the width */ public BookSettings(ArrayList<SheetSettings> worksheetSettings) { this.worksheetSettings = worksheetSettings; @@ -63,52 +65,49 @@ public class BookSettings implements OfficeConstants { /** * Set the flag indicating whether we have row/column headers. * - * @param hasColumnRowHeaders Flag to enable or disable headers. + * @param hasColumnRowHeaders Flag to enable or disable headers. */ public void setColumnRowHeaders(boolean hasColumnRowHeaders) { this.hasColumnRowHeaders = hasColumnRowHeaders; } - - /** - * Gets the <code>Vector</code> of <code>SheetSettings</code> + * Gets the {@code Vector} of {@code SheetSettings}. * - * @return <code>Vector</code> of <code>SheetSettings</code> + * @return {@code Vector} of {@code SheetSettings} */ public ArrayList<SheetSettings> getSheetSettings() { return worksheetSettings; } /** - * Gets the active sheet name + * Gets the active sheet name. * * @return the active sheet name */ public String getActiveSheet() { - return activeSheet; } /** - * Sets the active sheet name + * Sets the active sheet name. * - * @param activeSheet the active sheet name + * @param activeSheet the active sheet name. */ public void setActiveSheet(String activeSheet) { - this.activeSheet = activeSheet; } /** - * Adds an XML entry for a particular setting + * Adds an XML entry for a particular setting. * - * @param root the root node at which to add the xml entry - * @param attribute the name of the attribute to add - * @param type the attribute type (int, short etc) - * @param value the value of the attribute + * @param root the root node at which to add the xml entry. + * @param attribute the name of the attribute to add. + * @param type the attribute type ({@code int}, {@code short} etc). + * @param value the value of the attribute. */ - private void addConfigItem(Node root, String attribute, String type, String value) { + private void addConfigItem(Node root, String attribute, String type, + String value) { Element configItem = settings.createElement(TAG_CONFIG_ITEM); configItem.setAttribute(ATTRIBUTE_CONFIG_NAME, attribute); @@ -120,10 +119,10 @@ public class BookSettings implements OfficeConstants { } /** - * Writes out a settings.xml entry for this BookSettings object + * Writes out a settings.xml entry for this {@code BookSettings} object. * - * @param settings a <code>Document</code> object representing the settings.xml - * @param root the root xml node to add to + * @param settings a {@code Document} object representing the settings.xml + * @param root the root xml node to add to. */ public void writeNode(org.w3c.dom.Document settings, Node root) { @@ -140,13 +139,12 @@ public class BookSettings implements OfficeConstants { } /** - * Sets a variable based on a String value read from XML + * Sets a variable based on a {@code String} value read from XML. * - * @param name xml name of the attribute to set - * @param value String value fo the attribute + * @param name xml name of the attribute to set. + * @param value {@code String} value for the attribute. */ private void addAttribute(String name, String value) { - if(name.equals("ActiveTable")) { activeSheet = value; } else if(name.equals("HasColumnRowHeaders")) { @@ -156,9 +154,9 @@ public class BookSettings implements OfficeConstants { } /** - * Reads document settings from xml and inits SheetSettings variables + * Reads document settings from xml and inits {@code SheetSettings} variables. * - * @param root XML Node to read from + * @param root XML {@code Node} to read from. */ private void readNode(Node root) { @@ -208,4 +206,4 @@ public class BookSettings implements OfficeConstants { } } } -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java index 434912c6159d..1e319f4d7da3 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/CellStyle.java @@ -30,20 +30,20 @@ import org.openoffice.xmerge.converter.xml.StyleCatalog; import org.openoffice.xmerge.util.Debug; /** - * Represents a text <code>Style</code> in an OpenOffice document. + * Represents a text {@code Style} in an OpenOffice document. */ public class CellStyle extends Style implements Cloneable { private Format fmt = new Format(); /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node The <i>style:style</i> <code>Node</code> containing - * the <code>Style</code>. (This <code>Node</code> is - * assumed have a <i>family</i> attribute of <i>text</i>). - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node The <i>style:style</i> {@code Node} containing the + * {@code Style}. (This {@code Node} is assumed have a + * <i>family</i> attribute of <i>text</i>). + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public CellStyle(Node node, StyleCatalog sc) { super(node, sc); @@ -83,39 +83,39 @@ public class CellStyle extends Style implements Cloneable { } } - /** - * Constructor for use when going from client device format to DOM + * Constructor for use when going from client device format to DOM. * - * @param name Name of cell <code>Style</code>. Can be null. - * @param family Family of text <code>Style</code> (usually - * <i>text</i>). Can be null. - * @param parent Name of parent text <code>Style</code>, or null - * for none. - * @param fmt size in points. - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of cell {@code Style}. Can be {@code null}. + * @param family Family of text {@code Style} (usually <i>text</i>). Can + * be {@code null}. + * @param parent Name of parent text {@code Style}, or {@code null} for + * none. + * @param fmt size in points. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ - public CellStyle(String name, String family, String parent,Format fmt, StyleCatalog sc) { + public CellStyle(String name, String family, String parent,Format fmt, + StyleCatalog sc) { super(name, family, parent, sc); this.fmt = fmt; } /** - * Returns the <code>Format</code> object for this particular style + * Returns the {@code Format} object for this particular style. * - * @return the <code>Format</code> object + * @return the {@code Format} object */ public Format getFormat() { return fmt; } /** - * Parse a color specification of the form <i>#rrggbb</i> + * Parse a color specification of the form <i>{@literal #rrggbb}</i>. * - * @param value <code>Color</code> specification to parse. + * @param value {@code Color} specification to parse. * - * @return The <code>Color</code> associated the value. + * @return The {@code Color} associated the value. */ private Color parseColorString(String value) { // Assume color value is of form #rrggbb @@ -135,12 +135,11 @@ public class CellStyle extends Style implements Cloneable { return new Color(red, green, blue, 0); } - /** - * Set an attribute. + * Set an attribute. * - * @param attr The attribute to set. - * @param value The attribute value to set. + * @param attr The attribute to set. + * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { @@ -252,16 +251,14 @@ public class CellStyle extends Style implements Cloneable { } } - /** - * Return a <code>Style</code> object corresponding to this one, - * but with all of the inherited information from parent - * <code>Style</code> objects filled in. The object returned will - * be a new object, not a reference to this object, even if it does - * not need any information added. + * Return a {@code Style} object corresponding to this one, but with all of + * the inherited information from parent {@code Style} objects filled in. * - * @return The <code>StyleCatalog</code> in which to look up - * ancestors. + * <p>The object returned will be a new object, not a reference to this + * object, even if it does not need any information added.</p> + * + * @return The {@code StyleCatalog} in which to look up ancestors. */ @Override public Style getResolved() { @@ -321,17 +318,15 @@ public class CellStyle extends Style implements Cloneable { return resolved; } - /** - * Create a new <code>Node</code> in the <code>Document</code>, and - * write this <code>Style</code> to it. + * Create a new {@code Node} in the {@code Document}, and write this + * {@code Style} to it. * - * @param parentDoc Parent <code>Document</code> of the - * <code>Node</code> to create. - * @param name Name to use for the new <code>Node</code> (e.g. - * <i>style:style</i>) + * @param parentDoc Parent {@code Document} of the {@code Node} to create. + * @param name Name to use for the new {@code Node} (e.g. + * <i>style:style</i>) * - * @return Created <code>Node</code>. + * @return Created {@code Node}. */ @Override public Node createNode(org.w3c.dom.Document parentDoc, String name) { @@ -340,16 +335,14 @@ public class CellStyle extends Style implements Cloneable { return node; } - /** - * Return true if <code>style</code> specifies as much or less - * than this <code>Style</code>, and nothing it specifies - * contradicts this <code>Style</code>. + * Return {@code true} if {@code style} specifies as much or less than this + * {@code Style}, and nothing it specifies contradicts this {@code Style}. * - * @param style The <code>Style</code> to check. + * @param style The {@code Style} to check. * - * @return true if <code>style</code> is a subset, false - * otherwise. + * @return {@code true} if {@code style} is a subset, {@code false} + * otherwise. */ @Override public boolean isSubset(Style style) { @@ -365,13 +358,11 @@ public class CellStyle extends Style implements Cloneable { return true; } - /** - * Write this <code>Style</code> object's attributes to a - * <code>Node</code> in the <code>Document</code>. + * Write this {@code Style} object's attributes to a {@code Node} in the + * {@code Document}. * - * @param node The <code>Node</code> to add <code>Style</code> - * attributes. + * @param node The {@code Node} to add {@code Style} attributes. */ private void writeAttributes(Element node) { @@ -442,14 +433,12 @@ public class CellStyle extends Style implements Cloneable { } - /** - * Given a <code>Color</code>, return a string of the form - * <i>#rrggbb</i>. + * Given a {@code Color}, return a string of the form <i>{@literal #rrggbb}</i>. * - * @param c The <code>Color</code> value. + * @param c The {@code Color} value. * - * @return The <code>Color</code> value in the form <i>#rrggbb</i>. + * @return The {@code Color} value in the form <i>{@literal #rrggbb}</i>. */ private String buildColorString(Color c) { int v[] = new int[3]; @@ -466,7 +455,6 @@ public class CellStyle extends Style implements Cloneable { return colorString; } - private static String[] ignored = { "style:text-autospace", "style:text-underline-color", "fo:margin-left", "fo:margin-right", "fo:text-indent", @@ -480,15 +468,13 @@ public class CellStyle extends Style implements Cloneable { "style:line-break", "fo:keep-with-next" }; - - /* - * This code checks whether an attribute is one that we - * intentionally ignore. + /** + * This code checks whether an attribute is one that we intentionally ignore. * - * @param attribute The attribute to check. + * @param attribute The attribute to check. * - * @return true if <code>attribute</code> can be ignored, - * otherwise false. + * @return {@code true} if {@code attribute} can be ignored, otherwise + * {@code false}. */ private boolean isIgnored(String attribute) { for (int i = 0; i < ignored.length; i++) { @@ -497,5 +483,4 @@ public class CellStyle extends Style implements Cloneable { } return false; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java index 2577096ce038..d8e2caea05b4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnRowInfo.java @@ -19,9 +19,10 @@ package org.openoffice.xmerge.converter.xml.sxc; /** - * This is a class to define a table-column structure. This can then be - * used by plugins to write or read their own column types. + * This is a class to define a table-column structure. * + * <p>This can then be used by plug-ins to write or read their own column types. + * </p> */ public class ColumnRowInfo { @@ -38,9 +39,9 @@ public class ColumnRowInfo { private Format fmt = new Format(); /** - * Constructor for a <code>ColumnRowInfo</code> + * Constructor for a {@code ColumnRowInfo}. * - * @param type whether ROW or COLUMN record . + * @param type whether {@code ROW} or {@code COLUMN} record. */ public ColumnRowInfo(int type) { @@ -48,11 +49,11 @@ public class ColumnRowInfo { } /** - * Constructor for a <code>ColumnRowInfo</code> + * Constructor for a {@code ColumnRowInfo}. * - * @param dimension if it's a row the height, a column the width. - * @param repeated how many times it is repeated. - * @param type whether ROW or COLUMN record. + * @param dimension if it's a row the height, a column the width. + * @param repeated how many times it is repeated. + * @param type whether {@code ROW} or {@code COLUMN} record. */ private ColumnRowInfo(int dimension, int repeated, int type) { @@ -62,13 +63,12 @@ public class ColumnRowInfo { } /** - * Constructor for a <code>ColumnRowInfo</code> that includes userDefined - * field. + * Constructor for a {@code ColumnRowInfo} that includes userDefined field. * - * @param dimension if it's a row the height, a column the width. - * @param repeated how many times it is repeated. - * @param type whether ROW or COLUMN record. - * @param userDefined whether the record is manually set. + * @param dimension if it's a row the height, a column the width. + * @param repeated how many times it is repeated. + * @param type whether {@code ROW} or {@code COLUMN} record. + * @param userDefined whether the record is manually set. */ public ColumnRowInfo(int dimension, int repeated, int type, boolean userDefined) { @@ -87,9 +87,9 @@ public class ColumnRowInfo { } /** - * Get the current format. + * Get the current {@code Format}. * - * @return The current format. + * @return The current {@code Format}. */ public Format getFormat() { @@ -137,9 +137,9 @@ public class ColumnRowInfo { } /** - * Does this <code>ColumnRowInfo</code> represent a row? + * Does this {@code ColumnRowInfo} represent a row? * - * @return True if a row, false if not. + * @return {@code true} if a row, {@code false} if not. */ public boolean isRow() { @@ -147,9 +147,9 @@ public class ColumnRowInfo { } /** - * Does this <code>ColumnRowInfo</code> represent a column? + * Does this {@code ColumnRowInfo} represent a column? * - * @return True if a column, false if not. + * @return {@code true} if a column, {@code false} if not. */ public boolean isColumn() { @@ -157,9 +157,9 @@ public class ColumnRowInfo { } /** - * Test if the row height as been set manually + * Test if the row height as been set manually. * - * @return true if user defined otherwise false + * @return {@code true} if user defined otherwise {@code false}. */ public boolean isUserDefined() { @@ -167,9 +167,9 @@ public class ColumnRowInfo { } /** - * Test if the row height is default + * Test if the row height is default. * - * @return true if default otherwise false + * @return {@code true} if default otherwise {@code false}. */ public boolean isDefaultSize() { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java index 0adb79bd46c2..d2ce990d554b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/ColumnStyle.java @@ -29,19 +29,19 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.TwipsConverter; /** - * Represents a text <code>Style</code> in an OpenOffice document. + * Represents a text {@code Style} in an OpenOffice document. */ public class ColumnStyle extends Style implements Cloneable { private int colWidth = 0; /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node The <i>style:style</i> <code>Node</code> containing - * the <code>Style</code>. (This <code>Node</code> is - * assumed have a <i>family</i> attribute of <i>text</i>). - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node The <i>style:style</i> {@code Node} containing the + * {@code Style}. (This {@code Node} is assumed have a + * <i>family</i> attribute of <i>text</i>). + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public ColumnStyle(Node node, StyleCatalog sc) { super(node, sc); @@ -82,16 +82,16 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Constructor for use when going from client device format to DOM + * Constructor for use when going from client device format to DOM. * - * @param name Name of text <code>Style</code>. Can be null. - * @param family Family of text <code>Style</code> (usually - * <i>text</i>). Can be null. - * @param parent Name of parent text <code>Style</code>, or null - * for none. - * @param colWidth the width of this column - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of text {@code Style}. Can be {@code null}. + * @param family Family of text {@code Style} (usually <i>text</i>). + * Can be {@code null}. + * @param parent Name of parent text {@code Style}, or {@code null} for + * none. + * @param colWidth the width of this column. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public ColumnStyle(String name, String family, String parent, int colWidth, StyleCatalog sc) { super(name, family, parent, sc); @@ -99,7 +99,7 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Returns the width of this column + * Returns the width of this column. * * @return The width of this column. */ @@ -108,7 +108,7 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Sets the width of this column + * Sets the width of this column. * * @param colWidth The width of this column. */ @@ -118,11 +118,11 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Parse a colwidth in the form "1.234cm" to twips + * Parse a colwidth in the form {@literal "1.234cm"} to twips. * - * @param value <code>String</code> specification to parse. + * @param value {@code String} specification to parse. * - * @return The twips equivalent. + * @return The twips equivalent. */ private int parseColWidth(String value) { @@ -140,10 +140,10 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Set an attribute. + * Set an attribute. * - * @param attr The attribute to set. - * @param value The attribute value to set. + * @param attr The attribute to set. + * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { @@ -156,14 +156,13 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Return a <code>Style</code> object corresponding to this one, - * but with all of the inherited information from parent - * <code>Style</code> objects filled in. The object returned will - * be a new object, not a reference to this object, even if it does - * not need any information added. + * Return a {@code Style} object corresponding to this one, but with all of + * the inherited information from parent {@code Style} objects filled in. * - * @return The <code>Style</code> in which to look up - * ancestors. + * <p>The object returned will be a new object, not a reference to this + * object, even if it does not need any information added.</p> + * + * @return The {@code Style} in which to look up ancestors. */ @Override public Style getResolved() { @@ -206,15 +205,14 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Create a new <code>Node</code> in the <code>Document</code>, and - * write this <code>Style</code> to it. + * Create a new {@code Node} in the <code>Document</code>, and write this + * {@code Style} to it. * - * @param parentDoc Parent <code>Document</code> of the - * <code>Node</code> to create. - * @param name Name to use for the new <code>Node</code> (e.g. - * <i>style:style</i>) + * @param parentDoc Parent {@code Document} of the {@code Node} to create. + * @param name Name to use for the new {@code Node} (e.g. + * <i>style:style</i>) * - * @return Created <code>Node</code>. + * @return Created {@code Node}. */ @Override public Node createNode(org.w3c.dom.Document parentDoc, String name) { @@ -224,14 +222,13 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Return true if <code>style</code> specifies as much or less - * than this <code>Style</code>, and nothing it specifies - * contradicts this <code>Style</code>. + * Return {@code true} if {@code style} specifies as much or less than this + * {@code Style}, and nothing it specifies contradicts this {@code Style}. * - * @param style The <code>Style</code> to check. + * @param style The {@code Style} to check. * - * @return true if <code>style</code> is a subset, false - * otherwise. + * @return {@code true} if <code>style</code> is a subset, {@code false} + * otherwise. */ @Override public boolean isSubset(Style style) { @@ -246,11 +243,10 @@ public class ColumnStyle extends Style implements Cloneable { } /** - * Write this <code>Style</code> object's attributes to a - * <code>Node</code> in the <code>Document</code>. + * Write this {@code Style} object's attributes to a {@code Node} in the + * {@code Document}. * - * @param node The <code>Node</code> to add <code>Style</code> - * attributes. + * @param node The {@code Node} to add {@code Style} attributes. */ private void writeAttributes(Element node) { @@ -259,5 +255,4 @@ public class ColumnStyle extends Style implements Cloneable { node.setAttribute("style:column-width", width); } } - -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java index ef427c8bc35c..04eebc081663 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/DocumentMergerImpl.java @@ -39,14 +39,12 @@ import org.openoffice.xmerge.merger.MergeAlgorithm; import org.openoffice.xmerge.util.XmlUtil; import org.openoffice.xmerge.util.Debug; - /** - * Generic small device implementation of <code>DocumentMerger</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory - * SxcPluginFactory}. + * Generic small device implementation of {@code DocumentMerger} for + * the {@link org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory + * SxcPluginFactory}. * - * <p>Used with SXC <code>Document</code> objects.</p> + * <p>Used with SXC {@code Document} objects.</p> */ public class DocumentMergerImpl implements DocumentMerger { @@ -54,13 +52,13 @@ public class DocumentMergerImpl implements DocumentMerger { private org.openoffice.xmerge.Document orig = null; /** - * Constructor + * Constructor. * - * @param doc The original "Office" <code>Document</code> - * to merge. - * @param cc The <code>ConverterCapabilities</code>. + * @param doc The original "Office" {@code Document} to merge. + * @param cc The {@code ConverterCapabilities}. */ - public DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc) { + public DocumentMergerImpl(org.openoffice.xmerge.Document doc, + ConverterCapabilities cc) { cc_ = cc; this.orig = doc; } @@ -121,8 +119,8 @@ public class DocumentMergerImpl implements DocumentMerger { numOfWorkSheet = workSheetList2.getLength(); - // for those workSheet from target don't have a matching one - // in the original workSheet list, we add it + // for those workSheet from target don't have a matching one in the + // original workSheet list, we add it // find out the office body node first NodeList officeBodyList = @@ -135,12 +133,9 @@ public class DocumentMergerImpl implements DocumentMerger { Node workSheet= workSheetList2.item(j); // try to match the workSheet - Node matchingWorkSheet = matchWorkSheet(workSheet, workSheetList1); - // add the new WorkSheet to the original document iff match not - // found - + // add the new WorkSheet to the original document iff match not found if (matchingWorkSheet == null) { Node cloneNode = XmlUtil.deepClone(officeBody, workSheet); officeBody.appendChild(cloneNode); @@ -149,13 +144,13 @@ public class DocumentMergerImpl implements DocumentMerger { } /** - * Try to find a WorkSheet from the modified WorkSheetList that - * has a matching table name from the original WorkSheet. + * Try to find a WorkSheet from the modified WorkSheetList that has a + * matching table name from the original WorkSheet. * - * @param orgSheet The original WorkSheet. - * @param modSheetList The modified WorkSheet. + * @param orgSheet The original WorkSheet. + * @param modSheetList The modified WorkSheet. * - * @return The Node in modSheetList that matches the orgSheet. + * @return The {@code Node} in modSheetList that matches the {@code orgSheet}. */ private Node matchWorkSheet(Node orgSheet, NodeList modSheetList) { @@ -185,5 +180,4 @@ public class DocumentMergerImpl implements DocumentMerger { return matchSheet; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java index 8be897c47e9e..f6d6cf22a000 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java @@ -21,34 +21,32 @@ package org.openoffice.xmerge.converter.xml.sxc; import java.awt.Color; /** - * This class specifies the format for a given spreadsheet cell. - * + * This class specifies the format for a given spreadsheet cell. */ public class Format implements Cloneable { - /** Horizontal Alignment Constants. */ + /** Horizontal Alignment Constants. */ final public static int RIGHT_ALIGN = 0x01; final public static int CENTER_ALIGN = 0x02; final public static int LEFT_ALIGN = 0x03; - - /** Vertical Alignment Constants. */ + /** Vertical Alignment Constants. */ final public static int TOP_ALIGN = 0x01; final public static int MIDDLE_ALIGN = 0x02; final public static int BOTTOM_ALIGN = 0x03; /** Indicates <i>bold</i> text. */ - final public static int BOLD = 0x01; + final public static int BOLD = 0x01; /** Indicates <i>italic</i> text. */ - final public static int ITALIC = 0x02; + final public static int ITALIC = 0x02; /** Indicates <i>underlined</i> text. */ - final public static int UNDERLINE = 0x04; + final public static int UNDERLINE = 0x04; /** Indicates <i>strike-through</i> in the text. */ - final public static int STRIKETHRU = 0x08; + final public static int STRIKETHRU = 0x08; /** Indicates <i>superscripted</i> text. */ - final public static int SUPERSCRIPT = 0x10; + final public static int SUPERSCRIPT = 0x10; /** Indicates <i>subscripted</i> text. */ - final public static int SUBSCRIPT = 0x20; + final public static int SUBSCRIPT = 0x20; final public static int LEFT_BORDER = 0x40; final public static int RIGHT_BORDER = 0x80; @@ -77,19 +75,19 @@ public class Format implements Cloneable { private int mask = 0; /** - * Constructor for creating a new <code>Format</code>. + * Constructor for creating a new {@code Format}. */ public Format() { clearFormatting(); } /** - * Constructor that creates a new <code>Format</code> object - * by setting all the format attributes. + * Constructor that creates a new {@code Format} object by setting all the + * format attributes. * - * @param attributes Attributes flags (alignment, bold, etc.) - * @param fontSize Size of the font in points. - * @param fontName Name of the font to use. + * @param attributes Attributes flags (alignment, bold, etc.) + * @param fontSize Size of the font in points. + * @param fontName Name of the font to use. */ public Format(int attributes, int fontSize, String fontName) { @@ -99,10 +97,10 @@ public class Format implements Cloneable { } /** - * Constructor for creating a new <code>Format</code> object - * based on an existing one. + * Constructor for creating a new {@code Format} object based on an existing + * one. * - * @param fmt <code>Format</code> to copy. + * @param fmt {@code Format} to copy. */ public Format(Format fmt) { category = fmt.getCategory(); @@ -122,7 +120,7 @@ public class Format implements Cloneable { } /** - * Reset this <code>Format</code> description. + * Reset this {@code Format} description. */ public void clearFormatting() { category = ""; @@ -140,10 +138,10 @@ public class Format implements Cloneable { } /** - * Set one or more text attributes. + * Set one or more text attributes. * - * @param flags Flag attributes to set. - * @param toggle True to set flags, false to clear them. + * @param flags Flag attributes to set. + * @param toggle {@code true} to set flags, {@code false} to clear them. */ public void setAttribute(int flags, boolean toggle) { mask |= flags; @@ -155,13 +153,13 @@ public class Format implements Cloneable { } /** - * Return true if the <code>attribute</code> is set to <i>on</i> + * Return {@code true} if the {@code attribute} is set to <i>on</i>. * - * @param attribute Attribute to check ({@link #BOLD}, - * {@link #ITALIC}, etc.) + * @param attribute Attribute to check ({@link #BOLD}, {@link #ITALIC}, + * etc.). * - * @return true if <code>attribute</code> is set to <i>on</i>, - * otherwise false. + * @return {@code true} if {@code attribute} is set to <i>on</i>, otherwise + * {@code false}. */ public boolean getAttribute(int attribute) { if ((mask & attribute) == 0) @@ -169,145 +167,144 @@ public class Format implements Cloneable { return (!((attributes & attribute) == 0)); } - - /** - * Set the formatting category of this object, ie number, date, - * currency.The <code>OfficeConstants</code> class contains string - * constants for the category types. + * Set the formatting category of this object, ie number, date, currency. + * + * <p>The <code>OfficeConstants</code> class contains string constants for + * the category types.</p> * - * @see org.openoffice.xmerge.converter.xml.OfficeConstants + * @see org.openoffice.xmerge.converter.xml.OfficeConstants * - * @param newCategory The name of the category to be set. + * @param newCategory The name of the category to be set. */ public void setCategory(String newCategory) { category = newCategory; } /** - * Return the formatting category of the object. + * Return the formatting category of the object. * - * @see org.openoffice.xmerge.converter.xml.OfficeConstants + * @see org.openoffice.xmerge.converter.xml.OfficeConstants * - * @return The formatting category of the object. + * @return The formatting category of the object. */ public String getCategory() { return category; } /** - * In the case of Formula returns the value of the formula. + * In the case of Formula returns the value of the formula. * - * @return The value of the formula + * @return The value of the formula. */ public String getValue() { return value; } - /** - * In the case of formula the contents are set as the formula string and - * the value of the formula is a formatting attribute. + /** + * In the case of formula the contents are set as the formula string and + * the value of the formula is a formatting attribute. * - * @param newValue the formuala value + * @param newValue the formula value. */ public void setValue(String newValue) { value = newValue; } /** - * Set the <code>Format</code> specifier for this category. + * Set the {@code Format} specifier for this category. * - * @param formatString The new <code>Format</code> specifier. + * @param formatString The new {@code Format} specifier. */ public void setFormatSpecifier(String formatString) { formatSpecifier = formatString; } /** - * Get the <code>Format</code> specifier for this category. + * Get the {@code Format} specifier for this category. * - * @return <code>Format</code> specifier for this category. + * @return {@code Format} specifier for this category. */ public String getFormatSpecifier() { return formatSpecifier; } /** - * Set the precision of the number to be displayed. + * Set the precision of the number to be displayed. * - * @param precision The number of decimal places to display. + * @param precision The number of decimal places to display. */ public void setDecimalPlaces(int precision) { decimalPlaces = precision; } /** - * Get the number of decimal places displayed. + * Get the number of decimal places displayed. * - * @return Number of decimal places. + * @return Number of decimal places. */ public int getDecimalPlaces() { return decimalPlaces; } /** - * Set the font used for this cell. + * Set the font used for this cell. * - * @param fontName The name of the font. + * @param fontName The name of the font. */ public void setFontName(String fontName) { this.fontName = fontName; } /** - * Get the font used for this cell. + * Get the font used for this cell. * - * @return The font name. + * @return The font name. */ public String getFontName() { return fontName; } /** - * Set the font size (in points) used for this cell. + * Set the font size (in points) used for this cell. * - * @param fontSize The font size in points. + * @param fontSize The font size in points. */ public void setFontSize(int fontSize) { sizeInPoints = fontSize; } /** - * Get the font size (in points) used for this cell. + * Get the font size (in points) used for this cell. * - * @return The font size in points. + * @return The font size in points. */ public int getFontSize() { return sizeInPoints; } - /** - * Set the vertical alignment used for this cell. + /** + * Set the vertical alignment used for this cell. * - * @param vertAlign The vertical alignment. + * @param vertAlign The vertical alignment. */ public void setVertAlign(int vertAlign) { this.vertAlign = vertAlign; } /** - * Get the vertical alignment used for this cell. + * Get the vertical alignment used for this cell. * - * @return The vertical alignment. + * @return The vertical alignment. */ public int getVertAlign() { return vertAlign; } - /** - * Set the alignment used for this cell. + /** + * Set the alignment used for this cell. * - * @param align The alignment to use. + * @param align The alignment to use. */ public void setAlign(int align) { this.align = align; @@ -323,10 +320,9 @@ public class Format implements Cloneable { } /** - * Set the Foreground <code>Color</code> for this cell. + * Set the Foreground {@code Color} for this cell. * - * @param c A <code>Color</code> object representing the - * foreground color. + * @param c A {@code Color} object representing the foreground color. */ public void setForeground(Color c) { if(c!=null) @@ -334,19 +330,18 @@ public class Format implements Cloneable { } /** - * Get the Foreground <code>Color</code> for this cell. + * Get the Foreground {@code Color} for this cell. * - * @return Foreground <code>Color</code> value. + * @return Foreground {@code Color} value. */ public Color getForeground() { return foreground; } /** - * Set the Background <code>Color</code> for this cell + * Set the Background {@code Color} for this cell. * - * @param c A <code>Color</code> object representing - * the background color. + * @param c A {@code Color} object representing the background color. */ public void setBackground(Color c) { if(c!=null) @@ -354,18 +349,18 @@ public class Format implements Cloneable { } /** - * Get the Background <code>Color</code> for this cell + * Get the Background {@code Color} for this cell. * - * @return Background <code>Color</code> value + * @return Background {@code Color} value. */ public Color getBackground() { return background; } /** - * Get a string representation of this <code>Format</code> + * Get a {@code String} representation of this {@code Format}. * - * @return A string indicating the value and category. + * @return A {@code String} indicating the value and category. */ @Override public String toString() { @@ -373,10 +368,9 @@ public class Format implements Cloneable { } /** - * Tests if the current <code>Format</code> object has default attribute - * values. + * Tests if the current {@code Format} object has default attribute values. * - * @return true if it contains default value + * @return {@code true} if it contains default value. */ public boolean isDefault() { @@ -401,14 +395,12 @@ public class Format implements Cloneable { } /** - * Return true if passed <code>Format</code> specifies as much or less - * than this <code>Format</code>, and nothing it specifies - * contradicts this <code>Format</code>. + * Return true if passed {@code Format} specifies as much or less than this + * {@code Format}, and nothing it specifies contradicts this {@code Format}. * - * @param rhs The <code>Format</code> to check. + * @param rhs The {@code Format} to check. * - * @return true if <code>rhs</code> is a subset, false - * otherwise. + * @return {@code true} if {@code rhs} is a subset, {@code false} otherwise. */ public boolean isSubset(Format rhs) { if (rhs.getClass() != this.getClass()) @@ -439,4 +431,4 @@ public class Format implements Cloneable { return true; } -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java index 7589143cc57f..051236d4fe4d 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java @@ -27,43 +27,42 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.XmlUtil; /** - * This is a class to define a Name Definition structure. This can then be - * used by plugins to write or read their own definition types. + * This is a class to define a Name Definition structure. + * + * <p>This can then be used by plug-ins to write or read their own definition + * types.</p> */ public class NameDefinition implements OfficeConstants { - private String name; // name which identifies the definition - private String definition; // the definition itself - private String baseCellAddress; // the basecelladdress - private boolean rangeType = false; // true if definition of type range - private boolean expressionType = false; // true if definition of type expression + private String name; // name which identifies the definition + private String definition; // the definition itself + private String baseCellAddress; // the basecelladdress + private boolean rangeType = false; // true if definition of type range + private boolean expressionType = false; // true if definition of type expression /** - * Default Constructor for a <code>NameDefinition</code> - * + * Default Constructor for a {@code NameDefinition}. */ public NameDefinition() { - } /** - * Constructor that takes a <code>Node</code> to build a - * <code>NameDefinition</code> + * Constructor that takes a {@code Node} to build a {@code NameDefinition}. * - * @param root XML Node to read from + * @param root XML {@code Node} to read from. */ public NameDefinition(Node root) { readNode(root); } /** - * Constructor for a <code>NameDefinition</code> + * Constructor for a {@code NameDefinition}. * - * @param name Name that identifies the definition - * @param definition The definition itself - * @param baseCellAddress The base cell address - * @param rangeType True if definition of range type - * @param expressionType True if definition of expression type + * @param name Name that identifies the definition. + * @param definition The definition itself. + * @param baseCellAddress The base cell address. + * @param rangeType {@code true} if definition of range type. + * @param expressionType {@code true} if definition of expression type. */ public NameDefinition(String name, String definition, String baseCellAddress, boolean rangeType, boolean expressionType ) { @@ -75,66 +74,64 @@ public class NameDefinition implements OfficeConstants { } /** - * returns Name of the definition + * Returns Name of the definition. * - * @return the name which identifies the definition + * @return the name which identifies the definition. */ public String getName() { - return name; } + /** - * sets the definition + * Sets the definition. * - * @param newDefinition sets the definition + * @param newDefinition sets the definition. */ public void setDefinition(String newDefinition) { - definition = newDefinition; } + /** - * Returns the definition itself + * Returns the definition itself. * - * @return the definition + * @return the definition. */ public String getDefinition() { - return definition; } /** - * Returns the base Cell address + * Returns the base Cell address. * - * @return the base cell address + * @return the base cell address. */ public String getBaseCellAddress() { - return baseCellAddress; } /** - * Tests if definition is of type expression + * Tests if definition is of type expression. * - * @return whether or not this name definition is of type expression + * @return whether or not this name definition is of type expression. */ public boolean isExpressionType() { return expressionType; } /** - * Tests if definition is of type range + * Tests if definition is of type range. * - * @return whether or not this name definition is of type range + * @return whether or not this name definition is of type range. */ public boolean isRangeType() { return rangeType; } /** - * Writes out a content.xml entry for this NameDefinition object + * Writes out a content.xml entry for this NameDefinition object. * - * @param doc A <code>Document</code> object representing the settings.xml - * @param root The root xml node to add to + * @param doc A {@code Document} object representing the settings.xml + * @param root The root xml {@code Node} to add to. */ public void writeNode(org.w3c.dom.Document doc, Node root) { @@ -161,9 +158,9 @@ public class NameDefinition implements OfficeConstants { } /** - * Reads document settings from xml and inits Settings variables + * Reads document settings from xml and inits Settings variables. * - * @param root XML Node to read from + * @param root XML {@code Node} to read from. */ private void readNode(Node root) { @@ -205,5 +202,4 @@ public class NameDefinition implements OfficeConstants { Debug.log(Debug.TRACE, "<OTHERS " + XmlUtil.getNodeInfo(root) + " />"); } } - -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java index bae24b5a8d4c..343a4df96cfd 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/RowStyle.java @@ -29,19 +29,19 @@ import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.TwipsConverter; /** - * Represents a text <code>Style</code> in an OpenOffice document. + * Represents a text {@code Style} in an OpenOffice document. */ public class RowStyle extends Style implements Cloneable { private int rowHeight = 255; /** - * Constructor for use when going from DOM to client device format. + * Constructor for use when going from DOM to client device format. * - * @param node The <i>style:style</i> <code>Node</code> containing - * the <code>Style</code>. (This <code>Node</code> is - * assumed have a <i>family</i> attribute of <i>text</i>). - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param node The <i>style:style</i> {@code Node} containing the + * {@code Style}. (This {@code Node} is assumed have a + * <i>family</i> attribute of <i>text</i>). + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public RowStyle(Node node, StyleCatalog sc) { super(node, sc); @@ -82,16 +82,16 @@ public class RowStyle extends Style implements Cloneable { } /** - * Constructor for use when going from client device format to DOM + * Constructor for use when going from client device format to DOM. * - * @param name Name of text <code>Style</code>. Can be null. - * @param family Family of text <code>Style</code> (usually - * <i>text</i>). Can be null. - * @param parent Name of parent text <code>Style</code>, or null - * for none. - * @param rowHeight The height of this row - * @param sc The <code>StyleCatalog</code>, which is used for - * looking up ancestor <code>Style</code> objects. + * @param name Name of text {@code Style}. Can be {@code null}. + * @param family Family of text {@code Style} (usually <i>text</i>). + * Can be {@code null}. + * @param parent Name of parent text {@code Style}, or {@code null} + * for none. + * @param rowHeight The height of this row. + * @param sc The {@code StyleCatalog}, which is used for looking up + * ancestor {@code Style} objects. */ public RowStyle(String name, String family, String parent,int rowHeight, StyleCatalog sc) { super(name, family, parent, sc); @@ -99,7 +99,7 @@ public class RowStyle extends Style implements Cloneable { } /** - * Returns the height of this row + * Returns the height of this row. * * @return The height of this row. */ @@ -108,20 +108,20 @@ public class RowStyle extends Style implements Cloneable { } /** - * Sets the height of this row + * Sets the height of this row. * - * @param RowHeight The height of this row. + * @param RowHeight The height of this row. */ public void setRowHeight(int RowHeight) { this.rowHeight = RowHeight; } /** - * Parse a rowheight in the form "1.234cm" to twips + * Parse a rowheight in the form {@literal "1.234cm"} to twips. * - * @param value <code>String</code> specification to parse. + * @param value {@code String} specification to parse. * - * @return The twips equivalent. + * @return The twips equivalent. */ private int parseRowHeight(String value) { @@ -140,10 +140,10 @@ public class RowStyle extends Style implements Cloneable { } /** - * Set an attribute. + * Set an attribute. * - * @param attr The attribute to set. - * @param value The attribute value to set. + * @param attr The attribute to set. + * @param value The attribute value to set. */ private void handleAttribute(String attr, String value) { @@ -156,14 +156,13 @@ public class RowStyle extends Style implements Cloneable { } /** - * Return a <code>Style</code> object corresponding to this one, - * but with all of the inherited information from parent - * <code>Style</code> objects filled in. The object returned will - * be a new object, not a reference to this object, even if it does - * not need any information added. + * Return a {@code Style} object corresponding to this one, but with all of + * the inherited information from parent {@code Style} objects filled in. * - * @return The <code>StyleCatalog</code> in which to look up - * ancestors. + * <p>The object returned will be a new object, not a reference to this + * object, even if it does not need any information added.</p> + * + * @return The {@code StyleCatalog} in which to look up ancestors. */ @Override public Style getResolved() { @@ -206,15 +205,14 @@ public class RowStyle extends Style implements Cloneable { } /** - * Create a new <code>Node</code> in the <code>Document</code>, and - * write this <code>Style</code> to it. + * Create a new {@code Node} in the {@code Document}, and write this + * {@code Style} to it. * - * @param parentDoc Parent <code>Document</code> of the - * <code>Node</code> to create. - * @param name Name to use for the new <code>Node</code> (e.g. - * <i>style:style</i>) + * @param parentDoc Parent {@code Document} of the {@code Node} to create. + * @param name Name to use for the new {@code Node} (e.g. + * <i>style:style</i>) * - * @return Created <code>Node</code>. + * @return Created {@code Node}. */ @Override public Node createNode(org.w3c.dom.Document parentDoc, String name) { @@ -224,14 +222,13 @@ public class RowStyle extends Style implements Cloneable { } /** - * Return true if <code>style</code> specifies as much or less - * than this <code>Style</code>, and nothing it specifies - * contradicts this <code>Style</code>. + * Return true if {@code style} specifies as much or less than this + * {@code Style}, and nothing it specifies contradicts this {@code Style}. * - * @param style The <code>Style</code> to check. + * @param style The {@code Style} to check. * - * @return true if <code>style</code> is a subset, false - * otherwise. + * @return {@code true} if {@code style} is a subset, {@code false} + * otherwise. */ @Override public boolean isSubset(Style style) { @@ -246,11 +243,10 @@ public class RowStyle extends Style implements Cloneable { } /** - * Write this <code>Style</code> object's attributes to a - * <code>Node</code> in the <code>Document</code>. + * Write this {@code Style} object's attributes to a {@code Node} in the + * {@code Document}. * - * @param node The <code>Node</code> to add <code>Style</code> - * attributes. + * @param node The {@code Node} to add {@code Style} attributes. */ private void writeAttributes(Element node) { @@ -259,5 +255,4 @@ public class RowStyle extends Style implements Cloneable { node.setAttribute("style:row-height", height); } } - -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java index be2b5ccc3db5..d3ce082bc925 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java @@ -32,7 +32,7 @@ import org.openoffice.xmerge.converter.xml.OfficeConstants; */ public class SheetSettings implements OfficeConstants { - /** A w3c <code>Document</code>. */ + /** A w3c {@code Document}. */ private org.w3c.dom.Document settings = null; private String sheetName; @@ -46,63 +46,58 @@ public class SheetSettings implements OfficeConstants { private int posTop = 0; private int paneNumber = 2; - final private static int SPLIT = 0x01; final private static int FREEZE = 0x02; /** - * Default Constructor for a <code>SheetSettings</code> - * + * Default Constructor for a {@code SheetSettings}. */ public SheetSettings() { } /** - * Constructor that takes a <code>Node</code> to build a <code>SheetSettings</code> + * Constructor that takes a {@code Node} to build a {@code SheetSettings}. * - * @param root XML Node to read from + * @param root XML {@code Node} to read from. */ public SheetSettings(Node root) { readNode(root); } /** - * Constructor for a <code>SheetSettings</code> + * Constructor for a {@code SheetSettings}. * - * @param name The name for the new sheet + * @param name The name for the new sheet. */ public SheetSettings(String name) { sheetName = name; } /** - * sets the position of the acitve cell + * Sets the position of the active cell. * - * @param activeCell the current curor position + * @param activeCell the current cursor position. */ public void setCursor(Point activeCell) { - cursorX = (int) activeCell.getX(); cursorY = (int) activeCell.getY(); } /** - * Gets the position of the acitve cell + * Gets the position of the active cell. * - * @return The position as a <code>Point</code> + * @return The position as a {@code Point}. */ public Point getCursor() { - return (new Point(cursorX, cursorY)); } /** - * Sets the position of the freeze + * Sets the position of the freeze. * - * @param splitPoint the point at where the split occurs + * @param splitPoint the point at where the split occurs. */ public void setFreeze(Point splitPoint) { - splitTypeX = FREEZE; splitTypeY = FREEZE; splitPointX = (int) splitPoint.getX(); @@ -110,9 +105,9 @@ public class SheetSettings implements OfficeConstants { } /** - * Sets the position of the split + * Sets the position of the split. * - * @param splitPoint the point at where the split occurs + * @param splitPoint the point at where the split occurs. */ public void setSplit(Point splitPoint) { @@ -123,9 +118,9 @@ public class SheetSettings implements OfficeConstants { } /** - * gets the position of the split + * Gets the position of the split. * - * @return The position as a <code>Point</code> where the split occurs + * @return The position as a {@code Point} where the split occurs. */ public Point getSplit() { @@ -133,88 +128,94 @@ public class SheetSettings implements OfficeConstants { } /** - * gets the type of the split + * Gets the type of the split. * - * @return The split type as a <code>Point</code> + * @return The split type as a {@code Point}. */ public Point getSplitType() { return (new Point(splitTypeX, splitTypeY)); } - - /** - * Gets the leftmost column visibile in the right pane. + * Gets the leftmost column visible in the right pane. * - * @return the 0-based index to the column + * @return the 0-based index to the column. */ public int getLeft() { - return posLeft; } + /** * Gets the top row visible in the lower pane. * - * @return The top row visible in the lower pane + * @return The top row visible in the lower pane. */ public int getTop() { - return posTop; } /** - * Gets the active Panel - * 0 - Bottom Right, 1 - Top Right - * 2 - Bottom Left, 3 - Top Left + * Gets the active Panel. + * + * <blockquote><table summary="Table with all values for an active panel" + * border="1" cellpadding="3" cellspacing="0"> + * <tr><th>Value</th><th>Meaning</th></tr> + * <tr><td align="center">0</td><td>Bottom Right</td></tr> + * <tr><td align="center">1</td><td>Top Right</td></tr> + * <tr><td align="center">2</td><td>Bottom Left</td></tr> + * <tr><td align="center">3</td><td>Top Left</td></tr> + * </table></blockquote> * - * @return int representing the active panel + * @return {@code int} representing the active panel. */ public int getPaneNumber() { - return paneNumber; } /** - * Sets the sheetname this settings object applies to + * Sets the {@code sheetName} this settings object applies to. * - * @param sheetName the name of the worksheet + * @param sheetName the name of the worksheet. */ public void setSheetName(String sheetName) { - this.sheetName = sheetName; - } /** - * Sets the active pane number - * 0 - Bottom Right, 1 - Top Right - * 2 - Bottom Left, 3 - Top Left + * Sets the active pane number. + * + * <blockquote><table summary="Table with all values for an active panel" + * border="1" cellpadding="3" cellspacing="0"> + * <tr><th>Value</th><th>Meaning</th></tr> + * <tr><td align="center">0</td><td>Bottom Right</td></tr> + * <tr><td align="center">1</td><td>Top Right</td></tr> + * <tr><td align="center">2</td><td>Bottom Left</td></tr> + * <tr><td align="center">3</td><td>Top Left</td></tr> + * </table></blockquote> * - * @param paneNumber the pane number + * @param paneNumber the pane number. */ public void setPaneNumber(int paneNumber) { - this.paneNumber = paneNumber; } /** - * Gets the name of the worksheet these <code>Settings</code> apply to + * Gets the name of the worksheet these {@code Settings} apply to. * - * @return the name of the worksheet + * @return the name of the worksheet. */ public String getSheetName() { - return sheetName; } /** - * Adds an XML entry for a particular setting + * Adds an XML entry for a particular setting. * - * @param root the root node at which to add the xml entry - * @param attribute the name of the attribute to add - * @param type the attribute type (int, short etc) - * @param value the value of the attribute + * @param root the root {@code Node} at which to add the xml entry. + * @param attribute the name of the attribute to add. + * @param type the attribute type ({@code int}, {@code short} etc). + * @param value the value of the attribute. */ private void addConfigItem(Node root, String attribute, String type, String value) { @@ -228,10 +229,10 @@ public class SheetSettings implements OfficeConstants { } /** - * Writes out a settings.xml entry for this SheetSettings object + * Writes out a settings.xml entry for this {@code SheetSettings} object. * - * @param settings a <code>Document</code> object representing the settings.xml - * @param root the root xml node to add to + * @param settings a {@code Document} object representing the settings.xml + * @param root the root xml node to add to. */ public void writeNode(org.w3c.dom.Document settings, Node root) { @@ -265,10 +266,10 @@ public class SheetSettings implements OfficeConstants { } /** - * Sets a variable based on a String value read from XML + * Sets a variable based on a {@code String} value read from XML. * - * @param name xml name of the attribute to set - * @param value String value fo the attribute + * @param name xml name of the attribute to set. + * @param value {@code String} value for the attribute. */ private void addAttribute(String name, String value) { @@ -297,9 +298,9 @@ public class SheetSettings implements OfficeConstants { } /** - * Reads document settings from xml and inits SheetSettings variables + * Reads document settings from xml and inits {@code SheetSettings} variables. * - * @param root XML Node to read from + * @param root XML {@code Node} to read from. */ private void readNode(Node root) { @@ -342,4 +343,4 @@ public class SheetSettings implements OfficeConstants { } } } -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java index d49f5a6b4fa3..4ad1080daa02 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java @@ -24,140 +24,129 @@ import java.util.Iterator; import org.openoffice.xmerge.ConvertData; /** - * This class is a abstract class for encoding a "Device" - * <code>Document</code> format into an alternative spreadsheet format. - * + * This {@code class} is a {@code abstract class} for encoding a "Device" + * {@code Document} format into an alternative spreadsheet format. */ public abstract class SpreadsheetDecoder { /** - * Returns the total number of sheets in the WorkBook. + * Returns the total number of sheets in the WorkBook. * - * @return The number of sheets in the WorkBook. + * @return The number of sheets in the WorkBook. */ public abstract int getNumberOfSheets(); /** - * Returns an Enumeration to a Vector of <code>NameDefinition</code>. + * Returns an Enumeration to a Vector of {@code NameDefinition}. * - * @return The Enumeration + * @return The Enumeration. */ public abstract Iterator<NameDefinition> getNameDefinitions(); /** - * Returns an <code>BookSettings</code> + * Returns the {@code BookSettings}. * - * @return The Enumeration + * @return The Enumeration. */ public abstract BookSettings getSettings(); - /** - * Returns an Enumeration to a Vector of <code>ColumnRowInfo</code>. + /** + * Returns an Enumeration to a Vector of {@code ColumnRowInfo}. * - * @return The Enumeration + * @return The Enumeration. */ public abstract Iterator<ColumnRowInfo> getColumnRowInfos(); /** - * Returns the number of populated rows in the current WorkSheet. + * Returns the number of populated rows in the current WorkSheet. * - * @return the number of populated rows in the current WorkSheet. + * @return the number of populated rows in the current WorkSheet. */ public abstract int getNumberOfRows(); - /** - * Returns the number of populated columns in the current WorkSheet. + * Returns the number of populated columns in the current WorkSheet. * - * @return The number of populated columns in the current WorkSheet. + * @return The number of populated columns in the current WorkSheet. */ public abstract int getNumberOfColumns(); - /** - * Returns the name of the current WorkSheet. + * Returns the name of the current WorkSheet. * - * @return Name of the current WorkSheet. + * @return Name of the current WorkSheet. */ public abstract String getSheetName(); - /** - * Returns the number of the active column. + * Returns the number of the active column. * - * @return The number of the active column. + * @return The number of the active column. */ public abstract int getColNumber(); - /** - * Returns the number of the active row. + * Returns the number of the active row. * - * @return The number of the active row. + * @return The number of the active row. */ public abstract int getRowNumber(); - /** - * Sets the active WorkSheet. + * Sets the active WorkSheet. * - * @param sheetIndex The index of the sheet to be made active. + * @param sheetIndex The index of the sheet to be made active. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public abstract void setWorksheet(int sheetIndex) throws IOException; - /** - * Move on the next populated cell in the current WorkSheet. + * Move on the next populated cell in the current WorkSheet. * - * @return true if successful, false otherwise. + * @return {@code true} if successful, {@code false} otherwise. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public abstract boolean goToNextCell() throws IOException; - /** - * Return the contents of the active cell. + * Return the contents of the active cell. * - * @return The cell contents. + * @return The cell contents. */ public abstract String getCellContents(); /** - * Return the value of the active cell. Used in the case of Formula where - * the cell contents and the cell value are not the same thing. + * Return the value of the active cell. + * + * <p>Used in the case of Formula where the cell contents and the cell + * value are not the same thing.</p> * * @return The cell value. */ public abstract String getCellValue(); /** - * Return the data type of the active cell. + * Return the data type of the active cell. * - * @return The cell data type. + * @return The cell data type. */ public abstract String getCellDataType(); - /** - * Return a <code>Format</code> object describing the active cells - * formatting. + * Return a {@code Format} object describing the active cells formatting. * - * @return <code>Format</code> object for the cell. + * @return {@code Format} object for the cell. */ public abstract Format getCellFormat(); - /** - * Add the contents of a <code>ConvertData</code> to the workbook. + * Add the contents of a {@code ConvertData} to the workbook. * - * @param cd The <code>ConvertData</code> containing the - * content. + * @param cd The {@code ConvertData} containing the content. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public abstract void addDeviceContent(ConvertData cd) throws IOException; -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java index 3b79122f32f6..e87748773fc6 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java @@ -22,72 +22,60 @@ import java.io.IOException; import java.util.ArrayList; /** - * <p>This class is a abstract class for encoding an SXC into an - * alternative spreadsheet format.</p> + * This {@code class} is an {@code abstract class} for encoding an SXC into an + * alternative spreadsheet format. * - * <p>TODO - Add appropriate exceptions to each of the methods.</p> + * <p>ToDo - Add appropriate exceptions to each of the methods.</p> * */ public abstract class SpreadsheetEncoder { - /** - * Create a new WorkSheet within the WorkBook. + * Create a new WorkSheet within the WorkBook. * - * @param sheetName The name of the WorkSheet. + * @param sheetName The name of the WorkSheet. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public abstract void createWorksheet(String sheetName) throws IOException; - - - - /** - * Add a cell to the current WorkSheet. + * Add a cell to the current WorkSheet. * - * @param row The row number of the cell - * @param column The column number of the cell - * @param fmt The <code>Format</code> object describing the - * appearance of this cell. - * @param cellContents The text or formula of the cell's contents. + * @param row The row number of the cell + * @param column The column number of the cell + * @param fmt The {@code Format} object describing the appearance + * of this cell. + * @param cellContents The text or formula of the cell's contents. */ - public abstract void addCell(int row, int column, - Format fmt, String cellContents) throws IOException; - + public abstract void addCell(int row, int column, Format fmt, + String cellContents) throws IOException; /** - * Get the number of sheets in the WorkBook. + * Get the number of sheets in the WorkBook. * - * @return The number of sheets in the WorkBook. + * @return The number of sheets in the WorkBook. */ public abstract int getNumberOfSheets(); - - - - /** - * Set the width of the columns in the WorkBook. + * Set the width of the columns in the WorkBook. * - * @param columnRows An <code>IntArrayList</code> of column - * widths. + * @param columnRows An {@code IntArrayList} of column widths. */ public abstract void setColumnRows(ArrayList<ColumnRowInfo> columnRows) throws IOException; /** - * Set the name definition of this spreadsheet + * Set the name definition of this spreadsheet. * - * @param nd The <code>NameDefinition</code> to use. + * @param nd The {@code NameDefinition} to use. */ public abstract void setNameDefinition(NameDefinition nd) throws IOException; /** - * Adds settings to the WorkBook. + * Adds settings to the WorkBook. * - * @param s The <code>BookSettings</code> to add. + * @param s The {@code BookSettings} to add. */ public abstract void addSettings(BookSettings s) throws IOException; -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java index dbf26291296d..00a59d5d2a07 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcConstants.java @@ -18,10 +18,8 @@ package org.openoffice.xmerge.converter.xml.sxc; - /** * Interface defining constants for Sxc attributes. - * */ public interface SxcConstants { @@ -36,4 +34,4 @@ public interface SxcConstants { /** Name of the default style. */ String DEFAULT_STYLE = "Default"; -} +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java index fe977d8fa482..91a6ec3492bb 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocument.java @@ -22,30 +22,26 @@ import org.openoffice.xmerge.converter.xml.OfficeDocument; import org.openoffice.xmerge.converter.xml.OfficeConstants; /** - * This class is an implementation of <code>OfficeDocument</code> for - * the SXC format. + * This class is an implementation of {@code OfficeDocument} for the SXC format. */ public class SxcDocument extends OfficeDocument { /** - * Constructor with arguments to set <code>name</code>. + * Constructor with arguments to set {@code name}. * - * @param name The name of the <code>Document</code> + * @param name The name of the {@code Document}. */ public SxcDocument(String name) { super(name); } - /** - * Constructor with arguments to set <code>name</code>, the - * <code>namespaceAware</code> flag, and the <code>validating</code> - * flag. + * Constructor with arguments to set {@code name}, the {@code namespaceAware} + * flag, and the {@code validating} flag. * - * @param name The name of the <code>Document</code>. - * @param namespaceAware The value of the <code>namespaceAware</code> - * flag. - * @param validating The value of the <code>validating</code> flag. + * @param name The name of the {@code Document}. + * @param namespaceAware The value of the {@code namespaceAware} flag. + * @param validating The value of the {@code validating} flag. */ public SxcDocument(String name, boolean namespaceAware, boolean validating) { @@ -53,9 +49,9 @@ public class SxcDocument extends OfficeDocument { } /** - * Returns the Office file extension for the SXC format. + * Returns the Office file extension for the SXC format. * - * @return The Office file extension for the SXC format. + * @return The Office file extension for the SXC format. */ @Override protected String getFileExtension() { @@ -63,9 +59,9 @@ public class SxcDocument extends OfficeDocument { } /** - * Returns the Office attribute for the SXC format. + * Returns the Office attribute for the SXC format. * - * @return The Office attribute for the SXC format. + * @return The Office attribute for the SXC format. */ @Override protected String getOfficeClassAttribute() { @@ -81,6 +77,4 @@ public class SxcDocument extends OfficeDocument { protected final String getDocumentMimeType() { return OfficeConstants.SXC_MIME_TYPE; } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java index 55f9c3917a23..0675e5805102 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java @@ -34,36 +34,34 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * <p>General spreadsheet implementation of <code>DocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory - * SxcPluginFactory}. Used with SXC <code>Document</code> objects.</p> + * General spreadsheet implementation of {@code DocumentDeserializer} for the + * {@link org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory + * SxcPluginFactory}. * - * <p>The <code>deserialize</code> method uses a <code>DocDecoder</code> - * to read the device spreadsheet format into a <code>String</code> - * object, then it calls <code>buildDocument</code> to create a - * <code>SxcDocument</code> object from it.</p> + * <p>Used with SXC {@code Document} objects.</p> * + * <p>The {@code deserialize} method uses a {@code DocDecoder} to read the device + * spreadsheet format into a {@code String} object, then it calls + * {@code buildDocument} to create a {@code SxcDocument} object from it.</p> */ public abstract class SxcDocumentDeserializer implements OfficeConstants, DocumentDeserializer { /** - * A <code>SpreadsheetDecoder</code> object for decoding from - * device formats. + * A {@code SpreadsheetDecoder} object for decoding from device formats. */ private SpreadsheetDecoder decoder = null; - /** A w3c <code>Document</code>. */ + /** A w3c {@code Document}. */ private org.w3c.dom.Document settings = null; - /** A w3c <code>Document</code>. */ + /** A w3c {@code Document}. */ private org.w3c.dom.Document doc = null; - /** An <code>ConvertData</code> object assigned to this object. */ + /** A {@code ConvertData} object assigned to this object. */ private ConvertData cd = null; - /** A style catalog for the workbook */ + /** A {@code StyleCatalog} for the workbook. */ private StyleCatalog styleCat = null; private int textStyles = 1; @@ -71,75 +69,67 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, private int rowStyles = 1; /** - * Constructor. + * Constructor. * - * @param cd <code>ConvertData</code> consisting of a - * device content object. + * @param cd {@code ConvertData} consisting of a device content object. */ public SxcDocumentDeserializer(ConvertData cd) { this.cd = cd; } - /** - * This abstract method will be implemented by concrete subclasses - * and will return an application-specific Decoder. + * This {@code abstract} method will be implemented by concrete subclasses + * and will return an application-specific Decoder. * - * @param workbook The WorkBook to read. - * @param password The WorkBook password. + * @param workbook The WorkBook to read. + * @param password The WorkBook password. * - * @return The appropriate <code>SpreadSheetDecoder</code>. + * @return The appropriate {@code SpreadSheetDecoder}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public abstract SpreadsheetDecoder createDecoder(String workbook, String[] worksheetNames, String password) throws IOException; - /** - * <p>This method will return the name of the WorkBook from the - * <code>ConvertData</code>. Allows for situations where the - * WorkBook name differs from the Device Content name.</p> + * This method will return the name of the WorkBook from the + * {@code ConvertData}. + * + * <p>Allows for situations where the WorkBook name differs from the Device + * Content name.</p> * - * <p>Implemented in the Deserializer as the Decoder's constructor requires - * a name.</p> + * <p>Implemented in the Deserializer as the Decoder's constructor requires + * a name.</p> * - * @param cd The <code>ConvertData</code> containing the Device - * content. + * @param cd The {@code ConvertData} containing the Device content. * - * @return The WorkBook name. + * @return The WorkBook name. */ protected abstract String getWorkbookName(ConvertData cd) throws IOException; - /** - * This method will return the name of the WorkSheet from the - * <code>ConvertData</code>. + * This method will return the name of the WorkSheet from the + * {@code ConvertData}. * - * @param cd The <code>ConvertData</code> containing the Device - * content. + * @param cd The {@code ConvertData} containing the Device content. * - * @return The WorkSheet names. + * @return The WorkSheet names. */ protected abstract String[] getWorksheetNames(ConvertData cd) throws IOException; - /** - * <p>Method to convert a set of "Device" - * <code>Document</code> objects into a <code>SxcDocument</code> - * object and returns it as a <code>Document</code>.</p> + * Method to convert a set of "Device" {@code Document} objects + * into a {@code SxcDocument} object and returns it as a {@code Document}. * - * <p>This method is not thread safe for performance reasons. - * This method should not be called from within two threads. - * It would be best to call this method only once per object - * instance.</p> + * <p>This method is not thread safe for performance reasons. This method + * should not be called from within two threads. It would be best to call + * this method only once per object instance.</p> * - * @return document An <code>SxcDocument</code> consisting - * of the data converted from the input - * stream. + * @return document A {@code SxcDocument} consisting of the data converted + * from the input stream. * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. + * @throws ConvertException If any conversion error occurs. + * @throws IOException If any I/O error occurs. */ public Document deserialize() throws ConvertException, IOException { @@ -163,7 +153,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // be the name of the StarCalc file minus the file extension suffix. // Create a Decoder to decode the DeviceContent to a spreadsheet document - // TODO - we aren't using a password in StarCalc, so we can + // ToDo - we aren't using a password in StarCalc, so we can // use any value for password here. If StarCalc XML supports // passwords in the future, we should try to get the correct // password value here. @@ -182,14 +172,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * This initializes a font table so we can include some basic font - * support for spreadsheets. - * + * This initializes a font table so we can include some basic font support + * for spreadsheets. */ private void initFontTable() { - String fontTable[]= new String[] { "Tahoma", "Tahoma", "swiss", "variable", - "Courier New", "'Courier New'", "modern", "fixed"}; + String fontTable[]= new String[] { "Tahoma", "Tahoma", "swiss", "variable", + "Courier New", "'Courier New'", + "modern", "fixed" }; // Traverse to the office:body element. // There should only be one. NodeList list = doc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); @@ -211,10 +201,9 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * Outer level method used to decode a WorkBook - * into a <code>Document</code>. + * Outer level method used to decode a WorkBook into a {@code Document}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void decode() throws IOException { @@ -259,16 +248,12 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } - - /** - * This method process the settings portion - * of the <code>Document</code>. + * This method process the settings portion of the {@code Document}. * - * @param root The root <code>Node</code> of the - * <code>Document</code> we are building. This - * <code>Node</code> should be a TAG_OFFICE_SETTINGS - * tag. + * @param root The root {@code Node} of the {@code Document} we are + * building. This {@code Node} should be a + * {@code TAG_OFFICE_SETTINGS} tag. */ protected void processSettings(Node root) { @@ -286,15 +271,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * This method process a Name Definition Table and generates a portion - * of the <code>Document</code>. + * This method process a Name Definition Table and generates a portion of + * the {@code Document}. * - * @param root The root <code>Node</code> of the - * <code>Document</code> we are building. This - * <code>Node</code> should be a TAG_OFFICE_BODY - * tag. + * @param root The root {@code Node} of the {@code Document} we are + * building. This {@code Node} should be a + * {@code TAG_OFFICE_BODY} tag. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void processNameDefinition(Node root, Iterator<NameDefinition> eNameDefinitions) throws IOException { @@ -314,16 +298,16 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * This method process a WorkSheet and generates a portion - * of the <code>Document</code>. A spreadsheet is represented - * as a table Node in StarOffice XML format. + * This method process a WorkSheet and generates a portion of the + * {@code Document}. + * + * <p>A spreadsheet is represented as a table Node in StarOffice XML format.</p> * - * @param root The root <code>Node</code> of the - * <code>Document</code> we are building. This - * <code>Node</code> should be a TAG_OFFICE_BODY - * tag. + * @param root The root {@code Node} of the {@code Document} we are + * building. This {@code Node} should be a + * {@code TAG_OFFICE_BODY} tag. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void processTable(Node root) throws IOException { @@ -338,7 +322,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // Set the table name attribute tableElement.setAttribute(ATTRIBUTE_TABLE_NAME, sheetName); - // TODO - style currently hardcoded - get real value + // ToDo - style currently hardcoded - get real value // Set table style-name attribute tableElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, "Default"); @@ -347,7 +331,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Debug.log(Debug.TRACE, "<SheetName>" + sheetName + "</SheetName>"); - // add the various different table-columns + // Add the various different table-columns processColumns(tableElement); // Get each cell and add to doc @@ -357,18 +341,16 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * <p>This method process the cells in a <code>Document</code> - * and generates a portion of the <code>Document</code>.</p> + * This method process the cells in a {@code Document} and generates a + * portion of the {@code Document}. * - * <p>This method assumes that records are sorted by - * row and then column.</p> + * <p>This method assumes that records are sorted by row and then column.</p> * - * @param root The <code>Node</code> of the <code>Document</code> - * we are building that we will append our cell - * <code>Node</code> objects. This <code>Node</code> - * should be a TAG_TABLE tag. + * @param root The {@code Node} of the {@code Document} we are building + * that we will append our cell {@code Node} objects. This + * {@code Node} should be a {@code TAG_TABLE} tag. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void processColumns(Node root) throws IOException { @@ -406,18 +388,16 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } /** - * <p>This method process the cells in a <code>Document</code> - * and generates a portion of the <code>Document</code>.</p> + * This method process the cells in a {@code Document} and generates a + * portion of the {@code Document}. * - * <p>This method assumes that records are sorted by - * row and then column.</p> + * <p>This method assumes that records are sorted by row and then column.</p> * - * @param root The <code>Node</code> of the <code>Document</code> - * we are building that we will append our cell - * <code>Node</code> objects. This <code>Node</code> - * should be a TAG_TABLE tag. + * @param root The {@code Node} of the {@code Document} we are building + * that we will append our cell {@code Node} objects. This + * {@code Node} should be a {@code TAG_TABLE} tag. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void processCells(Node root) throws IOException { @@ -438,7 +418,6 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // The number of columns in the spreadsheet int lastColumn = decoder.getNumberOfColumns(); - Node autoStylesNode = null; // Loop over all cells in the spreadsheet @@ -477,7 +456,6 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // Create an element node for the new row rowElement = doc.createElement(TAG_TABLE_ROW); - for(Iterator<ColumnRowInfo> e = decoder.getColumnRowInfos();e.hasNext();) { ColumnRowInfo cri = e.next(); if(cri.isRow() && cri.getRepeated()==newRow-1) { @@ -552,7 +530,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, if (autoStylesNode == null) { autoStylesNode = doc.createElement(TAG_OFFICE_AUTOMATIC_STYLES); doc.insertBefore(autoStylesNode, bodyNode); - } + } CellStyle tStyle = new CellStyle( "Default",SxcConstants.TABLE_CELL_STYLE_FAMILY, @@ -599,44 +577,40 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, // Now write the style catalog to the document if(autoStylesNode!=null) { - Debug.log(Debug.TRACE,"Well the autostyle node was found!!!"); + Debug.log(Debug.TRACE, "Well the autostyle node was found!!!"); NodeList nl = styleCat.writeNode(doc, "dummy").getChildNodes(); int nlLen = nl.getLength(); // nl.item reduces the length - for (int i = 0; i < nlLen; i++) { - autoStylesNode.appendChild(nl.item(0)); - } + for (int i = 0; i < nlLen; i++) { + autoStylesNode.appendChild(nl.item(0)); + } } if (row != 0) { - // The sheet does have rows, so write out a /tr Debug.log(Debug.TRACE, "</tr>"); } } - /** - * This method will add empty rows to the <code>Document</code>. - * It is called when the conversion process encounters - * a row (or rows) that do not contain any data in its cells. + * This method will add empty rows to the {@code Document}. + * + * <p>It is called when the conversion process encounters a row (or rows) + * that do not contain any data in its cells.</p> * - * @param numEmptyRows The number of empty rows that we - * need to add to the <code>Document</code>. - * @param root The <code>Node</code> of the - * <code>Document</code> we are building - * that we will append our empty row - * <code>Node</code> objects. This - * <code>Node</code> should be a TAG_TABLE - * tag. - * @param numEmptyCells The number of empty cells in the - * empty row. + * @param numEmptyRows The number of empty rows that we need to add to + * the {@code Document}. + * @param root The {@code Node} of the {@code Document} we are + * building that we will append our empty row + * {@code Node} objects. This {@code Node} should + * be a {@code TAG_TABLE} tag. + * @param numEmptyCells The number of empty cells in the empty row. */ protected void addEmptyRows(int numEmptyRows, Node root, int numEmptyCells) { // Create an element node for the row Element rowElement = doc.createElement(TAG_TABLE_ROW); - // TODO - style currently hardcoded - get real value + // ToDo - style currently hardcoded - get real value // Set row style-name attribute rowElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, "Default"); @@ -657,29 +631,25 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } - /** - * This method will add empty cells to the <code>Document</code>. - * It is called when the conversion process encounters a row - * that contains some cells without data. + * This method will add empty cells to the {@code Document}. + * + * <p>It is called when the conversion process encounters a row that + * contains some cells without data.</p> * - * @param numColsSkipped The number of empty cells - * that we need to add to the - * current row. - * @param row The <code>Node</code> of the - * <code>Document</code> we - * are building that we will - * append our empty cell - * <code>Node</code> objects. - * This <code>Node</code> should - * be a TAG_TABLE_ROW tag. + * @param numColsSkipped The number of empty cells that we need to add to + * the current row. + * @param row The {@code Node} of the {@code Document} we are + * building that we will append our empty cell + * {@code Node} objects. This {@code Node} should + * be a {@code TAG_TABLE_ROW} tag. */ protected void addEmptyCells(int numColsSkipped, Node row) { // Create an empty cellElement Element cellElement = doc.createElement(TAG_TABLE_CELL); - // TODO - style currently hardcoded - get real value + // ToDo - style currently hardcoded - get real value // Set cell style-name attribute cellElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, "Default"); @@ -701,17 +671,15 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } } - /** - * This method process the data in a cell and sets - * the appropriate attributes on the cell <code>Element</code>. + * This method process the data in a cell and sets the appropriate attributes + * on the cell {@code Element}. * - * @param cellElement A TAG_TABLE_CELL <code>Element</code> - * that we will be adding attributes to - * based on the type of data in the cell. - * @param type The type of data contained in the cell. - * @param contents The contents of the data contained in - * the cell. + * @param cellElement A {@code TAG_TABLE_CELL} {@code Element} that we + * will be adding attributes to based on the type of + * data in the cell. + * @param type The type of data contained in the cell. + * @param contents The contents of the data contained in the cell. */ protected void processCellData(Element cellElement, String type, String contents) { @@ -770,6 +738,4 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } } } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java index ba060cbf3e4b..bf6d2dc7f9f4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java @@ -36,90 +36,84 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * <p>General spreadsheet implementation of <code>DocumentSerializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory - * SxcPluginFactory}. Used with SXC <code>Document</code> objects.</p> + * General spreadsheet implementation of {@code DocumentSerializer} for the + * {@link org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory + * SxcPluginFactory}. * - * <p>The <code>serialize</code> method traverses the DOM - * <code>Document</code> from the given <code>Document</code> object. - * It uses a <code>DocEncoder</code> object for the actual conversion - * of contents to the device spreadsheet format.</p> + * <p>Used with SXC {@code Document} objects.</p> * + * <p>The {@code serialize} method traverses the DOM {@code Document} from the + * given {@code Document} object. It uses a {@code DocEncoder} object for the + * actual conversion of contents to the device spreadsheet format.</p> */ public abstract class SxcDocumentSerializer implements OfficeConstants, DocumentSerializer { - /** <code>Format</code> object describing the cell. */ + /** {@code Format} object describing the cell. */ private Format fmt = null; - /** The row number. */ + /** The row number. */ private int rowID = 1; - /** The column number. */ + /** The column number. */ private int colID = 1; - /** The number of times the current row is repeated. */ + /** The number of times the current row is repeated. */ private int rowsRepeated = 1; - /** The number of times the current column is repeated. */ + /** The number of times the current column is repeated. */ private int colsRepeated = 1; - /** The number of times the current column is repeated. */ + /** The number of times the current column is repeated. */ private StyleCatalog styleCat = null; + /** - * An array of column widths of the current worksheet. Width is - * measured in number of characters. + * An array of column widths of the current worksheet. + * Width is measured in number of characters. */ private ArrayList<ColumnRowInfo> ColumnRowList; /** - * A <code>SpreadsheetEncoder</code> object for encoding to - * appropriate format. + * A {@code SpreadsheetEncoder} object for encoding to appropriate format. */ protected SpreadsheetEncoder encoder = null; - /** <code>SxcDocument</code> object that this converter processes. */ + /** {@code SxcDocument} object that this converter processes. */ protected SxcDocument sxcDoc = null; - /** - * Constructor. + * Constructor. * - * @param document Input <code>SxcDocument</code> - * <code>Document</code>. + * @param document Input {@code SxcDocument} {@code Document}. */ public SxcDocumentSerializer(Document document) { fmt = new Format(); sxcDoc = (SxcDocument) document; } - /** - * <p>Method to convert a DOM <code>Document</code> into - * "Device" <code>Document</code> objects.</p> + * Method to convert a DOM {@code Document} into "Device" + * {@code Document} objects. * - * <p>This method is not thread safe for performance reasons. - * This method should not be called from within two threads. - * It would be best to call this method only once per object - * instance.</p> + * <p>This method is not thread safe for performance reasons. This method + * should not be called from within two threads. It would be best to call + * this method only once per object instance.</p> * - * @return <code>ConvertData</code> containing "Device" - * <code>Document</code> objects. + * @return {@code ConvertData} containing "Device" + * {@code Document}objects. * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. + * @throws ConvertException If any conversion error occurs. + * @throws IOException If any I/O error occurs. */ public abstract ConvertData serialize() throws ConvertException, IOException; - /** - * This method traverses <i>office:settings</i> <code>Element</code>. + * This method traverses <i>office:settings</i> {@code Element}. * - * @param node <i>office:settings</i> <code>Node</code>. + * @param node <i>office:settings</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public void traverseSettings(Node node) throws IOException { if (node.hasChildNodes()) { @@ -154,12 +148,12 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } } - /* - * Handles the loading of defined styles from the style.xml file as well - * as automatic styles from the content.xml file. + /** + * Handles the loading of defined styles from the style.xml file as well as + * automatic styles from the content.xml file. * - * Any change to a defined style, such as a short bold section, falls into - * the latter category. + * <p>Any change to a defined style, such as a short bold section, falls + * into the latter category. */ protected void loadStyles(SxcDocument sxcDoc) { @@ -188,11 +182,11 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } /** - * This method traverses <i>office:body</i> <code>Element</code>. + * This method traverses <i>office:body</i> {@code Element}. * - * @param node <i>office:body</i> <code>Node</code>. + * @param node <i>office:body</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void traverseBody(Node node) throws IOException { @@ -242,14 +236,12 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, Debug.log(Debug.TRACE, "</DEBUGLOG>"); } - /** - * This method traverses the <i>table:table</i> element - * <code>Node</code>. + * This method traverses the <i>table:table</i> element {@code Node}. * - * @param node A <i>table:table</i> <code>Node</code>. + * @param node A <i>table:table</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void traverseNamedExpressions(Node node) throws IOException { @@ -274,12 +266,11 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } /** - * This method traverses the <i>table:table</i> element - * <code>Node</code>. + * This method traverses the <i>table:table</i> element {@code Node}. * - * @param node A <i>table:table</i> <code>Node</code>. + * @param node A <i>table:table</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void traverseTable(Node node) throws IOException { @@ -288,7 +279,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, ColumnRowList = new ArrayList<ColumnRowInfo>(); // Get table attributes - // TODO - extract style from attribute + // ToDo - extract style from attribute NamedNodeMap att = node.getAttributes(); @@ -339,12 +330,11 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } /** - * This method traverses the <i>table:table-row</i> element - * <code>Node</code>. + * This method traverses the <i>table:table-row</i> element {@code Node}. * - * @param node A <i>table:table-row</i> <code>Node</code>. + * @param node A <i>table:table-row</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void traverseTableRow(Node node) throws IOException { @@ -454,12 +444,12 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, Debug.log(Debug.TRACE, "</TR>"); } - /** - * This method traverses the <i>table:table-column</i> - * <code>Node</code>. Not yet implemented. + * This method traverses the <i>table:table-column</i> {@code Node}. + * + * <p>Not yet implemented.</p> * - * @param node A <i>table:table-column</i> <code>Node</code>. + * @param node A <i>table:table-column</i> {@code Node}. * * @throws IOException If any I/O error occurs. */ @@ -527,12 +517,11 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } /** - * This method traverses a <i>table:table-cell</i> element - * <code>Node</code>. + * This method traverses a <i>table:table-cell</i> element {@code Node}. * - * @param node a <i>table:table-cell</i> <code>Node</code>. + * @param node a <i>table:table-cell</i> {@code Node}. * - * @throws IOException if any I/O error occurs. + * @throws IOException if any I/O error occurs. */ protected void traverseCell(Node node) throws IOException { @@ -541,15 +530,11 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, int debug_i=0; Node debug_attrib = null; fmt.clearFormatting(); - if (cellAtt == null || cellAtt.item(0) == null) - { + if (cellAtt == null || cellAtt.item(0) == null) { Debug.log(Debug.INFO, "No Cell Attributes\n"); // return; - } - else - { - while ((debug_attrib = cellAtt.item(debug_i++)) != null) - { + } else { + while ((debug_attrib = cellAtt.item(debug_i++)) != null) { Debug.log(Debug.INFO, "Cell Attribute " + debug_i + ": " + debug_attrib.getNodeName() + " : " + debug_attrib.getNodeValue() + "\n"); @@ -749,13 +734,12 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } - /** - * This method traverses the <i>text:p</i> element <code>Node</code>. + * This method traverses the <i>text:p</i> element {@code Node}. * - * @param node A <i>text:p</i> <code>Node</code>. + * @param node A <i>text:p</i> {@code Node}. * - * @throws IOException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ protected void traverseParagraph(Node node) throws IOException { @@ -763,14 +747,10 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, int debug_i=0; Node debug_attrib = null; - if (cellAtt == null || cellAtt.item(0) == null) - { + if (cellAtt == null || cellAtt.item(0) == null) { Debug.log(Debug.INFO, "No Paragraph Attributes\n"); - } - else - { - while ((debug_attrib = cellAtt.item(debug_i++)) != null) - { + } else { + while ((debug_attrib = cellAtt.item(debug_i++)) != null) { Debug.log(Debug.INFO, "Paragraph Attribute " + debug_i + ": " + debug_attrib.getNodeName() + " : " + debug_attrib.getNodeValue() + "\n"); @@ -821,17 +801,17 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } } - /** - * This method will take the input cell value and add - * it to the spreadsheet <code>Document</code> we are currently - * encoding. This method correctly handles cells that are - * repeated in either the row, cell, or both directions. + * This method will take the input cell value and add it to the spreadsheet + * {@code Document} we are currently encoding. * - * @param cellValue The contents of the cell we want to add - * to the spreadsheet <code>Document</code>. + * <p>This method correctly handles cells that are repeated in either the + * row, cell, or both directions.</p> * - * @throws IOException If any I/O error occurs. + * @param cellValue The contents of the cell we want to add to the + * spreadsheet {@code Document}. + * + * @throws IOException If any I/O error occurs. */ protected void addCell(String cellValue) throws IOException { @@ -852,7 +832,6 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, Debug.log(Debug.TRACE, "<TD>"); - // Add the cell data to the encoded spreadsheet document encoder.addCell(row, col, fmt, cellValue); @@ -868,23 +847,21 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } - - /** - * This method takes a <i>table:table-cell</i> <code>Node</code> - * and traverses down to the <i>text:p</i> tag. The value is - * extracted from the <i>text:p</i> tag and the number of decimal - * places is calculated. + * This method takes a <i>table:table-cell</i> {@code Node} and traverses + * down to the <i>text:p</i> tag. * - * @param node A <i>table:table-cell</i> <code>Node</code>. + * <p>The value is extracted from the <i>text:p</i> tag and the number of + * decimal places is calculated.</p> * - * @return The number of decimal places in the display - * string of the data in the input <code>Node</code>. + * @param node A <i>table:table-cell</i> {@code Node}. + * + * @return The number of decimal places in the display string of the data + * in the input {@code Node}. */ protected int getDecimalPlaces(Node node) { int decimals = 0; - Element element = null; // cast org.w3c.dom.Node to org.w3c.dom.Element @@ -902,21 +879,16 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, } Node paragraph = list.item(0); - if (paragraph.hasChildNodes()) { NodeList nodeList = paragraph.getChildNodes(); - int len = nodeList.getLength(); - for (int j = 0; j < len; j++) { Node child = nodeList.item(j); - if (child.getNodeType() == Node.TEXT_NODE) { String s = child.getNodeValue(); - int k = s.lastIndexOf("."); if (k > 0) { s = s.substring(k+1); @@ -928,6 +900,4 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, return decimals; } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java index b034dcab2dda..1b3008c637bd 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcPluginFactory.java @@ -26,50 +26,44 @@ import org.openoffice.xmerge.PluginFactory; import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentMergerFactory; - /** - * General implementation of the <code>PluginFactory</code> interface - * for SXC <code>Document</code> objects. + * General implementation of the {@code PluginFactory} interface for SXC + * {@code Document} objects. * - * @see org.openoffice.xmerge.DocumentDeserializer - * @see org.openoffice.xmerge.DocumentMerger - * @see org.openoffice.xmerge.DocumentSerializer + * @see org.openoffice.xmerge.DocumentDeserializer + * @see org.openoffice.xmerge.DocumentMerger + * @see org.openoffice.xmerge.DocumentSerializer */ public abstract class SxcPluginFactory extends PluginFactory implements DocumentMergerFactory { - /** - * Constructor that caches the <code>ConvertInfo</code> that - * corresponds to the registry information for this plug-in. + * Constructor that caches the {@code ConvertInfo} that corresponds to the + * registry information for this plug-in. * - * @param ci <code>ConvertInfo</code> object. + * @param ci {@code ConvertInfo} object. */ public SxcPluginFactory(ConverterInfo ci) { super(ci); } - @Override public Document createOfficeDocument(String name, InputStream is) throws IOException { - // read zipped XML stream - + // Read zipped XML stream SxcDocument doc = new SxcDocument(name); doc.read(is); return doc; } - @Override + @Override public Document createOfficeDocument(String name, InputStream is,boolean isZip) throws IOException { - // read zipped XML stream - + // Read zipped XML stream SxcDocument doc = new SxcDocument(name); doc.read(is,isZip); return doc; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java index 8728319d953e..37cf99699064 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwDocument.java @@ -22,52 +22,46 @@ import org.openoffice.xmerge.converter.xml.OfficeDocument; import org.openoffice.xmerge.converter.xml.OfficeConstants; /** - * This class is an implementation of <code>OfficeDocument</code> for - * the SXW format. + * This class is an implementation of {@code OfficeDocument} for the SXW format. */ public class SxwDocument extends OfficeDocument { - /** - * Constructor with arguments to set <code>name</code>. + * Constructor with arguments to set {@code name}. * - * @param name The name of the <code>Document</code> + * @param name The name of the {@code Document}. */ public SxwDocument(String name) { super(name); } - /** - * Constructor with arguments to set <code>name</code>, the - * <code>namespaceAware</code> flag, and the <code>validating</code> - * flag. + * Constructor with arguments to set {@code name}, the {@code namespaceAware} + * flag, and the {@code validating} flag. * - * @param name The name of the <code>Document</code>. - * @param namespaceAware The value of the namespaceAware flag. - * @param validating The value of the validating flag. + * @param name The name of the {@code Document}. + * @param namespaceAware The value of the {@code namespaceAware} flag. + * @param validating The value of the {@code validating} flag. */ public SxwDocument(String name, boolean namespaceAware, boolean validating) { super(name, namespaceAware, validating); } - /** - * Returns the Office file extension for the SXW format. + * Returns the Office file extension for the SXW format. * - * @return The Office file extension for the SXW format. + * @return The Office file extension for the SXW format. */ @Override protected String getFileExtension() { return OfficeConstants.SXW_FILE_EXTENSION; } - /** - * Returns the Office attribute for the SXW format. + * Returns the Office attribute for the SXW format. * - * @return The Office attribute for the SXW format. + * @return The Office attribute for the SXW format. */ @Override protected String getOfficeClassAttribute() { @@ -77,12 +71,10 @@ public class SxwDocument extends OfficeDocument { /** * Method to return the MIME type of the document. * - * @return String The document's MIME type. + * @return The document's MIME type. */ @Override protected final String getDocumentMimeType() { return OfficeConstants.SXW_MIME_TYPE; } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java index c0cb42d1a122..c529a3126bd1 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxw/SxwPluginFactory.java @@ -26,44 +26,42 @@ import org.openoffice.xmerge.Document; import org.openoffice.xmerge.util.registry.ConverterInfo; /** - * General implementation of the <code>PluginFactory</code> interface - * for SXW documents. + * General implementation of the {@code PluginFactory} interface for SXW + * documents. * - * @see org.openoffice.xmerge.DocumentDeserializer - * @see org.openoffice.xmerge.DocumentMerger - * @see org.openoffice.xmerge.DocumentSerializer + * @see org.openoffice.xmerge.DocumentDeserializer + * @see org.openoffice.xmerge.DocumentMerger + * @see org.openoffice.xmerge.DocumentSerializer */ public abstract class SxwPluginFactory extends PluginFactory { /** - * Constructor that caches the <code>ConvertInfo</code> that - * corresponds to the registry information for this plug-in. + * Constructor that caches the {@code ConvertInfo} that corresponds to the + * registry information for this plug-in. * - * @param ci <code>ConvertInfo</code> object. + * @param ci {@code ConvertInfo} object. */ public SxwPluginFactory (ConverterInfo ci) { super(ci); } - @Override public Document createOfficeDocument(String name, InputStream is) throws IOException { - // read zipped XML stream + // Read zipped XML stream SxwDocument doc = new SxwDocument(name); doc.read(is); return doc; } - @Override + @Override public Document createOfficeDocument(String name, InputStream is,boolean isZip) throws IOException { - // read XML stream + // Read XML stream SxwDocument doc = new SxwDocument(name); doc.read(is,isZip); return doc; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java index 31600c70113f..5569af0a8c33 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java @@ -22,15 +22,13 @@ import org.openoffice.xmerge.ConverterCapabilities; import org.openoffice.xmerge.converter.xml.OfficeConstants; /** - * <p>Xslt implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl - * PluginFactoryImpl}.</p> + * Xslt implementation of {@code ConverterCapabilities} for the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl PluginFactoryImpl}. * - * <p>Used with StarWriter XML to/from XSLT supported formats conversions. The - * <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> + * <p>Used with StarWriter XML to/from XSLT supported formats conversions. The + * {@code ConverterCapibilies} specify which "Office" {@code Document} + * tags and attributes are supported on the "Device" {@code Document} + * format.</p> */ public final class ConverterCapabilitiesImpl implements ConverterCapabilities { @@ -69,16 +67,13 @@ public final class ConverterCapabilitiesImpl return false; } - public boolean canConvertAttribute(String tag, - String attribute) { + public boolean canConvertAttribute(String tag, String attribute) { if (OfficeConstants.TAG_SPACE.equals(tag)) { - if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) return true; } return false; } -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java index 2d3bf4551607..434d60c4f2f3 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java @@ -42,108 +42,92 @@ import org.openoffice.xmerge.converter.dom.DOMDocument; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.registry.ConverterInfo; - /** - * <p>Xslt implementation of - * org.openoffice.xmerge.DocumentSerializer - * for the {@link - * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl - * PluginFactoryImpl}.</p> + * Xslt implementation of {@code org.openoffice.xmerge.DocumentSerializer} + * for the {@link org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}. * - * <p>The <code>serialize</code> method transforms the DOM - * document from the given <code>Document</code> object by - * means of a supplied Xsl Stylesheet.</p> + * <p>The {@code serialize} method transforms the DOM document from the given + * {@code Document} object by means of a supplied Xsl Stylesheet.</p> */ public final class DocumentDeserializerImpl implements DocumentDeserializer,URIResolver { - /** A <code>ConvertData</code> object assigned to this object. */ + /** A {@code ConvertData} object assigned to this object. */ private ConvertData cd = null; private PluginFactoryImpl pluginFactory = null; /** - * Constructor that assigns the given <code>ConvertData</code> - * to this object. - * - * @param pf A <code>PluginFactoryImpl</code> object. + * Constructor that assigns the given {@code ConvertData} to this object. * - * @param cd A <code>ConvertData</code> object to read data for - * the conversion process by the <code>deserialize</code> - * method. + * @param pf A {@code PluginFactoryImpl} object. + * @param cd A {@code ConvertData} object to read data for the conversion + * process by the {@code deserialize} method. */ public DocumentDeserializerImpl(PluginFactoryImpl pf,ConvertData cd) { this.cd = cd; - pluginFactory = pf; + pluginFactory = pf; } - - - /* - * This method performs the xslt transformation on the supplied <code> - * Document</code> and returns a <code>ByteArrayOutputStream</code> object. - * - * Xslt transformation code + /** + * This method performs the xslt transformation on the supplied + * {@code Document} and returns a {@code ByteArrayOutputStream} object. * - * @return baos A <code>ByteArrayOutputStream</code> object containing - * the result of the Xslt transformation. - * @throws TransformerException,TransformerConfigurationException - * , FileNotFoundException,IOException + * <p>Xslt transformation code.</p> * + * @return A {@code ByteArrayOutputStream} object containing the result + * of the Xslt transformation. */ public Document deserialize() throws ConvertException, IOException { - log("\nFound the XSLT deserializer"); - Iterator<Object> enumerate = cd.getDocumentEnumeration(); - org.w3c.dom.Document domDoc=null; - DOMDocument docOut=null; - ByteArrayOutputStream baos =null; - GenericOfficeDocument sxwDoc = new GenericOfficeDocument("output"); - while (enumerate.hasNext()) { - docOut = (DOMDocument) enumerate.next(); - } - domDoc = docOut.getContentDOM(); - try{ - baos = transform(domDoc); - sxwDoc.initContentDOM(); - DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); - dFactory.setNamespaceAware(true); - DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); - sxwDoc.setContentDOM(dBuilder.parse(new ByteArrayInputStream(baos.toByteArray()))); - - } - catch(Exception e){ - System.out.println("The following error occurred:"+e); - } - return sxwDoc; + log("\nFound the XSLT deserializer"); + Iterator<Object> enumerate = cd.getDocumentEnumeration(); + org.w3c.dom.Document domDoc = null; + DOMDocument docOut = null; + ByteArrayOutputStream baos = null; + GenericOfficeDocument sxwDoc = new GenericOfficeDocument("output"); + while (enumerate.hasNext()) { + docOut = (DOMDocument) enumerate.next(); + } + domDoc = docOut.getContentDOM(); + try { + baos = transform(domDoc); + sxwDoc.initContentDOM(); + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + sxwDoc.setContentDOM(dBuilder.parse(new ByteArrayInputStream(baos.toByteArray()))); + + } catch (Exception e) { + System.out.println("The following error occurred:" + e); + } + return sxwDoc; } - public Source resolve(String href,String base) - throws TransformerException{ - if (href !=null){ - if(href.equals("javax.xml.transform.dom.DOMSource")|| href.equals("")) + public Source resolve(String href, String base) throws TransformerException { + if (href != null) { + if (href.equals("javax.xml.transform.dom.DOMSource") || href.equals("")) { + return null; + } + try { + ConverterInfo ci = pluginFactory.getConverterInfo(); + String newhRef = "jar:" + ci.getJarName() + "!/" + href; + StreamSource sheetFile = new StreamSource(newhRef); + return sheetFile; + } catch (Exception e) { + System.out.println("\nException in Xslt Resolver " + e); + return null; + } + } else { return null; - try{ - ConverterInfo ci = pluginFactory.getConverterInfo(); - String newhRef ="jar:"+ci.getJarName()+"!/"+href; - StreamSource sheetFile= new StreamSource(newhRef); - return sheetFile; - } - catch (Exception e){ - System.out.println("\nException in Xslt Resolver " +e); - return null; - } } - else - return null; } - /** + /** * This method performs the xslt transformation on the supplied Dom Tree. * - * Xslt transformation code - * + * <p>Xslt transformation code.</p> */ - private ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc) - { + private ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc){ log("\nTransforming..."); ConverterInfo ci = pluginFactory.getConverterInfo(); @@ -191,7 +175,7 @@ public final class DocumentDeserializerImpl return baos; } - /** + /** * Sends message to the log object. * * @param str Debug message. @@ -200,6 +184,4 @@ public final class DocumentDeserializerImpl Debug.log(Debug.TRACE, str); } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java index da0f71e4f4d1..da0d308d463b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java @@ -33,12 +33,9 @@ import org.openoffice.xmerge.merger.merge.DocumentMerge; import org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge; import org.openoffice.xmerge.util.Debug; - /** - * Xslt implementation of <code>DocumentMerger</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl - * PluginFactoryImpl}. + * Xslt implementation of {@code DocumentMerger} for the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl PluginFactoryImpl}. */ public class DocumentMergerImpl implements DocumentMerger { @@ -80,6 +77,4 @@ public class DocumentMergerImpl implements DocumentMerger { docMerge.applyDifference(i1, i2, diffTable); } -} - - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java index b010c1a6f668..25131cb03184 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java @@ -49,48 +49,43 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; /** - * <p>Xslt implementation of - * org.openoffice.xmerge.DocumentSerializer - * for the {@link - * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl - * PluginFactoryImpl}.</p> + * Xslt implementation of {@code org.openoffice.xmerge.DocumentSerializer} + * for the {@link org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}. * - * <p>The <code>serialize</code> method transforms the DOM - * document from the given <code>Document</code> object by - * means of a supplied Xsl Stylesheet.</p> + * <p>The {@code serialize} method transforms the DOM document from the given + * {@code Document} object by means of a supplied Xsl Stylesheet.</p> */ - public final class DocumentSerializerImpl implements DocumentSerializer,OfficeConstants,URIResolver { - - /** SXW <code>Document</code> object that this converter processes. */ + /** SXW {@code Document} object that this converter processes. */ private GenericOfficeDocument sxwDoc = null; private PluginFactoryImpl pluginFactory = null; /** - * Constructor. + * Constructor. * - * @param pf A <code>PluginFactoryImpl</code> - * @param doc A SXW <code>Document</code> to be converted. + * @param pf A {@code PluginFactoryImpl}. + * @param doc A SXW {@code Document} to be converted. */ public DocumentSerializerImpl(PluginFactoryImpl pf,Document doc) { pluginFactory=pf; sxwDoc = (GenericOfficeDocument) doc; } - /** - * Method to convert a <code>Document</code> with an xsl stylesheet. - * It creates a <code>Document</code> object, which is then transformed - * with the Xslt processor. A <code>ConvertData </code> object is - * constructed and returned. + * Method to convert a {@code Document} with an xsl stylesheet. * - * @return cd A <code>ConvertData</code> object. - * @throws ConvertException If any I/O error occurs. - * @throws IOException If any I/O error occurs. + * <p>It creates a {@code Document} object, which is then transformed with the + * Xslt processor. A {@code ConvertData} object is constructed and returned.</p> + * + * @return A {@code ConvertData} object. + * + * @throws ConvertException If any I/O error occurs. + * @throws IOException If any I/O error occurs. */ public ConvertData serialize() throws ConvertException, IOException { String docName = sxwDoc.getName(); @@ -202,77 +197,70 @@ public final class DocumentSerializerImpl return cd; } - public Source resolve(String href,String base) - throws TransformerException{ - if (href !=null){ - if(href.equals("javax.xml.transform.dom.DOMSource")|| href.equals("")) - return null; - try{ - ConverterInfo ci = pluginFactory.getConverterInfo(); - String newhRef ="jar:"+ci.getJarName()+"!/"+href; - StreamSource sheetFile= new StreamSource(newhRef); - return sheetFile; - } - catch (Exception e){ - System.out.println("\nException in Xslt Resolver " +e); + public Source resolve(String href, String base) + throws TransformerException { + if (href != null) { + if (href.equals("javax.xml.transform.dom.DOMSource") || href.equals("")) { + return null; + } + try { + ConverterInfo ci = pluginFactory.getConverterInfo(); + String newhRef = "jar:" + ci.getJarName() + "!/" + href; + StreamSource sheetFile = new StreamSource(newhRef); + return sheetFile; + } catch (Exception e) { + System.out.println("\nException in Xslt Resolver " + e); + return null; + } + } else { return null; } - } - else - return null; } - /** - * This method performs the sxl transformation on the supplied <code> - * Document</code> and returns a <code>DOMResult</code> object. + * This method performs the sxl transformation on the supplied + * {@code Document} and returns a {@code DOMResult} object. * - * Xslt transformation code + * <p>Xslt transformation code.</p> * - * @return baos A <code>ByteArrayOutputStream</code> object containing - * the result of the Xslt transformation. + * @return A {@code ByteArrayOutputStream} object containing the result + * of the Xslt transformation. */ - private ByteArrayOutputStream transform(org.w3c.dom.Document domDoc) - { - ConverterInfo ci = pluginFactory.getConverterInfo(); - ByteArrayOutputStream baos= new ByteArrayOutputStream(); - try{ - - DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); - dFactory.setNamespaceAware(true); - - DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); - String teststr = ci.getXsltSerial(); + private ByteArrayOutputStream transform(org.w3c.dom.Document domDoc) { + ConverterInfo ci = pluginFactory.getConverterInfo(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { - teststr= teststr.substring(0,6); - org.w3c.dom.Document xslDoc=null; - if ((teststr.equals("http:/"))||(teststr.equals("file:/")) - ||(teststr.equals("jar://"))){ - System.out.println(ci.getXsltSerial()); - xslDoc= dBuilder.parse(ci.getXsltSerial()); + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); - } - else{ - xslDoc = dBuilder.parse( - "jar:"+ci.getJarName()+"!/"+ci.getXsltSerial()); - } + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + String teststr = ci.getXsltSerial(); - DOMSource xslDomSource = new DOMSource(xslDoc); - DOMSource xmlDomSource = new DOMSource(domDoc); + teststr = teststr.substring(0, 6); + org.w3c.dom.Document xslDoc = null; + if ((teststr.equals("http:/")) || (teststr.equals("file:/")) + || (teststr.equals("jar://"))) { + System.out.println(ci.getXsltSerial()); + xslDoc = dBuilder.parse(ci.getXsltSerial()); - //call the tranformer using the XSL, Source and Result. - TransformerFactory tFactory = TransformerFactory.newInstance(); - tFactory.setURIResolver(this); - Transformer transformer = tFactory.newTransformer(xslDomSource); + } else { + xslDoc = dBuilder.parse( + "jar:" + ci.getJarName() + "!/" + ci.getXsltSerial()); + } - transformer.transform(xmlDomSource, new StreamResult(baos)); - } - catch(Exception e){ - System.out.println("An error occurred in the transformation : "+e); - } - return baos; - } + DOMSource xslDomSource = new DOMSource(xslDoc); + DOMSource xmlDomSource = new DOMSource(domDoc); + //call the tranformer using the XSL, Source and Result. + TransformerFactory tFactory = TransformerFactory.newInstance(); + tFactory.setURIResolver(this); + Transformer transformer = tFactory.newTransformer(xslDomSource); + transformer.transform(xmlDomSource, new StreamResult(baos)); + } catch (Exception e) { + System.out.println("An error occurred in the transformation : " + e); + } + return baos; + } } - diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java index f06f90ec4c32..1552780169be 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java @@ -21,30 +21,27 @@ package org.openoffice.xmerge.converter.xml.xslt; import org.openoffice.xmerge.converter.xml.OfficeDocument; /** - * This class is an implementation of <code>OfficeDocument</code> for - * the generic office format. + * This class is an implementation of {@code OfficeDocument} for the generic + * office format. */ public class GenericOfficeDocument extends OfficeDocument { /** - * Constructor with arguments to set <code>name</code>. + * Constructor with arguments to set {@code name}. * - * @param name The name of the <code>Document</code> + * @param name The name of the {@code Document}. */ public GenericOfficeDocument(String name) { super(name); } - /** - * Constructor with arguments to set <code>name</code>, the - * <code>namespaceAware</code> flag, and the <code>validating</code> - * flag. + * Constructor with arguments to set {@code name}, the {@code namespaceAware} + * flag, and the {@code validating} flag. * - * @param name The name of the <code>Document</code>. - * @param namespaceAware The value of the <code>namespaceAware</code> - * flag. - * @param validating The value of the <code>validating</code> flag. + * @param name The name of the {@code Document}. + * @param namespaceAware The value of the {@code namespaceAware} flag. + * @param validating The value of the {@code validating} flag. */ public GenericOfficeDocument(String name, boolean namespaceAware, boolean validating) { @@ -52,9 +49,9 @@ public class GenericOfficeDocument extends OfficeDocument { } /** - * Returns the Office file extension for the generic format. + * Returns the Office file extension for the generic format. * - * @return The Office file extension for the generic format. + * @return The Office file extension for the generic format. */ @Override protected String getFileExtension() { @@ -62,26 +59,23 @@ public class GenericOfficeDocument extends OfficeDocument { } /** - * Returns the Office attribute for the generic format. + * Returns the Office attribute for the generic format. * - * @return The Office attribute for the generic format. + * @return The Office attribute for the generic format. */ @Override protected String getOfficeClassAttribute() { - - return ""; + return ""; } /** * Method to return the MIME type of the document. * - * @return String The document's MIME type. + * @return The document's MIME type. */ @Override protected String getDocumentMimeType() { /* TODO: Determine the MIME-type from the input. */ return ""; } - -} - +}
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java index 593ed3402c5c..c89fb72329aa 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java @@ -37,21 +37,18 @@ import org.openoffice.xmerge.converter.dom.DOMDocument; import org.openoffice.xmerge.util.registry.ConverterInfo; /** - * <p>Xslt implementation of the <code>PluginFactory</code>. - * This encapsulates conversion of StarWriter XML format to and from - * a supported format.</p> + * Xslt implementation of the {@code PluginFactory}. * - * <p>The superclass produces a particular - * {@link org.openoffice.xmerge.Document Document} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxw.SxwDocument - * SxwDocument} that the converters in this class work with. Thus, - * this class only implements the methods that produces the converters, - * i.e. {@link - * org.openoffice.xmerge.DocumentSerializer - * DocumentSerializer} and {@link - * org.openoffice.xmerge.DocumentDeserializer - * DocumentDeserializer}</p> + * <p>This encapsulates conversion of StarWriter XML format to and from a + * supported format.</p> + * + * <p>The superclass produces a particular {@link org.openoffice.xmerge.Document + * Document} object, i.e. {@link + * org.openoffice.xmerge.converter.xml.sxw.SxwDocument xwDocument} that the + * converters in this class work with. Thus, this class only implements the + * methods that produces the converters, i.e. {@link + * org.openoffice.xmerge.DocumentSerializer DocumentSerializer} and {@link + * org.openoffice.xmerge.DocumentDeserializer DocumentDeserializer}</p> */ public final class PluginFactoryImpl extends PluginFactory implements DocumentDeserializerFactory, DocumentSerializerFactory, DocumentMergerFactory @@ -65,46 +62,41 @@ public final class PluginFactoryImpl extends PluginFactory private final static ConverterCapabilities converterCap = new ConverterCapabilitiesImpl(); - /** - * Returns an instance of <code>DocumentSerializerImpl</code>, - * which is an implementation of the <code>DocumentSerializer</code> - * interface. + * Returns an instance of {@code DocumentSerializerImpl}, which is an + * implementation of the {@code DocumentSerializer} interface. * - * @param doc <code>Document</code> object to be - * converted/serialized. + * @param doc {@code Document} object to be converted/serialized. * - * @return A <code>DocumentSerializerImpl</code> object. + * @return A {@code DocumentSerializerImpl} object. */ public DocumentSerializer createDocumentSerializer(Document doc) { return new DocumentSerializerImpl(this,doc); } - /** - * Returns an instance of <code>DocumentDeserializerImpl</code>, - * which is an implementation of the <code>DocumentDeserializer</code> - * interface. + * Returns an instance of <code>DocumentDeserializerImpl</code>, + * which is an implementation of the <code>DocumentDeserializer</code> + * interface. * - * @param cd <code>ConvertData</code> object. + * @param cd {@code ConvertData} object. * - * @return A DocumentDeserializerImpl object. + * @return A {@code DocumentDeserializerImpl} object. */ public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - return new DocumentDeserializerImpl(this,cd); } - @Override - public org.openoffice.xmerge.Document createDeviceDocument(String str, java.io.InputStream inputStream) throws java.io.IOException { + @Override + public org.openoffice.xmerge.Document createDeviceDocument(String str, + java.io.InputStream inputStream) throws java.io.IOException { String ext = this.getDeviceFileExtension(); DOMDocument domDoc = new DOMDocument(str,ext); domDoc.read(inputStream); return domDoc; } - - @Override + @Override public Document createOfficeDocument(String name, InputStream is) throws IOException { @@ -114,8 +106,8 @@ public final class PluginFactoryImpl extends PluginFactory return doc; } - @Override - public Document createOfficeDocument(String name, InputStream is,boolean isZip) + @Override + public Document createOfficeDocument(String name, InputStream is, boolean isZip) throws IOException { // read zipped XML stream @@ -125,67 +117,51 @@ public final class PluginFactoryImpl extends PluginFactory } /** - * Returns a <code>String</code> containing the file extension of a - * <code>Document</code>. This method uses a properties file to determine - * a mapping from the device mime in the <code>ConverterInfo</code> to a - * particular file extension. If a mapping is not specified, the default - * is ".txt". + * Returns a {@code String} containing the file extension of a + * {@code Document}. + * + * <p>This method uses a properties file to determine a mapping from the + * device mime in the {@code ConverterInfo} to a particular file extension. + * If a mapping is not specified, the default is ".txt".</p> * - * @return <code>String</code>. + * @return The file extension of a {@code Document}. */ - - - public String getDeviceFileExtension(){ - Class<? extends PluginFactoryImpl> c = this.getClass(); - InputStream is = c.getResourceAsStream("XsltPlugin.properties"); - Properties props = new Properties(); - String ext= ".txt"; - String mimeType = null; - ConverterInfo ci = this.getConverterInfo(); - Iterator<String> enumerate = ci.getDeviceMime(); - while (enumerate.hasNext()) { - mimeType= enumerate.next(); - } - try { - props.load(is); - - String info = props.getProperty(mimeType); - if (info != null) { - ext = info; - } - } catch (Exception e) { + public String getDeviceFileExtension() { + Class<? extends PluginFactoryImpl> c = this.getClass(); + InputStream is = c.getResourceAsStream("XsltPlugin.properties"); + Properties props = new Properties(); + String ext = ".txt"; + String mimeType = null; + ConverterInfo ci = this.getConverterInfo(); + Iterator<String> enumerate = ci.getDeviceMime(); + while (enumerate.hasNext()) { + mimeType = enumerate.next(); + } + try { + props.load(is); + + String info = props.getProperty(mimeType); + if (info != null) { + ext = info; + } + } catch (Exception e) { // It is okay for the property file to not exist. - - } - return ext; + } + return ext; } /** - * Returns an instance of <code>DocumentMergerImpl</code>, - * which is an implementation of the <code>DocumentMerger</code> - * interface. + * Returns an instance of {@code DocumentMergerImpl}, which is an + * implementation of the {@code DocumentMerger} interface. * - * @param doc <code>Document</code> to merge. + * @param doc {@code Document} to merge. * - * @return A DocumentMergerImpl object. + * @return A {@code DocumentMergerImpl} object. */ public DocumentMerger createDocumentMerger(Document doc) { - ConverterCapabilities cc = converterCap; + ConverterCapabilities cc = converterCap; DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); return merger; - } - -} - - - - - - - - - - - +}
\ No newline at end of file |