aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Mottadelli <paolo@apache.org>2008-03-25 17:55:26 +0000
committerPaolo Mottadelli <paolo@apache.org>2008-03-25 17:55:26 +0000
commit7e352cbe15c1ce2299801f8038e5bc7794498133 (patch)
treebc4a84a2532adf1c8e1fe65ea54633022c00ee47
parent0c991c8d8355c228c94a921e9a15fc43f2299e6b (diff)
downloadpoi-7e352cbe15c1ce2299801f8038e5bc7794498133.tar.gz
poi-7e352cbe15c1ce2299801f8038e5bc7794498133.zip
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
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java26
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java14
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java5
4 files changed, 29 insertions, 26 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
index 0e79149e6d..81af8d8a9e 100644
--- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
@@ -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);
+ }
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
index cf281b8065..bd260dd17a 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
@@ -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) {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
index 8f8477e17e..d848498b3d 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
@@ -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;
@@ -27,6 +29,14 @@ public class XSSFCellFill {
public Enum 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() {
CTPatternFill patternFill = fill.getPatternFill();
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
index ace6b95c0a..1cd6f063d2 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
@@ -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();