mirror of https://github.com/apache/poi.git
XSSFCellBorder does not expose CTBorder object (same for XSSFCellFill); StylesTable refactored
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@640915 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c991c8d83
commit
7e352cbe15
|
@ -44,7 +44,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument;
|
||||||
import javax.xml.namespace.QName;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,28 +197,14 @@ public class StylesTable implements StylesSource, XSSFModel {
|
||||||
return new XSSFCellBorder(borders.get((int)idx));
|
return new XSSFCellBorder(borders.get((int)idx));
|
||||||
}
|
}
|
||||||
public long putBorder(XSSFCellBorder border) {
|
public long putBorder(XSSFCellBorder border) {
|
||||||
return putBorder(border.getCTBorder());
|
return putBorder(border, borders);
|
||||||
}
|
|
||||||
public synchronized long putBorder(CTBorder border) {
|
|
||||||
if(borders.contains(border)) {
|
|
||||||
return borders.indexOf(border);
|
|
||||||
}
|
|
||||||
borders.add(border);
|
|
||||||
return borders.size() - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public XSSFCellFill getFillAt(long idx) {
|
public XSSFCellFill getFillAt(long idx) {
|
||||||
return new XSSFCellFill(fills.get((int) idx));
|
return new XSSFCellFill(fills.get((int) idx));
|
||||||
}
|
}
|
||||||
public long putFill(XSSFCellFill fill) {
|
public long putFill(XSSFCellFill fill) {
|
||||||
return putFill(fill.getCTFill());
|
return putFill(fill, fills);
|
||||||
}
|
|
||||||
public synchronized long putFill(CTFill fill) {
|
|
||||||
if (fills.contains(fill)) {
|
|
||||||
return fills.indexOf(fill);
|
|
||||||
}
|
|
||||||
fills.add(fill);
|
|
||||||
return fills.size() - 1;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* For unit testing only
|
* For unit testing only
|
||||||
|
@ -331,4 +316,11 @@ public class StylesTable implements StylesSource, XSSFModel {
|
||||||
// Save
|
// Save
|
||||||
doc.save(out, options);
|
doc.save(out, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long putBorder(XSSFCellBorder border, LinkedList<CTBorder> borders) {
|
||||||
|
return border.putBorder(borders);
|
||||||
|
}
|
||||||
|
private long putFill(XSSFCellFill fill, LinkedList<CTFill> fills) {
|
||||||
|
return fill.putFill(fills);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package org.apache.poi.xssf.usermodel.extensions;
|
package org.apache.poi.xssf.usermodel.extensions;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle.Enum;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle.Enum;
|
||||||
|
@ -43,12 +45,12 @@ public class XSSFCellBorder {
|
||||||
TOP, RIGHT, BOTTOM, LEFT
|
TOP, RIGHT, BOTTOM, LEFT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public long putBorder(LinkedList<CTBorder> borders) {
|
||||||
* TODO - is this the best way to allow StylesTable
|
if(borders.contains(border)) {
|
||||||
* to record us?
|
return borders.indexOf(border);
|
||||||
*/
|
}
|
||||||
public CTBorder getCTBorder() {
|
borders.add(border);
|
||||||
return border;
|
return borders.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum getBorderStyle(BorderSides side) {
|
public Enum getBorderStyle(BorderSides side) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.apache.poi.xssf.usermodel.extensions;
|
package org.apache.poi.xssf.usermodel.extensions;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType.Enum;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType.Enum;
|
||||||
|
@ -27,6 +29,14 @@ public class XSSFCellFill {
|
||||||
public Enum getPatternType() {
|
public Enum getPatternType() {
|
||||||
return getPatternFill().getPatternType();
|
return getPatternFill().getPatternType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long putFill(LinkedList<CTFill> fills) {
|
||||||
|
if (fills.contains(fill)) {
|
||||||
|
return fills.indexOf(fill);
|
||||||
|
}
|
||||||
|
fills.add(fill);
|
||||||
|
return fills.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
private CTPatternFill getPatternFill() {
|
private CTPatternFill getPatternFill() {
|
||||||
CTPatternFill patternFill = fill.getPatternFill();
|
CTPatternFill patternFill = fill.getPatternFill();
|
||||||
|
|
|
@ -36,7 +36,6 @@ public class TestXSSFCellStyle extends TestCase {
|
||||||
|
|
||||||
private StylesTable stylesTable;
|
private StylesTable stylesTable;
|
||||||
private CTBorder ctBorderA;
|
private CTBorder ctBorderA;
|
||||||
private CTBorder ctBorderB;
|
|
||||||
private CTFill ctFill;
|
private CTFill ctFill;
|
||||||
private CTXf cellStyleXf;
|
private CTXf cellStyleXf;
|
||||||
private CTXf cellXf;
|
private CTXf cellXf;
|
||||||
|
@ -49,11 +48,11 @@ public class TestXSSFCellStyle extends TestCase {
|
||||||
|
|
||||||
// Until we do XSSFBorder properly, cheat
|
// Until we do XSSFBorder properly, cheat
|
||||||
ctBorderA = CTBorder.Factory.newInstance();
|
ctBorderA = CTBorder.Factory.newInstance();
|
||||||
long borderId = stylesTable.putBorder(ctBorderA);
|
XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
|
||||||
|
long borderId = stylesTable.putBorder(borderA);
|
||||||
assertEquals(0, borderId);
|
assertEquals(0, borderId);
|
||||||
|
|
||||||
XSSFCellBorder borderB = new XSSFCellBorder();
|
XSSFCellBorder borderB = new XSSFCellBorder();
|
||||||
ctBorderB = borderB.getCTBorder();
|
|
||||||
assertEquals(1, stylesTable.putBorder(borderB));
|
assertEquals(1, stylesTable.putBorder(borderB));
|
||||||
|
|
||||||
ctFill = CTFill.Factory.newInstance();
|
ctFill = CTFill.Factory.newInstance();
|
||||||
|
|
Loading…
Reference in New Issue