Fix some IDE warnings, JavaDoc, ...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1766063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-10-21 16:31:37 +00:00
parent 359820ba80
commit 0610a20d87
7 changed files with 182 additions and 224 deletions

View File

@ -57,16 +57,16 @@ public enum HyperlinkType {
/**
* The codes don't have any real meaning.
* There bytes that are read in and written out from HSSF, HSLF, XSSF, and XSLF are different
* They are bytes that are read in and written out from HSSF, HSLF, XSSF, and XSLF are different
* that the codes here.
* These codes only exist to assist in transitioning from using ints to enums.
*
* @param code
* @param code The unique number for this type.
* @deprecated POI 3.15 beta 3
*/
@Internal(since="3.15 beta 3")
@Deprecated
private HyperlinkType(int code) {
HyperlinkType(int code) {
this.code = code;
}

View File

@ -43,6 +43,7 @@ public final class WindowOneRecord extends StandardRecord {
BitFieldFactory.getInstance(0x01); // is this window is hidden
static final private BitField iconic =
BitFieldFactory.getInstance(0x02); // is this window is an icon
@SuppressWarnings("unused")
static final private BitField reserved = BitFieldFactory.getInstance(0x04); // reserved
static final private BitField hscroll =
BitFieldFactory.getInstance(0x08); // display horizontal scrollbar
@ -353,41 +354,37 @@ public final class WindowOneRecord extends StandardRecord {
return field_9_tab_width_ratio;
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
buffer.append("[WINDOW1]\n");
buffer.append(" .h_hold = ")
.append(Integer.toHexString(getHorizontalHold())).append("\n");
buffer.append(" .v_hold = ")
.append(Integer.toHexString(getVerticalHold())).append("\n");
buffer.append(" .width = ")
.append(Integer.toHexString(getWidth())).append("\n");
buffer.append(" .height = ")
.append(Integer.toHexString(getHeight())).append("\n");
buffer.append(" .options = ")
.append(Integer.toHexString(getOptions())).append("\n");
buffer.append(" .hidden = ").append(getHidden())
.append("\n");
buffer.append(" .iconic = ").append(getIconic())
.append("\n");
buffer.append(" .hscroll = ")
.append(getDisplayHorizontalScrollbar()).append("\n");
buffer.append(" .vscroll = ")
.append(getDisplayVerticalScrollbar()).append("\n");
buffer.append(" .tabs = ").append(getDisplayTabs())
.append("\n");
buffer.append(" .activeSheet = ")
.append(Integer.toHexString(getActiveSheetIndex())).append("\n");
buffer.append(" .firstVisibleTab = ")
.append(Integer.toHexString(getFirstVisibleTab())).append("\n");
buffer.append(" .numselectedtabs = ")
.append(Integer.toHexString(getNumSelectedTabs())).append("\n");
buffer.append(" .tabwidthratio = ")
.append(Integer.toHexString(getTabWidthRatio())).append("\n");
buffer.append("[/WINDOW1]\n");
return buffer.toString();
public String toString() {
return "[WINDOW1]\n" +
" .h_hold = " +
Integer.toHexString(getHorizontalHold()) + "\n" +
" .v_hold = " +
Integer.toHexString(getVerticalHold()) + "\n" +
" .width = " +
Integer.toHexString(getWidth()) + "\n" +
" .height = " +
Integer.toHexString(getHeight()) + "\n" +
" .options = " +
Integer.toHexString(getOptions()) + "\n" +
" .hidden = " + getHidden() +
"\n" +
" .iconic = " + getIconic() +
"\n" +
" .hscroll = " +
getDisplayHorizontalScrollbar() + "\n" +
" .vscroll = " +
getDisplayVerticalScrollbar() + "\n" +
" .tabs = " + getDisplayTabs() +
"\n" +
" .activeSheet = " +
Integer.toHexString(getActiveSheetIndex()) + "\n" +
" .firstVisibleTab = " +
Integer.toHexString(getFirstVisibleTab()) + "\n" +
" .numselectedtabs = " +
Integer.toHexString(getNumSelectedTabs()) + "\n" +
" .tabwidthratio = " +
Integer.toHexString(getTabWidthRatio()) + "\n" +
"[/WINDOW1]\n";
}
public void serialize(LittleEndianOutput out) {

View File

@ -28,7 +28,7 @@ import java.io.IOException;
* data from slow (ie, non FileInputStream) sources, for example when
* reading an OLE2 Document over a network.
*
* Possible extentions: add a timeout. Curently a call to read(byte[]) on this
* Possible extensions: add a timeout. Currently a call to read(byte[]) on this
* class is blocking, so use at your own peril if your underlying stream blocks.
*
* @author Jens Gerhard

View File

@ -36,40 +36,33 @@ public class FontMetricsDumper
Properties props = new Properties();
Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for ( int i = 0; i < allFonts.length; i++ )
{
String fontName = allFonts[i].getFontName();
for (Font allFont : allFonts) {
String fontName = allFont.getFontName();
Font font = new Font(fontName, Font.BOLD, 10);
FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
int fontHeight = fontMetrics.getHeight();
props.setProperty("font." + fontName + ".height", fontHeight+"");
StringBuffer characters = new StringBuffer();
for (char c = 'a'; c <= 'z'; c++)
{
characters.append( c + ", " );
props.setProperty("font." + fontName + ".height", fontHeight + "");
StringBuilder characters = new StringBuilder();
for (char c = 'a'; c <= 'z'; c++) {
characters.append(c).append(", ");
}
for (char c = 'A'; c <= 'Z'; c++)
{
characters.append( c + ", " );
for (char c = 'A'; c <= 'Z'; c++) {
characters.append(c).append(", ");
}
for (char c = '0'; c <= '9'; c++)
{
characters.append( c + ", " );
for (char c = '0'; c <= '9'; c++) {
characters.append(c).append(", ");
}
StringBuffer widths = new StringBuffer();
for (char c = 'a'; c <= 'z'; c++)
{
widths.append( fontMetrics.getWidths()[c] + ", " );
StringBuilder widths = new StringBuilder();
for (char c = 'a'; c <= 'z'; c++) {
widths.append(fontMetrics.getWidths()[c]).append(", ");
}
for (char c = 'A'; c <= 'Z'; c++)
{
widths.append( fontMetrics.getWidths()[c] + ", " );
for (char c = 'A'; c <= 'Z'; c++) {
widths.append(fontMetrics.getWidths()[c]).append(", ");
}
for (char c = '0'; c <= '9'; c++)
{
widths.append( fontMetrics.getWidths()[c] + ", " );
for (char c = '0'; c <= '9'; c++) {
widths.append(fontMetrics.getWidths()[c]).append(", ");
}
props.setProperty("font." + fontName + ".characters", characters.toString());
props.setProperty("font." + fontName + ".widths", widths.toString());

View File

@ -265,7 +265,6 @@ public class Range { // TODO -instantiable superclass
// This means there's nested stuff, so we
// can just zap the lot
text = text.substring(0, first13) + text.substring(last15 + 1);
continue;
}
return text;
@ -648,8 +647,8 @@ public class Range { // TODO -instantiable superclass
public void replaceText(String pPlaceHolder, String pValue, int pOffset) {
int absPlaceHolderIndex = getStartOffset() + pOffset;
Range subRange = new Range(absPlaceHolderIndex, (absPlaceHolderIndex + pPlaceHolder
.length()), this);
Range subRange = new Range(absPlaceHolderIndex,
(absPlaceHolderIndex + pPlaceHolder.length()), this);
subRange.insertBefore(pValue);
// re-create the sub-range so we can delete it
@ -669,15 +668,14 @@ public class Range { // TODO -instantiable superclass
* The replacement text (e.g., "Apache Software Foundation")
*/
public void replaceText(String pPlaceHolder, String pValue) {
boolean keepLooking = true;
while (keepLooking) {
while (true) {
String text = text();
int offset = text.indexOf(pPlaceHolder);
if (offset >= 0)
if (offset >= 0) {
replaceText(pPlaceHolder, pValue, offset);
else
keepLooking = false;
} else {
break;
}
}
}
@ -726,10 +724,8 @@ public class Range { // TODO -instantiable superclass
istd = papx.getIstd();
}
CharacterRun chp = new CharacterRun( chpx, _doc.getStyleSheet(), istd,
this );
return chp;
return new CharacterRun( chpx, _doc.getStyleSheet(), istd,
this);
}
/**
@ -742,8 +738,7 @@ public class Range { // TODO -instantiable superclass
public Section getSection(int index) {
initSections();
SEPX sepx = _sections.get(index + _sectionStart);
Section sep = new Section(sepx, this);
return sep;
return new Section(sepx, this);
}
/**
@ -949,8 +944,6 @@ public class Range { // TODO -instantiable superclass
*
* @param rpl
* A list of property nodes.
* @param min
* A hint on where to start looking.
* @param start
* The starting character offset.
* @param end

View File

@ -39,7 +39,6 @@ import org.apache.poi.util.POILogger;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@ -130,7 +129,6 @@ public class TestBugs extends TestCase
/**
* Bug 33519 - HWPF fails to read a file
* @throws IOException
*/
public void test33519() throws IOException
{
@ -139,7 +137,6 @@ public class TestBugs extends TestCase
/**
* Bug 34898 - WordExtractor doesn't read the whole string from the file
* @throws IOException
*/
public void test34898() throws IOException
{
@ -180,7 +177,6 @@ public class TestBugs extends TestCase
/**
* Bug 44331 - HWPFDocument.write destroys fields
* @throws IOException
*/
@SuppressWarnings("deprecation")
public void test44431() throws IOException
@ -209,7 +205,6 @@ public class TestBugs extends TestCase
/**
* Bug 44331 - HWPFDocument.write destroys fields
* @throws IOException
*/
public void test44431_2() throws IOException
{
@ -237,7 +232,6 @@ public class TestBugs extends TestCase
/**
* Bug 45473 - HWPF cannot read file after save
* @throws IOException
*/
public void test45473() throws IOException
{
@ -292,7 +286,6 @@ public class TestBugs extends TestCase
/**
* [RESOLVED FIXED] Bug 46817 - Regression: Text from some table cells
* missing
* @throws IOException
*/
public void test46817() throws IOException
{
@ -307,7 +300,6 @@ public class TestBugs extends TestCase
* [FAILING] Bug 47286 - Word documents saves in wrong format if source
* contains form elements
*
* @throws IOException
*/
@SuppressWarnings("deprecation")
public void test47286() throws IOException
@ -526,7 +518,6 @@ public class TestBugs extends TestCase
/**
* [FAILING] Bug 50955 - error while retrieving the text file
* @throws IOException
*/
public void test50955() throws IOException
{
@ -571,9 +562,6 @@ public class TestBugs extends TestCase
/**
* [RESOLVED FIXED] Bug 51604 - replace text fails for doc (poi 3.8 beta
* release from download site )
*
* @throws IOException
* @throws FileNotFoundException
*/
public void test51604p2() throws Exception
{
@ -581,18 +569,7 @@ public class TestBugs extends TestCase
Range range = doc.getRange();
int numParagraph = range.numParagraphs();
for (int i = 0; i < numParagraph; i++ )
{
Paragraph paragraph = range.getParagraph(i);
int numCharRuns = paragraph.numCharacterRuns();
for (int j = 0; j < numCharRuns; j++ )
{
CharacterRun charRun = paragraph.getCharacterRun(j);
String text = charRun.text();
if (text.contains("Header" ) )
charRun.replaceText(text, "added");
}
}
replaceText(range, numParagraph);
doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
final FileInformationBlock fileInformationBlock = doc
@ -610,6 +587,21 @@ public class TestBugs extends TestCase
assertEquals(doc.getText().length(), totalLength);
}
private void replaceText(Range range, int numParagraph) {
for (int i = 0; i < numParagraph; i++ )
{
Paragraph paragraph = range.getParagraph(i);
int numCharRuns = paragraph.numCharacterRuns();
for (int j = 0; j < numCharRuns; j++ )
{
CharacterRun charRun = paragraph.getCharacterRun(j);
String text = charRun.text();
if (text.contains("Header" ) )
charRun.replaceText(text, "added");
}
}
}
/**
* [RESOLVED FIXED] Bug 51604 - replace text fails for doc (poi 3.8 beta
* release from download site )
@ -632,18 +624,7 @@ public class TestBugs extends TestCase
Range range = doc.getRange();
int numParagraph = range.numParagraphs();
for (int i = 0; i < numParagraph; i++ )
{
Paragraph paragraph = range.getParagraph(i);
int numCharRuns = paragraph.numCharacterRuns();
for (int j = 0; j < numCharRuns; j++ )
{
CharacterRun charRun = paragraph.getCharacterRun(j);
String text = charRun.text();
if (text.contains("Header" ) )
charRun.replaceText(text, "added");
}
}
replaceText(range, numParagraph);
doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
@ -675,7 +656,6 @@ public class TestBugs extends TestCase
/**
* Bug 51678 - Extracting text from Bug51524.zip is slow Bug 51524 -
* PapBinTable constructor is slow
* @throws IOException
*/
public void test51678And51524() throws IOException
{
@ -822,34 +802,21 @@ public class TestBugs extends TestCase
private int section2BottomMargin = 1440;
private final int section2NumColumns = 3;
@SuppressWarnings("SuspiciousNameCombination")
public void testHWPFSections() {
HWPFDocument document = null;
Paragraph para = null;
Section section = null;
Range overallRange = null;
int numParas = 0;
int numSections = 0;
document = HWPFTestDataSamples.openSampleFile("Bug53453Section.doc");
overallRange = document.getOverallRange();
numParas = overallRange.numParagraphs();
HWPFDocument document = HWPFTestDataSamples.openSampleFile("Bug53453Section.doc");
Range overallRange = document.getOverallRange();
int numParas = overallRange.numParagraphs();
for(int i = 0; i < numParas; i++) {
para = overallRange.getParagraph(i);
numSections = para.numSections();
Paragraph para = overallRange.getParagraph(i);
int numSections = para.numSections();
for(int j = 0; j < numSections; j++) {
section = para.getSection(j);
Section section = para.getSection(j);
if(para.text().trim().equals("Section1")) {
assertEquals(section1BottomMargin, section.getMarginBottom());
assertEquals(section1LeftMargin, section.getMarginLeft());
assertEquals(section1RightMargin, section.getMarginRight());
assertEquals(section1TopMargin, section.getMarginTop());
assertEquals(section1NumColumns, section.getNumColumns());
assertSection1Margin(section);
}
else if(para.text().trim().equals("Section2")) {
assertEquals(section2BottomMargin, section.getMarginBottom());
assertEquals(section2LeftMargin, section.getMarginLeft());
assertEquals(section2RightMargin, section.getMarginRight());
assertEquals(section2TopMargin, section.getMarginTop());
assertEquals(section2NumColumns, section.getNumColumns());
assertSection2Margin(section);
// Change the margin widths
this.section2BottomMargin = (int)(1.5 * AbstractWordUtils.TWIPS_PER_INCH);
@ -869,53 +836,70 @@ public class TestBugs extends TestCase
overallRange = document.getOverallRange();
numParas = overallRange.numParagraphs();
for(int i = 0; i < numParas; i++) {
para = overallRange.getParagraph(i);
numSections = para.numSections();
Paragraph para = overallRange.getParagraph(i);
int numSections = para.numSections();
for(int j = 0; j < numSections; j++) {
section = para.getSection(j);
Section section = para.getSection(j);
if(para.text().trim().equals("Section1")) {
// No changes to the margins in Section1
assertEquals(section1BottomMargin, section.getMarginBottom());
assertEquals(section1LeftMargin, section.getMarginLeft());
assertEquals(section1RightMargin, section.getMarginRight());
assertEquals(section1TopMargin, section.getMarginTop());
assertEquals(section1NumColumns, section.getNumColumns());
assertSection1Margin(section);
}
else if(para.text().trim().equals("Section2")) {
// The margins in Section2 have kept the new settings.
assertEquals(section2BottomMargin, section.getMarginBottom());
assertEquals(section2LeftMargin, section.getMarginLeft());
assertEquals(section2RightMargin, section.getMarginRight());
assertEquals(section2TopMargin, section.getMarginTop());
assertEquals(section2NumColumns, section.getNumColumns());
assertSection2Margin(section);
}
}
}
}
@SuppressWarnings("Duplicates")
private void assertSection1Margin(Section section) {
assertEquals(section1BottomMargin, section.getMarginBottom());
assertEquals(section1LeftMargin, section.getMarginLeft());
assertEquals(section1RightMargin, section.getMarginRight());
assertEquals(section1TopMargin, section.getMarginTop());
assertEquals(section1NumColumns, section.getNumColumns());
}
@SuppressWarnings("Duplicates")
private void assertSection2Margin(Section section) {
assertEquals(section2BottomMargin, section.getMarginBottom());
assertEquals(section2LeftMargin, section.getMarginLeft());
assertEquals(section2RightMargin, section.getMarginRight());
assertEquals(section2TopMargin, section.getMarginTop());
assertEquals(section2NumColumns, section.getNumColumns());
}
public void testRegressionIn315beta2() {
HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFile("cap.stanford.edu_profiles_viewbiosketch_facultyid=4009&name=m_maciver.doc");
assertNotNull(hwpfDocument);
}
public void DISABLEDtest57603SevenRowTable() throws Exception {
HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFile("57603-seven_columns.doc");
HWPFDocument hwpfDocument2 = HWPFTestDataSamples.writeOutAndReadBack(hwpfDocument);
assertNotNull(hwpfDocument2);
}
public void test57843() throws IOException {
public void test57603SevenRowTable() throws Exception {
try {
File f = POIDataSamples.getDocumentInstance().getFile("57843.doc");
boolean readOnly = true;
POIFSFileSystem fs = new POIFSFileSystem(f, readOnly);
HWPFOldDocument doc = new HWPFOldDocument(fs);
assertNotNull(doc);
doc.close();
fs.close();
fixed("57843");
HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFile("57603-seven_columns.doc");
HWPFDocument hwpfDocument2 = HWPFTestDataSamples.writeOutAndReadBack(hwpfDocument);
assertNotNull(hwpfDocument2);
hwpfDocument2.close();
hwpfDocument.close();
fixed("57603");
} catch (ArrayIndexOutOfBoundsException e) {
// expected until this bug is fixed
}
}
public void test57843() throws IOException {
File f = POIDataSamples.getDocumentInstance().getFile("57843.doc");
POIFSFileSystem fs = new POIFSFileSystem(f, true);
try {
HWPFOldDocument doc = new HWPFOldDocument(fs);
assertNotNull(doc);
doc.close();
fixed("57843");
} catch (ArrayIndexOutOfBoundsException e) {
// expected until this bug is fixed
} finally {
fs.close();
}
}
}

View File

@ -95,6 +95,7 @@ import org.junit.Test;
* <b>YK: If a bug can be tested in terms of common ss interfaces,
* define the test in the base class {@link BaseTestBugzillaIssues}</b>
*/
@SuppressWarnings("deprecation")
public final class TestBugs extends BaseTestBugzillaIssues {
// to not affect other tests running in the same JVM
@After
@ -894,7 +895,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
/**
* Problems with extracting check boxes from
* HSSFObjectData
* @throws Exception
*/
@Test(expected=FileNotFoundException.class)
public void bug44840() throws Exception {
@ -943,33 +943,15 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Check all names fit within range, and use
// DeletedArea3DPtg
InternalWorkbook w = wb1.getWorkbook();
for(int i=0; i<w.getNumNames(); i++) {
NameRecord r = w.getNameRecord(i);
assertTrue(r.getSheetNumber() <= wb1.getNumberOfSheets());
Ptg[] nd = r.getNameDefinition();
assertEquals(1, nd.length);
assertTrue(nd[0] instanceof DeletedArea3DPtg);
}
assertNames(wb1, w);
// Delete the 2nd sheet
wb1.removeSheetAt(1);
// Re-check
assertEquals(1, wb1.getNumberOfNames());
assertEquals(2, wb1.getNumberOfSheets());
for(int i=0; i<w.getNumNames(); i++) {
NameRecord r = w.getNameRecord(i);
assertTrue(r.getSheetNumber() <= wb1.getNumberOfSheets());
Ptg[] nd = r.getNameDefinition();
assertEquals(1, nd.length);
assertTrue(nd[0] instanceof DeletedArea3DPtg);
}
assertNames(wb1, w);
// Save and re-load
HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
@ -979,20 +961,23 @@ public final class TestBugs extends BaseTestBugzillaIssues {
assertEquals(1, wb2.getNumberOfNames());
assertEquals(2, wb2.getNumberOfSheets());
assertNames(wb2, w);
wb2.close();
}
private void assertNames(HSSFWorkbook wb1, InternalWorkbook w) {
for(int i=0; i<w.getNumNames(); i++) {
NameRecord r = w.getNameRecord(i);
assertTrue(r.getSheetNumber() <= wb2.getNumberOfSheets());
assertTrue(r.getSheetNumber() <= wb1.getNumberOfSheets());
Ptg[] nd = r.getNameDefinition();
assertEquals(1, nd.length);
assertTrue(nd[0] instanceof DeletedArea3DPtg);
}
wb2.close();
}
/**
* Test that fonts get added properly
* @throws IOException
*/
@Test
public void bug45338() throws IOException {
@ -1061,12 +1046,14 @@ public final class TestBugs extends BaseTestBugzillaIssues {
"Thingy", false, true, (short)2, (byte)2
)
);
HSSFFont font = wb.findFont(
(short) 11, (short) 123, (short) 22,
"Thingy", false, true, (short) 2, (byte) 2
);
assertNotNull(font);
assertEquals(
5,
wb.findFont(
(short)11, (short)123, (short)22,
"Thingy", false, true, (short)2, (byte)2
).getIndex()
font.getIndex()
);
assertEquals(nf,
wb.findFont(
@ -1187,10 +1174,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
* In this sample file, the vector column
* is C, and the data column is B.
*
* For now, blows up with an exception from ExtPtg
* Expected ExpPtg to be converted from Shared to Non-Shared...
*/
@Ignore
@Ignore("For now, blows up with an exception from ExtPtg")
@Test
public void test43623() throws Exception {
HSSFWorkbook wb1 = openSample("43623.xls");
assertEquals(1, wb1.getNumberOfSheets());
@ -1223,7 +1210,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
/**
* People are all getting confused about the last
* row and cell number
* @throws IOException
*/
@Test
public void bug30635() throws IOException {
@ -1796,7 +1782,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Ensure the print setup
assertEquals("new_sheet!$A$1:$C$1", wb2.getPrintArea(0));
assertEquals("new_sheet!$A$1:$C$1", wb2.getName("Print_Area").getRefersToFormula());
HSSFName printArea = wb2.getName("Print_Area");
assertNotNull(printArea);
assertEquals("new_sheet!$A$1:$C$1", printArea.getRefersToFormula());
// Needs reference not value
NameRecord nr = wb2.getWorkbook().getNameRecord(
@ -1902,30 +1890,33 @@ public final class TestBugs extends BaseTestBugzillaIssues {
*/
@Test
public void bug49185() throws Exception {
HSSFWorkbook wb1 = openSample("49185.xls");
Name name = wb1.getName("foobarName");
assertEquals("This is a comment", name.getComment());
HSSFWorkbook wb1 = openSample("49185.xls");
Name name = wb1.getName("foobarName");
assertNotNull(name);
assertEquals("This is a comment", name.getComment());
// Rename the name, comment comes with it
name.setNameName("ChangedName");
assertEquals("This is a comment", name.getComment());
// Rename the name, comment comes with it
name.setNameName("ChangedName");
assertEquals("This is a comment", name.getComment());
// Save and re-check
HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
wb1.close();
name = wb2.getName("ChangedName");
assertEquals("This is a comment", name.getComment());
// Save and re-check
HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
wb1.close();
name = wb2.getName("ChangedName");
assertNotNull(name);
assertEquals("This is a comment", name.getComment());
// Now try to change it
name.setComment("Changed Comment");
assertEquals("Changed Comment", name.getComment());
// Now try to change it
name.setComment("Changed Comment");
assertEquals("Changed Comment", name.getComment());
// Save and re-check
HSSFWorkbook wb3 = writeOutAndReadBack(wb2);
wb2.close();
name = wb3.getName("ChangedName");
assertEquals("Changed Comment", name.getComment());
wb3.close();
// Save and re-check
HSSFWorkbook wb3 = writeOutAndReadBack(wb2);
wb2.close();
name = wb3.getName("ChangedName");
assertNotNull(name);
assertEquals("Changed Comment", name.getComment());
wb3.close();
}
/**
@ -2081,7 +2072,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
/**
* Last row number when shifting rows
* @throws IOException
*/
@Test
public void bug50416LastRowNumber() throws IOException {
@ -2562,10 +2552,11 @@ public final class TestBugs extends BaseTestBugzillaIssues {
/** Row style information is 12 not 16 bits */
@Test
public void bug49237() throws Exception {
HSSFWorkbook wb = openSample("49237.xls");
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(0);
HSSFCellStyle rstyle = row.getRowStyle();
Workbook wb = openSample("49237.xls");
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
CellStyle rstyle = row.getRowStyle();
assertNotNull(rstyle);
assertEquals(BorderStyle.DOUBLE, rstyle.getBorderBottomEnum());
wb.close();
}