XSSFSheet removeMergedRegion + tests
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@646527 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e047e25094
commit
3c1c5bac83
@ -202,6 +202,7 @@ under the License.
|
|||||||
<path id="scratchpad.classpath">
|
<path id="scratchpad.classpath">
|
||||||
<path refid="main.classpath"/>
|
<path refid="main.classpath"/>
|
||||||
<pathelement location="${main.output.dir}"/>
|
<pathelement location="${main.output.dir}"/>
|
||||||
|
<pathelement location="${scratchpad.output.dir}"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<path id="contrib.classpath">
|
<path id="contrib.classpath">
|
||||||
@ -234,6 +235,7 @@ under the License.
|
|||||||
|
|
||||||
<path id="test.ooxml.classpath">
|
<path id="test.ooxml.classpath">
|
||||||
<path refid="ooxml.classpath"/>
|
<path refid="ooxml.classpath"/>
|
||||||
|
<path refid="scratchpad.classpath"/>
|
||||||
<pathelement location="${ooxml.output.dir}"/>
|
<pathelement location="${ooxml.output.dir}"/>
|
||||||
<pathelement location="${ooxml.output.test.dir}"/>
|
<pathelement location="${ooxml.output.test.dir}"/>
|
||||||
<pathelement location="${main.output.test.dir}"/> <!-- ooxml tests use some utilities from main tests -->
|
<pathelement location="${main.output.test.dir}"/> <!-- ooxml tests use some utilities from main tests -->
|
||||||
@ -553,7 +555,7 @@ under the License.
|
|||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="test" depends="test-main,test-scratchpad,test-contrib"
|
<target name="test" depends="test-main,test-scratchpad,test-contrib,test-ooxml"
|
||||||
description="Tests main, contrib and scratchpad"/>
|
description="Tests main, contrib and scratchpad"/>
|
||||||
|
|
||||||
<target name="-test-main-check">
|
<target name="-test-main-check">
|
||||||
@ -585,6 +587,8 @@ under the License.
|
|||||||
<exclude name="**/All*Tests.java"/>
|
<exclude name="**/All*Tests.java"/>
|
||||||
<exclude name="**/TestUnfixedBugs.java"/>
|
<exclude name="**/TestUnfixedBugs.java"/>
|
||||||
<exclude name="**/TestcaseRecordInputStream.java"/>
|
<exclude name="**/TestcaseRecordInputStream.java"/>
|
||||||
|
<exclude name="**/TestRawDataBlock.java"/>
|
||||||
|
<exclude name="**/TestRawDataBlockList.java"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</batchtest>
|
</batchtest>
|
||||||
</junit>
|
</junit>
|
||||||
@ -792,6 +796,7 @@ under the License.
|
|||||||
<fileset dir="${ooxml.src.test}">
|
<fileset dir="${ooxml.src.test}">
|
||||||
<include name="**/Test*.java"/>
|
<include name="**/Test*.java"/>
|
||||||
<exclude name="**/All*Tests.java"/>
|
<exclude name="**/All*Tests.java"/>
|
||||||
|
<exclude name="**/TestExtractorFactory.java"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</batchtest>
|
</batchtest>
|
||||||
</junit>
|
</junit>
|
||||||
@ -1315,7 +1320,7 @@ FORREST_HOME environment variable!</echo>
|
|||||||
<!-- Abort the build if JUnit is missing. -->
|
<!-- Abort the build if JUnit is missing. -->
|
||||||
<target name="fail-unless-junit-is-available" depends="init">
|
<target name="fail-unless-junit-is-available" depends="init">
|
||||||
<condition property="isAvailable.junit">
|
<condition property="isAvailable.junit">
|
||||||
<available classname="junit.framework.TestCase"/>
|
<available file="${junit.jar1.dir}"/>
|
||||||
</condition>
|
</condition>
|
||||||
<antcall target="fail-junit"/>
|
<antcall target="fail-junit"/>
|
||||||
</target>
|
</target>
|
||||||
|
@ -65,7 +65,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetView;
|
|||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
|
|
||||||
|
|
||||||
|
|
||||||
public class XSSFSheet implements Sheet {
|
public class XSSFSheet implements Sheet {
|
||||||
@ -645,8 +644,16 @@ public class XSSFSheet implements Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeMergedRegion(int index) {
|
public void removeMergedRegion(int index) {
|
||||||
// TODO Auto-generated method stub
|
CTMergeCell[] mergeCellsArray = new CTMergeCell[getMergedCells().sizeOfMergeCellArray() - 1];
|
||||||
|
for (int i = 0 ; i < getMergedCells().sizeOfMergeCellArray() ; i++) {
|
||||||
|
if (i < index) {
|
||||||
|
mergeCellsArray[i] = getMergedCells().getMergeCellArray(i);
|
||||||
|
}
|
||||||
|
else if (i > index) {
|
||||||
|
mergeCellsArray[i - 1] = getMergedCells().getMergeCellArray(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getMergedCells().setMergeCellArray(mergeCellsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRow(Row row) {
|
public void removeRow(Row row) {
|
||||||
|
@ -570,6 +570,27 @@ public class TestXSSFSheet extends TestCase {
|
|||||||
assertEquals(1, sheet.getNumMergedRegions());
|
assertEquals(1, sheet.getNumMergedRegions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRemoveMergedRegion() {
|
||||||
|
Workbook workbook = new XSSFWorkbook();
|
||||||
|
CTSheet ctSheet = CTSheet.Factory.newInstance();
|
||||||
|
CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
|
||||||
|
XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
|
||||||
|
Region region_1 = new Region("A1:B2");
|
||||||
|
Region region_2 = new Region("C3:D4");
|
||||||
|
Region region_3 = new Region("E5:F6");
|
||||||
|
sheet.addMergedRegion(region_1);
|
||||||
|
sheet.addMergedRegion(region_2);
|
||||||
|
sheet.addMergedRegion(region_3);
|
||||||
|
assertEquals("C3:D4", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
|
||||||
|
assertEquals(3, sheet.getNumMergedRegions());
|
||||||
|
sheet.removeMergedRegion(1);
|
||||||
|
assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
|
||||||
|
assertEquals(2, sheet.getNumMergedRegions());
|
||||||
|
sheet.removeMergedRegion(1);
|
||||||
|
sheet.removeMergedRegion(0);
|
||||||
|
assertEquals(0, sheet.getNumMergedRegions());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private XSSFSheet createSheet(XSSFWorkbook workbook, String name) {
|
private XSSFSheet createSheet(XSSFWorkbook workbook, String name) {
|
||||||
XSSFSheet sheet = (XSSFSheet) workbook.createSheet(name);
|
XSSFSheet sheet = (XSSFSheet) workbook.createSheet(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user