You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/08/18 18:50:28 UTC
svn commit: r805492 [1/5] - in /poi/trunk/src:
contrib/src/org/apache/poi/contrib/poibrowser/
contrib/src/org/apache/poi/hssf/contrib/view/ java/org/apache/poi/hpsf/
java/org/apache/poi/hpsf/wellknown/ java/org/apache/poi/hssf/eventmodel/
java/org/apac...
Author: josh
Date: Tue Aug 18 16:50:24 2009
New Revision: 805492
URL: http://svn.apache.org/viewvc?rev=805492&view=rev
Log:
Fixed compiler warnings - unnecessary else
Modified:
poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/ExtendableTreeCellRenderer.java
poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java
poi/trunk/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java
poi/trunk/src/java/org/apache/poi/hpsf/MutablePropertySet.java
poi/trunk/src/java/org/apache/poi/hpsf/Property.java
poi/trunk/src/java/org/apache/poi/hpsf/Section.java
poi/trunk/src/java/org/apache/poi/hpsf/SummaryInformation.java
poi/trunk/src/java/org/apache/poi/hpsf/Thumbnail.java
poi/trunk/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java
poi/trunk/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
poi/trunk/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
poi/trunk/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
poi/trunk/src/java/org/apache/poi/hssf/record/UnicodeString.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFClientAnchor.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
poi/trunk/src/java/org/apache/poi/util/HexDump.java
poi/trunk/src/java/org/apache/poi/util/IOUtils.java
poi/trunk/src/java/org/apache/poi/util/SystemOutLogger.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java
poi/trunk/src/ooxml/java/org/apache/poi/util/PackageHelper.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/HeaderFooter.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HeaderFooter.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/HDGFLZW.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/SanityChecker.java
Modified: poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/ExtendableTreeCellRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/ExtendableTreeCellRenderer.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/ExtendableTreeCellRenderer.java (original)
+++ poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/ExtendableTreeCellRenderer.java Tue Aug 18 16:50:24 2009
@@ -136,10 +136,10 @@
/* The class has no renderer, try the superclass, if any. */
final Class superclass = c.getSuperclass();
- if (superclass != null)
+ if (superclass != null) {
return findRenderer(superclass);
- else
- return null;
+ }
+ return null;
}
}
Modified: poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java (original)
+++ poi/trunk/src/contrib/src/org/apache/poi/contrib/poibrowser/TreeReaderListener.java Tue Aug 18 16:50:24 2009
@@ -33,7 +33,7 @@
* <p>Organizes document information in a tree model in order to be
* e.g. displayed in a Swing {@link javax.swing.JTree}. An instance of this
* class is created with a root tree node ({@link MutableTreeNode}) and
- * registered as a {@link POIFSReaderListener} with a {@link
+ * registered as a {@link POIFSReaderListener} with a {@link
* org.apache.poi.poifs.eventfilesystem.POIFSReader}. While the latter processes
* a POI filesystem it calls this class' {@link #processPOIFSReaderEvent} for
* each document it has been registered for. This method appends the document it
@@ -204,20 +204,16 @@
}
return n;
}
- else
- {
- /* The path is somewhere down in the POI filesystem's
- * hierarchy. We need the tree node of this path's parent
- * and attach our new node to it. */
- final String name = path.getComponent(path.length() - 1);
- final POIFSDocumentPath parentPath = path.getParent();
- final MutableTreeNode parentNode =
- getNode(parentPath, fsName, root);
- n = new DefaultMutableTreeNode(name);
- pathToNode.put(path, n);
- parentNode.insert(n, 0);
- return n;
- }
+ /* else - The path is somewhere down in the POI filesystem's
+ * hierarchy. We need the tree node of this path's parent
+ * and attach our new node to it. */
+ final String name = path.getComponent(path.length() - 1);
+ final POIFSDocumentPath parentPath = path.getParent();
+ final MutableTreeNode parentNode =
+ getNode(parentPath, fsName, root);
+ n = new DefaultMutableTreeNode(name);
+ pathToNode.put(path, n);
+ parentNode.insert(n, 0);
+ return n;
}
-
}
Modified: poi/trunk/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java (original)
+++ poi/trunk/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java Tue Aug 18 16:50:24 2009
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.contrib.view;
@@ -196,7 +196,7 @@
toAppendTo.append(format(((Number)obj).doubleValue()));
return toAppendTo;
}
- else throw new IllegalArgumentException("Can only handle Numbers");
+ throw new IllegalArgumentException("Can only handle Numbers");
}
public Object parseObject(String source,
Modified: poi/trunk/src/java/org/apache/poi/hpsf/MutablePropertySet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/MutablePropertySet.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/MutablePropertySet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/MutablePropertySet.java Tue Aug 18 16:50:24 2009
@@ -75,10 +75,10 @@
/**
* <p>Constructs a <code>MutablePropertySet</code> by doing a deep copy of
- * an existing <code>PropertySet</code>. All nested elements, i.e.
+ * an existing <code>PropertySet</code>. All nested elements, i.e.
* <code>Section</code>s and <code>Property</code> instances, will be their
* mutable counterparts in the new <code>MutablePropertySet</code>.</p>
- *
+ *
* @param ps The property set to copy
*/
public MutablePropertySet(final PropertySet ps)
@@ -190,7 +190,7 @@
/**
* <p>Writes the property set to an output stream.</p>
- *
+ *
* @param out the output stream to write the section to
* @exception IOException if an error when writing to the output stream
* occurs
@@ -232,10 +232,10 @@
catch (HPSFRuntimeException ex)
{
final Throwable cause = ex.getReason();
- if (cause instanceof UnsupportedEncodingException)
+ if (cause instanceof UnsupportedEncodingException) {
throw new IllegalPropertySetDataException(cause);
- else
- throw ex;
+ }
+ throw ex;
}
}
@@ -259,7 +259,7 @@
* the {@link MutablePropertySet} only.</p>
*
* @return the contents of this property set stream
- *
+ *
* @throws WritingNotSupportedException if HPSF does not yet support writing
* of a property's variant type.
* @throws IOException if an I/O exception occurs.
@@ -280,7 +280,7 @@
* @param dir The directory in the POI filesystem to write the document to.
* @param name The document's name. If there is already a document with the
* same name in the directory the latter will be overwritten.
- *
+ *
* @throws WritingNotSupportedException
* @throws IOException
*/
Modified: poi/trunk/src/java/org/apache/poi/hpsf/Property.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Property.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Property.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Property.java Tue Aug 18 16:50:24 2009
@@ -46,7 +46,7 @@
* over time but largely depends on your feedback so that the POI team knows
* which variant types are really needed. So please feel free to submit error
* reports or patches for the types you need.</p>
- *
+ *
* <p>Microsoft documentation: <a
* href="http://msdn.microsoft.com/library/en-us/stg/stg/property_set_display_name_dictionary.asp?frame=true">
* Property Set Display Name Dictionary</a>.
@@ -110,7 +110,7 @@
/**
* <p>Creates a property.</p>
- *
+ *
* @param id the property's ID.
* @param type the property's type, see {@link Variant}.
* @param value the property's value. Only certain types are allowed, see
@@ -183,7 +183,7 @@
/**
* <p>Reads a dictionary.</p>
- *
+ *
* @param src The byte array containing the bytes making out the dictionary.
* @param offset At this offset within <var>src </var> the dictionary
* starts.
@@ -296,7 +296,7 @@
* 4.</p>
*
* @return the property's size in bytes
- *
+ *
* @exception WritingNotSupportedException if HPSF does not yet support the
* property's variant type.
*/
@@ -337,13 +337,14 @@
* ID == 0 is a special case: It does not have a type, and its value is the
* section's dictionary. Another special case are strings: Two properties
* may have the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
- *
+ *
* @see Object#equals(java.lang.Object)
*/
public boolean equals(final Object o)
{
- if (!(o instanceof Property))
+ if (!(o instanceof Property)) {
return false;
+ }
final Property p = (Property) o;
final Object pValue = p.getValue();
final long pId = p.getID();
@@ -355,8 +356,8 @@
return false;
/* It's clear now that both values are non-null. */
- final Class valueClass = value.getClass();
- final Class pValueClass = pValue.getClass();
+ final Class<?> valueClass = value.getClass();
+ final Class<?> pValueClass = pValue.getClass();
if (!(valueClass.isAssignableFrom(pValueClass)) &&
!(pValueClass.isAssignableFrom(valueClass)))
return false;
@@ -373,10 +374,10 @@
{
if (t1 == t2 ||
(t1 == Variant.VT_LPSTR && t2 == Variant.VT_LPWSTR) ||
- (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR))
+ (t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR)) {
return true;
- else
- return false;
+ }
+ return false;
}
Modified: poi/trunk/src/java/org/apache/poi/hpsf/Section.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Section.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Section.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Section.java Tue Aug 18 16:50:24 2009
@@ -146,7 +146,7 @@
* @param src Contains the complete property set stream.
* @param offset The position in the stream that points to the
* section's format ID.
- *
+ *
* @exception UnsupportedEncodingException if the section's codepage is not
* supported.
*/
@@ -183,7 +183,7 @@
/*
* Read the properties. The offset is positioned at the first
* entry of the property list. There are two problems:
- *
+ *
* 1. For each property we have to find out its length. In the
* property list we find each property's ID and its offset relative
* to the section's beginning. Unfortunately the properties in the
@@ -191,8 +191,8 @@
* possible to calculate the length as
* (offset of property(i+1) - offset of property(i)). Before we can
* that we first have to sort the property list by ascending offsets.
- *
- * 2. We have to read the property with ID 1 before we read other
+ *
+ * 2. We have to read the property with ID 1 before we read other
* properties, at least before other properties containing strings.
* The reason is that property 1 specifies the codepage. If it is
* 1200, all strings are in Unicode. In other words: Before we can
@@ -205,10 +205,10 @@
* seconds pass reads the other properties.
*/
properties = new Property[propertyCount];
-
+
/* Pass 1: Read the property list. */
int pass1Offset = o1;
- final List propertyList = new ArrayList(propertyCount);
+ final List<PropertyListEntry> propertyList = new ArrayList<PropertyListEntry>(propertyCount);
PropertyListEntry ple;
for (int i = 0; i < properties.length; i++)
{
@@ -232,15 +232,13 @@
/* Calculate the properties' lengths. */
for (int i = 0; i < propertyCount - 1; i++)
{
- final PropertyListEntry ple1 =
- (PropertyListEntry) propertyList.get(i);
- final PropertyListEntry ple2 =
- (PropertyListEntry) propertyList.get(i + 1);
+ PropertyListEntry ple1 = propertyList.get(i);
+ PropertyListEntry ple2 = propertyList.get(i + 1);
ple1.length = ple2.offset - ple1.offset;
}
if (propertyCount > 0)
{
- ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
+ ple = propertyList.get(propertyCount - 1);
ple.length = size - ple.offset;
if (ple.length <= 0)
{
@@ -412,11 +410,11 @@
protected boolean getPropertyBooleanValue(final int id)
{
final Boolean b = (Boolean) getProperty(id);
- if (b != null)
- return b.booleanValue();
- else
+ if (b == null) {
return false;
}
+ return b.booleanValue();
+ }
@@ -475,23 +473,23 @@
/**
* <p>Checks whether this section is equal to another object. The result is
* <code>false</code> if one of the the following conditions holds:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The format IDs of the two sections are not equal.</p></li>
- *
+ *
* <li><p>The sections have a different number of properties. However,
* properties with ID 1 (codepage) are not counted.</p></li>
- *
+ *
* <li><p>The other object is not a {@link Section}.</p></li>
- *
+ *
* <li><p>The properties have different values. The order of the properties
* is irrelevant.</p></li>
- *
+ *
* </ul>
- *
+ *
* @param o The object to compare this section with
* @return <code>true</code> if the objects are equal, <code>false</code> if
* not
@@ -504,7 +502,7 @@
if (!s.getFormatID().equals(getFormatID()))
return false;
- /* Compare all properties except 0 and 1 as they must be handled
+ /* Compare all properties except 0 and 1 as they must be handled
* specially. */
Property[] pa1 = new Property[getProperties().length];
Property[] pa2 = new Property[s.getProperties().length];
@@ -559,10 +557,10 @@
dictionaryEqual = p10.getValue().equals(p20.getValue());
else if (p10 != null || p20 != null)
dictionaryEqual = false;
- if (!dictionaryEqual)
- return false;
- else
+ if (dictionaryEqual) {
return Util.equals(pa1, pa2);
+ }
+ return false;
}
@@ -571,7 +569,7 @@
* <p>Removes a field from a property array. The resulting array is
* compactified and returned.</p>
*
- * @param pa The property array.
+ * @param pa The property array.
* @param i The index of the field to be removed.
* @return the compactified array.
*/
Modified: poi/trunk/src/java/org/apache/poi/hpsf/SummaryInformation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/SummaryInformation.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/SummaryInformation.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/SummaryInformation.java Tue Aug 18 16:50:24 2009
@@ -24,13 +24,12 @@
/**
* <p>Convenience class representing a Summary Information stream in a
* Microsoft Office document.</p>
- *
+ *
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
* @see DocumentSummaryInformation
*/
-public class SummaryInformation extends SpecialPropertySet
-{
+public final class SummaryInformation extends SpecialPropertySet {
/**
* <p>The document name a summary information stream usually has in a POIFS
@@ -46,7 +45,7 @@
/**
* <p>Creates a {@link SummaryInformation} from a given {@link
* PropertySet}.</p>
- *
+ *
* @param ps A property set which should be created from a summary
* information stream.
* @throws UnexpectedPropertySetTypeException if <var>ps</var> does not
@@ -65,7 +64,7 @@
/**
* <p>Returns the title (or <code>null</code>).</p>
- *
+ *
* @return The title or <code>null</code>
*/
public String getTitle()
@@ -77,7 +76,7 @@
/**
* <p>Sets the title.</p>
- *
+ *
* @param title The title to set.
*/
public void setTitle(final String title)
@@ -101,7 +100,7 @@
/**
* <p>Returns the subject (or <code>null</code>).</p>
- *
+ *
* @return The subject or <code>null</code>
*/
public String getSubject()
@@ -113,7 +112,7 @@
/**
* <p>Sets the subject.</p>
- *
+ *
* @param subject The subject to set.
*/
public void setSubject(final String subject)
@@ -137,7 +136,7 @@
/**
* <p>Returns the author (or <code>null</code>).</p>
- *
+ *
* @return The author or <code>null</code>
*/
public String getAuthor()
@@ -149,7 +148,7 @@
/**
* <p>Sets the author.</p>
- *
+ *
* @param author The author to set.
*/
public void setAuthor(final String author)
@@ -173,7 +172,7 @@
/**
* <p>Returns the keywords (or <code>null</code>).</p>
- *
+ *
* @return The keywords or <code>null</code>
*/
public String getKeywords()
@@ -185,7 +184,7 @@
/**
* <p>Sets the keywords.</p>
- *
+ *
* @param keywords The keywords to set.
*/
public void setKeywords(final String keywords)
@@ -209,7 +208,7 @@
/**
* <p>Returns the comments (or <code>null</code>).</p>
- *
+ *
* @return The comments or <code>null</code>
*/
public String getComments()
@@ -221,7 +220,7 @@
/**
* <p>Sets the comments.</p>
- *
+ *
* @param comments The comments to set.
*/
public void setComments(final String comments)
@@ -245,7 +244,7 @@
/**
* <p>Returns the template (or <code>null</code>).</p>
- *
+ *
* @return The template or <code>null</code>
*/
public String getTemplate()
@@ -257,7 +256,7 @@
/**
* <p>Sets the template.</p>
- *
+ *
* @param template The template to set.
*/
public void setTemplate(final String template)
@@ -281,7 +280,7 @@
/**
* <p>Returns the last author (or <code>null</code>).</p>
- *
+ *
* @return The last author or <code>null</code>
*/
public String getLastAuthor()
@@ -293,7 +292,7 @@
/**
* <p>Sets the last author.</p>
- *
+ *
* @param lastAuthor The last author to set.
*/
public void setLastAuthor(final String lastAuthor)
@@ -317,7 +316,7 @@
/**
* <p>Returns the revision number (or <code>null</code>). </p>
- *
+ *
* @return The revision number or <code>null</code>
*/
public String getRevNumber()
@@ -329,7 +328,7 @@
/**
* <p>Sets the revision number.</p>
- *
+ *
* @param revNumber The revision number to set.
*/
public void setRevNumber(final String revNumber)
@@ -354,24 +353,24 @@
/**
* <p>Returns the total time spent in editing the document (or
* <code>0</code>).</p>
- *
+ *
* @return The total time spent in editing the document or 0 if the {@link
* SummaryInformation} does not contain this information.
*/
public long getEditTime()
{
final Date d = (Date) getProperty(PropertyIDMap.PID_EDITTIME);
- if (d == null)
+ if (d == null) {
return 0;
- else
- return Util.dateToFileTime(d);
+ }
+ return Util.dateToFileTime(d);
}
/**
* <p>Sets the total time spent in editing the document.</p>
- *
+ *
* @param time The time to set.
*/
public void setEditTime(final long time)
@@ -396,7 +395,7 @@
/**
* <p>Returns the last printed time (or <code>null</code>).</p>
- *
+ *
* @return The last printed time or <code>null</code>
*/
public Date getLastPrinted()
@@ -408,7 +407,7 @@
/**
* <p>Sets the lastPrinted.</p>
- *
+ *
* @param lastPrinted The lastPrinted to set.
*/
public void setLastPrinted(final Date lastPrinted)
@@ -433,7 +432,7 @@
/**
* <p>Returns the creation time (or <code>null</code>).</p>
- *
+ *
* @return The creation time or <code>null</code>
*/
public Date getCreateDateTime()
@@ -445,7 +444,7 @@
/**
* <p>Sets the creation time.</p>
- *
+ *
* @param createDateTime The creation time to set.
*/
public void setCreateDateTime(final Date createDateTime)
@@ -470,7 +469,7 @@
/**
* <p>Returns the last save time (or <code>null</code>).</p>
- *
+ *
* @return The last save time or <code>null</code>
*/
public Date getLastSaveDateTime()
@@ -482,7 +481,7 @@
/**
* <p>Sets the total time spent in editing the document.</p>
- *
+ *
* @param time The time to set.
*/
public void setLastSaveDateTime(final Date time)
@@ -509,7 +508,7 @@
/**
* <p>Returns the page count or 0 if the {@link SummaryInformation} does
* not contain a page count.</p>
- *
+ *
* @return The page count or 0 if the {@link SummaryInformation} does not
* contain a page count.
*/
@@ -522,7 +521,7 @@
/**
* <p>Sets the page count.</p>
- *
+ *
* @param pageCount The page count to set.
*/
public void setPageCount(final int pageCount)
@@ -547,7 +546,7 @@
/**
* <p>Returns the word count or 0 if the {@link SummaryInformation} does
* not contain a word count.</p>
- *
+ *
* @return The word count or <code>null</code>
*/
public int getWordCount()
@@ -559,7 +558,7 @@
/**
* <p>Sets the word count.</p>
- *
+ *
* @param wordCount The word count to set.
*/
public void setWordCount(final int wordCount)
@@ -584,7 +583,7 @@
/**
* <p>Returns the character count or 0 if the {@link SummaryInformation}
* does not contain a char count.</p>
- *
+ *
* @return The character count or <code>null</code>
*/
public int getCharCount()
@@ -596,7 +595,7 @@
/**
* <p>Sets the character count.</p>
- *
+ *
* @param charCount The character count to set.
*/
public void setCharCount(final int charCount)
@@ -622,12 +621,12 @@
* <p>Returns the thumbnail (or <code>null</code>) <strong>when this
* method is implemented. Please note that the return type is likely to
* change!</strong></p>
- *
+ *
* <p><strong>Hint to developers:</strong> Drew Varner <Drew.Varner
* -at- sc.edu> said that this is an image in WMF or Clipboard (BMP?)
* format. However, we won't do any conversion into any image type but
* instead just return a byte array.</p>
- *
+ *
* @return The thumbnail or <code>null</code>
*/
public byte[] getThumbnail()
@@ -639,7 +638,7 @@
/**
* <p>Sets the thumbnail.</p>
- *
+ *
* @param thumbnail The thumbnail to set.
*/
public void setThumbnail(final byte[] thumbnail)
@@ -664,7 +663,7 @@
/**
* <p>Returns the application name (or <code>null</code>).</p>
- *
+ *
* @return The application name or <code>null</code>
*/
public String getApplicationName()
@@ -676,7 +675,7 @@
/**
* <p>Sets the application name.</p>
- *
+ *
* @param applicationName The application name to set.
*/
public void setApplicationName(final String applicationName)
@@ -700,24 +699,24 @@
/**
* <p>Returns a security code which is one of the following values:</p>
- *
+ *
* <ul>
- *
+ *
* <li><p>0 if the {@link SummaryInformation} does not contain a
* security field or if there is no security on the document. Use
* {@link PropertySet#wasNull()} to distinguish between the two
* cases!</p></li>
- *
+ *
* <li><p>1 if the document is password protected</p></li>
- *
+ *
* <li><p>2 if the document is read-only recommended</p></li>
- *
+ *
* <li><p>4 if the document is read-only enforced</p></li>
- *
+ *
* <li><p>8 if the document is locked for annotations</p></li>
- *
+ *
* </ul>
- *
+ *
* @return The security code or <code>null</code>
*/
public int getSecurity()
@@ -729,7 +728,7 @@
/**
* <p>Sets the security code.</p>
- *
+ *
* @param security The security code to set.
*/
public void setSecurity(final int security)
Modified: poi/trunk/src/java/org/apache/poi/hpsf/Thumbnail.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Thumbnail.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Thumbnail.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Thumbnail.java Tue Aug 18 16:50:24 2009
@@ -25,8 +25,7 @@
* @author Drew Varner (Drew.Varner inOrAround sc.edu)
* @see SummaryInformation#getThumbnail()
*/
-public class Thumbnail
-{
+public final class Thumbnail {
/**
* <p>Offset in bytes where the Clipboard Format Tag starts in the
@@ -128,7 +127,7 @@
* <p>A <code>byte[]</code> to hold a thumbnail image in ({@link
* Variant#VT_CF VT_CF}) format.</p>
*/
- private byte[] thumbnailData = null;
+ private byte[] _thumbnailData = null;
@@ -154,7 +153,7 @@
*/
public Thumbnail(final byte[] thumbnailData)
{
- this.thumbnailData = thumbnailData;
+ this._thumbnailData = thumbnailData;
}
@@ -168,7 +167,7 @@
*/
public byte[] getThumbnail()
{
- return thumbnailData;
+ return _thumbnailData;
}
@@ -182,7 +181,7 @@
*/
public void setThumbnail(final byte[] thumbnail)
{
- this.thumbnailData = thumbnail;
+ this._thumbnailData = thumbnail;
}
@@ -261,21 +260,18 @@
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
- if (!(getClipboardFormat() == CF_METAFILEPICT))
+ if (!(getClipboardFormat() == CF_METAFILEPICT)) {
throw new HPSFException("Clipboard Format of Thumbnail must " +
"be CF_METAFILEPICT.");
- else
- {
- byte[] thumbnail = getThumbnail();
- int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
- byte[] wmfImage = new byte[wmfImageLength];
- System.arraycopy(thumbnail,
- OFFSET_WMFDATA,
- wmfImage,
- 0,
- wmfImageLength);
- return wmfImage;
}
+ byte[] thumbnail = getThumbnail();
+ int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
+ byte[] wmfImage = new byte[wmfImageLength];
+ System.arraycopy(thumbnail,
+ OFFSET_WMFDATA,
+ wmfImage,
+ 0,
+ wmfImageLength);
+ return wmfImage;
}
-
}
Modified: poi/trunk/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/wellknown/SectionIDMap.java Tue Aug 18 16:50:24 2009
@@ -70,7 +70,7 @@
};
/**
- * <p>A property without a known name is described by this string.</p>
+ * <p>A property without a known name is described by this string.</p>
*/
public static final String UNDEFINED = "[undefined]";
@@ -121,15 +121,13 @@
final long pid)
{
final PropertyIDMap m = getInstance().get(sectionFormatID);
- if (m == null)
+ if (m == null) {
return UNDEFINED;
- else
- {
- final String s = (String) m.get(pid);
- if (s == null)
- return UNDEFINED;
- return s;
}
+ final String s = (String) m.get(pid);
+ if (s == null)
+ return UNDEFINED;
+ return s;
}
@@ -137,7 +135,7 @@
/**
* <p>Returns the {@link PropertyIDMap} for a given section format
* ID.</p>
- *
+ *
* @param sectionFormatID the section format ID
* @return the property ID map
*/
@@ -166,7 +164,7 @@
/**
* <p>Associates a section format ID with a {@link
* PropertyIDMap}.</p>
- *
+ *
* @param sectionFormatID the section format ID
* @param propertyIDMap the property ID map
* @return as defined by {@link java.util.Map#put}
@@ -183,7 +181,7 @@
* @deprecated Use {@link #put(byte[], PropertyIDMap)} instead!
*
* @see #put(byte[], PropertyIDMap)
- *
+ *
* @param key This parameter remains undocumented since the method is
* deprecated.
* @param value This parameter remains undocumented since the method is
Modified: poi/trunk/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/eventmodel/ModelFactory.java Tue Aug 18 16:50:24 2009
@@ -71,25 +71,22 @@
}
//ERFListener
- public boolean processRecord(Record rec)
- {
- if (rec.getSid() == BOFRecord.sid) {
- if (lastEOF != true) {
- throw new RuntimeException("Not yet handled embedded models");
- } else {
- BOFRecord bof = (BOFRecord)rec;
- switch (bof.getType()) {
- case BOFRecord.TYPE_WORKBOOK:
- currentmodel = new Workbook();
- break;
- case BOFRecord.TYPE_WORKSHEET:
- currentmodel = Sheet.createSheet();
- break;
- default:
+ public boolean processRecord(Record rec) {
+ if (rec.getSid() == BOFRecord.sid) {
+ if (lastEOF != true) {
+ throw new RuntimeException("Not yet handled embedded models");
+ }
+ BOFRecord bof = (BOFRecord)rec;
+ switch (bof.getType()) {
+ case BOFRecord.TYPE_WORKBOOK:
+ currentmodel = new Workbook();
+ break;
+ case BOFRecord.TYPE_WORKSHEET:
+ currentmodel = Sheet.createSheet();
+ break;
+ default:
throw new RuntimeException("Unsupported model type "+bof.getType());
- }
-
- }
+ }
}
if (rec.getSid() == EOFRecord.sid) {
@@ -98,8 +95,6 @@
} else {
lastEOF = false;
}
-
-
return true;
}
@@ -115,6 +110,4 @@
mfl.process(model);
}
}
-
-
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/FormatTrackingHSSFListener.java Tue Aug 18 16:50:24 2009
@@ -31,130 +31,128 @@
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
/**
- * A proxy HSSFListener that keeps track of the document
- * formatting records, and provides an easy way to look
- * up the format strings used by cells from their ids.
+ * A proxy HSSFListener that keeps track of the document formatting records, and
+ * provides an easy way to look up the format strings used by cells from their
+ * ids.
*/
public class FormatTrackingHSSFListener implements HSSFListener {
- private HSSFListener childListener;
- private HSSFDataFormatter formatter = new HSSFDataFormatter();
- private Map customFormatRecords = new Hashtable();
- private List xfRecords = new ArrayList();
+ private final HSSFListener _childListener;
+ private HSSFDataFormatter _formatter = new HSSFDataFormatter();
+ private final Map<Integer, FormatRecord> _customFormatRecords = new Hashtable<Integer, FormatRecord>();
+ private final List<ExtendedFormatRecord> _xfRecords = new ArrayList<ExtendedFormatRecord>();
public FormatTrackingHSSFListener(HSSFListener childListener) {
- this.childListener = childListener;
+ _childListener = childListener;
}
-
+
protected int getNumberOfCustomFormats() {
- return customFormatRecords.size();
+ return _customFormatRecords.size();
}
+
protected int getNumberOfExtendedFormats() {
- return xfRecords.size();
+ return _xfRecords.size();
}
-
+
/**
- * Process this record ourselves, and then
- * pass it on to our child listener
+ * Process this record ourselves, and then pass it on to our child listener
*/
public void processRecord(Record record) {
// Handle it ourselves
processRecordInternally(record);
-
+
// Now pass on to our child
- childListener.processRecord(record);
+ _childListener.processRecord(record);
}
-
+
/**
- * Process the record ourselves, but do not
- * pass it on to the child Listener.
+ * Process the record ourselves, but do not pass it on to the child
+ * Listener.
+ *
* @param record
*/
public void processRecordInternally(Record record) {
- if(record instanceof FormatRecord) {
+ if (record instanceof FormatRecord) {
FormatRecord fr = (FormatRecord) record;
- customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
+ _customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
}
- if(record instanceof ExtendedFormatRecord) {
+ if (record instanceof ExtendedFormatRecord) {
ExtendedFormatRecord xr = (ExtendedFormatRecord) record;
- xfRecords.add(xr);
+ _xfRecords.add(xr);
}
}
-
+
/**
- * Formats the given numeric of date Cell's contents
- * as a String, in as close as we can to the way
- * that Excel would do so.
- * Uses the various format records to manage this.
- *
- * TODO - move this to a central class in such a
- * way that hssf.usermodel can make use of it too
+ * Formats the given numeric of date Cell's contents as a String, in as
+ * close as we can to the way that Excel would do so. Uses the various
+ * format records to manage this.
+ *
+ * TODO - move this to a central class in such a way that hssf.usermodel can
+ * make use of it too
*/
public String formatNumberDateCell(CellValueRecordInterface cell) {
double value;
- if(cell instanceof NumberRecord) {
- value = ((NumberRecord)cell).getValue();
- } else if(cell instanceof FormulaRecord) {
- value = ((FormulaRecord)cell).getValue();
+ if (cell instanceof NumberRecord) {
+ value = ((NumberRecord) cell).getValue();
+ } else if (cell instanceof FormulaRecord) {
+ value = ((FormulaRecord) cell).getValue();
} else {
throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell);
}
-
- // Get the built in format, if there is one
+
+ // Get the built in format, if there is one
int formatIndex = getFormatIndex(cell);
String formatString = getFormatString(cell);
-
- if(formatString == null) {
- return Double.toString(value);
- } else {
- // Format, using the nice new
- // HSSFDataFormatter to do the work for us
- return formatter.formatRawCellContents(value, formatIndex, formatString);
- }
+
+ if (formatString == null) {
+ return Double.toString(value);
+ }
+ // Format, using the nice new
+ // HSSFDataFormatter to do the work for us
+ return _formatter.formatRawCellContents(value, formatIndex, formatString);
}
-
+
/**
- * Returns the format string, eg $##.##, for the
- * given number format index.
+ * Returns the format string, eg $##.##, for the given number format index.
*/
public String getFormatString(int formatIndex) {
- String format = null;
- if(formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
- FormatRecord tfr = (FormatRecord)customFormatRecords.get(new Integer(formatIndex));
- if(tfr == null) {
- System.err.println("Requested format at index " + formatIndex + ", but it wasn't found");
- } else {
- format = tfr.getFormatString();
- }
- } else {
- format = HSSFDataFormat.getBuiltinFormat((short)formatIndex);
- }
+ String format = null;
+ if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
+ FormatRecord tfr = _customFormatRecords.get(new Integer(formatIndex));
+ if (tfr == null) {
+ System.err.println("Requested format at index " + formatIndex
+ + ", but it wasn't found");
+ } else {
+ format = tfr.getFormatString();
+ }
+ } else {
+ format = HSSFDataFormat.getBuiltinFormat((short) formatIndex);
+ }
return format;
}
-
+
/**
- * Returns the format string, eg $##.##, used
- * by your cell
+ * Returns the format string, eg $##.##, used by your cell
*/
public String getFormatString(CellValueRecordInterface cell) {
int formatIndex = getFormatIndex(cell);
- if(formatIndex == -1) {
- // Not found
- return null;
- }
- return getFormatString(formatIndex);
+ if (formatIndex == -1) {
+ // Not found
+ return null;
+ }
+ return getFormatString(formatIndex);
}
-
+
/**
- * Returns the index of the format string, used by your cell,
- * or -1 if none found
+ * Returns the index of the format string, used by your cell, or -1 if none
+ * found
*/
public int getFormatIndex(CellValueRecordInterface cell) {
- ExtendedFormatRecord xfr = (ExtendedFormatRecord)
- xfRecords.get(cell.getXFIndex());
- if(xfr == null) {
- System.err.println("Cell " + cell.getRow() + "," + cell.getColumn() + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
- return -1;
- }
- return xfr.getFormatIndex();
+ ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
+ if (xfr == null) {
+ System.err.println("Cell " + cell.getRow() + "," + cell.getColumn()
+ + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
+ return -1;
+ }
+ return xfr.getFormatIndex();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java Tue Aug 18 16:50:24 2009
@@ -65,13 +65,13 @@
* http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java</link>
*/
public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
- private POIFSFileSystem fs;
- private boolean includeSheetNames = true;
- private boolean formulasNotResults = false;
+ private POIFSFileSystem _fs;
+ boolean _includeSheetNames = true;
+ boolean _formulasNotResults = false;
public EventBasedExcelExtractor(POIFSFileSystem fs) {
super(null);
- this.fs = fs;
+ _fs = fs;
}
/**
@@ -94,14 +94,14 @@
* Should sheet names be included? Default is true
*/
public void setIncludeSheetNames(boolean includeSheetNames) {
- this.includeSheetNames = includeSheetNames;
+ _includeSheetNames = includeSheetNames;
}
/**
* Should we return the formula itself, and not
* the result it produces? Default is false
*/
public void setFormulasNotResults(boolean formulasNotResults) {
- this.formulasNotResults = formulasNotResults;
+ _formulasNotResults = formulasNotResults;
}
@@ -113,7 +113,7 @@
try {
TextListener tl = triggerExtraction();
- text = tl.text.toString();
+ text = tl._text.toString();
if(! text.endsWith("\n")) {
text = text + "\n";
}
@@ -127,30 +127,33 @@
private TextListener triggerExtraction() throws IOException {
TextListener tl = new TextListener();
FormatTrackingHSSFListener ft = new FormatTrackingHSSFListener(tl);
- tl.ft = ft;
+ tl._ft = ft;
// Register and process
HSSFEventFactory factory = new HSSFEventFactory();
HSSFRequest request = new HSSFRequest();
request.addListenerForAllRecords(ft);
- factory.processWorkbookEvents(request, fs);
+ factory.processWorkbookEvents(request, _fs);
return tl;
}
private class TextListener implements HSSFListener {
- private FormatTrackingHSSFListener ft;
+ FormatTrackingHSSFListener _ft;
private SSTRecord sstRecord;
- private List sheetNames = new ArrayList();
- private StringBuffer text = new StringBuffer();
+ private final List<String> sheetNames;
+ final StringBuffer _text = new StringBuffer();
private int sheetNum = -1;
private int rowNum;
private boolean outputNextStringValue = false;
private int nextRow = -1;
+ public TextListener() {
+ sheetNames = new ArrayList<String>();
+ }
public void processRecord(Record record) {
String thisText = null;
int thisRow = -1;
@@ -166,9 +169,9 @@
sheetNum++;
rowNum = -1;
- if(includeSheetNames) {
- if(text.length() > 0) text.append("\n");
- text.append(sheetNames.get(sheetNum));
+ if(_includeSheetNames) {
+ if(_text.length() > 0) _text.append("\n");
+ _text.append(sheetNames.get(sheetNum));
}
}
break;
@@ -180,7 +183,7 @@
FormulaRecord frec = (FormulaRecord) record;
thisRow = frec.getRow();
- if(formulasNotResults) {
+ if(_formulasNotResults) {
thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
} else {
if(frec.hasCachedResultString()) {
@@ -232,12 +235,12 @@
if(thisText != null) {
if(thisRow != rowNum) {
rowNum = thisRow;
- if(text.length() > 0)
- text.append("\n");
+ if(_text.length() > 0)
+ _text.append("\n");
} else {
- text.append("\t");
+ _text.append("\t");
}
- text.append(thisText);
+ _text.append(thisText);
}
}
@@ -247,35 +250,33 @@
*/
private String formatNumberDateCell(CellValueRecordInterface cell, double value) {
// Get the built in format, if there is one
- int formatIndex = ft.getFormatIndex(cell);
- String formatString = ft.getFormatString(cell);
+ int formatIndex = _ft.getFormatIndex(cell);
+ String formatString = _ft.getFormatString(cell);
if(formatString == null) {
return Double.toString(value);
- } else {
- // Is it a date?
- if(HSSFDateUtil.isADateFormat(formatIndex,formatString) &&
- HSSFDateUtil.isValidExcelDate(value)) {
- // Java wants M not m for month
- formatString = formatString.replace('m','M');
- // Change \- into -, if it's there
- formatString = formatString.replaceAll("\\\\-","-");
-
- // Format as a date
- Date d = HSSFDateUtil.getJavaDate(value, false);
- DateFormat df = new SimpleDateFormat(formatString);
- return df.format(d);
- } else {
- if(formatString == "General") {
- // Some sort of wierd default
- return Double.toString(value);
- }
-
- // Format as a number
- DecimalFormat df = new DecimalFormat(formatString);
- return df.format(value);
- }
}
+ // Is it a date?
+ if(HSSFDateUtil.isADateFormat(formatIndex,formatString) &&
+ HSSFDateUtil.isValidExcelDate(value)) {
+ // Java wants M not m for month
+ formatString = formatString.replace('m','M');
+ // Change \- into -, if it's there
+ formatString = formatString.replaceAll("\\\\-","-");
+
+ // Format as a date
+ Date d = HSSFDateUtil.getJavaDate(value, false);
+ DateFormat df = new SimpleDateFormat(formatString);
+ return df.format(d);
+ }
+ if(formatString == "General") {
+ // Some sort of wierd default
+ return Double.toString(value);
+ }
+
+ // Format as a number
+ DecimalFormat df = new DecimalFormat(formatString);
+ return df.format(value);
}
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java Tue Aug 18 16:50:24 2009
@@ -50,18 +50,14 @@
anchor.setDy2( (short) a.getDy2() );
return anchor;
}
- else
- {
- HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
- EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
- anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
- anchor.setOptions( (short) 0x0000 );
- anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
- anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
- anchor.setDx2( (short) Math.max(a.getDx2(), a.getDx1()) );
- anchor.setDy2( (short) Math.max(a.getDy2(), a.getDy1()) );
- return anchor;
- }
+ HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
+ EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
+ anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
+ anchor.setOptions( (short) 0x0000 );
+ anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
+ anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
+ anchor.setDx2( (short) Math.max(a.getDx2(), a.getDx1()) );
+ anchor.setDy2( (short) Math.max(a.getDy2(), a.getDy1()) );
+ return anchor;
}
-
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java Tue Aug 18 16:50:24 2009
@@ -116,17 +116,14 @@
System.arraycopy( rawData, 0, data, 4 + offset, rawData.length);
return rawData.length + 4;
}
- else
- {
- LittleEndian.putShort(data, 0 + offset, getSid());
- LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+ LittleEndian.putShort(data, 0 + offset, getSid());
+ LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
- int pos = offset + 4;
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize( pos, data, new NullEscherSerializationListener() );
- }
+ int pos = offset + 4;
+ for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+ {
+ EscherRecord r = (EscherRecord) iterator.next();
+ pos += r.serialize( pos, data, new NullEscherSerializationListener() );
}
return getRecordSize();
}
@@ -172,7 +169,7 @@
{
escherRecords.clear();
}
-
+
/**
* If we have a EscherContainerRecord as one of our
* children (and most top level escher holders do),
@@ -204,7 +201,7 @@
return r;
}
}
-
+
// Then check our children in turn
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = it.next();
@@ -215,7 +212,7 @@
}
}
}
-
+
// Not found in this lot
return null;
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java Tue Aug 18 16:50:24 2009
@@ -95,11 +95,11 @@
private short field_6_not_used;
- private FontFormatting fontFormatting;
+ private FontFormatting _fontFormatting;
- private BorderFormatting borderFormatting;
+ private BorderFormatting _borderFormatting;
- private PatternFormatting patternFormatting;
+ private PatternFormatting _patternFormatting;
private Formula field_17_formula1;
private Formula field_18_formula2;
@@ -117,9 +117,9 @@
field_5_options = undocumented.clear(field_5_options);
field_6_not_used = (short)0x8002; // Excel seems to write this value, but it doesn't seem to care what it reads
- fontFormatting=null;
- borderFormatting=null;
- patternFormatting=null;
+ _fontFormatting=null;
+ _borderFormatting=null;
+ _patternFormatting=null;
field_17_formula1=Formula.create(Ptg.EMPTY_PTG_ARRAY);
field_18_formula2=Formula.create(Ptg.EMPTY_PTG_ARRAY);
}
@@ -157,15 +157,15 @@
field_6_not_used = in.readShort();
if (containsFontFormattingBlock()) {
- fontFormatting = new FontFormatting(in);
+ _fontFormatting = new FontFormatting(in);
}
if (containsBorderFormattingBlock()) {
- borderFormatting = new BorderFormatting(in);
+ _borderFormatting = new BorderFormatting(in);
}
if (containsPatternFormattingBlock()) {
- patternFormatting = new PatternFormatting(in);
+ _patternFormatting = new PatternFormatting(in);
}
// "You may not use unions, intersections or array constants in Conditional Formatting criteria"
@@ -184,19 +184,16 @@
}
public void setFontFormatting(FontFormatting fontFormatting)
{
- this.fontFormatting = fontFormatting;
+ _fontFormatting = fontFormatting;
setOptionFlag(fontFormatting != null, font);
}
public FontFormatting getFontFormatting()
{
if( containsFontFormattingBlock())
{
- return fontFormatting;
- }
- else
- {
- return null;
+ return _fontFormatting;
}
+ return null;
}
public boolean containsAlignFormattingBlock()
@@ -214,19 +211,16 @@
}
public void setBorderFormatting(BorderFormatting borderFormatting)
{
- this.borderFormatting = borderFormatting;
+ _borderFormatting = borderFormatting;
setOptionFlag(borderFormatting != null, bord);
}
public BorderFormatting getBorderFormatting()
{
if( containsBorderFormattingBlock())
{
- return borderFormatting;
- }
- else
- {
- return null;
+ return _borderFormatting;
}
+ return null;
}
public boolean containsPatternFormattingBlock()
@@ -235,19 +229,16 @@
}
public void setPatternFormatting(PatternFormatting patternFormatting)
{
- this.patternFormatting = patternFormatting;
+ _patternFormatting = patternFormatting;
setOptionFlag(patternFormatting!=null, patt);
}
public PatternFormatting getPatternFormatting()
{
if( containsPatternFormattingBlock())
{
- return patternFormatting;
- }
- else
- {
- return null;
+ return _patternFormatting;
}
+ return null;
}
public boolean containsProtectionFormattingBlock()
@@ -452,16 +443,16 @@
out.writeShort(field_6_not_used);
if (containsFontFormattingBlock()) {
- byte[] fontFormattingRawRecord = fontFormatting.getRawRecord();
+ byte[] fontFormattingRawRecord = _fontFormatting.getRawRecord();
out.write(fontFormattingRawRecord);
}
if (containsBorderFormattingBlock()) {
- borderFormatting.serialize(out);
+ _borderFormatting.serialize(out);
}
if (containsPatternFormattingBlock()) {
- patternFormatting.serialize(out);
+ _patternFormatting.serialize(out);
}
field_17_formula1.serializeTokens(out);
@@ -470,7 +461,7 @@
protected int getDataSize() {
return 12 +
- (containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+
+ (containsFontFormattingBlock()?_fontFormatting.getRawRecord().length:0)+
(containsBorderFormattingBlock()?8:0)+
(containsPatternFormattingBlock()?4:0)+
getFormulaSize(field_17_formula1)+
@@ -486,13 +477,13 @@
buffer.append(" OPTION FLAGS=0x"+Integer.toHexString(getOptions()));
if (false) {
if (containsFontFormattingBlock()) {
- buffer.append(fontFormatting.toString());
+ buffer.append(_fontFormatting.toString());
}
if (containsBorderFormattingBlock()) {
- buffer.append(borderFormatting.toString());
+ buffer.append(_borderFormatting.toString());
}
if (containsPatternFormattingBlock()) {
- buffer.append(patternFormatting.toString());
+ buffer.append(_patternFormatting.toString());
}
buffer.append("[/CFRULE]\n");
}
@@ -504,13 +495,13 @@
rec.field_5_options = field_5_options;
rec.field_6_not_used = field_6_not_used;
if (containsFontFormattingBlock()) {
- rec.fontFormatting = (FontFormatting) fontFormatting.clone();
+ rec._fontFormatting = (FontFormatting) _fontFormatting.clone();
}
if (containsBorderFormattingBlock()) {
- rec.borderFormatting = (BorderFormatting) borderFormatting.clone();
+ rec._borderFormatting = (BorderFormatting) _borderFormatting.clone();
}
if (containsPatternFormattingBlock()) {
- rec.patternFormatting = (PatternFormatting) patternFormatting.clone();
+ rec._patternFormatting = (PatternFormatting) _patternFormatting.clone();
}
rec.field_17_formula1 = field_17_formula1.copy();
rec.field_18_formula2 = field_17_formula1.copy();
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java Tue Aug 18 16:50:24 2009
@@ -58,24 +58,21 @@
{
return writeData( offset, data, rawData );
}
- else
+ byte[] buffer = new byte[getRawDataSize()];
+ int pos = 0;
+ for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
{
- byte[] buffer = new byte[getRawDataSize()];
- int pos = 0;
- for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
- }
-
- return writeData( offset, data, buffer );
+ EscherRecord r = (EscherRecord) iterator.next();
+ pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
}
+
+ return writeData( offset, data, buffer );
}
-
+
/**
* Process the bytes into escher records.
* (Not done by default in case we break things,
- * unless you set the "poi.deserialize.escher"
+ * unless you set the "poi.deserialize.escher"
* system property)
*/
public void processChildRecords() {
@@ -140,5 +137,4 @@
LittleEndian.putShort(data, 0 + offset, ContinueRecord.sid);
LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader);
}
-
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/UnicodeString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/UnicodeString.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/UnicodeString.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/UnicodeString.java Tue Aug 18 16:50:24 2009
@@ -38,23 +38,23 @@
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
*/
-public final class UnicodeString implements Comparable {
+public final class UnicodeString implements Comparable<UnicodeString> {
private short field_1_charCount;
private byte field_2_optionflags;
private String field_3_string;
- private List field_4_format_runs;
+ private List<FormatRun> field_4_format_runs;
private byte[] field_5_ext_rst;
private static final BitField highByte = BitFieldFactory.getInstance(0x1);
private static final BitField extBit = BitFieldFactory.getInstance(0x4);
private static final BitField richText = BitFieldFactory.getInstance(0x8);
- public static class FormatRun implements Comparable {
- short character;
- short fontIndex;
+ public static class FormatRun implements Comparable<FormatRun> {
+ final short _character;
+ short _fontIndex;
public FormatRun(short character, short fontIndex) {
- this.character = character;
- this.fontIndex = fontIndex;
+ this._character = character;
+ this._fontIndex = fontIndex;
}
public FormatRun(LittleEndianInput in) {
@@ -62,11 +62,11 @@
}
public short getCharacterPos() {
- return character;
+ return _character;
}
public short getFontIndex() {
- return fontIndex;
+ return _fontIndex;
}
public boolean equals(Object o) {
@@ -75,25 +75,26 @@
}
FormatRun other = ( FormatRun ) o;
- return character == other.character && fontIndex == other.fontIndex;
+ return _character == other._character && _fontIndex == other._fontIndex;
}
- public int compareTo(Object obj) {
- FormatRun r = (FormatRun)obj;
- if ((character == r.character) && (fontIndex == r.fontIndex))
+ public int compareTo(FormatRun r) {
+ if (_character == r._character && _fontIndex == r._fontIndex) {
return 0;
- if (character == r.character)
- return fontIndex - r.fontIndex;
- else return character - r.character;
+ }
+ if (_character == r._character) {
+ return _fontIndex - r._fontIndex;
+ }
+ return _character - r._character;
}
public String toString() {
- return "character="+character+",fontIndex="+fontIndex;
+ return "character="+_character+",fontIndex="+_fontIndex;
}
public void serialize(LittleEndianOutput out) {
- out.writeShort(character);
- out.writeShort(fontIndex);
+ out.writeShort(_character);
+ out.writeShort(_fontIndex);
}
}
@@ -151,8 +152,8 @@
return false;
for (int i=0;i<size;i++) {
- FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
- FormatRun run2 = (FormatRun)other.field_4_format_runs.get(i);
+ FormatRun run1 = field_4_format_runs.get(i);
+ FormatRun run2 = other.field_4_format_runs.get(i);
if (!run1.equals(run2))
return false;
@@ -206,10 +207,10 @@
} else {
field_3_string = in.readUnicodeLEString(getCharCount());
}
-
+
if (isRichText() && (runCount > 0)) {
- field_4_format_runs = new ArrayList(runCount);
+ field_4_format_runs = new ArrayList<FormatRun>(runCount);
for (int i=0;i<runCount;i++) {
field_4_format_runs.add(new FormatRun(in));
}
@@ -328,20 +329,22 @@
}
public FormatRun getFormatRun(int index) {
- if (field_4_format_runs == null)
- return null;
- if ((index < 0) || (index >= field_4_format_runs.size()))
- return null;
- return (FormatRun)field_4_format_runs.get(index);
+ if (field_4_format_runs == null) {
+ return null;
+ }
+ if (index < 0 || index >= field_4_format_runs.size()) {
+ return null;
+ }
+ return field_4_format_runs.get(index);
}
private int findFormatRunAt(int characterPos) {
int size = field_4_format_runs.size();
for (int i=0;i<size;i++) {
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
- if (r.character == characterPos)
+ FormatRun r = field_4_format_runs.get(i);
+ if (r._character == characterPos)
return i;
- else if (r.character > characterPos)
+ else if (r._character > characterPos)
return -1;
}
return -1;
@@ -353,10 +356,11 @@
* replaced with the font run to be added.
*/
public void addFormatRun(FormatRun r) {
- if (field_4_format_runs == null)
- field_4_format_runs = new ArrayList();
+ if (field_4_format_runs == null) {
+ field_4_format_runs = new ArrayList<FormatRun>();
+ }
- int index = findFormatRunAt(r.character);
+ int index = findFormatRunAt(r._character);
if (index != -1)
field_4_format_runs.remove(index);
@@ -369,9 +373,10 @@
field_2_optionflags = richText.setByte(field_2_optionflags);
}
- public Iterator formatIterator() {
- if (field_4_format_runs != null)
+ public Iterator<FormatRun> formatIterator() {
+ if (field_4_format_runs != null) {
return field_4_format_runs.iterator();
+ }
return null;
}
@@ -398,21 +403,19 @@
/**
- * Swaps all use in the string of one font index
+ * Swaps all use in the string of one font index
* for use of a different font index.
* Normally only called when fonts have been
* removed / re-ordered
*/
public void swapFontUse(short oldFontIndex, short newFontIndex) {
- Iterator i = field_4_format_runs.iterator();
- while(i.hasNext()) {
- FormatRun run = (FormatRun)i.next();
- if(run.fontIndex == oldFontIndex) {
- run.fontIndex = newFontIndex;
+ for (FormatRun run : field_4_format_runs) {
+ if(run._fontIndex == oldFontIndex) {
+ run._fontIndex = newFontIndex;
}
}
}
-
+
/**
* unlike the real records we return the same as "getString()" rather than debug info
* @see #getDebugInfo()
@@ -431,7 +434,6 @@
* @return String of output for biffviewer etc.
*
*/
-
public String getDebugInfo()
{
StringBuffer buffer = new StringBuffer();
@@ -444,7 +446,7 @@
buffer.append(" .string = ").append(getString()).append("\n");
if (field_4_format_runs != null) {
for (int i = 0; i < field_4_format_runs.size();i++) {
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
+ FormatRun r = field_4_format_runs.get(i);
buffer.append(" .format_run"+i+" = ").append(r.toString()).append("\n");
}
}
@@ -464,7 +466,7 @@
if (isExtendedText() && field_5_ext_rst != null) {
extendedDataSize = field_5_ext_rst.length;
}
-
+
out.writeString(field_3_string, numberOfRichTextRuns, extendedDataSize);
if (numberOfRichTextRuns > 0) {
@@ -474,7 +476,7 @@
if (out.getAvailableSpace() < 4) {
out.writeContinue();
}
- FormatRun r = (FormatRun)field_4_format_runs.get(i);
+ FormatRun r = field_4_format_runs.get(i);
r.serialize(out);
}
}
@@ -496,9 +498,7 @@
}
}
- public int compareTo(Object obj)
- {
- UnicodeString str = ( UnicodeString ) obj;
+ public int compareTo(UnicodeString str) {
int result = getString().compareTo(str.getString());
@@ -524,8 +524,8 @@
return size - str.field_4_format_runs.size();
for (int i=0;i<size;i++) {
- FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
- FormatRun run2 = (FormatRun)str.field_4_format_runs.get(i);
+ FormatRun run1 = field_4_format_runs.get(i);
+ FormatRun run2 = str.field_4_format_runs.get(i);
result = run1.compareTo(run2);
if (result != 0)
@@ -571,11 +571,9 @@
str.field_2_optionflags = field_2_optionflags;
str.field_3_string = field_3_string;
if (field_4_format_runs != null) {
- str.field_4_format_runs = new ArrayList();
- int size = field_4_format_runs.size();
- for (int i = 0; i < size; i++) {
- FormatRun r = (FormatRun) field_4_format_runs.get(i);
- str.field_4_format_runs.add(new FormatRun(r.character, r.fontIndex));
+ str.field_4_format_runs = new ArrayList<FormatRun>();
+ for (FormatRun r : field_4_format_runs) {
+ str.field_4_format_runs.add(new FormatRun(r._character, r._fontIndex));
}
}
if (field_5_ext_rst != null) {
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java?rev=805492&r1=805491&r2=805492&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/FontDetails.java Tue Aug 18 16:50:24 2009
@@ -29,9 +29,9 @@
*/
public class FontDetails
{
- private String fontName;
- private int height;
- private Map charWidths = new HashMap();
+ private String _fontName;
+ private int _height;
+ private final Map<Character, Integer> charWidths = new HashMap<Character, Integer>();
/**
* Construct the font details with the given name and height.
@@ -41,18 +41,18 @@
*/
public FontDetails( String fontName, int height )
{
- this.fontName = fontName;
- this.height = height;
+ _fontName = fontName;
+ _height = height;
}
public String getFontName()
{
- return fontName;
+ return _fontName;
}
public int getHeight()
{
- return height;
+ return _height;
}
public void addChar( char c, int width )
@@ -68,10 +68,10 @@
public int getCharWidth( char c )
{
Integer widthInteger = (Integer)(charWidths.get(new Character(c)));
- if (widthInteger == null && c != 'W')
+ if (widthInteger == null && c != 'W') {
return getCharWidth('W');
- else
- return widthInteger.intValue();
+ }
+ return widthInteger.intValue();
}
public void addChars( char[] characters, int[] widths )
@@ -82,15 +82,15 @@
}
}
- protected static String buildFontHeightProperty(String fontName) {
- return "font." + fontName + ".height";
- }
- protected static String buildFontWidthsProperty(String fontName) {
- return "font." + fontName + ".widths";
- }
- protected static String buildFontCharactersProperty(String fontName) {
- return "font." + fontName + ".characters";
- }
+ protected static String buildFontHeightProperty(String fontName) {
+ return "font." + fontName + ".height";
+ }
+ protected static String buildFontWidthsProperty(String fontName) {
+ return "font." + fontName + ".widths";
+ }
+ protected static String buildFontCharactersProperty(String fontName) {
+ return "font." + fontName + ".characters";
+ }
/**
* Create an instance of <code>FontDetails</code> by loading them from the
@@ -173,6 +173,4 @@
return list;
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org