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
aa7fa34376
commit
5b32d35fb6
@ -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.CTXf;
|
||||
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));
|
||||
}
|
||||
public long putBorder(XSSFCellBorder border) {
|
||||
return putBorder(border.getCTBorder());
|
||||
}
|
||||
public synchronized long putBorder(CTBorder border) {
|
||||
if(borders.contains(border)) {
|
||||
return borders.indexOf(border);
|
||||
}
|
||||
borders.add(border);
|
||||
return borders.size() - 1;
|
||||
return putBorder(border, borders);
|
||||
}
|
||||
|
||||
public XSSFCellFill getFillAt(long idx) {
|
||||
return new XSSFCellFill(fills.get((int) idx));
|
||||
}
|
||||
public long putFill(XSSFCellFill fill) {
|
||||
return putFill(fill.getCTFill());
|
||||
}
|
||||
public synchronized long putFill(CTFill fill) {
|
||||
if (fills.contains(fill)) {
|
||||
return fills.indexOf(fill);
|
||||
}
|
||||
fills.add(fill);
|
||||
return fills.size() - 1;
|
||||
return putFill(fill, fills);
|
||||
}
|
||||
/**
|
||||
* For unit testing only
|
||||
@ -331,4 +316,11 @@ public class StylesTable implements StylesSource, XSSFModel {
|
||||
// Save
|
||||
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;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle.Enum;
|
||||
@ -43,12 +45,12 @@ public class XSSFCellBorder {
|
||||
TOP, RIGHT, BOTTOM, LEFT
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO - is this the best way to allow StylesTable
|
||||
* to record us?
|
||||
*/
|
||||
public CTBorder getCTBorder() {
|
||||
return border;
|
||||
public long putBorder(LinkedList<CTBorder> borders) {
|
||||
if(borders.contains(border)) {
|
||||
return borders.indexOf(border);
|
||||
}
|
||||
borders.add(border);
|
||||
return borders.size() - 1;
|
||||
}
|
||||
|
||||
public Enum getBorderStyle(BorderSides side) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.CTPatternFill;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType.Enum;
|
||||
@ -28,6 +30,14 @@ public class XSSFCellFill {
|
||||
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() {
|
||||
CTPatternFill patternFill = fill.getPatternFill();
|
||||
if (patternFill == null) {
|
||||
|
@ -36,7 +36,6 @@ public class TestXSSFCellStyle extends TestCase {
|
||||
|
||||
private StylesTable stylesTable;
|
||||
private CTBorder ctBorderA;
|
||||
private CTBorder ctBorderB;
|
||||
private CTFill ctFill;
|
||||
private CTXf cellStyleXf;
|
||||
private CTXf cellXf;
|
||||
@ -49,11 +48,11 @@ public class TestXSSFCellStyle extends TestCase {
|
||||
|
||||
// Until we do XSSFBorder properly, cheat
|
||||
ctBorderA = CTBorder.Factory.newInstance();
|
||||
long borderId = stylesTable.putBorder(ctBorderA);
|
||||
XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
|
||||
long borderId = stylesTable.putBorder(borderA);
|
||||
assertEquals(0, borderId);
|
||||
|
||||
XSSFCellBorder borderB = new XSSFCellBorder();
|
||||
ctBorderB = borderB.getCTBorder();
|
||||
assertEquals(1, stylesTable.putBorder(borderB));
|
||||
|
||||
ctFill = CTFill.Factory.newInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user