Various code cleanups, "final" for static methods is useless, for-loops, simplify boolean conditions, try-with-resource, javadoc, ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
75c63b6bbe
commit
b644047b70
@ -70,7 +70,7 @@ public class SVTableUtils {
|
|||||||
/** This method retrieves the AWT Color representation from the colour hash table
|
/** This method retrieves the AWT Color representation from the colour hash table
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* package */ static final Color getAWTColor(int index, Color deflt) {
|
/* package */ static Color getAWTColor(int index, Color deflt) {
|
||||||
HSSFColor clr = colors.get(index);
|
HSSFColor clr = colors.get(index);
|
||||||
if (clr == null) {
|
if (clr == null) {
|
||||||
return deflt;
|
return deflt;
|
||||||
@ -79,7 +79,7 @@ public class SVTableUtils {
|
|||||||
return new Color(rgb[0],rgb[1],rgb[2]);
|
return new Color(rgb[0],rgb[1],rgb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ static final Color getAWTColor(HSSFColorPredefined clr) {
|
/* package */ static Color getAWTColor(HSSFColorPredefined clr) {
|
||||||
short[] rgb = clr.getTriplet();
|
short[] rgb = clr.getTriplet();
|
||||||
return new Color(rgb[0],rgb[1],rgb[2]);
|
return new Color(rgb[0],rgb[1],rgb[2]);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class LinkedDropDownLists {
|
|||||||
* @param dataSheet An instance of a class that implements the Sheet Sheet
|
* @param dataSheet An instance of a class that implements the Sheet Sheet
|
||||||
* interface (HSSFSheet or XSSFSheet).
|
* interface (HSSFSheet or XSSFSheet).
|
||||||
*/
|
*/
|
||||||
private static final void buildDataSheet(Sheet dataSheet) {
|
private static void buildDataSheet(Sheet dataSheet) {
|
||||||
Row row = null;
|
Row row = null;
|
||||||
Cell cell = null;
|
Cell cell = null;
|
||||||
Name name = null;
|
Name name = null;
|
||||||
|
@ -62,7 +62,7 @@ public class HPSFFileHandler extends POIFSFileHandler {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
private static final Set<String> unmodifiableHashSet(String... a) {
|
private static Set<String> unmodifiableHashSet(String... a) {
|
||||||
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
|
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
|
|||||||
// held on the first bit
|
// held on the first bit
|
||||||
if (b == getNeedRecalculation()) {
|
if (b == getNeedRecalculation()) {
|
||||||
return;
|
return;
|
||||||
} else if (b) {
|
}
|
||||||
|
|
||||||
|
if (b) {
|
||||||
field_2_need_recalculation_and_id++;
|
field_2_need_recalculation_and_id++;
|
||||||
} else {
|
} else {
|
||||||
field_2_need_recalculation_and_id--;
|
field_2_need_recalculation_and_id--;
|
||||||
@ -105,8 +107,7 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
|
|||||||
}
|
}
|
||||||
CellRangeAddressList cral = new CellRangeAddressList();
|
CellRangeAddressList cral = new CellRangeAddressList();
|
||||||
CellRangeAddress enclosingRange = null;
|
CellRangeAddress enclosingRange = null;
|
||||||
for (int i = 0; i < cellRanges.length; i++) {
|
for (CellRangeAddress cr : cellRanges) {
|
||||||
CellRangeAddress cr = cellRanges[i];
|
|
||||||
enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange);
|
enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange);
|
||||||
cral.addCellRangeAddress(cr);
|
cral.addCellRangeAddress(cr);
|
||||||
}
|
}
|
||||||
@ -119,8 +120,9 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String getRecordName();
|
protected abstract String getRecordName();
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
|
||||||
buffer.append("[").append(getRecordName()).append("]\n");
|
buffer.append("[").append(getRecordName()).append("]\n");
|
||||||
buffer.append("\t.numCF = ").append(getNumberOfConditionalFormats()).append("\n");
|
buffer.append("\t.numCF = ").append(getNumberOfConditionalFormats()).append("\n");
|
||||||
|
@ -148,7 +148,7 @@ public final class ExtSSTRecord extends ContinuableRecord {
|
|||||||
return _sstInfos;
|
return _sstInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int getNumberOfInfoRecsForStrings(int numStrings) {
|
public static int getNumberOfInfoRecsForStrings(int numStrings) {
|
||||||
int infoRecs = (numStrings / DEFAULT_BUCKET_SIZE);
|
int infoRecs = (numStrings / DEFAULT_BUCKET_SIZE);
|
||||||
if ((numStrings % DEFAULT_BUCKET_SIZE) != 0)
|
if ((numStrings % DEFAULT_BUCKET_SIZE) != 0)
|
||||||
infoRecs ++;
|
infoRecs ++;
|
||||||
@ -166,7 +166,7 @@ public final class ExtSSTRecord extends ContinuableRecord {
|
|||||||
*
|
*
|
||||||
* @return the size of the extsst record
|
* @return the size of the extsst record
|
||||||
*/
|
*/
|
||||||
public static final int getRecordSizeForStrings(int numStrings) {
|
public static int getRecordSizeForStrings(int numStrings) {
|
||||||
return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8;
|
return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -33,13 +31,11 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
*
|
*
|
||||||
* @version 2.0-pre
|
* @version 2.0-pre
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class GridsetRecord extends StandardRecord implements Cloneable {
|
public final class GridsetRecord extends StandardRecord implements Cloneable {
|
||||||
public final static short sid = 0x82;
|
public final static short sid = 0x82;
|
||||||
public short field_1_gridset_flag;
|
public short field_1_gridset_flag;
|
||||||
|
|
||||||
public GridsetRecord()
|
public GridsetRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridsetRecord(RecordInputStream in)
|
public GridsetRecord(RecordInputStream in)
|
||||||
@ -52,15 +48,10 @@ public final class GridsetRecord extends StandardRecord implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @param gridset - <b>true</b> if no gridlines are print, <b>false</b> if gridlines are not print.
|
* @param gridset - <b>true</b> if no gridlines are print, <b>false</b> if gridlines are not print.
|
||||||
*/
|
*/
|
||||||
|
public void setGridset(boolean gridset) {
|
||||||
public void setGridset(boolean gridset)
|
if (gridset) {
|
||||||
{
|
|
||||||
if (gridset == true)
|
|
||||||
{
|
|
||||||
field_1_gridset_flag = 1;
|
field_1_gridset_flag = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
field_1_gridset_flag = 0;
|
field_1_gridset_flag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,21 +61,16 @@ public final class GridsetRecord extends StandardRecord implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @return gridset - true if gridlines are NOT printed, false if they are.
|
* @return gridset - true if gridlines are NOT printed, false if they are.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getGridset()
|
public boolean getGridset()
|
||||||
{
|
{
|
||||||
return (field_1_gridset_flag == 1);
|
return (field_1_gridset_flag == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[GRIDSET]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .gridset = " + getGridset() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[GRIDSET]\n");
|
"[/GRIDSET]\n";
|
||||||
buffer.append(" .gridset = ").append(getGridset())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/GRIDSET]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -31,8 +30,7 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
|
|||||||
public final static short sid = 0x0083;
|
public final static short sid = 0x0083;
|
||||||
private short field_1_hcenter;
|
private short field_1_hcenter;
|
||||||
|
|
||||||
public HCenterRecord()
|
public HCenterRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HCenterRecord(RecordInputStream in)
|
public HCenterRecord(RecordInputStream in)
|
||||||
@ -44,15 +42,10 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
|
|||||||
* set whether or not to horizonatally center this sheet.
|
* set whether or not to horizonatally center this sheet.
|
||||||
* @param hc center - t/f
|
* @param hc center - t/f
|
||||||
*/
|
*/
|
||||||
|
public void setHCenter(boolean hc) {
|
||||||
public void setHCenter(boolean hc)
|
if (hc) {
|
||||||
{
|
|
||||||
if (hc == true)
|
|
||||||
{
|
|
||||||
field_1_hcenter = 1;
|
field_1_hcenter = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
field_1_hcenter = 0;
|
field_1_hcenter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,21 +54,16 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
|
|||||||
* get whether or not to horizonatally center this sheet.
|
* get whether or not to horizonatally center this sheet.
|
||||||
* @return center - t/f
|
* @return center - t/f
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getHCenter()
|
public boolean getHCenter()
|
||||||
{
|
{
|
||||||
return (field_1_hcenter == 1);
|
return (field_1_hcenter == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[HCENTER]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .hcenter = " + getHCenter() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[HCENTER]\n");
|
"[/HCENTER]\n";
|
||||||
buffer.append(" .hcenter = ").append(getHCenter())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/HCENTER]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -66,7 +66,7 @@ public final class NameRecord extends ContinuableRecord {
|
|||||||
public static final int OPT_COMPLEX = 0x0010;
|
public static final int OPT_COMPLEX = 0x0010;
|
||||||
public static final int OPT_BUILTIN = 0x0020;
|
public static final int OPT_BUILTIN = 0x0020;
|
||||||
public static final int OPT_BINDATA = 0x1000;
|
public static final int OPT_BINDATA = 0x1000;
|
||||||
public static final boolean isFormula(int optValue) {
|
public static boolean isFormula(int optValue) {
|
||||||
return (optValue & 0x0F) == 0;
|
return (optValue & 0x0F) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -28,15 +26,11 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* REFERENCE: PG 372 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
|
* REFERENCE: PG 372 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
|
||||||
* @version 2.0-pre
|
* @version 2.0-pre
|
||||||
*/
|
*/
|
||||||
|
public final class PrecisionRecord extends StandardRecord {
|
||||||
public final class PrecisionRecord
|
|
||||||
extends StandardRecord
|
|
||||||
{
|
|
||||||
public final static short sid = 0xE;
|
public final static short sid = 0xE;
|
||||||
public short field_1_precision;
|
public short field_1_precision;
|
||||||
|
|
||||||
public PrecisionRecord()
|
public PrecisionRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrecisionRecord(RecordInputStream in)
|
public PrecisionRecord(RecordInputStream in)
|
||||||
@ -49,15 +43,10 @@ public final class PrecisionRecord
|
|||||||
*
|
*
|
||||||
* @param fullprecision - or not
|
* @param fullprecision - or not
|
||||||
*/
|
*/
|
||||||
|
public void setFullPrecision(boolean fullprecision) {
|
||||||
public void setFullPrecision(boolean fullprecision)
|
if (fullprecision) {
|
||||||
{
|
|
||||||
if (fullprecision == true)
|
|
||||||
{
|
|
||||||
field_1_precision = 1;
|
field_1_precision = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
field_1_precision = 0;
|
field_1_precision = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,21 +56,16 @@ public final class PrecisionRecord
|
|||||||
*
|
*
|
||||||
* @return fullprecision - or not
|
* @return fullprecision - or not
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getFullPrecision()
|
public boolean getFullPrecision()
|
||||||
{
|
{
|
||||||
return (field_1_precision == 1);
|
return (field_1_precision == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[PRECISION]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .precision = " + getFullPrecision() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[PRECISION]\n");
|
"[/PRECISION]\n";
|
||||||
buffer.append(" .precision = ").append(getFullPrecision())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/PRECISION]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,8 +14,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -29,15 +26,11 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* @author Jason Height (jheight at chariot dot net dot au)
|
* @author Jason Height (jheight at chariot dot net dot au)
|
||||||
* @version 2.0-pre
|
* @version 2.0-pre
|
||||||
*/
|
*/
|
||||||
|
public final class PrintGridlinesRecord extends StandardRecord {
|
||||||
public final class PrintGridlinesRecord
|
|
||||||
extends StandardRecord
|
|
||||||
{
|
|
||||||
public final static short sid = 0x2b;
|
public final static short sid = 0x2b;
|
||||||
private short field_1_print_gridlines;
|
private short field_1_print_gridlines;
|
||||||
|
|
||||||
public PrintGridlinesRecord()
|
public PrintGridlinesRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintGridlinesRecord(RecordInputStream in)
|
public PrintGridlinesRecord(RecordInputStream in)
|
||||||
@ -50,15 +43,10 @@ public final class PrintGridlinesRecord
|
|||||||
*
|
*
|
||||||
* @param pg make spreadsheet ugly - Y/N
|
* @param pg make spreadsheet ugly - Y/N
|
||||||
*/
|
*/
|
||||||
|
public void setPrintGridlines(boolean pg) {
|
||||||
public void setPrintGridlines(boolean pg)
|
if (pg) {
|
||||||
{
|
|
||||||
if (pg == true)
|
|
||||||
{
|
|
||||||
field_1_print_gridlines = 1;
|
field_1_print_gridlines = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
field_1_print_gridlines = 0;
|
field_1_print_gridlines = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,21 +56,16 @@ public final class PrintGridlinesRecord
|
|||||||
*
|
*
|
||||||
* @return make spreadsheet ugly - Y/N
|
* @return make spreadsheet ugly - Y/N
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getPrintGridlines()
|
public boolean getPrintGridlines()
|
||||||
{
|
{
|
||||||
return (field_1_print_gridlines == 1);
|
return (field_1_print_gridlines == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[PRINTGRIDLINES]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .printgridlines = " + getPrintGridlines() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[PRINTGRIDLINES]\n");
|
"[/PRINTGRIDLINES]\n";
|
||||||
buffer.append(" .printgridlines = ").append(getPrintGridlines())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/PRINTGRIDLINES]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -30,15 +28,11 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* @author Jason Height (jheight at chariot dot net dot au)
|
* @author Jason Height (jheight at chariot dot net dot au)
|
||||||
* @version 2.0-pre
|
* @version 2.0-pre
|
||||||
*/
|
*/
|
||||||
|
public final class PrintHeadersRecord extends StandardRecord {
|
||||||
public final class PrintHeadersRecord
|
|
||||||
extends StandardRecord
|
|
||||||
{
|
|
||||||
public final static short sid = 0x2a;
|
public final static short sid = 0x2a;
|
||||||
private short field_1_print_headers;
|
private short field_1_print_headers;
|
||||||
|
|
||||||
public PrintHeadersRecord()
|
public PrintHeadersRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintHeadersRecord(RecordInputStream in)
|
public PrintHeadersRecord(RecordInputStream in)
|
||||||
@ -50,15 +44,10 @@ public final class PrintHeadersRecord
|
|||||||
* set to print the headers - y/n
|
* set to print the headers - y/n
|
||||||
* @param p printheaders or not
|
* @param p printheaders or not
|
||||||
*/
|
*/
|
||||||
|
public void setPrintHeaders(boolean p) {
|
||||||
public void setPrintHeaders(boolean p)
|
if (p) {
|
||||||
{
|
|
||||||
if (p == true)
|
|
||||||
{
|
|
||||||
field_1_print_headers = 1;
|
field_1_print_headers = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
field_1_print_headers = 0;
|
field_1_print_headers = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,21 +56,16 @@ public final class PrintHeadersRecord
|
|||||||
* get whether to print the headers - y/n
|
* get whether to print the headers - y/n
|
||||||
* @return printheaders or not
|
* @return printheaders or not
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getPrintHeaders()
|
public boolean getPrintHeaders()
|
||||||
{
|
{
|
||||||
return (field_1_print_headers == 1);
|
return (field_1_print_headers == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[PRINTHEADERS]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .printheaders = " + getPrintHeaders() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[PRINTHEADERS]\n");
|
"[/PRINTHEADERS]\n";
|
||||||
buffer.append(" .printheaders = ").append(getPrintHeaders())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/PRINTHEADERS]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianOutput;
|
import org.apache.poi.util.LittleEndianOutput;
|
||||||
@ -29,15 +27,13 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* @author Jason Height (jheight at chariot dot net dot au)
|
* @author Jason Height (jheight at chariot dot net dot au)
|
||||||
* @version 2.0-pre
|
* @version 2.0-pre
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class SaveRecalcRecord
|
public final class SaveRecalcRecord
|
||||||
extends StandardRecord
|
extends StandardRecord
|
||||||
{
|
{
|
||||||
public final static short sid = 0x5f;
|
public final static short sid = 0x5f;
|
||||||
private short field_1_recalc;
|
private short field_1_recalc;
|
||||||
|
|
||||||
public SaveRecalcRecord()
|
public SaveRecalcRecord() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaveRecalcRecord(RecordInputStream in)
|
public SaveRecalcRecord(RecordInputStream in)
|
||||||
@ -49,32 +45,24 @@ public final class SaveRecalcRecord
|
|||||||
* set whether to recalculate formulas/etc before saving or not
|
* set whether to recalculate formulas/etc before saving or not
|
||||||
* @param recalc - whether to recalculate or not
|
* @param recalc - whether to recalculate or not
|
||||||
*/
|
*/
|
||||||
|
public void setRecalc(boolean recalc) {
|
||||||
public void setRecalc(boolean recalc)
|
field_1_recalc = ( short ) (recalc ? 1 : 0);
|
||||||
{
|
|
||||||
field_1_recalc = ( short ) ((recalc == true) ? 1
|
|
||||||
: 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get whether to recalculate formulas/etc before saving or not
|
* get whether to recalculate formulas/etc before saving or not
|
||||||
* @return recalc - whether to recalculate or not
|
* @return recalc - whether to recalculate or not
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean getRecalc()
|
public boolean getRecalc()
|
||||||
{
|
{
|
||||||
return (field_1_recalc == 1);
|
return (field_1_recalc == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "[SAVERECALC]\n" +
|
||||||
StringBuffer buffer = new StringBuffer();
|
" .recalc = " + getRecalc() +
|
||||||
|
"\n" +
|
||||||
buffer.append("[SAVERECALC]\n");
|
"[/SAVERECALC]\n";
|
||||||
buffer.append(" .recalc = ").append(getRecalc())
|
|
||||||
.append("\n");
|
|
||||||
buffer.append("[/SAVERECALC]\n");
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(LittleEndianOutput out) {
|
public void serialize(LittleEndianOutput out) {
|
||||||
|
@ -168,7 +168,7 @@ public class HSSFColor implements Color {
|
|||||||
*
|
*
|
||||||
* @return a Map containing all colours keyed by <tt>Integer</tt> excel-style palette indexes
|
* @return a Map containing all colours keyed by <tt>Integer</tt> excel-style palette indexes
|
||||||
*/
|
*/
|
||||||
public static final synchronized Map<Integer,HSSFColor> getIndexHash() {
|
public static synchronized Map<Integer,HSSFColor> getIndexHash() {
|
||||||
if(indexHash == null) {
|
if(indexHash == null) {
|
||||||
indexHash = Collections.unmodifiableMap( createColorsByIndexMap() );
|
indexHash = Collections.unmodifiableMap( createColorsByIndexMap() );
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ public class HSSFColor implements Color {
|
|||||||
* the table, then call {@link #getIndexHash()} which returns a
|
* the table, then call {@link #getIndexHash()} which returns a
|
||||||
* statically cached immutable map of colours.
|
* statically cached immutable map of colours.
|
||||||
*/
|
*/
|
||||||
public static final Map<Integer,HSSFColor> getMutableIndexHash() {
|
public static Map<Integer,HSSFColor> getMutableIndexHash() {
|
||||||
return createColorsByIndexMap();
|
return createColorsByIndexMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an algorithm runner.
|
// Create an algorithm runner.
|
||||||
IDStarAlgorithm algorithm = null;
|
IDStarAlgorithm algorithm;
|
||||||
switch(algoType) {
|
switch(algoType) {
|
||||||
case DGET: algorithm = new DGet(); break;
|
case DGET: algorithm = new DGet(); break;
|
||||||
case DMIN: algorithm = new DMin(); break;
|
case DMIN: algorithm = new DMin(); break;
|
||||||
@ -97,7 +97,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
// Iterate over all DB entries.
|
// Iterate over all DB entries.
|
||||||
final int height = db.getHeight();
|
final int height = db.getHeight();
|
||||||
for(int row = 1; row < height; ++row) {
|
for(int row = 1; row < height; ++row) {
|
||||||
boolean matches = true;
|
boolean matches;
|
||||||
try {
|
try {
|
||||||
matches = fullfillsConditions(db, row, cdb);
|
matches = fullfillsConditions(db, row, cdb);
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
* @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first!
|
* @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first!
|
||||||
* @param db Database
|
* @param db Database
|
||||||
* @return Corresponding column number.
|
* @return Corresponding column number.
|
||||||
* @throws EvaluationException
|
* @throws EvaluationException If it's not possible to turn all headings into strings.
|
||||||
*/
|
*/
|
||||||
private static int getColumnForName(ValueEval nameValueEval, AreaEval db)
|
private static int getColumnForName(ValueEval nameValueEval, AreaEval db)
|
||||||
throws EvaluationException {
|
throws EvaluationException {
|
||||||
@ -193,7 +193,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
// Whether the condition column matches a database column, if not it's a
|
// Whether the condition column matches a database column, if not it's a
|
||||||
// special column that accepts formulas.
|
// special column that accepts formulas.
|
||||||
boolean columnCondition = true;
|
boolean columnCondition = true;
|
||||||
ValueEval condition = null;
|
ValueEval condition;
|
||||||
|
|
||||||
// The condition to apply.
|
// The condition to apply.
|
||||||
condition = resolveReference(cdb, conditionRow, column);
|
condition = resolveReference(cdb, conditionRow, column);
|
||||||
@ -212,7 +212,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
// No column found, it's again a special column that accepts formulas.
|
// No column found, it's again a special column that accepts formulas.
|
||||||
columnCondition = false;
|
columnCondition = false;
|
||||||
|
|
||||||
if(columnCondition == true) { // normal column condition
|
if(columnCondition) { // normal column condition
|
||||||
// Should not throw, checked above.
|
// Should not throw, checked above.
|
||||||
ValueEval value = resolveReference(db, row, getColumnForName(targetHeader, db));
|
ValueEval value = resolveReference(db, row, getColumnForName(targetHeader, db));
|
||||||
if(!testNormalCondition(value, condition)) {
|
if(!testNormalCondition(value, condition)) {
|
||||||
@ -228,7 +228,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
"D* function with formula conditions");
|
"D* function with formula conditions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matches == true) {
|
if (matches) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,8 +256,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
} else {
|
} else {
|
||||||
return testNumericCondition(value, operator.smallerThan, number);
|
return testNumericCondition(value, operator.smallerThan, number);
|
||||||
}
|
}
|
||||||
}
|
} else if(conditionString.startsWith(">")) { // It's a >/>= condition.
|
||||||
else if(conditionString.startsWith(">")) { // It's a >/>= condition.
|
|
||||||
String number = conditionString.substring(1);
|
String number = conditionString.substring(1);
|
||||||
if(number.startsWith("=")) {
|
if(number.startsWith("=")) {
|
||||||
number = number.substring(1);
|
number = number.substring(1);
|
||||||
@ -265,15 +264,14 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
} else {
|
} else {
|
||||||
return testNumericCondition(value, operator.largerThan, number);
|
return testNumericCondition(value, operator.largerThan, number);
|
||||||
}
|
}
|
||||||
}
|
} else if(conditionString.startsWith("=")) { // It's a = condition.
|
||||||
else if(conditionString.startsWith("=")) { // It's a = condition.
|
|
||||||
String stringOrNumber = conditionString.substring(1);
|
String stringOrNumber = conditionString.substring(1);
|
||||||
|
|
||||||
if(stringOrNumber.isEmpty()) {
|
if(stringOrNumber.isEmpty()) {
|
||||||
return value instanceof BlankEval;
|
return value instanceof BlankEval;
|
||||||
}
|
}
|
||||||
// Distinguish between string and number.
|
// Distinguish between string and number.
|
||||||
boolean itsANumber = false;
|
boolean itsANumber;
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(stringOrNumber);
|
Integer.parseInt(stringOrNumber);
|
||||||
itsANumber = true;
|
itsANumber = true;
|
||||||
@ -300,25 +298,17 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
return valueString.startsWith(conditionString);
|
return valueString.startsWith(conditionString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if(condition instanceof NumericValueEval) {
|
||||||
else if(condition instanceof NumericValueEval) {
|
double conditionNumber = ((NumericValueEval) condition).getNumberValue();
|
||||||
double conditionNumber = ((NumericValueEval)condition).getNumberValue();
|
|
||||||
Double valueNumber = getNumberFromValueEval(value);
|
Double valueNumber = getNumberFromValueEval(value);
|
||||||
if(valueNumber == null) {
|
return valueNumber != null && conditionNumber == valueNumber;
|
||||||
return false;
|
} else if(condition instanceof ErrorEval) {
|
||||||
}
|
|
||||||
|
|
||||||
return conditionNumber == valueNumber;
|
|
||||||
}
|
|
||||||
else if(condition instanceof ErrorEval) {
|
|
||||||
if(value instanceof ErrorEval) {
|
if(value instanceof ErrorEval) {
|
||||||
return ((ErrorEval)condition).getErrorCode() == ((ErrorEval)value).getErrorCode();
|
return ((ErrorEval)condition).getErrorCode() == ((ErrorEval)value).getErrorCode();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +330,7 @@ public final class DStarRunner implements Function3Arg {
|
|||||||
double value = ((NumericValueEval)valueEval).getNumberValue();
|
double value = ((NumericValueEval)valueEval).getNumberValue();
|
||||||
|
|
||||||
// Construct double from condition.
|
// Construct double from condition.
|
||||||
double conditionValue = 0.0;
|
double conditionValue;
|
||||||
try {
|
try {
|
||||||
conditionValue = Integer.parseInt(condition);
|
conditionValue = Integer.parseInt(condition);
|
||||||
} catch (NumberFormatException e) { // It's not an int.
|
} catch (NumberFormatException e) { // It's not an int.
|
||||||
|
@ -60,7 +60,7 @@ public class ImReal extends Fixed1ArgFunction implements FreeRefFunction {
|
|||||||
boolean result = m.matches();
|
boolean result = m.matches();
|
||||||
|
|
||||||
String real = "";
|
String real = "";
|
||||||
if (result == true) {
|
if (result) {
|
||||||
String realGroup = m.group(2);
|
String realGroup = m.group(2);
|
||||||
boolean hasRealPart = realGroup.length() != 0;
|
boolean hasRealPart = realGroup.length() != 0;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class Imaginary extends Fixed1ArgFunction implements FreeRefFunction {
|
|||||||
boolean result = m.matches();
|
boolean result = m.matches();
|
||||||
|
|
||||||
String imaginary = "";
|
String imaginary = "";
|
||||||
if (result == true) {
|
if (result) {
|
||||||
String imaginaryGroup = m.group(5);
|
String imaginaryGroup = m.group(5);
|
||||||
boolean hasImaginaryPart = imaginaryGroup.equals("i") || imaginaryGroup.equals("j");
|
boolean hasImaginaryPart = imaginaryGroup.equals("i") || imaginaryGroup.equals("j");
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import org.apache.commons.math3.linear.MatrixUtils;
|
|||||||
*/
|
*/
|
||||||
public abstract class MatrixFunction implements Function{
|
public abstract class MatrixFunction implements Function{
|
||||||
|
|
||||||
public static final void checkValues(double[] results) throws EvaluationException {
|
public static void checkValues(double[] results) throws EvaluationException {
|
||||||
for (int idx = 0; idx < results.length; idx++) {
|
for (int idx = 0; idx < results.length; idx++) {
|
||||||
if (Double.isNaN(results[idx]) || Double.isInfinite(results[idx])) {
|
if (Double.isNaN(results[idx]) || Double.isInfinite(results[idx])) {
|
||||||
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
||||||
|
@ -30,7 +30,7 @@ public abstract class NumericFunction implements Function {
|
|||||||
static final double TEN = 10.0;
|
static final double TEN = 10.0;
|
||||||
static final double LOG_10_TO_BASE_e = Math.log(TEN);
|
static final double LOG_10_TO_BASE_e = Math.log(TEN);
|
||||||
|
|
||||||
protected static final double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
|
protected static double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
|
||||||
if (arg == null) {
|
if (arg == null) {
|
||||||
throw new IllegalArgumentException("arg must not be null");
|
throw new IllegalArgumentException("arg must not be null");
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ public abstract class NumericFunction implements Function {
|
|||||||
/**
|
/**
|
||||||
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
|
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
|
||||||
*/
|
*/
|
||||||
public static final void checkValue(double result) throws EvaluationException {
|
public static void checkValue(double result) throws EvaluationException {
|
||||||
if (Double.isNaN(result) || Double.isInfinite(result)) {
|
if (Double.isNaN(result) || Double.isInfinite(result)) {
|
||||||
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class Rate implements Function {
|
|||||||
*
|
*
|
||||||
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
|
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
|
||||||
*/
|
*/
|
||||||
static final void checkValue(double result) throws EvaluationException {
|
static void checkValue(double result) throws EvaluationException {
|
||||||
if (Double.isNaN(result) || Double.isInfinite(result)) {
|
if (Double.isNaN(result) || Double.isInfinite(result)) {
|
||||||
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
throw new EvaluationException(ErrorEval.NUM_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg {
|
|||||||
* @return <code>true</code> if the name specifies a standard worksheet function,
|
* @return <code>true</code> if the name specifies a standard worksheet function,
|
||||||
* <code>false</code> if the name should be assumed to be an external function.
|
* <code>false</code> if the name should be assumed to be an external function.
|
||||||
*/
|
*/
|
||||||
public static final boolean isBuiltInFunctionName(String name) {
|
public static boolean isBuiltInFunctionName(String name) {
|
||||||
short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase(Locale.ROOT));
|
short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase(Locale.ROOT));
|
||||||
return ix >= 0;
|
return ix >= 0;
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ public class DataFormatter implements Observer {
|
|||||||
private BigDecimal divider;
|
private BigDecimal divider;
|
||||||
private static final BigDecimal ONE_THOUSAND = new BigDecimal(1000);
|
private static final BigDecimal ONE_THOUSAND = new BigDecimal(1000);
|
||||||
private final DecimalFormat df;
|
private final DecimalFormat df;
|
||||||
private static final String trimTrailingCommas(String s) {
|
private static String trimTrailingCommas(String s) {
|
||||||
return s.replaceAll(",+$", "");
|
return s.replaceAll(",+$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ public enum FormulaError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final boolean isValidCode(int errorCode) {
|
public static boolean isValidCode(int errorCode) {
|
||||||
for (FormulaError error : values()) {
|
for (FormulaError error : values()) {
|
||||||
if (error.getCode() == errorCode) return true;
|
if (error.getCode() == errorCode) return true;
|
||||||
if (error.getLongCode() == errorCode) return true;
|
if (error.getLongCode() == errorCode) return true;
|
||||||
|
@ -98,8 +98,8 @@ public class SheetBuilder {
|
|||||||
*/
|
*/
|
||||||
public Sheet build() {
|
public Sheet build() {
|
||||||
Sheet sheet = (sheetName == null) ? workbook.createSheet() : workbook.createSheet(sheetName);
|
Sheet sheet = (sheetName == null) ? workbook.createSheet() : workbook.createSheet(sheetName);
|
||||||
Row currentRow = null;
|
Row currentRow;
|
||||||
Cell currentCell = null;
|
Cell currentCell;
|
||||||
|
|
||||||
for (int rowIndex = 0; rowIndex < cells.length; ++rowIndex) {
|
for (int rowIndex = 0; rowIndex < cells.length; ++rowIndex) {
|
||||||
Object[] rowArray = cells[rowIndex];
|
Object[] rowArray = cells[rowIndex];
|
||||||
@ -125,7 +125,9 @@ public class SheetBuilder {
|
|||||||
private void setCellValue(Cell cell, Object value) {
|
private void setCellValue(Cell cell, Object value) {
|
||||||
if (value == null || cell == null) {
|
if (value == null || cell == null) {
|
||||||
return;
|
return;
|
||||||
} else if (value instanceof Number) {
|
}
|
||||||
|
|
||||||
|
if (value instanceof Number) {
|
||||||
double doubleValue = ((Number) value).doubleValue();
|
double doubleValue = ((Number) value).doubleValue();
|
||||||
cell.setCellValue(doubleValue);
|
cell.setCellValue(doubleValue);
|
||||||
} else if (value instanceof Date) {
|
} else if (value instanceof Date) {
|
||||||
@ -142,11 +144,7 @@ public class SheetBuilder {
|
|||||||
private boolean isFormulaDefinition(Object obj) {
|
private boolean isFormulaDefinition(Object obj) {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
String str = (String) obj;
|
String str = (String) obj;
|
||||||
if (str.length() < 2) {
|
return str.length() >= 2 && str.charAt(0) == '=';
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return ((String) obj).charAt(0) == '=';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class WorkbookUtil {
|
|||||||
* allowed to be null
|
* allowed to be null
|
||||||
* @return a valid string, "empty" if to short, "null" if null
|
* @return a valid string, "empty" if to short, "null" if null
|
||||||
*/
|
*/
|
||||||
public final static String createSafeSheetName(final String nameProposal) {
|
public static String createSafeSheetName(final String nameProposal) {
|
||||||
return createSafeSheetName(nameProposal, ' ');
|
return createSafeSheetName(nameProposal, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class WorkbookUtil {
|
|||||||
* @param replaceChar the char to replace invalid characters.
|
* @param replaceChar the char to replace invalid characters.
|
||||||
* @return a valid string, "empty" if to short, "null" if null
|
* @return a valid string, "empty" if to short, "null" if null
|
||||||
*/
|
*/
|
||||||
public final static String createSafeSheetName(final String nameProposal, char replaceChar) {
|
public static String createSafeSheetName(final String nameProposal, char replaceChar) {
|
||||||
if (nameProposal == null) {
|
if (nameProposal == null) {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
@ -141,20 +141,14 @@ public class POIXMLTypeLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {
|
public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {
|
||||||
InputStream is = new FileInputStream(file);
|
try (InputStream is = new FileInputStream(file)) {
|
||||||
try {
|
|
||||||
return parse(is, type, options);
|
return parse(is, type, options);
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {
|
public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {
|
||||||
InputStream is = file.openStream();
|
try (InputStream is = file.openStream()) {
|
||||||
try {
|
|
||||||
return parse(is, type, options);
|
return parse(is, type, options);
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
||||||
|
@ -109,7 +109,7 @@ public class RevocationData {
|
|||||||
* responses.
|
* responses.
|
||||||
*/
|
*/
|
||||||
public boolean hasOCSPs() {
|
public boolean hasOCSPs() {
|
||||||
return false == this.ocsps.isEmpty();
|
return !this.ocsps.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,7 +118,7 @@ public class RevocationData {
|
|||||||
* @return <code>true</code> if this revocation data set holds CRLs.
|
* @return <code>true</code> if this revocation data set holds CRLs.
|
||||||
*/
|
*/
|
||||||
public boolean hasCRLs() {
|
public boolean hasCRLs() {
|
||||||
return false == this.crls.isEmpty();
|
return !this.crls.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -819,7 +819,7 @@ public class XDGFShape extends XDGFSheet {
|
|||||||
*/
|
*/
|
||||||
public Path2D.Double getPath() {
|
public Path2D.Double getPath() {
|
||||||
for (GeometrySection geoSection : getGeometrySections()) {
|
for (GeometrySection geoSection : getGeometrySections()) {
|
||||||
if (geoSection.getNoShow() == true)
|
if (geoSection.getNoShow())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return geoSection.getPath(this);
|
return geoSection.getPath(this);
|
||||||
@ -833,7 +833,7 @@ public class XDGFShape extends XDGFSheet {
|
|||||||
*/
|
*/
|
||||||
public boolean hasGeometry() {
|
public boolean hasGeometry() {
|
||||||
for (GeometrySection geoSection : getGeometrySections()) {
|
for (GeometrySection geoSection : getGeometrySections()) {
|
||||||
if (geoSection.getNoShow() == false)
|
if (!geoSection.getNoShow())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -96,7 +96,7 @@ public class XSLFTextRun implements TextRun {
|
|||||||
|
|
||||||
String txt = ((CTRegularTextRun)_r).getT();
|
String txt = ((CTRegularTextRun)_r).getT();
|
||||||
TextCap cap = getTextCap();
|
TextCap cap = getTextCap();
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
for(int i = 0; i < txt.length(); i++) {
|
for(int i = 0; i < txt.length(); i++) {
|
||||||
char c = txt.charAt(i);
|
char c = txt.charAt(i);
|
||||||
if(c == '\t') {
|
if(c == '\t') {
|
||||||
@ -123,10 +123,7 @@ public class XSLFTextRun implements TextRun {
|
|||||||
public void setText(String text){
|
public void setText(String text){
|
||||||
if (_r instanceof CTTextField) {
|
if (_r instanceof CTTextField) {
|
||||||
((CTTextField)_r).setT(text);
|
((CTTextField)_r).setT(text);
|
||||||
} else if (_r instanceof CTTextLineBreak) {
|
} else if (!(_r instanceof CTTextLineBreak)) {
|
||||||
// ignored
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
((CTRegularTextRun)_r).setT(text);
|
((CTRegularTextRun)_r).setT(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ public enum XSSFBuiltinTableStyle {
|
|||||||
* Public so clients can initialize the map on startup rather than lazily
|
* Public so clients can initialize the map on startup rather than lazily
|
||||||
* during evaluation if desired.
|
* during evaluation if desired.
|
||||||
*/
|
*/
|
||||||
public static final synchronized void init() {
|
public static synchronized void init() {
|
||||||
if (! styleMap.isEmpty()) return;
|
if (! styleMap.isEmpty()) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,7 +158,6 @@ public final class XSSFGraphicFrame extends XSSFShape {
|
|||||||
CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
|
CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
|
||||||
appendChartElement(data, relId);
|
appendChartElement(data, relId);
|
||||||
chart.setGraphicFrame(this);
|
chart.setGraphicFrame(this);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,10 +242,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
|||||||
// Get the hyperlinks
|
// Get the hyperlinks
|
||||||
// TODO: make me optional/separated in private function
|
// TODO: make me optional/separated in private function
|
||||||
try {
|
try {
|
||||||
Iterator<PackageRelationship> relIter =
|
for (PackageRelationship rel : getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation())) {
|
||||||
getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
|
|
||||||
while (relIter.hasNext()) {
|
|
||||||
PackageRelationship rel = relIter.next();
|
|
||||||
hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
|
hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
|
||||||
}
|
}
|
||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException e) {
|
||||||
@ -453,7 +450,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
|||||||
// TODO this needs to be migrated out into section code
|
// TODO this needs to be migrated out into section code
|
||||||
if (type == HeaderFooterType.FIRST) {
|
if (type == HeaderFooterType.FIRST) {
|
||||||
CTSectPr ctSectPr = getSection();
|
CTSectPr ctSectPr = getSection();
|
||||||
if (ctSectPr.isSetTitlePg() == false) {
|
if (!ctSectPr.isSetTitlePg()) {
|
||||||
CTOnOff titlePg = ctSectPr.addNewTitlePg();
|
CTOnOff titlePg = ctSectPr.addNewTitlePg();
|
||||||
titlePg.setVal(STOnOff.ON);
|
titlePg.setVal(STOnOff.ON);
|
||||||
}
|
}
|
||||||
@ -475,7 +472,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
|||||||
// TODO this needs to be migrated out into section code
|
// TODO this needs to be migrated out into section code
|
||||||
if (type == HeaderFooterType.FIRST) {
|
if (type == HeaderFooterType.FIRST) {
|
||||||
CTSectPr ctSectPr = getSection();
|
CTSectPr ctSectPr = getSection();
|
||||||
if (ctSectPr.isSetTitlePg() == false) {
|
if (!ctSectPr.isSetTitlePg()) {
|
||||||
CTOnOff titlePg = ctSectPr.addNewTitlePg();
|
CTOnOff titlePg = ctSectPr.addNewTitlePg();
|
||||||
titlePg.setVal(STOnOff.ON);
|
titlePg.setVal(STOnOff.ON);
|
||||||
}
|
}
|
||||||
@ -600,7 +597,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
|||||||
* parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
|
* parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
|
||||||
* of the newly inserted paragraph.
|
* of the newly inserted paragraph.
|
||||||
*
|
*
|
||||||
* @param cursor
|
* @param cursor The cursor-position where the new paragraph should be added.
|
||||||
* @return the {@link XWPFParagraph} object representing the newly inserted
|
* @return the {@link XWPFParagraph} object representing the newly inserted
|
||||||
* CTP object
|
* CTP object
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +98,7 @@ public class XWPFSDTContent implements ISDTContent {
|
|||||||
text.append(o);
|
text.append(o);
|
||||||
addNewLine = false;
|
addNewLine = false;
|
||||||
}
|
}
|
||||||
if (addNewLine == true && i < bodyElements.size() - 1) {
|
if (addNewLine && i < bodyElements.size() - 1) {
|
||||||
text.append("\n");
|
text.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,10 +207,10 @@ public final class TestStylesTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
|
private static <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
|
||||||
assertFalse(map.containsKey(key));
|
assertFalse(map.containsKey(key));
|
||||||
}
|
}
|
||||||
private static final <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
|
private static <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
|
||||||
assertFalse(map.containsValue(value));
|
assertFalse(map.containsValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,9 @@ public abstract class RecordContainer extends Record
|
|||||||
/**
|
/**
|
||||||
* Adds the given new Child Record at the given location,
|
* Adds the given new Child Record at the given location,
|
||||||
* shuffling everything from there on down by one
|
* shuffling everything from there on down by one
|
||||||
* @param newChild
|
*
|
||||||
* @param position
|
* @param newChild The record to be added as child-record.
|
||||||
|
* @param position The index where the child should be added, 0-based
|
||||||
*/
|
*/
|
||||||
private void addChildAt(Record newChild, int position) {
|
private void addChildAt(Record newChild, int position) {
|
||||||
// Firstly, have the child added in at the end
|
// Firstly, have the child added in at the end
|
||||||
@ -168,8 +169,8 @@ public abstract class RecordContainer extends Record
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given Child Record after the supplied record
|
* Adds the given Child Record after the supplied record
|
||||||
* @param newChild
|
* @param newChild The record to add as new child.
|
||||||
* @param after
|
* @param after The record after which the given record should be added.
|
||||||
* @return the position of the added child within the list
|
* @return the position of the added child within the list
|
||||||
*/
|
*/
|
||||||
public int addChildAfter(Record newChild, Record after) {
|
public int addChildAfter(Record newChild, Record after) {
|
||||||
@ -186,8 +187,8 @@ public abstract class RecordContainer extends Record
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given Child Record before the supplied record
|
* Adds the given Child Record before the supplied record
|
||||||
* @param newChild
|
* @param newChild The record to add as new child.
|
||||||
* @param before
|
* @param before The record before which the given record should be added.
|
||||||
* @return the position of the added child within the list
|
* @return the position of the added child within the list
|
||||||
*/
|
*/
|
||||||
public int addChildBefore(Record newChild, Record before) {
|
public int addChildBefore(Record newChild, Record before) {
|
||||||
@ -309,8 +310,8 @@ public abstract class RecordContainer extends Record
|
|||||||
mout.write(new byte[4]);
|
mout.write(new byte[4]);
|
||||||
|
|
||||||
// Write out the children
|
// Write out the children
|
||||||
for(int i=0; i<children.length; i++) {
|
for (Record aChildren : children) {
|
||||||
children[i].writeOut(mout);
|
aChildren.writeOut(mout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update our header with the size
|
// Update our header with the size
|
||||||
@ -335,8 +336,8 @@ public abstract class RecordContainer extends Record
|
|||||||
baos.write(new byte[] {0,0,0,0});
|
baos.write(new byte[] {0,0,0,0});
|
||||||
|
|
||||||
// Write out our children
|
// Write out our children
|
||||||
for(int i=0; i<children.length; i++) {
|
for (Record aChildren : children) {
|
||||||
children[i].writeOut(baos);
|
aChildren.writeOut(baos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the bytes back
|
// Grab the bytes back
|
||||||
|
@ -169,7 +169,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Constructs a new, empty, Powerpoint document.
|
* Constructs a new, empty, Powerpoint document.
|
||||||
*/
|
*/
|
||||||
public static final HSLFSlideShowImpl create() {
|
public static HSLFSlideShowImpl create() {
|
||||||
InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt");
|
InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt");
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
throw new HSLFException("Missing resource 'empty.ppt'");
|
throw new HSLFException("Missing resource 'empty.ppt'");
|
||||||
|
@ -100,7 +100,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Constructor for reading MSG Files from the file system.
|
* Constructor for reading MSG Files from the file system.
|
||||||
*
|
*
|
||||||
* @param filename Name of the file to read
|
* @param filename Name of the file to read
|
||||||
* @throws IOException
|
* @exception IOException on errors reading, or invalid data
|
||||||
*/
|
*/
|
||||||
public MAPIMessage(String filename) throws IOException {
|
public MAPIMessage(String filename) throws IOException {
|
||||||
this(new File(filename));
|
this(new File(filename));
|
||||||
@ -109,7 +109,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Constructor for reading MSG Files from the file system.
|
* Constructor for reading MSG Files from the file system.
|
||||||
*
|
*
|
||||||
* @param file The file to read from
|
* @param file The file to read from
|
||||||
* @throws IOException
|
* @exception IOException on errors reading, or invalid data
|
||||||
*/
|
*/
|
||||||
public MAPIMessage(File file) throws IOException {
|
public MAPIMessage(File file) throws IOException {
|
||||||
this(new NPOIFSFileSystem(file));
|
this(new NPOIFSFileSystem(file));
|
||||||
@ -122,7 +122,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* in order to process. For lower memory use, use {@link #MAPIMessage(File)}
|
* in order to process. For lower memory use, use {@link #MAPIMessage(File)}
|
||||||
*
|
*
|
||||||
* @param in The InputStream to buffer then read from
|
* @param in The InputStream to buffer then read from
|
||||||
* @throws IOException
|
* @exception IOException on errors reading, or invalid data
|
||||||
*/
|
*/
|
||||||
public MAPIMessage(InputStream in) throws IOException {
|
public MAPIMessage(InputStream in) throws IOException {
|
||||||
this(new NPOIFSFileSystem(in));
|
this(new NPOIFSFileSystem(in));
|
||||||
@ -131,7 +131,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Constructor for reading MSG Files from a POIFS filesystem
|
* Constructor for reading MSG Files from a POIFS filesystem
|
||||||
*
|
*
|
||||||
* @param fs Open POIFS FileSystem containing the message
|
* @param fs Open POIFS FileSystem containing the message
|
||||||
* @throws IOException
|
* @exception IOException on errors reading, or invalid data
|
||||||
*/
|
*/
|
||||||
public MAPIMessage(NPOIFSFileSystem fs) throws IOException {
|
public MAPIMessage(NPOIFSFileSystem fs) throws IOException {
|
||||||
this(fs.getRoot());
|
this(fs.getRoot());
|
||||||
@ -140,7 +140,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Constructor for reading MSG Files from a certain
|
* Constructor for reading MSG Files from a certain
|
||||||
* point within a POIFS filesystem
|
* point within a POIFS filesystem
|
||||||
* @param poifsDir Directory containing the message
|
* @param poifsDir Directory containing the message
|
||||||
* @throws IOException
|
* @exception IOException on errors reading, or invalid data
|
||||||
*/
|
*/
|
||||||
public MAPIMessage(DirectoryNode poifsDir) throws IOException {
|
public MAPIMessage(DirectoryNode poifsDir) throws IOException {
|
||||||
super(poifsDir);
|
super(poifsDir);
|
||||||
@ -195,7 +195,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
/**
|
/**
|
||||||
* Gets the plain text body of this Outlook Message
|
* Gets the plain text body of this Outlook Message
|
||||||
* @return The string representation of the 'text' version of the body, if available.
|
* @return The string representation of the 'text' version of the body, if available.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the text-body chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getTextBody() throws ChunkNotFoundException {
|
public String getTextBody() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getTextBodyChunk());
|
return getStringFromChunk(mainChunks.getTextBodyChunk());
|
||||||
@ -205,7 +206,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Gets the html body of this Outlook Message, if this email
|
* Gets the html body of this Outlook Message, if this email
|
||||||
* contains a html version.
|
* contains a html version.
|
||||||
* @return The string representation of the 'html' version of the body, if available.
|
* @return The string representation of the 'html' version of the body, if available.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the html-body chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getHtmlBody() throws ChunkNotFoundException {
|
public String getHtmlBody() throws ChunkNotFoundException {
|
||||||
if(mainChunks.getHtmlBodyChunkBinary() != null) {
|
if(mainChunks.getHtmlBodyChunkBinary() != null) {
|
||||||
@ -218,7 +220,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* Gets the RTF Rich Message body of this Outlook Message, if this email
|
* Gets the RTF Rich Message body of this Outlook Message, if this email
|
||||||
* contains a RTF (rich) version.
|
* contains a RTF (rich) version.
|
||||||
* @return The string representation of the 'RTF' version of the body, if available.
|
* @return The string representation of the 'RTF' version of the body, if available.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the rtf-body chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getRtfBody() throws ChunkNotFoundException {
|
public String getRtfBody() throws ChunkNotFoundException {
|
||||||
ByteChunk chunk = mainChunks.getRtfBodyChunk();
|
ByteChunk chunk = mainChunks.getRtfBodyChunk();
|
||||||
@ -242,7 +245,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the subject line of the Outlook Message
|
* Gets the subject line of the Outlook Message
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the subject-chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getSubject() throws ChunkNotFoundException {
|
public String getSubject() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getSubjectChunk());
|
return getStringFromChunk(mainChunks.getSubjectChunk());
|
||||||
@ -251,7 +255,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
/**
|
/**
|
||||||
* Gets the display value of the "FROM" line of the outlook message
|
* Gets the display value of the "FROM" line of the outlook message
|
||||||
* This is not the actual address that was sent from but the formated display of the user name.
|
* This is not the actual address that was sent from but the formated display of the user name.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the from-chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getDisplayFrom() throws ChunkNotFoundException {
|
public String getDisplayFrom() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getDisplayFromChunk());
|
return getStringFromChunk(mainChunks.getDisplayFromChunk());
|
||||||
@ -264,7 +269,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* This is not the actual list of addresses/values that will be
|
* This is not the actual list of addresses/values that will be
|
||||||
* sent to if you click Reply in the email - those are stored
|
* sent to if you click Reply in the email - those are stored
|
||||||
* in {@link RecipientChunks}.
|
* in {@link RecipientChunks}.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the to-chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getDisplayTo() throws ChunkNotFoundException {
|
public String getDisplayTo() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getDisplayToChunk());
|
return getStringFromChunk(mainChunks.getDisplayToChunk());
|
||||||
@ -277,7 +283,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* This is not the actual list of addresses/values that will be
|
* This is not the actual list of addresses/values that will be
|
||||||
* sent to if you click Reply in the email - those are stored
|
* sent to if you click Reply in the email - those are stored
|
||||||
* in {@link RecipientChunks}.
|
* in {@link RecipientChunks}.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the cc-chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getDisplayCC() throws ChunkNotFoundException {
|
public String getDisplayCC() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getDisplayCCChunk());
|
return getStringFromChunk(mainChunks.getDisplayCCChunk());
|
||||||
@ -291,7 +298,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* sent to if you click Reply in the email - those are stored
|
* sent to if you click Reply in the email - those are stored
|
||||||
* in {@link RecipientChunks}.
|
* in {@link RecipientChunks}.
|
||||||
* This will only be present in sent emails, not received ones!
|
* This will only be present in sent emails, not received ones!
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the bcc-chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getDisplayBCC() throws ChunkNotFoundException {
|
public String getDisplayBCC() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getDisplayBCCChunk());
|
return getStringFromChunk(mainChunks.getDisplayBCCChunk());
|
||||||
@ -440,7 +448,6 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
// Found it! Tell all the string chunks
|
// Found it! Tell all the string chunks
|
||||||
String charset = m.group(1);
|
String charset = m.group(1);
|
||||||
set7BitEncoding(charset);
|
set7BitEncoding(charset);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ChunkNotFoundException e) {}
|
} catch(ChunkNotFoundException e) {}
|
||||||
@ -529,7 +536,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
/**
|
/**
|
||||||
* Gets the conversation topic of the parsed Outlook Message.
|
* Gets the conversation topic of the parsed Outlook Message.
|
||||||
* This is the part of the subject line that is after the RE: and FWD:
|
* This is the part of the subject line that is after the RE: and FWD:
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the conversation-topic chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public String getConversationTopic() throws ChunkNotFoundException {
|
public String getConversationTopic() throws ChunkNotFoundException {
|
||||||
return getStringFromChunk(mainChunks.getConversationTopic());
|
return getStringFromChunk(mainChunks.getConversationTopic());
|
||||||
@ -541,7 +549,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
* item, note, or actual outlook Message)
|
* item, note, or actual outlook Message)
|
||||||
* For emails the class will be IPM.Note
|
* For emails the class will be IPM.Note
|
||||||
*
|
*
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException If the message-class chunk does not exist and
|
||||||
|
* returnNullOnMissingChunk is set
|
||||||
*/
|
*/
|
||||||
public MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException {
|
public MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException {
|
||||||
String mc = getStringFromChunk(mainChunks.getMessageClass());
|
String mc = getStringFromChunk(mainChunks.getMessageClass());
|
||||||
@ -643,7 +652,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||||||
|
|
||||||
|
|
||||||
private String toSemicolonList(String[] l) {
|
private String toSemicolonList(String[] l) {
|
||||||
StringBuffer list = new StringBuffer();
|
StringBuilder list = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
|
||||||
for(String s : l) {
|
for(String s : l) {
|
||||||
|
@ -207,9 +207,9 @@ public final class Chunks implements ChunkGroupWithProperties {
|
|||||||
conversationTopic = (StringChunk) chunk;
|
conversationTopic = (StringChunk) chunk;
|
||||||
} else if (prop == MAPIProperty.SUBJECT) {
|
} else if (prop == MAPIProperty.SUBJECT) {
|
||||||
subjectChunk = (StringChunk) chunk;
|
subjectChunk = (StringChunk) chunk;
|
||||||
} else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
|
} /*else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}*/
|
||||||
|
|
||||||
else if (prop == MAPIProperty.DISPLAY_TO) {
|
else if (prop == MAPIProperty.DISPLAY_TO) {
|
||||||
displayToChunk = (StringChunk) chunk;
|
displayToChunk = (StringChunk) chunk;
|
||||||
|
@ -691,8 +691,6 @@ public abstract class AbstractWordConverter
|
|||||||
if ( separatorMark + 1 < endMark )
|
if ( separatorMark + 1 < endMark )
|
||||||
processCharacters( wordDocument, currentTableLevel,
|
processCharacters( wordDocument, currentTableLevel,
|
||||||
deadFieldValueSubrage, currentBlock );
|
deadFieldValueSubrage, currentBlock );
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processDocument( HWPFDocumentCore wordDocument )
|
public void processDocument( HWPFDocumentCore wordDocument )
|
||||||
@ -1106,7 +1104,7 @@ public abstract class AbstractWordConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( processed == false )
|
if (!processed)
|
||||||
{
|
{
|
||||||
processParagraph( wordDocument, flow, currentTableLevel,
|
processParagraph( wordDocument, flow, currentTableLevel,
|
||||||
paragraph, AbstractWordUtils.EMPTY );
|
paragraph, AbstractWordUtils.EMPTY );
|
||||||
|
@ -462,7 +462,6 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
WordToFoUtils.compactInlines( block );
|
WordToFoUtils.compactInlines( block );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processSection( HWPFDocumentCore wordDocument,
|
protected void processSection( HWPFDocumentCore wordDocument,
|
||||||
|
@ -202,11 +202,11 @@ public class WordToHtmlConverter extends AbstractWordConverter
|
|||||||
&& !AbstractWordUtils.equals( triplet.fontName,
|
&& !AbstractWordUtils.equals( triplet.fontName,
|
||||||
blockProperies.pFontName ) )
|
blockProperies.pFontName ) )
|
||||||
{
|
{
|
||||||
style.append( "font-family:" + triplet.fontName + ";" );
|
style.append("font-family:").append(triplet.fontName).append(";");
|
||||||
}
|
}
|
||||||
if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
|
if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
|
||||||
{
|
{
|
||||||
style.append( "font-size:" + characterRun.getFontSize() / 2 + "pt;" );
|
style.append("font-size:").append(characterRun.getFontSize() / 2).append("pt;");
|
||||||
}
|
}
|
||||||
if ( triplet.bold )
|
if ( triplet.bold )
|
||||||
{
|
{
|
||||||
@ -593,7 +593,6 @@ public class WordToHtmlConverter extends AbstractWordConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
WordToHtmlUtils.compactSpans( pElement );
|
WordToHtmlUtils.compactSpans( pElement );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ import org.junit.After;
|
|||||||
* Testing for {@link HSSFEventFactory}
|
* Testing for {@link HSSFEventFactory}
|
||||||
*/
|
*/
|
||||||
public final class TestHSSFEventFactory extends TestCase {
|
public final class TestHSSFEventFactory extends TestCase {
|
||||||
private static final InputStream openSample(String sampleFileName) {
|
private static InputStream openSample(String sampleFileName) {
|
||||||
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public final class TestFormulaRecord extends TestCase {
|
|||||||
|
|
||||||
fr0.setCachedResultBoolean(false);
|
fr0.setCachedResultBoolean(false);
|
||||||
fr1.setCachedResultBoolean(true);
|
fr1.setCachedResultBoolean(true);
|
||||||
if (fr0.getCachedBooleanValue() == true && fr1.getCachedBooleanValue() == false) {
|
if (fr0.getCachedBooleanValue() && !fr1.getCachedBooleanValue()) {
|
||||||
throw new AssertionFailedError("Identified bug 46479c");
|
throw new AssertionFailedError("Identified bug 46479c");
|
||||||
}
|
}
|
||||||
assertEquals(false, fr0.getCachedBooleanValue());
|
assertEquals(false, fr0.getCachedBooleanValue());
|
||||||
|
@ -34,10 +34,10 @@ import org.apache.poi.hssf.OldExcelFormatException;
|
|||||||
* checks
|
* checks
|
||||||
*/
|
*/
|
||||||
public class TestNotOLE2Exception extends TestCase {
|
public class TestNotOLE2Exception extends TestCase {
|
||||||
private static final InputStream openXLSSampleStream(String sampleFileName) {
|
private static InputStream openXLSSampleStream(String sampleFileName) {
|
||||||
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
||||||
}
|
}
|
||||||
private static final InputStream openDOCSampleStream(String sampleFileName) {
|
private static InputStream openDOCSampleStream(String sampleFileName) {
|
||||||
return POIDataSamples.getDocumentInstance().openResourceAsStream(sampleFileName);
|
return POIDataSamples.getDocumentInstance().openResourceAsStream(sampleFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import junit.framework.TestCase;
|
|||||||
*/
|
*/
|
||||||
public class TestOfficeXMLException extends TestCase {
|
public class TestOfficeXMLException extends TestCase {
|
||||||
|
|
||||||
private static final InputStream openSampleStream(String sampleFileName) {
|
private static InputStream openSampleStream(String sampleFileName) {
|
||||||
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
|
||||||
}
|
}
|
||||||
public void testOOXMLException() throws IOException
|
public void testOOXMLException() throws IOException
|
||||||
|
@ -109,14 +109,10 @@ public class TestForkedEvaluator {
|
|||||||
expectedEx.expect(UnsupportedOperationException.class);
|
expectedEx.expect(UnsupportedOperationException.class);
|
||||||
expectedEx.expectMessage("Underlying cell 'A2' is missing in master sheet.");
|
expectedEx.expectMessage("Underlying cell 'A2' is missing in master sheet.");
|
||||||
|
|
||||||
Workbook wb = createWorkbook();
|
try (Workbook wb = createWorkbook()) {
|
||||||
|
ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
|
||||||
try {
|
// attempt update input at cell A2 (which is missing)
|
||||||
ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
|
fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
|
||||||
// attempt update input at cell A2 (which is missing)
|
|
||||||
fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
|
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,14 @@ public abstract class AbstractPtgTestCase extends TestCase {
|
|||||||
* @param sampleFileName the filename.
|
* @param sampleFileName the filename.
|
||||||
* @return the loaded workbook.
|
* @return the loaded workbook.
|
||||||
*/
|
*/
|
||||||
protected static final HSSFWorkbook loadWorkbook(String sampleFileName) {
|
protected static HSSFWorkbook loadWorkbook(String sampleFileName) {
|
||||||
return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Workbook and adds one sheet with the specified name
|
* Creates a new Workbook and adds one sheet with the specified name
|
||||||
*/
|
*/
|
||||||
protected static final HSSFWorkbook createWorkbookWithSheet(String sheetName) {
|
protected static HSSFWorkbook createWorkbookWithSheet(String sheetName) {
|
||||||
HSSFWorkbook book = new HSSFWorkbook();
|
HSSFWorkbook book = new HSSFWorkbook();
|
||||||
book.createSheet(sheetName);
|
book.createSheet(sheetName);
|
||||||
return book;
|
return book;
|
||||||
|
Loading…
Reference in New Issue
Block a user