From 958a47a45384bd7a43239e5ebe5343599498c82f Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Tue, 28 Oct 2008 10:03:51 +0000 Subject: [PATCH] 1. moved ooxml enums into interfaces-jdk15, they are common and should be in the place as the interfaces 2. removed obsolete and deprecated classes 3. Fixed XSSFWorkbook.cloneSheet. Now it makes a 'true' deep copy of a sheet 4. ooxml has a compile-time dependency on scratchpad, fixed build.xml to reflect that git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@708497 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 2 +- .../usermodel/examples/FillsAndColors.java | 8 +- .../usermodel/examples/HyperlinkExample.java | 10 +- .../examples/WorkingWithBorders.java | 2 +- .../usermodel/examples/WorkingWithFonts.java | 6 +- .../examples/WorkingWithRichText.java | 5 - .../poi/hssf/usermodel/HSSFPalette.java | 3 +- .../poi/hssf/usermodel/HSSFPatriarch.java | 3 +- .../apache/poi/ss}/usermodel/BorderStyle.java | 2 +- .../apache/poi/ss/usermodel/CellStyle.java | 56 ++------ .../poi/ss/usermodel/CommentsSource.java | 36 ----- .../poi/ss}/usermodel/FillPatternType.java | 2 +- .../apache/poi/ss}/usermodel/FontCharset.java | 2 +- .../apache/poi/ss}/usermodel/FontFamily.java | 2 +- .../apache/poi/ss}/usermodel/FontScheme.java | 2 +- .../poi/ss/usermodel/FontUndeline.java} | 0 .../ss}/usermodel/HorizontalAlignment.java | 2 +- .../poi/ss}/usermodel/IndexedColors.java | 2 +- .../apache/poi/ss}/usermodel/PageOrder.java | 2 +- .../org/apache/poi/ss/usermodel/Palette.java | 75 ----------- .../apache/poi/ss}/usermodel/PaperSize.java | 2 +- .../apache/poi/ss/usermodel/Patriarch.java | 124 ------------------ .../poi/ss}/usermodel/PrintCellComments.java | 2 +- .../poi/ss}/usermodel/PrintOrientation.java | 2 +- .../org/apache/poi/ss/usermodel/Row.java | 4 - .../apache/poi/ss}/usermodel/ShapeTypes.java | 2 +- .../org/apache/poi/ss/usermodel/Sheet.java | 14 +- .../apache/poi/ss/usermodel/StylesSource.java | 30 ----- .../poi/ss}/usermodel/VerticalAlignment.java | 2 +- .../org/apache/poi/ss/usermodel/Workbook.java | 54 ++------ .../org/apache/poi/xssf/model/BinaryPart.java | 67 ---------- .../apache/poi/xssf/model/CommentsTable.java | 2 - .../org/apache/poi/xssf/model/Control.java | 99 -------------- .../org/apache/poi/xssf/model/Drawing.java | 94 ------------- .../poi/xssf/model/SharedStringSource.java | 28 ---- .../apache/poi/xssf/model/StylesTable.java | 6 +- .../org/apache/poi/xssf/model/ThemeTable.java | 67 ---------- .../poi/xssf/usermodel/XSSFCellStyle.java | 10 +- .../poi/xssf/usermodel/XSSFComment.java | 1 - .../poi/xssf/usermodel/XSSFConnector.java | 8 +- .../poi/xssf/usermodel/XSSFDataFormat.java | 1 - .../poi/xssf/usermodel/XSSFDrawing.java | 4 +- .../xssf/usermodel/XSSFEvaluationCell.java | 2 +- .../usermodel/XSSFEvaluationWorkbook.java | 2 +- .../apache/poi/xssf/usermodel/XSSFFont.java | 10 +- .../poi/xssf/usermodel/XSSFPrintSetup.java | 2 +- .../apache/poi/xssf/usermodel/XSSFSheet.java | 25 ++-- .../poi/xssf/usermodel/XSSFSimpleShape.java | 10 +- .../poi/xssf/usermodel/XSSFWorkbook.java | 110 +++++++++------- .../extensions/XSSFCellAlignment.java | 4 +- .../usermodel/extensions/XSSFCellBorder.java | 2 +- .../poi/xssf/usermodel/TestXSSFCellStyle.java | 5 +- .../poi/xssf/usermodel/TestXSSFFont.java | 6 +- .../xssf/usermodel/TestXSSFPrintSetup.java | 4 + .../poi/xssf/usermodel/TestXSSFWorkbook.java | 80 +++++------ .../usermodel/extensions/TestXSSFBorder.java | 2 +- .../extensions/TestXSSFCellFill.java | 1 - 57 files changed, 199 insertions(+), 911 deletions(-) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/BorderStyle.java (98%) delete mode 100644 src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CommentsSource.java rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/FillPatternType.java (98%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/FontCharset.java (98%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/FontFamily.java (97%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/FontScheme.java (97%) rename src/ooxml/{java/org/apache/poi/xssf/usermodel/FontUnderline.java => interfaces-jdk15/org/apache/poi/ss/usermodel/FontUndeline.java} (100%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/HorizontalAlignment.java (96%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/IndexedColors.java (98%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/PageOrder.java (97%) delete mode 100644 src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Palette.java rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/PaperSize.java (97%) delete mode 100644 src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Patriarch.java rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/PrintCellComments.java (97%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/PrintOrientation.java (97%) rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/ShapeTypes.java (97%) delete mode 100644 src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/StylesSource.java rename src/ooxml/{java/org/apache/poi/xssf => interfaces-jdk15/org/apache/poi/ss}/usermodel/VerticalAlignment.java (96%) delete mode 100644 src/ooxml/java/org/apache/poi/xssf/model/BinaryPart.java delete mode 100644 src/ooxml/java/org/apache/poi/xssf/model/Control.java delete mode 100644 src/ooxml/java/org/apache/poi/xssf/model/Drawing.java delete mode 100644 src/ooxml/java/org/apache/poi/xssf/model/SharedStringSource.java delete mode 100755 src/ooxml/java/org/apache/poi/xssf/model/ThemeTable.java diff --git a/build.xml b/build.xml index cbb3a252bb..310585ca30 100644 --- a/build.xml +++ b/build.xml @@ -519,7 +519,7 @@ under the License. - + diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java index 21efd3d6c3..eb4ce69c94 100755 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java @@ -18,12 +18,8 @@ package org.apache.poi.xssf.usermodel.examples; import java.io.FileOutputStream; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -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.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.xssf.usermodel.XSSFRichTextString; import org.apache.poi.xssf.usermodel.XSSFWorkbook; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java index 71e871cdd4..4e4c4c6477 100755 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java @@ -18,15 +18,9 @@ package org.apache.poi.xssf.usermodel.examples; import java.io.FileOutputStream; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.CreationHelper; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Hyperlink; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xssf.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.IndexedColors; /** * Demonstrates how to create hyperlinks. diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java index baca54c2ca..ee8e172d5e 100755 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java @@ -17,7 +17,7 @@ package org.apache.poi.xssf.usermodel.examples; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xssf.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.*; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java index 30991e13f7..c5d814b438 100755 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java @@ -16,13 +16,9 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel.examples; -import org.apache.poi.hssf.usermodel.HSSFFont; -import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFRichTextString; -import org.apache.poi.xssf.usermodel.IndexedColors; -import org.apache.poi.xssf.usermodel.extensions.XSSFColor; +import org.apache.poi.ss.usermodel.IndexedColors; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java index c8bb2f0223..34cb556c30 100755 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java @@ -18,13 +18,8 @@ package org.apache.poi.xssf.usermodel.examples; import org.apache.poi.xssf.usermodel.*; import org.apache.poi.ss.usermodel.*; -import org.apache.poi.hssf.util.HSSFColor; -import org.apache.xmlbeans.XmlOptions; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; import java.io.FileOutputStream; -import java.io.Writer; -import java.io.StringWriter; /** * Demonstrates how to work with rich text diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java index 4ec8e0dd02..4c9d63ebc4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java @@ -19,7 +19,6 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.record.PaletteRecord; import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.Palette; /** * Represents a workbook color palette. @@ -29,7 +28,7 @@ import org.apache.poi.ss.usermodel.Palette; * * @author Brian Sanders (bsanders at risklabs dot com) */ -public class HSSFPalette implements Palette +public class HSSFPalette { private PaletteRecord palette; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java index 2d3d6781ca..98af6e07da 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java @@ -25,7 +25,6 @@ import org.apache.poi.ddf.EscherComplexProperty; import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherProperty; import org.apache.poi.hssf.record.EscherAggregate; -import org.apache.poi.ss.usermodel.Patriarch; import org.apache.poi.util.StringUtil; /** @@ -35,7 +34,7 @@ import org.apache.poi.util.StringUtil; * @author Glen Stampoultzis (glens at apache.org) */ public class HSSFPatriarch - implements HSSFShapeContainer, Patriarch + implements HSSFShapeContainer { List shapes = new ArrayList(); HSSFSheet sheet; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/BorderStyle.java similarity index 98% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/BorderStyle.java index a9d596931c..7342c52261 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/BorderStyle.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * The enumeration value indicating the line style of a border in a cell, diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CellStyle.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CellStyle.java index a87ba53338..49e67fcb64 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CellStyle.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CellStyle.java @@ -227,7 +227,7 @@ public interface CellStyle { public final static short LEAST_DOTS = 18; /** - * get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects) + * get the index within the Workbook (sequence within the collection of ExtnededFormat objects) * @return unique index number of the underlying record this style represents (probably you don't care * unless you're comparing which one is which) */ @@ -236,14 +236,14 @@ public interface CellStyle { /** * set the data format (must be a valid format) - * @see org.apache.poi.hssf.usermodel.HSSFDataFormat + * @see DataFormat */ void setDataFormat(short fmt); /** * get the index of the format - * @see org.apache.poi.hssf.usermodel.HSSFDataFormat + * @see DataFormat */ short getDataFormat(); @@ -252,27 +252,18 @@ public interface CellStyle { */ public String getDataFormatString(); - /** - * Get the contents of the format string, by looking up - * the DataFormat against the supplied workbook - * @see org.apache.poi.hssf.usermodel.HSSFDataFormat - * XXX Commented out because it uses internal implementation Workbook class. - * - String getDataFormatString(Workbook workbook); - */ - /** * set the font for this style - * @param font a font object created or retreived from the HSSFWorkbook object - * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont() - * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) + * @param font a font object created or retreived from the Workbook object + * @see Workbook#createFont() + * @see Workbook#getFontAt(short) */ void setFont(Font font); /** * gets the index of the font for this style - * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) + * @see Workbook#getFontAt(short) */ short getFontIndex(); @@ -571,8 +562,6 @@ public interface CellStyle { /** * get the color to use for the left border - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) - * @param color The index of the color definition */ short getLeftBorderColor(); @@ -584,8 +573,7 @@ public interface CellStyle { /** * get the color to use for the left border - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) - * @param color The index of the color definition + * @return the index of the color definition */ short getRightBorderColor(); @@ -597,8 +585,7 @@ public interface CellStyle { /** * get the color to use for the top border - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) - * @param color The index of the color definition + * @return hhe index of the color definition */ short getTopBorderColor(); @@ -610,8 +597,7 @@ public interface CellStyle { /** * get the color to use for the left border - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) - * @param color The index of the color definition + * @return the index of the color definition */ short getBottomBorderColor(); @@ -650,26 +636,6 @@ public interface CellStyle { /** * set the background fill color. - *

- * For example: - *

-     * cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
-     * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex()); 
-     * 
- * optionally a Foreground and background fill can be applied: - * Note: Ensure Foreground color is set prior to background - *
-     * cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
-     * cs.setFillForegroundColor(new HSSFColor.BLUE().getIndex());
-     * cs.setFillBackgroundColor(new HSSFColor.RED().getIndex()); 
-     * 
- * or, for the special case of SOLID_FILL: - *
-     * cs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
-     * cs.setFillForegroundColor(new HSSFColor.RED().getIndex());
-     * 
- * It is necessary to set the fill style in order - * for the color to be shown in the cell. * * @param bg color */ @@ -678,7 +644,6 @@ public interface CellStyle { /** * get the background fill color - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @return fill color */ short getFillBackgroundColor(); @@ -692,7 +657,6 @@ public interface CellStyle { /** * get the foreground fill color - * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @return fill color */ short getFillForegroundColor(); diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CommentsSource.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CommentsSource.java deleted file mode 100644 index 34cb1bdf96..0000000000 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CommentsSource.java +++ /dev/null @@ -1,36 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -/** - * Allows the getting and saving of cell comments, - * associated with a given sheet. - */ -public interface CommentsSource { - public String getAuthor(long authorId); - - public int getNumberOfComments(); - - public int findAuthor(String author); - - public Comment findCellComment(int row, int column); - - public Comment findCellComment(String cellRef); - - public Comment addComment(); -} diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FillPatternType.java similarity index 98% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FillPatternType.java index 36e3c9e255..25c8495b0e 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FillPatternType.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * The enumeration value indicating the style of fill pattern being used for a cell format. diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontCharset.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontCharset.java similarity index 98% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/FontCharset.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontCharset.java index 215ccec991..ba06d8cc8f 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontCharset.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontCharset.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontFamily.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontFamily.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/FontFamily.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontFamily.java index dc34e76bf3..829246678e 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontFamily.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontFamily.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontScheme.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontScheme.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/FontScheme.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontScheme.java index 6576fbbbbf..e1b7712309 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontScheme.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontScheme.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/FontUnderline.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontUndeline.java similarity index 100% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/FontUnderline.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FontUndeline.java diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/HorizontalAlignment.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/HorizontalAlignment.java similarity index 96% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/HorizontalAlignment.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/HorizontalAlignment.java index da2c153532..bcc05d8fbf 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/HorizontalAlignment.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/HorizontalAlignment.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * The enumeration value indicating horizontal alignment of a cell, diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColors.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/IndexedColors.java similarity index 98% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColors.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/IndexedColors.java index 45e6dd3bb1..07237471aa 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColors.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/IndexedColors.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * A deprecated indexing scheme for colours that is still required for some records, and for backwards diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PageOrder.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PageOrder.java index 7aa7a90da1..341f2bf72a 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/PageOrder.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PageOrder.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * Specifies printed page order. diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Palette.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Palette.java deleted file mode 100644 index 8a4cf8bb7b..0000000000 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Palette.java +++ /dev/null @@ -1,75 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -public interface Palette { - - /** - * Retrieves the color at a given index - * - * @param index the palette index, between 0x8 to 0x40 inclusive - * @return the color, or null if the index is not populated - */ - Color getColor(short index); - - /** - * Finds the first occurance of a given color - * - * @param red the RGB red component, between 0 and 255 inclusive - * @param green the RGB green component, between 0 and 255 inclusive - * @param blue the RGB blue component, between 0 and 255 inclusive - * @return the color, or null if the color does not exist in this palette - */ - Color findColor(byte red, byte green, byte blue); - - /** - * Finds the closest matching color in the custom palette. The - * method for finding the distance between the colors is fairly - * primative. - * - * @param red The red component of the color to match. - * @param green The green component of the color to match. - * @param blue The blue component of the color to match. - * @return The closest color or null if there are no custom - * colors currently defined. - */ - Color findSimilarColor(byte red, byte green, byte blue); - - /** - * Sets the color at the given offset - * - * @param index the palette index, between 0x8 to 0x40 inclusive - * @param red the RGB red component, between 0 and 255 inclusive - * @param green the RGB green component, between 0 and 255 inclusive - * @param blue the RGB blue component, between 0 and 255 inclusive - */ - void setColorAtIndex(short index, byte red, byte green, byte blue); - - /** - * Adds a new color into an empty color slot. - * @param red The red component - * @param green The green component - * @param blue The blue component - * - * @return The new custom color. - * - * @throws RuntimeException if there are more more free color indexes. - */ - Color addColor(byte red, byte green, byte blue); - -} \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PaperSize.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PaperSize.java index 359e0d7139..cebab20381 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/PaperSize.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PaperSize.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * The enumeration value indicating the possible paper size for a sheet diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Patriarch.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Patriarch.java deleted file mode 100644 index 9026c99bb7..0000000000 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Patriarch.java +++ /dev/null @@ -1,124 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -import java.util.List; - -import org.apache.poi.hssf.usermodel.HSSFAnchor; -import org.apache.poi.hssf.usermodel.HSSFClientAnchor; -import org.apache.poi.hssf.usermodel.HSSFComment; -import org.apache.poi.hssf.usermodel.HSSFPicture; -import org.apache.poi.hssf.usermodel.HSSFPolygon; -import org.apache.poi.hssf.usermodel.HSSFShapeGroup; -import org.apache.poi.hssf.usermodel.HSSFSimpleShape; -import org.apache.poi.hssf.usermodel.HSSFTextbox; - -public interface Patriarch { - - /** - * Creates a new group record stored under this patriarch. - * - * @param anchor the client anchor describes how this group is attached - * to the sheet. - * @return the newly created group. - */ - HSSFShapeGroup createGroup(HSSFClientAnchor anchor); - - /** - * Creates a simple shape. This includes such shapes as lines, rectangles, - * and ovals. - * - * @param anchor the client anchor describes how this group is attached - * to the sheet. - * @return the newly created shape. - */ - HSSFSimpleShape createSimpleShape(HSSFClientAnchor anchor); - - /** - * Creates a picture. - * - * @param anchor the client anchor describes how this group is attached - * to the sheet. - * @return the newly created shape. - */ - HSSFPicture createPicture(HSSFClientAnchor anchor, int pictureIndex); - - /** - * Creates a polygon - * - * @param anchor the client anchor describes how this group is attached - * to the sheet. - * @return the newly created shape. - */ - HSSFPolygon createPolygon(HSSFClientAnchor anchor); - - /** - * Constructs a textbox under the patriarch. - * - * @param anchor the client anchor describes how this group is attached - * to the sheet. - * @return the newly created textbox. - */ - HSSFTextbox createTextbox(HSSFClientAnchor anchor); - - /** - * Constructs a cell comment. - * - * @param anchor the client anchor describes how this comment is attached - * to the sheet. - * @return the newly created comment. - */ - HSSFComment createComment(HSSFAnchor anchor); - - /** - * Returns a list of all shapes contained by the patriarch. - */ - List getChildren(); - - /** - * Total count of all children and their children's children. - */ - int countOfAllChildren(); - - /** - * Sets the coordinate space of this group. All children are contrained - * to these coordinates. - */ - void setCoordinates(int x1, int y1, int x2, int y2); - - /** - * The top left x coordinate of this group. - */ - int getX1(); - - /** - * The top left y coordinate of this group. - */ - int getY1(); - - /** - * The bottom right x coordinate of this group. - */ - int getX2(); - - /** - * The bottom right y coordinate of this group. - */ - int getY2(); - -} \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintCellComments.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintCellComments.java index 31c392be6a..ecbea6dafe 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintCellComments.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintCellComments.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * These enumerations specify how cell comments shall be displayed for paper printing purposes. diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintOrientation.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintOrientation.java index 4215acd9e6..8d5716f31e 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/PrintOrientation.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/PrintOrientation.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * The enumeration value indicating the print orientation for a sheet. diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java index 1c2efd0c35..f63ee010b2 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java @@ -21,10 +21,6 @@ import java.lang.Iterable; import java.util.Iterator; public interface Row extends Iterable { - - // used for collections - public final static int INITIAL_CAPACITY = 5; - /** * Use this to create new cells within the row and return it. *

diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ShapeTypes.java similarity index 97% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ShapeTypes.java index afe471fb22..ef8409340c 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/ShapeTypes.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ShapeTypes.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * All known types of automatic shapes in DrawingML diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java index d4b1c07c68..b29d1d037e 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java @@ -45,20 +45,12 @@ public interface Sheet extends Iterable { public static final byte PANE_UPPER_LEFT = (byte) 3; - /** - * Used for compile-time optimization. This is the initial size for the collection of - * rows. It is currently set to 20. If you generate larger sheets you may benefit - * by setting this to a higher number and recompiling a custom edition of HSSFSheet. - */ - - public final static int INITIAL_CAPACITY = 20; - /** * Create a new row within the sheet and return the high level representation * * @param rownum row number - * @return High level HSSFRow object representing a row in the sheet - * @see org.apache.poi.hssf.usermodel.HSSFRow + * @return High level Row object representing a row in the sheet + * @see Row * @see #removeRow(Row) */ Row createRow(int rownum); @@ -75,7 +67,7 @@ public interface Sheet extends Iterable { * Returns the logical row (not physical) 0-based. If you ask for a row that is not * defined you get a null. This is to say row 4 represents the fifth row on a sheet. * @param rownum row to get - * @return HSSFRow representing the rownumber or null if its not defined on the sheet + * @return Row representing the rownumber or null if its not defined on the sheet */ Row getRow(int rownum); diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/StylesSource.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/StylesSource.java deleted file mode 100644 index f5a9d6deb6..0000000000 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/StylesSource.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ -package org.apache.poi.ss.usermodel; - - - -public interface StylesSource { - public String getNumberFormatAt(long idx); - public long putNumberFormat(String fmt); - - public Font getFontAt(long idx); - public long putFont(Font font); - - public CellStyle getStyleAt(long idx); - public long putStyle(CellStyle style); -} diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/VerticalAlignment.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/VerticalAlignment.java similarity index 96% rename from src/ooxml/java/org/apache/poi/xssf/usermodel/VerticalAlignment.java rename to src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/VerticalAlignment.java index e583336108..2f93273287 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/VerticalAlignment.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/VerticalAlignment.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel; +package org.apache.poi.ss.usermodel; /** * This enumeration value indicates the type of vertical alignment for a cell, i.e., diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java index bca3b5e0f2..c7bd0f8ac2 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java @@ -25,15 +25,6 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; public interface Workbook { - /** - * used for compile-time performance/memory optimization. This determines the - * initial capacity for the sheet collection. Its currently set to 3. - * Changing it in this release will decrease performance - * since you're never allowed to have more or less than three sheets! - */ - - public final static int INITIAL_CAPACITY = 3; - /** Extended windows meta file */ public static final int PICTURE_TYPE_EMF = 2; @@ -72,20 +63,11 @@ public interface Workbook { * This may be different from the "selected sheet" since excel seems to * allow you to show the data of one sheet when another is seen "selected" * in the tabs (at the bottom). - * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean) + * @see Sheet#setSelected(boolean) * @param index */ void setSelectedTab(short index); - /** - * gets the tab whose data is actually seen when the sheet is opened. - * This may be different from the "selected sheet" since excel seems to - * allow you to show the data of one sheet when another is seen "selected" - * in the tabs (at the bottom). - * @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean) - */ - short getSelectedTab(); - /** * set the sheet name. * Will throw IllegalArgumentException if the name is greater than 31 chars @@ -115,28 +97,28 @@ public interface Workbook { int getSheetIndex(Sheet sheet); /** - * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns + * create an Sheet for this Workbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * - * @return HSSFSheet representing the new sheet. + * @return Sheet representing the new sheet. */ Sheet createSheet(); /** - * create an HSSFSheet from an existing sheet in the HSSFWorkbook. + * create an Sheet from an existing sheet in the Workbook. * - * @return HSSFSheet representing the cloned sheet. + * @return Sheet representing the cloned sheet. */ Sheet cloneSheet(int sheetNum); /** - * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns + * create an Sheet for this Workbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * * @param sheetname sheetname to set for the sheet. - * @return HSSFSheet representing the new sheet. + * @return Sheet representing the new sheet. */ Sheet createSheet(String sheetname); @@ -149,9 +131,9 @@ public interface Workbook { int getNumberOfSheets(); /** - * Get the HSSFSheet object at the given index. + * Get the Sheet object at the given index. * @param index of the sheet number (0-based physical & logical) - * @return HSSFSheet at the provided index + * @return Sheet at the provided index */ Sheet getSheetAt(int index); @@ -159,7 +141,7 @@ public interface Workbook { /** * Get sheet with the given name * @param name of the sheet - * @return HSSFSheet with the name provided or null if it does not exist + * @return Sheet with the name provided or null if it does not exist */ Sheet getSheet(String name); @@ -220,7 +202,7 @@ public interface Workbook { /** * get the font at the given index number * @param idx index number - * @return HSSFFont at the index + * @return XSSFFont at the index */ Font getFontAt(short idx); @@ -242,7 +224,7 @@ public interface Workbook { /** * get the cell style object at the given index * @param idx index within the set of styles - * @return HSSFCellStyle object at the index + * @return CellStyle object at the index */ CellStyle getCellStyleAt(short idx); @@ -271,12 +253,6 @@ public interface Workbook { */ Name getNameAt(int index); - /** gets the named range name - * @param index the named range index (0 based) - * @return named range name - */ - String getNameName(int index); - /** * Sets the printarea for the sheet provided *

@@ -346,10 +322,8 @@ public interface Workbook { void removeName(int index); /** - * Returns the instance of HSSFDataFormat for this workbook. - * @return the HSSFDataFormat object - * @see org.apache.poi.hssf.record.FormatRecord - * @see org.apache.poi.hssf.record.Record + * Returns the instance of DataFormat for this workbook. + * @return the DataFormat object */ DataFormat createDataFormat(); diff --git a/src/ooxml/java/org/apache/poi/xssf/model/BinaryPart.java b/src/ooxml/java/org/apache/poi/xssf/model/BinaryPart.java deleted file mode 100644 index 9582b8a61d..0000000000 --- a/src/ooxml/java/org/apache/poi/xssf/model/BinaryPart.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ -package org.apache.poi.xssf.model; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * An implementation of XSSFModel for binary parts of - * the file, eg images or vba macros - */ -public class BinaryPart implements XSSFModel { - private byte[] data; - - public BinaryPart(InputStream in) throws IOException { - readFrom(in); - } - - /** - * Fetch the contents of the binary part - */ - public byte[] getContents() { - return data; - } - /** - * Changes the contents of the binary part - */ - public void setContents(byte[] data) { - this.data = data; - } - - /** - * Reads the contents of the binary part in. - */ - public void readFrom(InputStream is) throws IOException { - int read = 0; - byte[] buffer = new byte[4096]; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - while( (read = is.read(buffer)) != -1 ) { - if(read > 0) { - baos.write(buffer, 0, read); - } - } - data = baos.toByteArray(); - } - - public void writeTo(OutputStream out) throws IOException { - out.write(data); - } -} diff --git a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java index ff32b8b7e4..b5fabd1a61 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java @@ -20,12 +20,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import org.apache.poi.ss.usermodel.CommentsSource; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.POIXMLDocumentPart; import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAuthors; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList; diff --git a/src/ooxml/java/org/apache/poi/xssf/model/Control.java b/src/ooxml/java/org/apache/poi/xssf/model/Control.java deleted file mode 100644 index 5296d7958d..0000000000 --- a/src/ooxml/java/org/apache/poi/xssf/model/Control.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.poi.xssf.model; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; - -import org.apache.poi.xssf.usermodel.XSSFActiveXData; -import org.apache.poi.xssf.usermodel.XSSFRelation; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlOptions; -import org.openxml4j.opc.PackagePart; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTControl; - -/** - * A control object in XSSF, which will typically - * have active x data associated with it. - */ -public class Control implements XSSFChildContainingModel { - private CTControl control; - private String originalId; - private ArrayList activexBins; - - public Control(InputStream is, String originalId) throws IOException { - readFrom(is); - this.originalId = originalId; - this.activexBins = new ArrayList(); - } - - public String getOriginalId() { - return this.originalId; - } - - public Control() { - this.control = CTControl.Factory.newInstance(); - } - /** - * For unit testing only! - */ - protected Control(CTControl control) { - this.control = control; - } - - public void readFrom(InputStream is) throws IOException { - try { - CTControl doc = CTControl.Factory.parse(is); - control = doc; - } catch (XmlException e) { - throw new IOException(e.getLocalizedMessage()); - } - } - public void writeTo(OutputStream out) throws IOException { - XmlOptions options = new XmlOptions(); - options.setSaveOuter(); - options.setUseDefaultNamespace(); - // Requests use of whitespace for easier reading - options.setSavePrettyPrint(); - control.save(out, options); - } - - /** - * We expect active x binary parts - */ - public String[] getChildrenRelationshipTypes() { - return new String[] { - XSSFRelation.ACTIVEX_BINS.getRelation() - }; - } - - public int getNumberOfChildren() { - return activexBins.size(); - } - - /** - * Generates and adds XSSFActiveXData children - */ - public void generateChild(PackagePart childPart, String childRelId) { - XSSFActiveXData actX = new XSSFActiveXData(childPart, childRelId); - activexBins.add(actX); - } - - public WritableChild getChildForWriting(int index) { - if(index >= activexBins.size()) { - throw new IllegalArgumentException("Can't get child at " + index + " when size is " + getNumberOfChildren()); - } - return new WritableChild( - activexBins.get(index), - XSSFRelation.ACTIVEX_BINS - ); - } - - public ArrayList getData() { - return this.activexBins; - } - - public void addData(XSSFActiveXData activeX) { - this.activexBins.add(activeX); - } -} \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/model/Drawing.java b/src/ooxml/java/org/apache/poi/xssf/model/Drawing.java deleted file mode 100644 index c151841798..0000000000 --- a/src/ooxml/java/org/apache/poi/xssf/model/Drawing.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.poi.xssf.model; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; - -import org.apache.poi.xssf.usermodel.XSSFPictureData; -import org.apache.poi.xssf.usermodel.XSSFRelation; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlOptions; -import org.openxml4j.opc.PackagePart; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDrawing; - -/** - * A drawing object in XSSF. May well have raw pictures - * attached to it as children. - */ -public class Drawing implements XSSFModel { - private CTDrawing drawing; - private String originalId; - - /** Raw pictures attached to the drawing */ - private ArrayList pictures; - - public Drawing(InputStream is, String originalId) throws IOException { - readFrom(is); - this.originalId = originalId; - this.pictures = new ArrayList(); - } - - public String getOriginalId() { - return this.originalId; - } - - public Drawing() { - this.drawing = CTDrawing.Factory.newInstance(); - } - /** - * For unit testing only! - */ - protected Drawing(CTDrawing drawing) { - this.drawing = drawing; - } - - public void readFrom(InputStream is) throws IOException { - try { - CTDrawing doc = CTDrawing.Factory.parse(is); - drawing = doc; - } catch (XmlException e) { - throw new IOException(e.getLocalizedMessage()); - } - } - public void writeTo(OutputStream out) throws IOException { - XmlOptions options = new XmlOptions(); - options.setSaveOuter(); - options.setUseDefaultNamespace(); - // Requests use of whitespace for easier reading - //options.setSavePrettyPrint(); - drawing.save(out, options); - } - - /** - * We expect image parts - */ - public String[] getChildrenRelationshipTypes() { - return new String[] { - XSSFRelation.IMAGES.getRelation() - }; - } - - public int getNumberOfChildren() { - return pictures.size(); - } - - /** - * Generates and adds XSSFActiveXData children - */ - public void generateChild(PackagePart childPart, String childRelId) { - //XSSFPictureData pd = new XSSFPictureData(childPart, childRelId); - //pictures.add(pd); - throw new RuntimeException("deprecated"); - } - - public ArrayList getPictures() - { - return this.pictures; - } - - public void addPictures(XSSFPictureData picture) - { - this.pictures.add(picture); - } -} \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringSource.java b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringSource.java deleted file mode 100644 index 55ad3eba34..0000000000 --- a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringSource.java +++ /dev/null @@ -1,28 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.xssf.model; - -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; - -/** - * Allows the getting and saving of shared strings - */ -public interface SharedStringSource { - CTRst getEntryAt(int ref); - int addEntry(CTRst rst); -} diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java index c68d29204e..bd33b80d3e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java @@ -23,15 +23,13 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; -import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.StylesSource; -import org.apache.poi.xssf.usermodel.FontFamily; -import org.apache.poi.xssf.usermodel.FontScheme; +import org.apache.poi.ss.usermodel.FontFamily; +import org.apache.poi.ss.usermodel.FontScheme; import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.apache.poi.xssf.usermodel.XSSFFont; import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder; diff --git a/src/ooxml/java/org/apache/poi/xssf/model/ThemeTable.java b/src/ooxml/java/org/apache/poi/xssf/model/ThemeTable.java deleted file mode 100755 index 1a641d8fe1..0000000000 --- a/src/ooxml/java/org/apache/poi/xssf/model/ThemeTable.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.poi.xssf.model; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlOptions; -import org.openxmlformats.schemas.drawingml.x2006.main.*; - -/** - * An instance of this part type contains information about a document's theme, which is a combination of color - * scheme, font scheme, and format scheme (the latter also being referred to as effects). - * For a SpreadsheetML document, the choice of theme affects the color and style of cell contents and charts, - * among other things. - * - * @author Yegor Kozlov - */ -public class ThemeTable implements XSSFModel { - private ThemeDocument doc; - private String originalId; - - public ThemeTable(InputStream is, String originalId) throws IOException { - readFrom(is); - this.originalId = originalId; - } - - public String getOriginalId() { - return this.originalId; - } - - public ThemeTable() { - this.doc = ThemeDocument.Factory.newInstance(); - } - - public void readFrom(InputStream is) throws IOException { - try { - doc = ThemeDocument.Factory.parse(is); - } catch (XmlException e) { - throw new IOException(e.getLocalizedMessage()); - } - } - - public void writeTo(OutputStream out) throws IOException { - XmlOptions options = new XmlOptions(); - options.setSaveOuter(); - options.setUseDefaultNamespace(); - - doc.save(out, options); - } - -} \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java index eba46909d0..fb8c2f770b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java @@ -17,9 +17,7 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.StylesSource; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment; import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder; @@ -310,7 +308,7 @@ public class XSSFCellStyle implements CellStyle, Cloneable { * Get the color to use for the bottom border *
* Color is optional. When missing, IndexedColors.AUTOMATIC is implied. - * @return the index of the color definition, default value is {@link IndexedColors.AUTOMATIC} + * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors.AUTOMATIC} * @see IndexedColors */ public short getBottomBorderColor() { @@ -664,7 +662,7 @@ public class XSSFCellStyle implements CellStyle, Cloneable { * Set the type of horizontal alignment for the cell * * @param align - the type of alignment - * @see HorizontalAlignment + * @see org.apache.poi.ss.usermodel.HorizontalAlignment */ public void setAlignment(HorizontalAlignment align) { setAlignment((short)align.ordinal()); @@ -1192,7 +1190,7 @@ public class XSSFCellStyle implements CellStyle, Cloneable { * Set the color to use for the top border * * @param color the index of the color definition - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setTopBorderColor(short color) { XSSFColor clr = new XSSFColor(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java index 2f1519a859..aad51a95e0 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java @@ -17,7 +17,6 @@ package org.apache.poi.xssf.usermodel; import org.apache.poi.ss.usermodel.Comment; -import org.apache.poi.ss.usermodel.CommentsSource; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.xssf.usermodel.helpers.RichTextStringHelper; import org.apache.poi.xssf.model.CommentsTable; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConnector.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConnector.java index 2127263ea9..92f0d1d73c 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConnector.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConnector.java @@ -95,10 +95,10 @@ public class XSSFConnector extends XSSFShape { } /** - * Gets the shape type, one of the constants defined in {@link org.apache.poi.xssf.usermodel.ShapeTypes}. + * Gets the shape type, one of the constants defined in {@link org.apache.poi.ss.usermodel.ShapeTypes}. * * @return the shape type - * @see org.apache.poi.xssf.usermodel.ShapeTypes + * @see org.apache.poi.ss.usermodel.ShapeTypes */ public int getShapeType() { return ctShape.getSpPr().getPrstGeom().getPrst().intValue(); @@ -107,8 +107,8 @@ public class XSSFConnector extends XSSFShape { /** * Sets the shape types. * - * @param type the shape type, one of the constants defined in {@link org.apache.poi.xssf.usermodel.ShapeTypes}. - * @see org.apache.poi.xssf.usermodel.ShapeTypes + * @param type the shape type, one of the constants defined in {@link org.apache.poi.ss.usermodel.ShapeTypes}. + * @see org.apache.poi.ss.usermodel.ShapeTypes */ public void setShapeType(int type) { ctShape.getSpPr().getPrstGeom().setPrst(STShapeType.Enum.forInt(type)); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java index 863932f311..ec11cf436b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java @@ -17,7 +17,6 @@ package org.apache.poi.xssf.usermodel; import org.apache.poi.ss.usermodel.DataFormat; -import org.apache.poi.ss.usermodel.StylesSource; import org.apache.poi.xssf.model.StylesTable; /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java index f64ddf3e3f..b444eb5ff0 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java @@ -39,6 +39,7 @@ public class XSSFDrawing extends POIXMLDocumentPart { * Root element of the SpreadsheetML Drawing part */ private CTDrawing drawing; + private boolean isNew; /** * Create a new SpreadsheetML drawing @@ -48,6 +49,7 @@ public class XSSFDrawing extends POIXMLDocumentPart { protected XSSFDrawing() { super(); drawing = newDrawing(); + isNew = true; } /** @@ -91,7 +93,7 @@ public class XSSFDrawing extends POIXMLDocumentPart { xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"> */ - xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")); + if(isNew) xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")); Map map = new HashMap(); map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a"); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java index b42659dbb7..0f78ef6a45 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java @@ -32,7 +32,7 @@ final class XSSFEvaluationCell implements EvaluationCell { public XSSFEvaluationCell(XSSFCell cell) { _cell = cell; - _evalSheet = new XSSFEvaluationSheet((XSSFSheet)cell.getSheet()); + _evalSheet = new XSSFEvaluationSheet(cell.getSheet()); } public XSSFEvaluationCell(XSSFCell cell, XSSFEvaluationSheet evaluationSheet) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java index add5470814..35b947ae44 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java @@ -75,7 +75,7 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E public EvaluationName getName(String name) { for(int i=0; i < _uBook.getNumberOfNames(); i++) { - String nameText = _uBook.getNameName(i); + String nameText = _uBook.getNameAt(i).getNameName(); if (name.equalsIgnoreCase(nameText)) { return new Name(_uBook.getNameAt(i), i, this); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java index 023cebbaa3..4424f6ec30 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java @@ -16,9 +16,7 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel; -import java.util.ArrayList; - -import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.extensions.XSSFColor; import org.apache.poi.xssf.model.StylesTable; import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; @@ -92,7 +90,7 @@ public class XSSFFont implements Font { * get character-set to use. * * @return byte - character-set - * @see FontCharset + * @see org.apache.poi.ss.usermodel.FontCharset */ public byte getCharSet() { CTIntProperty charset = ctFont.sizeOfCharsetArray() == 0 ? null : ctFont.getCharsetArray(0); @@ -233,7 +231,7 @@ public class XSSFFont implements Font { * get type of text underlining to use * * @return byte - underlining type - * @see FontUnderline + * @see org.apache.poi.ss.usermodel.FontUnderline */ public byte getUnderline() { CTUnderlineProperty underline = ctFont.sizeOfUArray() == 0 ? null : ctFont.getUArray(0); @@ -529,7 +527,7 @@ public class XSSFFont implements Font { * get the font family to use. * * @return the font family to use - * @see FontFamily + * @see org.apache.poi.ss.usermodel.FontFamily */ public int getFamily() { CTIntProperty family = ctFont.sizeOfFamilyArray() == 0 ? ctFont.addNewFamily() : ctFont.getFamilyArray(0); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java index 6231c47ba7..03d95e52ea 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java @@ -17,7 +17,7 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.usermodel.PrintSetup; +import org.apache.poi.ss.usermodel.*; import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 654802dd7d..dd983d6735 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel; import java.io.IOException; import java.io.OutputStream; +import java.io.InputStream; import java.util.*; import javax.xml.namespace.QName; @@ -110,12 +111,18 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { @Override protected void onDocumentRead() { try { - worksheet = WorksheetDocument.Factory.parse(getPackagePart().getInputStream()).getWorksheet(); - } catch (XmlException e){ - throw new POIXMLException(e); + read(getPackagePart().getInputStream()); } catch (IOException e){ throw new POIXMLException(e); } + } + + protected void read(InputStream is) throws IOException { + try { + worksheet = WorksheetDocument.Factory.parse(is).getWorksheet(); + } catch (XmlException e){ + throw new POIXMLException(e); + } initRows(worksheet); columnHelper = new ColumnHelper(worksheet); @@ -1645,6 +1652,13 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { @Override protected void commit() throws IOException { + PackagePart part = getPackagePart(); + OutputStream out = part.getOutputStream(); + write(out); + out.close(); + } + + protected void write(OutputStream out) throws IOException { if(worksheet.getColsArray().length == 1) { CTCols col = worksheet.getColsArray(0); @@ -1682,15 +1696,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet")); - Map map = new HashMap(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); - PackagePart part = getPackagePart(); - OutputStream out = part.getOutputStream(); worksheet.save(out, xmlOptions); - out.close(); } - } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java index 220765015d..d5dd19c1ba 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java @@ -23,7 +23,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; /** * Represents a shape with a predefined geometry in a SpreadsheetML drawing. - * Possible shape types are defined in {@link ShapeTypes} + * Possible shape types are defined in {@link org.apache.poi.ss.usermodel.ShapeTypes} * * @author Yegor Kozlov */ @@ -109,10 +109,10 @@ public class XSSFSimpleShape extends XSSFShape { } /** - * Gets the shape type, one of the constants defined in {@link ShapeTypes}. + * Gets the shape type, one of the constants defined in {@link org.apache.poi.ss.usermodel.ShapeTypes}. * * @return the shape type - * @see ShapeTypes + * @see org.apache.poi.ss.usermodel.ShapeTypes */ public int getShapeType() { return ctShape.getSpPr().getPrstGeom().getPrst().intValue(); @@ -121,8 +121,8 @@ public class XSSFSimpleShape extends XSSFShape { /** * Sets the shape types. * - * @param type the shape type, one of the constants defined in {@link ShapeTypes}. - * @see ShapeTypes + * @param type the shape type, one of the constants defined in {@link org.apache.poi.ss.usermodel.ShapeTypes}. + * @see org.apache.poi.ss.usermodel.ShapeTypes */ public void setShapeType(int type) { ctShape.getSpPr().getPrstGeom().setPrst(STShapeType.Enum.forInt(type)); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index ebb20e96eb..cc252d57d9 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -17,9 +17,7 @@ package org.apache.poi.xssf.usermodel; -import java.io.IOException; -import java.io.OutputStream; -import java.io.InputStream; +import java.io.*; import java.util.*; import javax.xml.namespace.QName; import org.apache.poi.POIXMLDocument; @@ -102,7 +100,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable pictures; - private static POILogger log = POILogFactory.getLogger(XSSFWorkbook.class); + private static POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class); /** * Create a new SpreadsheetML workbook. @@ -176,7 +174,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable 0 && srcName.endsWith(")")) { + String suffix = srcName.substring(bracketPos + 1, srcName.length() - ")".length()); + try { + uniqueIndex = Integer.parseInt(suffix.trim()); + uniqueIndex++; + baseName = srcName.substring(0, bracketPos).trim(); + } catch (NumberFormatException e) { + // contents of brackets not numeric + } + } while (true) { - //Try and find the next sheet name that is unique - String index = Integer.toString(i++); - if (name.length() + index.length() + 2 < 31) { - name = name + "("+index+")"; + // Try and find the next sheet name that is unique + String index = Integer.toString(uniqueIndex++); + String name; + if (baseName.length() + index.length() + 2 < 31) { + name = baseName + " (" + index + ")"; } else { - name = name.substring(0, 31 - index.length() - 2) + "(" +index + ")"; + name = baseName.substring(0, 31 - index.length() - 2) + "(" + index + ")"; } //If the sheet name is unique, then set it otherwise move on to the next number. if (getSheetIndex(name) == -1) { - break; + return name; } } - - XSSFSheet clonedSheet = createSheet(name); - clonedSheet.getCTWorksheet().set(srcSheet.getCTWorksheet()); - return clonedSheet; } /** @@ -518,18 +565,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, IterablegetNameAt(index).getName() - * - * @param index the named range index (0 based) - * @return named range name - * @see #getNameAt(int) - */ - public String getNameName(int index) { - return getNameAt(index).getNameName(); - } - /** * Gets the named range index by his name * Note:Excel named ranges are case-insensitive and @@ -598,21 +633,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable