mirror of https://github.com/apache/poi.git
Bug 57231: Add missing ArrayRecord.clone()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647255 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
766300e033
commit
124cda92e6
|
@ -94,5 +94,15 @@ public final class ArrayRecord extends SharedValueRecordBase {
|
||||||
}
|
}
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
ArrayRecord rec = new ArrayRecord(_formula.copy(), getRange());
|
||||||
|
|
||||||
|
// they both seem unused, but clone them nevertheless to have an exact copy
|
||||||
|
rec._options = _options;
|
||||||
|
rec._field3notUsed = _field3notUsed;
|
||||||
|
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,17 @@ package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
||||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
import org.apache.poi.ss.formula.Formula;
|
||||||
import org.apache.poi.ss.formula.FormulaParser;
|
import org.apache.poi.ss.formula.FormulaParser;
|
||||||
import org.apache.poi.ss.formula.FormulaRenderer;
|
import org.apache.poi.ss.formula.FormulaRenderer;
|
||||||
import org.apache.poi.ss.formula.FormulaType;
|
import org.apache.poi.ss.formula.FormulaType;
|
||||||
import org.apache.poi.ss.formula.Formula;
|
import org.apache.poi.ss.formula.ptg.Ptg;
|
||||||
import org.apache.poi.util.HexRead;
|
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
|
import org.apache.poi.util.HexRead;
|
||||||
|
|
||||||
public final class TestArrayRecord extends TestCase {
|
public final class TestArrayRecord extends TestCase {
|
||||||
|
|
||||||
|
@ -53,7 +56,22 @@ public final class TestArrayRecord extends TestCase {
|
||||||
byte[] ser = r2.serialize();
|
byte[] ser = r2.serialize();
|
||||||
//serialize and check that the data is the same as in r1
|
//serialize and check that the data is the same as in r1
|
||||||
assertEquals(HexDump.toHex(data), HexDump.toHex(ser));
|
assertEquals(HexDump.toHex(data), HexDump.toHex(ser));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void testBug57231() {
|
||||||
|
HSSFWorkbook wb = HSSFTestDataSamples
|
||||||
|
.openSampleWorkbook("57231_MixedGasReport.xls");
|
||||||
|
HSSFSheet sheet = wb.getSheet("master");
|
||||||
|
|
||||||
|
HSSFSheet newSheet = wb.cloneSheet(wb.getSheetIndex(sheet));
|
||||||
|
int idx = wb.getSheetIndex(newSheet);
|
||||||
|
wb.setSheetName(idx, "newName");
|
||||||
|
|
||||||
|
// Write the output to a file
|
||||||
|
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
|
assertNotNull(wbBack);
|
||||||
|
|
||||||
|
assertNotNull(wbBack.getSheet("master"));
|
||||||
|
assertNotNull(wbBack.getSheet("newName"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue