You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/04/16 00:47:43 UTC
svn commit: r648444 [3/3] - in /poi/branches/ooxml: ./
src/documentation/content/xdocs/ src/java/org/apache/poi/hssf/dev/
src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/
src/java/org/apache/poi/hssf/record/formula/ src/java/org...
Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java Tue Apr 15 15:47:30 2008
@@ -757,4 +757,50 @@
}
return addPicture(data, format);
}
+
+ /**
+ * Add a font in this presentation
+ *
+ * @param font the font to add
+ * @return 0-based index of the font
+ */
+ public int addFont(PPFont font) {
+ FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
+ int idx = fonts.getFontIndex(font.getFontName());
+ if(idx == -1){
+ idx = fonts.addFont(font.getFontName(), font.getCharSet(), font.getFontFlags(), font.getFontType(), font.getPitchAndFamily());
+ }
+ return idx;
+ }
+
+ /**
+ * Get a font by index
+ *
+ * @param idx 0-based index of the font
+ * @return of an instance of <code>PPFont</code> or <code>null</code> if not found
+ */
+ public PPFont getFont(int idx) {
+ PPFont font = null;
+ FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
+ Record[] ch = fonts.getChildRecords();
+ for (int i = 0; i < ch.length; i++) {
+ if(ch[i] instanceof FontEntityAtom) {
+ FontEntityAtom atom = (FontEntityAtom)ch[i];
+ if(atom.getFontIndex() == idx){
+ font = new PPFont(atom);
+ break;
+ }
+ }
+ }
+ return font;
+ }
+
+ /**
+ * get the number of fonts in the presentation
+ *
+ * @return number of fonts
+ */
+ public int getNumberOfFonts() {
+ return getDocumentRecord().getEnvironment().getFontCollection().getNumberOfFonts();
+ }
}
Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/empty.ppt
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/empty.ppt?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Tue Apr 15 15:47:30 2008
@@ -218,8 +218,8 @@
ArrayList lst2 = new ArrayList();
Shape[] sh = sl[k].getShapes();
for (int i = 0; i < sh.length; i++) {
- if (sh[i] instanceof TextBox){
- TextBox tbox = (TextBox)sh[i];
+ if (sh[i] instanceof TextShape){
+ TextShape tbox = (TextShape)sh[i];
lst2.add(tbox.getText());
}
}
Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Tue Apr 15 15:47:30 2008
@@ -316,8 +316,8 @@
ArrayList lst = new ArrayList();
Shape[] shape = slide.getShapes();
for (int i = 0; i < shape.length; i++) {
- if( shape[i] instanceof TextBox){
- TextRun textRun = ((TextBox)shape[i]).getTextRun();
+ if( shape[i] instanceof TextShape){
+ TextRun textRun = ((TextShape)shape[i]).getTextRun();
if(textRun != null) lst.add(textRun);
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Tue Apr 15 15:47:30 2008
@@ -142,7 +142,7 @@
assertEquals(true, flag.getValue());
assertEquals("Y", y.getValue());
assertEquals("N", n.getValue());
- assertEquals("IF", funif.toFormulaString((Workbook) null));
+ assertEquals("IF", funif.toFormulaString((HSSFWorkbook) null));
assertTrue("Goto ptg exists", goto1.isGoto());
}
@@ -283,7 +283,7 @@
}
public void testMacroFunction() {
- Workbook w = Workbook.createWorkbook();
+ HSSFWorkbook w = new HSSFWorkbook();
FormulaParser fp = new FormulaParser("FOO()", w);
fp.parse();
Ptg[] ptg = fp.getRPNPtg();
@@ -589,8 +589,7 @@
* a formula consisting of a single no-arg function got rendered without the function braces
*/
public void testToFormulaStringZeroArgFunction() {
-
- Workbook book = Workbook.createWorkbook(); // not really used in this test
+ HSSFWorkbook book = new HSSFWorkbook();
Ptg[] ptgs = {
new FuncPtg(10, 0),
@@ -889,7 +888,7 @@
}
}
public void testFuncPtgSelection() {
- Workbook book = Workbook.createWorkbook();
+ HSSFWorkbook book = new HSSFWorkbook();
Ptg[] ptgs;
ptgs = FormulaParser.parse("countif(A1:A2, 1)", book);
assertEquals(3, ptgs.length);
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Tue Apr 15 15:47:30 2008
@@ -19,11 +19,11 @@
import junit.framework.TestCase;
-import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
import org.apache.poi.hssf.record.cf.BorderFormatting;
import org.apache.poi.hssf.record.cf.FontFormatting;
import org.apache.poi.hssf.record.cf.PatternFormatting;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.util.LittleEndian;
@@ -38,7 +38,7 @@
public void testCreateCFRuleRecord ()
{
- Workbook workbook = Workbook.createWorkbook();
+ HSSFWorkbook workbook = new HSSFWorkbook();
CFRuleRecord record = CFRuleRecord.create(workbook, "7");
testCFRuleRecord(record);
@@ -278,7 +278,7 @@
}
public void testWrite() {
- Workbook workbook = Workbook.createWorkbook();
+ HSSFWorkbook workbook = new HSSFWorkbook();
CFRuleRecord rr = CFRuleRecord.create(workbook, ComparisonOperator.BETWEEN, "5", "10");
PatternFormatting patternFormatting = new PatternFormatting();
@@ -293,7 +293,8 @@
int flags = LittleEndian.getInt(data, 10);
assertEquals("unused flags should be 111", 0x00380000, flags & 0x00380000);
assertEquals("undocumented flags should be 0000", 0, flags & 0x03C00000); // Otherwise Excel gets unhappy
- assertEquals(0xA03FFFFF, flags);
+ // check all remaining flag bits (some are not well understood yet)
+ assertEquals(0x203FFFFF, flags);
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java Tue Apr 15 15:47:30 2008
@@ -24,12 +24,12 @@
import junit.framework.TestCase;
-import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.CFHeaderRecord;
import org.apache.poi.hssf.record.CFRuleRecord;
import org.apache.poi.hssf.record.RecordFactory;
import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
import org.apache.poi.hssf.record.cf.CellRange;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* Tests the serialization and deserialization of the CFRecordsAggregate
@@ -42,7 +42,7 @@
public void testCFRecordsAggregate()
{
- Workbook workbook = Workbook.createWorkbook();
+ HSSFWorkbook workbook = new HSSFWorkbook();
List recs = new ArrayList();
CFHeaderRecord header = new CFHeaderRecord();
CFRuleRecord rule1 = CFRuleRecord.create(workbook, "7");
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java Tue Apr 15 15:47:30 2008
@@ -51,13 +51,9 @@
/**
* Creates a new Workbook and adds one sheet with the specified name
*/
- protected static final Workbook createWorkbookWithSheet(String sheetName) {
-
- Workbook book = Workbook.createWorkbook();
- // this creates sheet if it doesn't exist
- book.checkExternSheet(0);
- // TODO - this call alone does not create the sheet even though the javadoc says it does
- book.setSheetName(0, sheetName);
+ protected static final HSSFWorkbook createWorkbookWithSheet(String sheetName) {
+ HSSFWorkbook book = new HSSFWorkbook();
+ book.createSheet(sheetName);
return book;
}
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java Tue Apr 15 15:47:30 2008
@@ -18,7 +18,7 @@
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.model.Workbook;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* Tests for Area3DPtg
@@ -35,7 +35,7 @@
Area3DPtg target = new Area3DPtg("A1:B1", (short)0);
String sheetName = "my sheet";
- Workbook book = createWorkbookWithSheet(sheetName);
+ HSSFWorkbook book = createWorkbookWithSheet(sheetName);
assertEquals("'my sheet'!A1:B1", target.toFormulaString(book));
book.setSheetName(0, "Sheet1");
@@ -44,7 +44,4 @@
book.setSheetName(0, "C64");
assertEquals("'C64'!A1:B1", target.toFormulaString(book));
}
-
-
-
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java Tue Apr 15 15:47:30 2008
@@ -18,7 +18,7 @@
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.model.Workbook;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* Tests for Ref3DPtg
@@ -31,7 +31,7 @@
Ref3DPtg target = new Ref3DPtg("A1", (short)0);
- Workbook book = createWorkbookWithSheet("my sheet");
+ HSSFWorkbook book = createWorkbookWithSheet("my sheet");
assertEquals("'my sheet'!A1", target.toFormulaString(book));
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java Tue Apr 15 15:47:30 2008
@@ -26,6 +26,7 @@
import org.apache.poi.hssf.record.formula.FuncPtg;
import org.apache.poi.hssf.record.formula.FuncVarPtg;
import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* Tests parsing of some built-in functions that were not properly
* registered in POI as bug #44675, #44733 (March/April 2008).
@@ -35,7 +36,7 @@
public final class TestParseMissingBuiltInFuncs extends TestCase {
private static Ptg[] parse(String formula) {
- Workbook book = Workbook.createWorkbook();
+ HSSFWorkbook book = new HSSFWorkbook();
return FormulaParser.parse(formula, book);
}
private static void confirmFunc(String formula, int expPtgArraySize, boolean isVarArgFunc, int funcIx) {
@@ -57,7 +58,7 @@
assertEquals(expCls, ptgF.getClass());
// check that parsed Ptg array converts back to formula text OK
- Workbook book = Workbook.createWorkbook();
+ HSSFWorkbook book = new HSSFWorkbook();
String reRenderedFormula = FormulaParser.toFormulaString(book, ptgs);
assertEquals(formula, reRenderedFormula);
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java Tue Apr 15 15:47:30 2008
@@ -203,7 +203,7 @@
assertEquals(2, ptg.getLastColumn());
assertEquals(0, ptg.getFirstRow());
assertEquals(65535, ptg.getLastRow());
- assertEquals("C:C", ptg.toFormulaString(wb.getWorkbook()));
+ assertEquals("C:C", ptg.toFormulaString(wb));
// Will show as C:C, but won't know how many
// rows it covers as we don't have the sheet
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java Tue Apr 15 15:47:30 2008
@@ -34,22 +34,26 @@
HSSFSheet sheet = workbook.createSheet();
String formula = "7";
- HSSFFontFormatting fontFmt = new HSSFFontFormatting();
+ HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+
+ HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
+ HSSFFontFormatting fontFmt = rule1.createFontFormatting();
fontFmt.setFontStyle(true, false);
- HSSFBorderFormatting bordFmt = new HSSFBorderFormatting();
+ HSSFBorderFormatting bordFmt = rule1.createBorderFormatting();
bordFmt.setBorderBottom(HSSFBorderFormatting.BORDER_THIN);
bordFmt.setBorderTop(HSSFBorderFormatting.BORDER_THICK);
bordFmt.setBorderLeft(HSSFBorderFormatting.BORDER_DASHED);
bordFmt.setBorderRight(HSSFBorderFormatting.BORDER_DOTTED);
- HSSFPatternFormatting patternFmt = new HSSFPatternFormatting();
- patternFmt.setFillBackgroundColor(HSSFColor.RED.index);
+ HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
+ patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
+
+ HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
HSSFConditionalFormattingRule [] cfRules =
{
- sheet.createConditionalFormattingRule(formula, fontFmt, bordFmt, patternFmt),
- sheet.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2", fontFmt, bordFmt, patternFmt)
+ rule1, rule2
};
short col = 1;
@@ -58,14 +62,14 @@
new Region(0,col,65535,col)
};
- sheet.addConditionalFormatting(regions, cfRules);
- sheet.addConditionalFormatting(regions, cfRules);
+ sheetCF.addConditionalFormatting(regions, cfRules);
+ sheetCF.addConditionalFormatting(regions, cfRules);
// Verification
- assertEquals(2, sheet.getNumConditionalFormattings());
- sheet.removeConditionalFormatting(1);
- assertEquals(1, sheet.getNumConditionalFormattings());
- HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(0);
+ assertEquals(2, sheetCF.getNumConditionalFormattings());
+ sheetCF.removeConditionalFormatting(1);
+ assertEquals(1, sheetCF.getNumConditionalFormattings());
+ HSSFConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
assertNotNull(cf);
regions = cf.getFormattingRegions();
@@ -79,7 +83,7 @@
assertEquals(2, cf.getNumberOfRules());
- HSSFConditionalFormattingRule rule1 = cf.getRule(0);
+ rule1 = cf.getRule(0);
assertEquals("7",rule1.getFormula1());
assertNull(rule1.getFormula2());
@@ -98,11 +102,10 @@
HSSFPatternFormatting r1pf = rule1.getPatternFormatting();
assertNotNull(r1pf);
- assertEquals(HSSFColor.RED.index,r1pf.getFillBackgroundColor());
+ assertEquals(HSSFColor.YELLOW.index,r1pf.getFillBackgroundColor());
- HSSFConditionalFormattingRule rule2 = cf.getRule(1);
+ rule2 = cf.getRule(1);
assertEquals("2",rule2.getFormula2());
assertEquals("1",rule2.getFormula1());
}
-
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java?rev=648444&r1=648443&r2=648444&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java Tue Apr 15 15:47:30 2008
@@ -211,12 +211,12 @@
Area3DPtg ptgB = (Area3DPtg)def.get(1);
Area3DPtg ptgC = (Area3DPtg)def.get(2);
UnionPtg ptgD = (UnionPtg)def.get(3);
- assertEquals("", ptgA.toFormulaString(workbook));
- assertEquals(refA, ptgB.toFormulaString(workbook));
- assertEquals(refB, ptgC.toFormulaString(workbook));
- assertEquals(",", ptgD.toFormulaString(workbook));
+ assertEquals("", ptgA.toFormulaString(wb));
+ assertEquals(refA, ptgB.toFormulaString(wb));
+ assertEquals(refB, ptgC.toFormulaString(wb));
+ assertEquals(",", ptgD.toFormulaString(wb));
- assertEquals(ref, nr.getAreaReference(workbook));
+ assertEquals(ref, nr.getAreaReference(wb));
// Check the high level definition
int idx = wb.getNameIndex("test");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org