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 04:41:50 UTC
svn commit: r805262 [2/6] - in /poi/trunk/src: java/org/apache/poi/hssf/dev/
java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/record/
java/org/apache/poi/hssf/record/formula/
java/org/apache/poi/hssf/record/formula/atp/ java/org/apache/poi/hssf...
Modified: poi/trunk/src/java/org/apache/poi/poifs/storage/PropertyBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/storage/PropertyBlock.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/storage/PropertyBlock.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/storage/PropertyBlock.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,29 +14,22 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.storage;
-import java.io.*;
-
-import java.util.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.property.Property;
-import org.apache.poi.util.IntegerField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.LittleEndianConsts;
/**
* A block of Property instances
*
* @author Marc Johnson (mjohnson at apache dot org)
*/
-
-public class PropertyBlock
- extends BigBlock
-{
+public final class PropertyBlock extends BigBlock {
private static final int _properties_per_block =
POIFSConstants.BIG_BLOCK_SIZE / POIFSConstants.PROPERTY_SIZE;
private Property[] _properties;
Modified: poi/trunk/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,15 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.storage;
-import org.apache.poi.poifs.property.RootProperty;
-
-import java.util.*;
+import java.io.IOException;
-import java.io.*;
+import org.apache.poi.poifs.property.RootProperty;
/**
* This class implements reading the small document block list from an
@@ -31,9 +27,7 @@
*
* @author Marc Johnson (mjohnson at apache dot org)
*/
-
-public class SmallBlockTableReader
-{
+public final class SmallBlockTableReader {
/**
* fetch the small document block list from an existing file
@@ -48,7 +42,6 @@
*
* @exception IOException
*/
-
public static BlockList getSmallDocumentBlocks(
final RawDataBlockList blockList, final RootProperty root,
final int sbatStart)
Modified: poi/trunk/src/java/org/apache/poi/util/IntList.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IntList.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IntList.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IntList.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,12 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
-import java.util.*;
-
/**
* A List of int's; as full an implementation of the java.util.List
* interface as possible, with an eye toward minimal creation of
@@ -47,7 +43,6 @@
*
* @author Marc Johnson
*/
-
public class IntList
{
private int[] _array;
@@ -62,14 +57,14 @@
public IntList()
{
this(_default_size);
- }
+ }
public IntList(final int initialCapacity)
{
this(initialCapacity,0);
}
-
-
+
+
/**
* create a copy of an existing IntList
*
@@ -94,17 +89,17 @@
_array = new int[ initialCapacity ];
if (fillval != 0) {
fillval = fillvalue;
- fillArray(fillval, _array, 0);
+ fillArray(fillval, _array, 0);
}
_limit = 0;
}
private void fillArray(int val, int[] array, int index) {
for (int k = index; k < array.length; k++) {
- array[k] = val;
+ array[k] = val;
}
}
-
+
/**
* add the specfied value at the specified index
*
@@ -653,11 +648,11 @@
int size = (new_size == _array.length) ? new_size + 1
: new_size;
int[] new_array = new int[ size ];
-
+
if (fillval != 0) {
- fillArray(fillval, new_array, _array.length);
+ fillArray(fillval, new_array, _array.length);
}
-
+
System.arraycopy(_array, 0, new_array, 0, _limit);
_array = new_array;
}
Modified: poi/trunk/src/java/org/apache/poi/util/NullLogger.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/NullLogger.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/NullLogger.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/NullLogger.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,12 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
-import java.util.*;
-
/**
* A logger class that strives to make it as easy as possible for
* developers to write log calls, while simultaneously making those
@@ -31,14 +27,13 @@
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/
-
public class NullLogger extends POILogger
{
public void initialize(final String cat)
{
- //do nothing
+ //do nothing
}
-
+
/**
* Log a message
*
@@ -462,5 +457,5 @@
//do nothing
}
-}
+}
Modified: poi/trunk/src/java/org/apache/poi/util/ShortList.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/ShortList.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/ShortList.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/ShortList.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,12 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
-import java.util.*;
-
/**
* A List of short's; as full an implementation of the java.util.List
* interface as possible, with an eye toward minimal creation of
Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java Tue Aug 18 02:41:45 2009
@@ -22,7 +22,6 @@
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.PackageHelper;
-import org.apache.xmlbeans.XmlException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.*;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java Tue Aug 18 02:41:45 2009
@@ -26,7 +26,6 @@
import org.apache.poi.ss.usermodel.FontFamily;
import org.apache.poi.ss.usermodel.FontScheme;
import org.apache.poi.ss.usermodel.BuiltinFormats;
-import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
@@ -80,17 +79,17 @@
* Create a new, empty StylesTable
*/
public StylesTable() {
- super();
+ super();
doc = StyleSheetDocument.Factory.newInstance();
doc.addNewStyleSheet();
// Initialization required in order to make the document readable by MSExcel
initialize();
}
- public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
- super(part, rel);
- readFrom(part.getInputStream());
- }
+ public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
+ super(part, rel);
+ readFrom(part.getInputStream());
+ }
/**
* Read this shared styles table from an XML file.
@@ -107,13 +106,13 @@
numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
}
if(doc.getStyleSheet().getFonts() != null){
- int idx = 0;
- for (CTFont font : doc.getStyleSheet().getFonts().getFontArray()) {
- XSSFFont f = new XSSFFont(font, idx);
- fonts.add(f);
- idx++;
- }
- }
+ int idx = 0;
+ for (CTFont font : doc.getStyleSheet().getFonts().getFontArray()) {
+ XSSFFont f = new XSSFFont(font, idx);
+ fonts.add(f);
+ idx++;
+ }
+ }
if(doc.getStyleSheet().getFills() != null)
for (CTFill fill : doc.getStyleSheet().getFills().getFillArray()) {
fills.add(new XSSFCellFill(fill));
@@ -149,7 +148,7 @@
return numberFormats.get(idx);
}
- public int putNumberFormat(String fmt) {
+ public int putNumberFormat(String fmt) {
if (numberFormats.containsValue(fmt)) {
// Find the key, and return that
for(Integer key : numberFormats.keySet() ) {
@@ -174,12 +173,12 @@
}
public int putFont(XSSFFont font) {
- int idx = fonts.indexOf(font);
- if (idx != -1) {
- return idx;
- }
- fonts.add(font);
- return fonts.size() - 1;
+ int idx = fonts.indexOf(font);
+ if (idx != -1) {
+ return idx;
+ }
+ fonts.add(font);
+ return fonts.size() - 1;
}
public XSSFCellStyle getStyleAt(int idx) {
@@ -205,42 +204,42 @@
return borders.get(idx);
}
- public int putBorder(XSSFCellBorder border) {
- int idx = borders.indexOf(border);
- if (idx != -1) {
- return idx;
- }
- borders.add(border);
- return borders.size() - 1;
- }
-
- public XSSFCellFill getFillAt(int idx) {
- return fills.get(idx);
- }
-
- public List<XSSFCellBorder> getBorders(){
- return borders;
- }
-
- public List<XSSFCellFill> getFills(){
- return fills;
- }
-
- public List<XSSFFont> getFonts(){
- return fonts;
- }
-
- public Map<Integer, String> getNumberFormats(){
- return numberFormats;
- }
-
- public int putFill(XSSFCellFill fill) {
- int idx = fills.indexOf(fill);
- if (idx != -1) {
- return idx;
- }
- fills.add(fill);
- return fills.size() - 1;
+ public int putBorder(XSSFCellBorder border) {
+ int idx = borders.indexOf(border);
+ if (idx != -1) {
+ return idx;
+ }
+ borders.add(border);
+ return borders.size() - 1;
+ }
+
+ public XSSFCellFill getFillAt(int idx) {
+ return fills.get(idx);
+ }
+
+ public List<XSSFCellBorder> getBorders(){
+ return borders;
+ }
+
+ public List<XSSFCellFill> getFills(){
+ return fills;
+ }
+
+ public List<XSSFFont> getFonts(){
+ return fonts;
+ }
+
+ public Map<Integer, String> getNumberFormats(){
+ return numberFormats;
+ }
+
+ public int putFill(XSSFCellFill fill) {
+ int idx = fills.indexOf(fill);
+ if (idx != -1) {
+ return idx;
+ }
+ fills.add(fill);
+ return fills.size() - 1;
}
public CTXf getCellXfAt(int idx) {
@@ -315,31 +314,31 @@
}
doc.getStyleSheet().setNumFmts(formats);
- int idx;
+ int idx;
// Fonts
CTFonts ctFonts = CTFonts.Factory.newInstance();
ctFonts.setCount(fonts.size());
- CTFont[] ctfnt = new CTFont[fonts.size()];
- idx = 0;
- for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
- ctFonts.setFontArray(ctfnt);
+ CTFont[] ctfnt = new CTFont[fonts.size()];
+ idx = 0;
+ for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
+ ctFonts.setFontArray(ctfnt);
doc.getStyleSheet().setFonts(ctFonts);
// Fills
CTFills ctFills = CTFills.Factory.newInstance();
ctFills.setCount(fills.size());
- CTFill[] ctf = new CTFill[fills.size()];
- idx = 0;
- for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
- ctFills.setFillArray(ctf);
+ CTFill[] ctf = new CTFill[fills.size()];
+ idx = 0;
+ for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
+ ctFills.setFillArray(ctf);
doc.getStyleSheet().setFills(ctFills);
// Borders
CTBorders ctBorders = CTBorders.Factory.newInstance();
ctBorders.setCount(borders.size());
- CTBorder[] ctb = new CTBorder[borders.size()];
- idx = 0;
- for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
+ CTBorder[] ctb = new CTBorder[borders.size()];
+ idx = 0;
+ for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
ctBorders.setBorderArray(ctb);
doc.getStyleSheet().setBorders(ctBorders);
@@ -376,13 +375,13 @@
doc.save(out, options);
}
- @Override
- protected void commit() throws IOException {
- PackagePart part = getPackagePart();
- OutputStream out = part.getOutputStream();
- writeTo(out);
- out.close();
- }
+ @Override
+ protected void commit() throws IOException {
+ PackagePart part = getPackagePart();
+ OutputStream out = part.getOutputStream();
+ writeTo(out);
+ out.close();
+ }
private void initialize() {
//CTFont ctFont = createDefaultFont();
@@ -452,36 +451,35 @@
return this.dxfs.size();
}
- public XSSFCellStyle createCellStyle() {
- CTXf xf = CTXf.Factory.newInstance();
- xf.setNumFmtId(0);
- xf.setFontId(0);
- xf.setFillId(0);
- xf.setBorderId(0);
- xf.setXfId(0);
- int xfSize = styleXfs.size();
- int indexXf = putCellXf(xf);
- return new XSSFCellStyle(indexXf - 1, xfSize - 1, this);
- }
-
- /**
- * Finds a font that matches the one with the supplied attributes
- */
- public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
- for (XSSFFont font : fonts) {
- if ( (font.getBoldweight() == boldWeight)
- && font.getColor() == color
- && font.getFontHeight() == fontHeight
- && font.getFontName().equals(name)
- && font.getItalic() == italic
- && font.getStrikeout() == strikeout
- && font.getTypeOffset() == typeOffset
- && font.getUnderline() == underline)
- {
- return font;
- }
- }
- return null;
- }
+ public XSSFCellStyle createCellStyle() {
+ CTXf xf = CTXf.Factory.newInstance();
+ xf.setNumFmtId(0);
+ xf.setFontId(0);
+ xf.setFillId(0);
+ xf.setBorderId(0);
+ xf.setXfId(0);
+ int xfSize = styleXfs.size();
+ int indexXf = putCellXf(xf);
+ return new XSSFCellStyle(indexXf - 1, xfSize - 1, this);
+ }
+ /**
+ * Finds a font that matches the one with the supplied attributes
+ */
+ public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
+ for (XSSFFont font : fonts) {
+ if ( (font.getBoldweight() == boldWeight)
+ && font.getColor() == color
+ && font.getFontHeight() == fontHeight
+ && font.getFontName().equals(name)
+ && font.getItalic() == italic
+ && font.getStrikeout() == strikeout
+ && font.getTypeOffset() == typeOffset
+ && font.getUnderline() == underline)
+ {
+ return font;
+ }
+ }
+ return null;
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java Tue Aug 18 02:41:45 2009
@@ -17,49 +17,48 @@
package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.DataFormat;
-import org.apache.poi.ss.usermodel.Hyperlink;
-import org.apache.poi.ss.usermodel.RichTextString;
public class XSSFCreationHelper implements CreationHelper {
private XSSFWorkbook workbook;
+
XSSFCreationHelper(XSSFWorkbook wb) {
workbook = wb;
}
-
- /**
- * Creates a new XSSFRichTextString for you.
- */
+
+ /**
+ * Creates a new XSSFRichTextString for you.
+ */
public XSSFRichTextString createRichTextString(String text) {
- XSSFRichTextString rt = new XSSFRichTextString(text);
- rt.setStylesTableReference(workbook.getStylesSource());
- return rt;
+ XSSFRichTextString rt = new XSSFRichTextString(text);
+ rt.setStylesTableReference(workbook.getStylesSource());
+ return rt;
}
-
+
public XSSFDataFormat createDataFormat() {
return workbook.createDataFormat();
}
-
+
public XSSFHyperlink createHyperlink(int type) {
return new XSSFHyperlink(type);
}
- /**
- * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
- *
- * @return a XSSFFormulaEvaluator instance
- */
- public XSSFFormulaEvaluator createFormulaEvaluator(){
- return new XSSFFormulaEvaluator(workbook);
- }
-
- /**
- * Creates a XSSFClientAnchor. Use this object to position drawing object in a sheet
- *
- * @return a XSSFClientAnchor instance
- * @see org.apache.poi.ss.usermodel.Drawing
- */
- public XSSFClientAnchor createClientAnchor(){
- return new XSSFClientAnchor();
- }
+ /**
+ * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
+ *
+ * @return a XSSFFormulaEvaluator instance
+ */
+ public XSSFFormulaEvaluator createFormulaEvaluator() {
+ return new XSSFFormulaEvaluator(workbook);
+ }
+
+ /**
+ * Creates a XSSFClientAnchor. Use this object to position drawing object in
+ * a sheet
+ *
+ * @return a XSSFClientAnchor instance
+ * @see org.apache.poi.ss.usermodel.Drawing
+ */
+ public XSSFClientAnchor createClientAnchor() {
+ return new XSSFClientAnchor();
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Tue Aug 18 02:41:45 2009
@@ -53,7 +53,6 @@
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.model.MapInfo;
-import org.apache.poi.xssf.extractor.XSSFExportToXml;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
@@ -570,7 +569,7 @@
throw new IllegalStateException("There are no defined names in this workbook");
}
if (nameIndex < 0 || nameIndex > nNames) {
- throw new IllegalArgumentException("Specified name index " + nameIndex
+ throw new IllegalArgumentException("Specified name index " + nameIndex
+ " is outside the allowable range (0.." + (nNames-1) + ").");
}
return namedRanges.get(nameIndex);
@@ -636,7 +635,7 @@
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
* @return String Null if no print area has been defined
*/
- public String getPrintArea(int sheetIndex) {
+ public String getPrintArea(int sheetIndex) {
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
if (name == null) return null;
//adding one here because 0 indicates a global named region; doesnt make sense for print areas
@@ -975,7 +974,7 @@
r = escapedName + "!$" + rowRef.getCellRefParts()[1] + ":$" + rowRef2.getCellRefParts()[1];
}
}
-
+
StringBuffer rng = new StringBuffer();
rng.append(c);
if(rng.length() > 0 && r.length() > 0) rng.append(',');
@@ -1243,7 +1242,7 @@
}
return embedds;
}
-
+
public boolean isHidden() {
throw new RuntimeException("Not implemented yet");
}
@@ -1280,7 +1279,7 @@
* Fired when a formula is deleted from this workbook,
* for example when calling cell.setCellFormula(null)
*
- * @see XSSFCell#setCellFormula(String)
+ * @see XSSFCell#setCellFormula(String)
*/
protected void onDeleteFormula(XSSFCell cell){
if(calcChain != null) {
@@ -1294,7 +1293,7 @@
* <p>
* The calculation chain object specifies the order in which the cells in a workbook were last calculated
* </p>
- *
+ *
* @return the <code>CalculationChain</code> object or <code>null</code> if not defined
*/
public CalculationChain getCalculationChain(){
@@ -1302,19 +1301,19 @@
}
/**
- *
+ *
* @return a collection of custom XML mappings defined in this workbook
*/
public Collection<XSSFMap> getCustomXMLMappings(){
return mapInfo == null ? new ArrayList<XSSFMap>() : mapInfo.getAllXSSFMaps();
}
-
+
/**
- *
+ *
* @return the helper class used to query the custom XML mapping defined in this workbook
*/
public MapInfo getMapInfo(){
return mapInfo;
}
-
+
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java Tue Aug 18 02:41:45 2009
@@ -18,119 +18,151 @@
package org.apache.poi.xssf.usermodel.extensions;
import org.apache.poi.ss.usermodel.HeaderFooter;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.helpers.HeaderFooterHelper;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
/**
* Parent class of all XSSF headers and footers.
- *
- * For a list of all the different fields that can be
- * placed into a header or footer, such as page number,
- * bold, underline etc, see the follow formatting syntax
- *
+ *
+ * For a list of all the different fields that can be placed into a header or
+ * footer, such as page number, bold, underline etc, see the follow formatting
+ * syntax
+ *
*<b> Header/Footer Formatting Syntax</b>
*<p>
- * There are a number of formatting codes that can be written inline with the actual header / footer text, which
- * affect the formatting in the header or footer.
+ * There are a number of formatting codes that can be written inline with the
+ * actual header / footer text, which affect the formatting in the header or
+ * footer.
*</p>
*
- * This example shows the text "Center Bold Header" on the first line (center section), and the date on the second
- * line (center section).
- * &CCenter &"-,Bold"Bold &"-,Regular"Header_x000A_&D
- *
- * <b>General Rules:</b>
- * There is no required order in which these codes must appear.
- * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
- *
+ * This example shows the text "Center Bold Header" on the first line (center
+ * section), and the date on the second line (center section). &CCenter
+ * &"-,Bold"Bold &"-,Regular"Header_x000A_&D
+ *
+ * <b>General Rules:</b> There is no required order in which these codes must
+ * appear. The first occurrence of the following codes turns the formatting ON,
+ * the second occurrence turns it OFF again:
+ *
* <dl>
- * <dt> &L </dt> <dd>code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
- * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
- * order of appearance, and placed into the left section.</dd>
- * <dt> &P </dt> <dd> code for "current page #"</dd>
- * <dt> &N </dt> <dd> code for "total pages"</dd>
- * <dt>&font size </dt> <dd> code for "text font size", where font size is a font size in points.</dd>
- * <dt> &K </dt> <dd> code for "text font color"
- * RGB Color is specified as RRGGBB
- * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
- * value, NN is the tint/shade value.</dd>
- * <dt> &S </dt> <dd> code for "text strikethrough" on / off</dd>
- * <dt> &X </dt> <dd> code for "text super script" on / off</dd>
- * <dt> &Y </dt> <dd> code for "text subscript" on / off</dd>
- * <dt> &C </dt> <dd> code for "center section". When two or more occurrences of this section marker exist, the contents
- * from all markers are concatenated, in the order of appearance, and placed into the center section.
- * SpreadsheetML Reference Material - Worksheets 1966</dd>
- * <dt> &D </dt> <dd> code for "date"</dd>
- * <dt> &T </dt> <dd> code for "time"</dd>
- * <dt> &G </dt> <dd> code for "picture as background"</dd>
- * <dt> &U </dt> <dd> code for "text single underline"</dd>
- * <dt> &E </dt> <dd> code for "double underline"</dd>
- * <dt> &R </dt> <dd> code for "right section". When two or more occurrences of this section marker exist, the contents
- * from all markers are concatenated, in the order of appearance, and placed into the right section.</dd>
- * <dt> &Z </dt> <dd> code for "this workbook's file path"</dd>
- * <dt> &F </dt> <dd> code for "this workbook's file name"</dd>
- * <dt> &A </dt> <dd> code for "sheet tab name"</dd>
- * <dt> &+ </dt> <dd> code for add to page #.</dd>
- * <dt> &- </dt> <dd> code for subtract from page #.</dd>
- * <dt> &"font name,font type" - code for "text font name" and "text font type", where font name and font type
- * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
- * name, it means "none specified". Both of font name and font type can be localized values.</dd>
- * <dt> &"-,Bold" </dt> <dd> code for "bold font style"</dd>
- * <dt> &B </dt> <dd> also means "bold font style"</dd>
- * <dt> &"-,Regular" </dt> <dd> code for "regular font style"</dd>
- * <dt> &"-,Italic" </dt> <dd> code for "italic font style"</dd>
- * <dt> &I </dt> <dd> also means "italic font style"</dd>
- * <dt> &"-,Bold Italic" </dt> <dd> code for "bold italic font style"</dd>
- * <dt> &O </dt> <dd> code for "outline style"</dd>
- * <dt> &H </dt> <dd> code for "shadow style"</dd>
+ * <dt>&L</dt>
+ * <dd>code for "left section" (there are three header / footer locations,
+ * "left", "center", and "right"). When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the left section.</dd>
+ * <dt>&P</dt>
+ * <dd>code for "current page #"</dd>
+ * <dt>&N</dt>
+ * <dd>code for "total pages"</dd>
+ * <dt>&font size</dt>
+ * <dd>code for "text font size", where font size is a font size in points.</dd>
+ * <dt>&K</dt>
+ * <dd>code for "text font color" RGB Color is specified as RRGGBB Theme Color
+ * is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-"
+ * of the tint/shade value, NN is the tint/shade value.</dd>
+ * <dt>&S</dt>
+ * <dd>code for "text strikethrough" on / off</dd>
+ * <dt>&X</dt>
+ * <dd>code for "text super script" on / off</dd>
+ * <dt>&Y</dt>
+ * <dd>code for "text subscript" on / off</dd>
+ * <dt>&C</dt>
+ * <dd>code for "center section". When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the center section. SpreadsheetML Reference
+ * Material - Worksheets 1966</dd>
+ * <dt>&D</dt>
+ * <dd>code for "date"</dd>
+ * <dt>&T</dt>
+ * <dd>code for "time"</dd>
+ * <dt>&G</dt>
+ * <dd>code for "picture as background"</dd>
+ * <dt>&U</dt>
+ * <dd>code for "text single underline"</dd>
+ * <dt>&E</dt>
+ * <dd>code for "double underline"</dd>
+ * <dt>&R</dt>
+ * <dd>code for "right section". When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the right section.</dd>
+ * <dt>&Z</dt>
+ * <dd>code for "this workbook's file path"</dd>
+ * <dt>&F</dt>
+ * <dd>code for "this workbook's file name"</dd>
+ * <dt>&A</dt>
+ * <dd>code for "sheet tab name"</dd>
+ * <dt>&+</dt>
+ * <dd>code for add to page #.</dd>
+ * <dt>&-</dt>
+ * <dd>code for subtract from page #.</dd>
+ * <dt>&"font name,font type" - code for "text font name" and "text font type",
+ * where font name and font type are strings specifying the name and type of the
+ * font, separated by a comma. When a hyphen appears in font name, it means
+ * "none specified". Both of font name and font type can be localized
+ * values.</dd>
+ * <dt>&"-,Bold"</dt>
+ * <dd>code for "bold font style"</dd>
+ * <dt>&B</dt>
+ * <dd>also means "bold font style"</dd>
+ * <dt>&"-,Regular"</dt>
+ * <dd>code for "regular font style"</dd>
+ * <dt>&"-,Italic"</dt>
+ * <dd>code for "italic font style"</dd>
+ * <dt>&I</dt>
+ * <dd>also means "italic font style"</dd>
+ * <dt>&"-,Bold Italic"</dt>
+ * <dd>code for "bold italic font style"</dd>
+ * <dt>&O</dt>
+ * <dd>code for "outline style"</dd>
+ * <dt>&H</dt>
+ * <dd>code for "shadow style"</dd>
* </dl>
- *
- *
+ *
+ *
*/
public abstract class XSSFHeaderFooter implements HeaderFooter {
- private HeaderFooterHelper helper;
- private CTHeaderFooter headerFooter;
+ private HeaderFooterHelper helper;
+ private CTHeaderFooter headerFooter;
private boolean stripFields = false;
/**
* Create an instance of XSSFHeaderFooter from the supplied XML bean
+ *
* @param headerFooter
*/
- public XSSFHeaderFooter(CTHeaderFooter headerFooter) {
- this.headerFooter = headerFooter;
- this.helper = new HeaderFooterHelper();
- }
-
- /**
- * Returns the underlying CTHeaderFooter xml bean
- *
- * @return the underlying CTHeaderFooter xml bean
- */
- public CTHeaderFooter getHeaderFooter() {
- return this.headerFooter;
- }
-
- public String getValue() {
- String value = getText();
- if(value == null)
- return "";
- return value;
- }
-
-
- /**
- * Are fields currently being stripped from
- * the text that this {@link XSSFHeaderFooter} returns?
- * Default is false, but can be changed
+ public XSSFHeaderFooter(CTHeaderFooter headerFooter) {
+ this.headerFooter = headerFooter;
+ this.helper = new HeaderFooterHelper();
+ }
+
+ /**
+ * Returns the underlying CTHeaderFooter xml bean
+ *
+ * @return the underlying CTHeaderFooter xml bean
+ */
+ public CTHeaderFooter getHeaderFooter() {
+ return this.headerFooter;
+ }
+
+ public String getValue() {
+ String value = getText();
+ if (value == null)
+ return "";
+ return value;
+ }
+
+ /**
+ * Are fields currently being stripped from the text that this
+ * {@link XSSFHeaderFooter} returns? Default is false, but can be changed
*/
public boolean areFieldsStripped() {
return stripFields;
}
+
/**
- * Should fields (eg macros) be stripped from
- * the text that this class returns?
- * Default is not to strip.
+ * Should fields (eg macros) be stripped from the text that this class
+ * returns? Default is not to strip.
+ *
* @param stripFields
*/
public void setAreFieldsStripped(boolean stripFields) {
@@ -138,69 +170,66 @@
}
/**
- * Removes any fields (eg macros, page markers etc)
- * from the string.
- * Normally used to make some text suitable for showing
- * to humans, and the resultant text should not normally
- * be saved back into the document!
+ * Removes any fields (eg macros, page markers etc) from the string.
+ * Normally used to make some text suitable for showing to humans, and the
+ * resultant text should not normally be saved back into the document!
*/
public static String stripFields(String text) {
return org.apache.poi.hssf.usermodel.HeaderFooter.stripFields(text);
}
-
- public abstract String getText();
-
- protected abstract void setText(String text);
-
- /**
- * get the text representing the center part of this element
- */
- public String getCenter() {
- String text = helper.getCenterSection(getText());
- if(stripFields)
- return stripFields(text);
- return text;
- }
-
- /**
- * get the text representing the left part of this element
- */
- public String getLeft() {
- String text = helper.getLeftSection(getText());
- if(stripFields)
- return stripFields(text);
- return text;
- }
-
- /**
- * get the text representing the right part of this element
- */
- public String getRight() {
- String text = helper.getRightSection(getText());
- if(stripFields)
- return stripFields(text);
- return text;
- }
-
- /**
- * set a centered string value for this element
- */
- public void setCenter(String newCenter) {
- setText(helper.setCenterSection(getText(), newCenter));
- }
-
- /**
- * set a left string value for this element
- */
- public void setLeft(String newLeft) {
- setText(helper.setLeftSection(getText(), newLeft));
- }
-
- /**
- * set a right string value for this element
- */
- public void setRight(String newRight) {
- setText(helper.setRightSection(getText(), newRight));
- }
+ public abstract String getText();
+
+ protected abstract void setText(String text);
+
+ /**
+ * get the text representing the center part of this element
+ */
+ public String getCenter() {
+ String text = helper.getCenterSection(getText());
+ if (stripFields)
+ return stripFields(text);
+ return text;
+ }
+
+ /**
+ * get the text representing the left part of this element
+ */
+ public String getLeft() {
+ String text = helper.getLeftSection(getText());
+ if (stripFields)
+ return stripFields(text);
+ return text;
+ }
+
+ /**
+ * get the text representing the right part of this element
+ */
+ public String getRight() {
+ String text = helper.getRightSection(getText());
+ if (stripFields)
+ return stripFields(text);
+ return text;
+ }
+
+ /**
+ * set a centered string value for this element
+ */
+ public void setCenter(String newCenter) {
+ setText(helper.setCenterSection(getText(), newCenter));
+ }
+
+ /**
+ * set a left string value for this element
+ */
+ public void setLeft(String newLeft) {
+ setText(helper.setLeftSection(getText(), newLeft));
+ }
+
+ /**
+ * set a right string value for this element
+ */
+ public void setRight(String newRight) {
+ setText(helper.setRightSection(getText(), newRight));
+ }
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java Tue Aug 18 02:41:45 2009
@@ -17,7 +17,6 @@
package org.apache.poi.openxml4j.opc;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -37,8 +36,6 @@
import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
import org.apache.poi.openxml4j.opc.internal.FileHelper;
import org.apache.poi.util.TempFile;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -64,19 +61,19 @@
//ZipFileAssert.assertEquals(originalFile, targetFile);
assertTrue(targetFile.delete());
}
-
+
/**
* Test that when we create a new Package, we give it
* the correct default content types
*/
public void testCreateGetsContentTypes() throws Exception {
File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
-
+
// Zap the target file, in case of an earlier run
if(targetFile.exists()) targetFile.delete();
-
+
OPCPackage pkg = OPCPackage.create(targetFile);
-
+
// Check it has content types for rels and xml
ContentTypeManager ctm = getContentTypeManager(pkg);
assertEquals(
@@ -108,7 +105,7 @@
// Zap the target file, in case of an earlier run
if(targetFile.exists()) targetFile.delete();
-
+
// Create a package
OPCPackage pkg = OPCPackage.create(targetFile);
PackagePartName corePartName = PackagingURIHelper
@@ -142,7 +139,7 @@
//ZipFileAssert.assertEquals(expectedFile, targetFile);
assertTrue(targetFile.delete());
}
-
+
/**
* Tests that we can create a new package, add a core
* document and another part, save and re-load and
@@ -151,7 +148,7 @@
public void testCreatePackageWithCoreDocument() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OPCPackage pkg = OPCPackage.create(baos);
-
+
// Add a core document
PackagePartName corePartName = PackagingURIHelper.createPartName("/xl/workbook.xml");
// Create main part relationship
@@ -162,7 +159,7 @@
OutputStream coreOut = corePart.getOutputStream();
coreOut.write("<dummy-xml />".getBytes());
coreOut.close();
-
+
// And another bit
PackagePartName sheetPartName = PackagingURIHelper.createPartName("/xl/worksheets/sheet1.xml");
PackageRelationship rel =
@@ -184,8 +181,8 @@
assertEquals("/", coreRel.getSourceURI().toString());
assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
assertNotNull(pkg.getPart(coreRel));
-
-
+
+
// Save and re-load
pkg.close();
File tmp = TempFile.createTempFile("testCreatePackageWithCoreDocument", ".zip");
@@ -290,7 +287,7 @@
//ZipFileAssert.assertEquals(expectedFile, targetFile);
assertTrue(targetFile.delete());
}
-
+
/**
* Checks that we can write a package to a simple
* OutputStream, in addition to the normal writing
@@ -318,15 +315,15 @@
*/
public void testOpenFromInputStream() throws Exception {
String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-
+
FileInputStream finp = new FileInputStream(originalFile);
-
+
OPCPackage p = OPCPackage.open(finp);
-
+
assertNotNull(p);
assertNotNull(p.getRelationships());
assertEquals(12, p.getParts().size());
-
+
// Check it has the usual bits
assertTrue(p.hasRelationships());
assertTrue(p.containPart(PackagingURIHelper.createPartName("/_rels/.rels")));
@@ -407,7 +404,7 @@
// Don't save modifications
p.revert();
}
-
+
public void testDeletePartRecursive() throws InvalidFormatException {
TreeMap<PackagePartName, String> expectedValues;
TreeMap<PackagePartName, String> values;
@@ -445,7 +442,7 @@
// Don't save modifications
p.revert();
}
-
+
private static ContentTypeManager getContentTypeManager(OPCPackage pkg) throws Exception {
Field f = OPCPackage.class.getDeclaredField("contentTypeManager");
f.setAccessible(true);
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/io/TestLoadSaveXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/io/TestLoadSaveXSSF.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/io/TestLoadSaveXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/io/TestLoadSaveXSSF.java Tue Aug 18 02:41:45 2009
@@ -24,7 +24,6 @@
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -35,8 +34,8 @@
String filename;
- protected void setUp() throws Exception {
- super.setUp();
+ protected void setUp() {
+
System.setProperty("org.apache.poi.util.POILogger", org.apache.poi.util.CommonsLogger.class.getName());
filename = System.getProperty("XSSF.testdata.path");
if (filename == null) {
@@ -52,12 +51,12 @@
Row row = sheet.getRow(0);
Cell cell = row.getCell((short) 1);
assertNotNull(cell);
- assertEquals(111.0, cell.getNumericCellValue());
+ assertEquals(111.0, cell.getNumericCellValue(), 0.0);
cell = row.getCell((short) 0);
assertEquals("Lorem", cell.getRichStringCellValue().getString());
}
- // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successfull.
+ // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successful.
public void testLoadStyles() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook(new File(filename, "styles.xlsx").getAbsolutePath());
Sheet sheet = workbook.getSheetAt(0);
@@ -67,11 +66,10 @@
// assertNotNull(style);
}
- // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successfull.
+ // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successful.
public void testLoadPictures() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook(new File(filename, "picture.xlsx").getAbsolutePath());
List<XSSFPictureData> pictures = workbook.getAllPictures();
assertEquals(1, pictures.size());
}
-
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Tue Aug 18 02:41:45 2009
@@ -17,21 +17,17 @@
package org.apache.poi.xssf.usermodel;
-import java.io.File;
import java.util.List;
-import junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
-import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
-public class TestXSSFBugs extends BaseTestBugzillaIssues {
+public final class TestXSSFBugs extends BaseTestBugzillaIssues {
@Override
protected XSSFITestDataProvider getTestDataProvider(){
return XSSFITestDataProvider.getInstance();
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java Tue Aug 18 02:41:45 2009
@@ -17,29 +17,16 @@
package org.apache.poi.xssf.usermodel;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRichTextString;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.ITestDataProvider;
-import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BaseTestDataFormat;
import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
/**
* Tests for {@link XSSFDataFormat}
*
*/
public final class TestXSSFDataFormat extends BaseTestDataFormat {
-
+
@Override
protected ITestDataProvider getTestDataProvider(){
return XSSFITestDataProvider.getInstance();
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java Tue Aug 18 02:41:45 2009
@@ -17,12 +17,8 @@
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
-
import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.xssf.usermodel.XSSFColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
@@ -38,14 +34,14 @@
public final class TestXSSFFont extends BaseTestFont{
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
-
- public void testDefaultFont() {
- baseTestDefaultFont("Calibri", (short)220, IndexedColors.BLACK.getIndex());
- }
+ @Override
+ protected XSSFITestDataProvider getTestDataProvider() {
+ return XSSFITestDataProvider.getInstance();
+ }
+
+ public void testDefaultFont() {
+ baseTestDefaultFont("Calibri", (short) 220, IndexedColors.BLACK.getIndex());
+ }
public void testConstructor() {
XSSFFont xssfFont=new XSSFFont();
@@ -160,7 +156,7 @@
xssfFont.setUnderline(Font.U_DOUBLE);
assertEquals(ctFont.getUArray().length,1);
assertEquals(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal());
-
+
xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
assertEquals(ctFont.getUArray().length,1);
assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java Tue Aug 18 02:41:45 2009
@@ -17,7 +17,6 @@
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.ss.usermodel.BaseTestNamedRange;
@@ -37,7 +36,7 @@
// First test that setting RR&C for same sheet more than once only creates a
// single Print_Titles built-in record
XSSFWorkbook wb = getTestDataProvider().createWorkbook();
- XSSFSheet sheet = wb.createSheet("First Sheet");
+ wb.createSheet("First Sheet");
wb.setRepeatingRowsAndColumns(0, -1, -1, -1, -1);
@@ -77,7 +76,7 @@
// check that setting RR&C on a second sheet causes a new Print_Titles built-in
// name to be created
- sheet = nwb.createSheet("SecondSheet");
+ nwb.createSheet("SecondSheet");
nwb.setRepeatingRowsAndColumns(1, 1, 2, 0, 0);
assertEquals(2, nwb.getNumberOfNames());
@@ -88,6 +87,4 @@
nwb.setRepeatingRowsAndColumns(1, -1, -1, -1, -1);
}
-
-
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java Tue Aug 18 02:41:45 2009
@@ -17,7 +17,6 @@
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.BaseTestPicture;
import org.apache.poi.xssf.XSSFITestDataProvider;
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java Tue Aug 18 02:41:45 2009
@@ -17,14 +17,12 @@
package org.apache.poi.xssf.usermodel;
+import java.util.Arrays;
+import java.util.List;
+
import junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
-import java.util.List;
-import java.util.Arrays;
-import java.io.IOException;
+import org.apache.poi.xssf.XSSFTestDataSamples;
/**
* @author Yegor Kozlov
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java Tue Aug 18 02:41:45 2009
@@ -187,13 +187,13 @@
pMargins.setHeader(1.5);
pMargins.setFooter(2);
XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
- assertEquals(1.5, printSetup.getHeaderMargin());
- assertEquals(2.0, printSetup.getFooterMargin());
+ assertEquals(1.5, printSetup.getHeaderMargin(), 0.0);
+ assertEquals(2.0, printSetup.getFooterMargin(), 0.0);
printSetup.setHeaderMargin(5);
printSetup.setFooterMargin(3.5);
- assertEquals(5.0, pMargins.getHeader());
- assertEquals(3.5, pMargins.getFooter());
+ assertEquals(5.0, pMargins.getHeader(), 0.0);
+ assertEquals(3.5, pMargins.getFooter(), 0.0);
}
public void testSetGetCopies() {
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java Tue Aug 18 02:41:45 2009
@@ -17,23 +17,9 @@
package org.apache.poi.xssf.usermodel;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-
import junit.framework.TestCase;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
/**
* Tests functionality of the XSSFRichTextRun object
@@ -42,7 +28,7 @@
*/
public final class TestXSSFRichTextString extends TestCase {
- public void testCreate() throws Exception {
+ public void testCreate() {
XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
assertEquals("Apache POI", rt.getString());
@@ -59,7 +45,7 @@
}
- public void testApplyFont() throws Exception {
+ public void testApplyFont() {
XSSFRichTextString rt = new XSSFRichTextString();
rt.append("123");
@@ -85,7 +71,7 @@
assertEquals(1, rt.getLengthOfFormattingRun(3));
}
- public void testClearFormatting() throws Exception {
+ public void testClearFormatting() {
XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
assertEquals("Apache POI", rt.getString());
@@ -105,10 +91,9 @@
rt.clearFormatting();
assertEquals("Apache POI", rt.getString());
assertEquals(0, rt.numFormattingRuns());
-
}
- public void testGetFonts() throws Exception {
+ public void testGetFonts() {
XSSFRichTextString rt = new XSSFRichTextString();
@@ -129,6 +114,5 @@
XSSFFont font2$ = rt.getFontOfFormattingRun(1);
assertEquals(font2.getBold(), font2$.getBold());
assertEquals(font2.getFontName(), font2$.getFontName());
-
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java Tue Aug 18 02:41:45 2009
@@ -17,21 +17,9 @@
package org.apache.poi.xssf.usermodel;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.xssf.model.SharedStringsTable;
-import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BaseTestRow;
import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.HSSFCell;
/**
* Tests for XSSFRow
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Tue Aug 18 02:41:45 2009
@@ -18,19 +18,23 @@
package org.apache.poi.xssf.usermodel;
import java.io.File;
-import java.util.Iterator;
-import junit.framework.TestCase;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CommentsTable;
import org.apache.poi.xssf.model.StylesTable;
-import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
public class TestXSSFSheet extends BaseTestSheet {
@@ -205,14 +209,14 @@
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
sheet.createFreezePane(2, 4);
- assertEquals((double) 2, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+ assertEquals(2.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
sheet.createFreezePane(3, 6, 10, 10);
- assertEquals((double) 3, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+ assertEquals(3.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
// assertEquals(10, sheet.getTopRow());
// assertEquals(10, sheet.getLeftCol());
sheet.createSplitPane(4, 8, 12, 12, 1);
- assertEquals((double) 8, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit());
+ assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0);
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
}
@@ -375,15 +379,15 @@
public void testSetColumnGroupCollapsed(){
Workbook wb = new XSSFWorkbook();
XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
-
+
CTCols cols=sheet1.getCTWorksheet().getColsArray(0);
assertEquals(0,cols.sizeOfColArray());
-
+
sheet1.groupColumn( (short)4, (short)7 );
sheet1.groupColumn( (short)9, (short)12 );
assertEquals(2,cols.sizeOfColArray());
-
+
assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -395,7 +399,7 @@
sheet1.groupColumn( (short)10, (short)11 );
assertEquals(4,cols.sizeOfColArray());
-
+
assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -412,11 +416,11 @@
assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(13, cols.getColArray(3).getMin()); // 1 based
assertEquals(13, cols.getColArray(3).getMax()); // 1 based
-
+
// collapse columns - 1
sheet1.setColumnGroupCollapsed( (short)5, true );
assertEquals(5,cols.sizeOfColArray());
-
+
assertEquals(true, cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -501,7 +505,7 @@
//outline level 2: the line under ==> collapsed==True
assertEquals(2,cols.getColArray(3).getOutlineLevel());
assertEquals(true,cols.getColArray(4).isSetCollapsed());
-
+
assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -610,7 +614,7 @@
sheet1.groupRow( 7, 14 );
sheet1.groupRow( 16, 19 );
- assertEquals(14,sheet1.getPhysicalNumberOfRows());
+ assertEquals(14,sheet1.getPhysicalNumberOfRows());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
@@ -625,7 +629,7 @@
assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
//collapsed
- sheet1.setRowGroupCollapsed( 7, true );
+ sheet1.setRowGroupCollapsed( 7, true );
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
@@ -698,7 +702,7 @@
// XML is 1 based, POI is 0 based
assertEquals(2, col.getMin());
assertEquals(2, col.getMax());
- assertEquals(22.0, col.getWidth());
+ assertEquals(22.0, col.getWidth(), 0.0);
// Now set another
sheet.setColumnWidth(3, 33 * 256);
@@ -711,12 +715,11 @@
col = cols.getColArray(0);
assertEquals(2, col.getMin()); // POI 1
assertEquals(2, col.getMax());
- assertEquals(22.0, col.getWidth());
+ assertEquals(22.0, col.getWidth(), 0.0);
col = cols.getColArray(1);
assertEquals(4, col.getMin()); // POI 3
assertEquals(4, col.getMax());
- assertEquals(33.0, col.getWidth());
+ assertEquals(33.0, col.getWidth(), 0.0);
}
-
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Tue Aug 18 02:41:45 2009
@@ -20,31 +20,26 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
-import java.util.zip.CRC32;
import java.util.List;
+import java.util.zip.CRC32;
-import junit.framework.TestCase;
-
+import org.apache.poi.POIXMLProperties;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.openxml4j.opc.*;
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
+import org.apache.poi.ss.usermodel.*;
import org.apache.poi.util.TempFile;
-import org.apache.poi.POIXMLProperties;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.model.StylesTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
public final class TestXSSFWorkbook extends BaseTestWorkbook {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
+ @Override
+ protected XSSFITestDataProvider getTestDataProvider(){
+ return XSSFITestDataProvider.getInstance();
+ }
/**
@@ -53,94 +48,94 @@
public void testSaveLoadNew() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook();
- //check that the default date system is set to 1900
- CTWorkbookPr pr = workbook.getCTWorkbook().getWorkbookPr();
- assertNotNull(pr);
- assertTrue(pr.isSetDate1904());
- assertFalse("XSSF must use the 1900 date system", pr.getDate1904());
+ //check that the default date system is set to 1900
+ CTWorkbookPr pr = workbook.getCTWorkbook().getWorkbookPr();
+ assertNotNull(pr);
+ assertTrue(pr.isSetDate1904());
+ assertFalse("XSSF must use the 1900 date system", pr.getDate1904());
- Sheet sheet1 = workbook.createSheet("sheet1");
+ Sheet sheet1 = workbook.createSheet("sheet1");
Sheet sheet2 = workbook.createSheet("sheet2");
workbook.createSheet("sheet3");
-
+
RichTextString rts = workbook.getCreationHelper().createRichTextString("hello world");
-
+
sheet1.createRow(0).createCell((short)0).setCellValue(1.2);
sheet1.createRow(1).createCell((short)0).setCellValue(rts);
sheet2.createRow(0);
-
+
assertEquals(0, workbook.getSheetAt(0).getFirstRowNum());
assertEquals(1, workbook.getSheetAt(0).getLastRowNum());
assertEquals(0, workbook.getSheetAt(1).getFirstRowNum());
assertEquals(0, workbook.getSheetAt(1).getLastRowNum());
assertEquals(0, workbook.getSheetAt(2).getFirstRowNum());
assertEquals(0, workbook.getSheetAt(2).getLastRowNum());
-
+
File file = TempFile.createTempFile("poi-", ".xlsx");
OutputStream out = new FileOutputStream(file);
workbook.write(out);
out.close();
-
+
// Check the package contains what we'd expect it to
OPCPackage pkg = OPCPackage.open(file.toString());
- PackagePart wbRelPart =
+ PackagePart wbRelPart =
pkg.getPart(PackagingURIHelper.createPartName("/xl/_rels/workbook.xml.rels"));
assertNotNull(wbRelPart);
assertTrue(wbRelPart.isRelationshipPart());
assertEquals(ContentTypes.RELATIONSHIPS_PART, wbRelPart.getContentType());
-
- PackagePart wbPart =
+
+ PackagePart wbPart =
pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
// Links to the three sheets, shared strings and styles
assertTrue(wbPart.hasRelationships());
assertEquals(5, wbPart.getRelationships().size());
-
+
// Load back the XSSFWorkbook
workbook = new XSSFWorkbook(pkg);
assertEquals(3, workbook.getNumberOfSheets());
assertNotNull(workbook.getSheetAt(0));
assertNotNull(workbook.getSheetAt(1));
assertNotNull(workbook.getSheetAt(2));
-
+
assertNotNull(workbook.getSharedStringSource());
assertNotNull(workbook.getStylesSource());
-
+
assertEquals(0, workbook.getSheetAt(0).getFirstRowNum());
assertEquals(1, workbook.getSheetAt(0).getLastRowNum());
assertEquals(0, workbook.getSheetAt(1).getFirstRowNum());
assertEquals(0, workbook.getSheetAt(1).getLastRowNum());
assertEquals(0, workbook.getSheetAt(2).getFirstRowNum());
assertEquals(0, workbook.getSheetAt(2).getLastRowNum());
-
+
sheet1 = workbook.getSheetAt(0);
assertEquals(1.2, sheet1.getRow(0).getCell(0).getNumericCellValue(), 0.0001);
assertEquals("hello world", sheet1.getRow(1).getCell(0).getRichStringCellValue().getString());
}
-
+
public void testExisting() throws Exception {
-
+
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
assertNotNull(workbook.getSharedStringSource());
assertNotNull(workbook.getStylesSource());
-
+
// And check a few low level bits too
OPCPackage pkg = OPCPackage.open(HSSFTestDataSamples.openSampleFileStream("Formatting.xlsx"));
- PackagePart wbPart =
+ PackagePart wbPart =
pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
-
+
// Links to the three sheets, shared, styles and themes
assertTrue(wbPart.hasRelationships());
assertEquals(6, wbPart.getRelationships().size());
}
-
+
public void testGetCellStyleAt(){
XSSFWorkbook workbook = new XSSFWorkbook();
short i = 0;
//get default style
CellStyle cellStyleAt = workbook.getCellStyleAt(i);
assertNotNull(cellStyleAt);
-
+
//get custom style
StylesTable styleSource = workbook.getStylesSource();
XSSFCellStyle customStyle = new XSSFCellStyle(styleSource);
@@ -149,9 +144,9 @@
customStyle.setFont(font);
int x = styleSource.putStyle(customStyle);
cellStyleAt = workbook.getCellStyleAt((short)x);
- assertNotNull(cellStyleAt);
+ assertNotNull(cellStyleAt);
}
-
+
public void testGetFontAt(){
XSSFWorkbook workbook = new XSSFWorkbook();
StylesTable styleSource = workbook.getStylesSource();
@@ -159,7 +154,7 @@
//get default font
Font fontAt = workbook.getFontAt(i);
assertNotNull(fontAt);
-
+
//get customized font
XSSFFont customFont = new XSSFFont();
customFont.setItalic(true);
@@ -167,23 +162,23 @@
fontAt = workbook.getFontAt((short)x);
assertNotNull(fontAt);
}
-
+
public void testGetNumCellStyles(){
XSSFWorkbook workbook = new XSSFWorkbook();
short i = workbook.getNumCellStyles();
//get default cellStyles
assertEquals(1, i);
//get wrong value
- assertNotSame(2, i);
+ assertNotSame(2, i);
}
-
+
public void testLoadSave() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
assertEquals(3, workbook.getNumberOfSheets());
assertEquals("dd/mm/yyyy", workbook.getSheetAt(0).getRow(1).getCell(0).getRichStringCellValue().getString());
assertNotNull(workbook.getSharedStringSource());
assertNotNull(workbook.getStylesSource());
-
+
// Write out, and check
// Load up again, check all still there
XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
@@ -191,7 +186,7 @@
assertNotNull(wb2.getSheetAt(0));
assertNotNull(wb2.getSheetAt(1));
assertNotNull(wb2.getSheetAt(2));
-
+
assertEquals("dd/mm/yyyy", wb2.getSheetAt(0).getRow(1).getCell(0).getRichStringCellValue().getString());
assertEquals("yyyy/mm/dd", wb2.getSheetAt(0).getRow(2).getCell(0).getRichStringCellValue().getString());
assertEquals("yyyy-mm-dd", wb2.getSheetAt(0).getRow(3).getCell(0).getRichStringCellValue().getString());
@@ -199,14 +194,14 @@
assertNotNull(wb2.getSharedStringSource());
assertNotNull(wb2.getStylesSource());
}
-
+
public void testStyles() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
-
+
StylesTable ss = workbook.getStylesSource();
assertNotNull(ss);
StylesTable st = ss;
-
+
// Has 8 number formats
assertEquals(8, st._getNumberFormatSize());
// Has 2 fonts
@@ -215,20 +210,20 @@
assertEquals(2, st.getFills().size());
// Has 1 border
assertEquals(1, st.getBorders().size());
-
+
// Add two more styles
- assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
+ assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
st.putNumberFormat("testFORMAT"));
- assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
+ assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
st.putNumberFormat("testFORMAT"));
- assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
+ assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
st.putNumberFormat("testFORMAT2"));
assertEquals(10, st._getNumberFormatSize());
-
-
+
+
// Save, load back in again, and check
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-
+
ss = workbook.getStylesSource();
assertNotNull(ss);
@@ -238,77 +233,77 @@
assertEquals(1, st.getBorders().size());
}
- public void testIncrementSheetId() throws Exception {
- XSSFWorkbook wb = getTestDataProvider().createWorkbook();
- int sheetId = (int)wb.createSheet().sheet.getSheetId();
- assertEquals(1, sheetId);
- sheetId = (int)wb.createSheet().sheet.getSheetId();
- assertEquals(2, sheetId);
-
- //test file with gaps in the sheetId sequence
- wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
- int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
- sheetId = (int)wb.createSheet().sheet.getSheetId();
- assertEquals(lastSheetId+1, sheetId);
- }
-
- /**
- * Test setting of core properties such as Title and Author
- */
- public void testWorkbookProperties() throws Exception {
- XSSFWorkbook workbook = new XSSFWorkbook();
- POIXMLProperties props = workbook.getProperties();
- assertNotNull(props);
- //the Application property must be set for new workbooks, see Bugzilla #47559
- assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
-
- PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
- assertNotNull(opcProps);
-
- opcProps.setTitleProperty("Testing Bugzilla #47460");
- assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
- opcProps.setCreatorProperty("poi-dev@poi.apache.org");
-
- workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
- assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
- opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
- assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
- assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
- }
-
- /**
- * Verify that the attached test data was not modified. If this test method
- * fails, the test data is not working properly.
- */
- public void test47668() throws Exception {
- XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("47668.xlsx");
- List<XSSFPictureData> allPictures = workbook.getAllPictures();
- assertEquals(2, allPictures.size());
-
- PackagePartName imagePartName = PackagingURIHelper
- .createPartName("/xl/media/image1.jpeg");
- PackagePart imagePart = workbook.getPackage().getPart(imagePartName);
- assertNotNull(imagePart);
-
- for (XSSFPictureData pictureData : allPictures) {
- PackagePart picturePart = pictureData.getPackagePart();
- assertSame(imagePart, picturePart);
- }
-
- XSSFSheet sheet0 = workbook.getSheetAt(0);
- XSSFDrawing drawing0 = sheet0.createDrawingPatriarch();
- XSSFPictureData pictureData0 = (XSSFPictureData) drawing0.getRelations().get(0);
- byte[] data0 = pictureData0.getData();
- CRC32 crc0 = new CRC32();
- crc0.update(data0);
-
- XSSFSheet sheet1 = workbook.getSheetAt(1);
- XSSFDrawing drawing1 = sheet1.createDrawingPatriarch();
- XSSFPictureData pictureData1 = (XSSFPictureData) drawing1.getRelations().get(0);
- byte[] data1 = pictureData1.getData();
- CRC32 crc1 = new CRC32();
- crc1.update(data1);
+ public void testIncrementSheetId() {
+ XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+ int sheetId = (int)wb.createSheet().sheet.getSheetId();
+ assertEquals(1, sheetId);
+ sheetId = (int)wb.createSheet().sheet.getSheetId();
+ assertEquals(2, sheetId);
+
+ //test file with gaps in the sheetId sequence
+ wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
+ int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
+ sheetId = (int)wb.createSheet().sheet.getSheetId();
+ assertEquals(lastSheetId+1, sheetId);
+ }
+
+ /**
+ * Test setting of core properties such as Title and Author
+ */
+ public void testWorkbookProperties() {
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ POIXMLProperties props = workbook.getProperties();
+ assertNotNull(props);
+ //the Application property must be set for new workbooks, see Bugzilla #47559
+ assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
+
+ PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
+ assertNotNull(opcProps);
+
+ opcProps.setTitleProperty("Testing Bugzilla #47460");
+ assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
+ opcProps.setCreatorProperty("poi-dev@poi.apache.org");
+
+ workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+ assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
+ opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
+ assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
+ assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
+ }
+
+ /**
+ * Verify that the attached test data was not modified. If this test method
+ * fails, the test data is not working properly.
+ */
+ public void test47668() throws Exception {
+ XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("47668.xlsx");
+ List<XSSFPictureData> allPictures = workbook.getAllPictures();
+ assertEquals(2, allPictures.size());
+
+ PackagePartName imagePartName = PackagingURIHelper
+ .createPartName("/xl/media/image1.jpeg");
+ PackagePart imagePart = workbook.getPackage().getPart(imagePartName);
+ assertNotNull(imagePart);
+
+ for (XSSFPictureData pictureData : allPictures) {
+ PackagePart picturePart = pictureData.getPackagePart();
+ assertSame(imagePart, picturePart);
+ }
+
+ XSSFSheet sheet0 = workbook.getSheetAt(0);
+ XSSFDrawing drawing0 = sheet0.createDrawingPatriarch();
+ XSSFPictureData pictureData0 = (XSSFPictureData) drawing0.getRelations().get(0);
+ byte[] data0 = pictureData0.getData();
+ CRC32 crc0 = new CRC32();
+ crc0.update(data0);
+
+ XSSFSheet sheet1 = workbook.getSheetAt(1);
+ XSSFDrawing drawing1 = sheet1.createDrawingPatriarch();
+ XSSFPictureData pictureData1 = (XSSFPictureData) drawing1.getRelations().get(0);
+ byte[] data1 = pictureData1.getData();
+ CRC32 crc1 = new CRC32();
+ crc1.update(data1);
- assertEquals(crc0.getValue(), crc1.getValue());
- }
+ assertEquals(crc0.getValue(), crc1.getValue());
+ }
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java Tue Aug 18 02:41:45 2009
@@ -22,11 +22,10 @@
import junit.framework.TestCase;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
-public class TestCTColComparator extends TestCase {
-
+public final class TestCTColComparator extends TestCase {
+
public void testCompare() {
CTColComparator comparator = new CTColComparator();
CTCol o1 = CTCol.Factory.newInstance();
@@ -44,7 +43,7 @@
o4.setMax(80);
assertEquals(-1, comparator.compare(o3, o4));
}
-
+
public void testArraysSort() {
CTColComparator comparator = new CTColComparator();
CTCol o1 = CTCol.Factory.newInstance();
@@ -73,5 +72,4 @@
assertEquals(8, cols[1].getMax());
assertEquals(80, cols[2].getMax());
}
-
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java Tue Aug 18 02:41:45 2009
@@ -21,7 +21,7 @@
import junit.framework.TestCase;
-import org.openxmlformats.schemas.officeDocument.x2006.math.STSpacingRule;
+import org.apache.poi.POIXMLDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
@@ -40,29 +40,27 @@
/**
* Tests for XWPF Paragraphs
*/
-public class TestXWPFParagraph extends TestCase {
+public final class TestXWPFParagraph extends TestCase {
/**
* A simple file
*/
private XWPFDocument xml;
- private File file;
-/*
+
protected void setUp() throws Exception {
super.setUp();
- file = new File(
+ File file = new File(
System.getProperty("HWPF.testdata.path") +
File.separator + "ThreeColHead.docx"
);
assertTrue(file.exists());
xml = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
}
-*/
+
/**
* Check that we get the right paragraph from the header
*/
- /*
- public void testHeaderParagraph() throws Exception {
+ public void disabled_testHeaderParagraph() {
XWPFHeader hdr = xml.getHeaderFooterPolicy().getDefaultHeader();
assertNotNull(hdr);
@@ -74,12 +72,11 @@
assertEquals("First header column!\tMid header\tRight header!", p
.getText());
}
-*/
+
/**
* Check that we get the right paragraphs from the document
*/
- /*
- public void testDocumentParagraph() throws Exception {
+ public void disabled_testDocumentParagraph() {
XWPFParagraph[] ps = xml.getParagraphs();
assertEquals(10, ps.length);
@@ -100,23 +97,23 @@
assertFalse(ps[4].isEmpty());
assertEquals("More on page one", ps[4].getText());
}
-*/
+
public void testSetGetBorderTop() {
//new clean instance of paragraph
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();
assertEquals(STBorder.NONE.intValue(), p.getBorderTop().getValue());
-
+
CTP ctp = p.getCTP();
CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
-
+
//bordi
CTPBdr bdr = ppr.addNewPBdr();
CTBorder borderTop = bdr.addNewTop();
borderTop.setVal(STBorder.DOUBLE);
bdr.setTop(borderTop);
-
+
assertEquals(Borders.DOUBLE, p.getBorderTop());
p.setBorderTop(Borders.SINGLE);
assertEquals(STBorder.SINGLE, borderTop.getVal());
@@ -128,7 +125,7 @@
XWPFParagraph p = doc.createParagraph();
assertEquals(STJc.LEFT.intValue(), p.getAlignment().getValue());
-
+
CTP ctp = p.getCTP();
CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
@@ -140,7 +137,7 @@
assertEquals(STJc.BOTH, ppr.getJc().getVal());
}
-
+
public void testSetGetSpacing() {
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();
@@ -149,7 +146,7 @@
CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
assertEquals(-1, p.getSpacingAfter());
-
+
CTSpacing spacing = ppr.addNewSpacing();
spacing.setAfter(new BigInteger("10"));
assertEquals(10, p.getSpacingAfter());
@@ -166,7 +163,7 @@
CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
assertEquals(STLineSpacingRule.INT_AUTO, p.getSpacingLineRule().getValue());
-
+
CTSpacing spacing = ppr.addNewSpacing();
spacing.setLineRule(STLineSpacingRule.AT_LEAST);
assertEquals(LineSpacingRule.AT_LEAST, p.getSpacingLineRule());
@@ -174,18 +171,18 @@
p.setSpacingAfter(100);
assertEquals(100, spacing.getAfter().intValue());
}
-
+
public void testSetGetIndentation() {
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();
assertEquals(-1, p.getIndentationLeft());
-
+
CTP ctp = p.getCTP();
CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
assertEquals(-1, p.getIndentationLeft());
-
+
CTInd ind = ppr.addNewInd();
ind.setLeft(new BigInteger("10"));
assertEquals(10, p.getIndentationLeft());
@@ -193,7 +190,7 @@
p.setIndentationLeft(100);
assertEquals(100, ind.getLeft().intValue());
}
-
+
public void testSetGetVerticalAlignment() {
//new clean instance of paragraph
XWPFDocument doc = new XWPFDocument();
@@ -240,6 +237,4 @@
p.setPageBreak(true);
assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal());
}
-
-
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java Tue Aug 18 02:41:45 2009
@@ -17,16 +17,12 @@
package org.apache.poi.hdf.extractor;
-import java.util.*;
-
/**
* Comment me
*
* @author Ryan Ackley
*/
-
-public final class StyleSheet
-{
+public final class StyleSheet {
private static final int NIL_STYLE = 4095;
private static final int PAP_TYPE = 1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org