more tests to ensure that poi compiles against poi-ooxml-schemas.jar

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1351994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2012-06-20 08:46:50 +00:00
parent 7aea48961d
commit 21e710c082
9 changed files with 137 additions and 9 deletions

View File

@ -425,7 +425,13 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
}
};
fetchParagraphProperty(fetcher);
return fetcher.getValue() == null ? getDefaultTabSize() : fetcher.getValue();
return fetcher.getValue() == null ? 0. : fetcher.getValue();
}
public void addTabStop(double value){
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
CTTextTabStopList tabStops = pr.isSetTabLst() ? pr.getTabLst() : pr.addNewTabLst();
tabStops.addNewTab().setPos(Units.toEMU(value));
}
/**

View File

@ -352,6 +352,39 @@ public class XSLFTextRun {
return fetcher.getValue() == null ? false : fetcher.getValue();
}
/**
* Set the baseline for both the superscript and subscript fonts.
* <p>
* The size is specified using a percentage.
* Positive values indicate superscript, negative values indicate subscript.
* </p>
*
* @param baselineOffset
*/
public void setBaselineOffset(double baselineOffset){
getRPr().setBaseline((int) baselineOffset * 1000);
}
/**
* Set whether the text in this run is formatted as superscript.
* Default base line offset is 30%
*
* @see #setBaselineOffset(double)
*/
public void setSuperscript(boolean flag){
setBaselineOffset(flag ? 30. : 0.);
}
/**
* Set whether the text in this run is formatted as subscript.
* Default base line offset is -25%.
*
* @see #setBaselineOffset(double)
*/
public void setSubscript(boolean flag){
setBaselineOffset(flag ? -25.0 : 0.);
}
/**
* @return whether a run of text will be formatted as a superscript text. Default is false.
*/

View File

@ -17,11 +17,7 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
import org.openxmlformats.schemas.drawingml.x2006.main.STPresetColorVal;
import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import java.awt.Color;
@ -149,4 +145,19 @@ public class TestXSLFColor extends TestCase {
assertEquals(XSLFColor.presetColors.get(colorName), color.getColor());
}
}
public void testSys() {
CTColor xml = CTColor.Factory.newInstance();
CTSystemColor sys = xml.addNewSysClr();
sys.setVal(STSystemColorVal.GRAY_TEXT);
XSLFColor color = new XSLFColor(xml, null, null);
assertEquals(Color.black, color.getColor());
xml = CTColor.Factory.newInstance();
sys = xml.addNewSysClr();
sys.setLastClr(new byte[]{(byte)0xFF, 0, 0});
color = new XSLFColor(xml, null, null);
assertEquals(Color.red, color.getColor());
}
}

View File

@ -19,9 +19,7 @@ package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import java.awt.Color;
@ -231,4 +229,14 @@ public class TestXSLFSimpleShape extends TestCase {
}
public void testShadowEffects(){
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
CTStyleMatrix styleMatrix = slide.getTheme().getXmlObject().getThemeElements().getFmtScheme();
CTEffectStyleList lst = styleMatrix.getEffectStyleLst();
assertNotNull(lst);
for(CTEffectStyleItem ef : lst.getEffectStyleList()){
CTOuterShadowEffect obj = ef.getEffectLst().getOuterShdw();
}
}
}

View File

@ -17,6 +17,7 @@
package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyle;
/**
* @author Yegor Kozlov
@ -30,4 +31,9 @@ public class TestXSLFTableStyles extends TestCase {
assertEquals(0, tblStyles.getStyles().size());
}
public void testStyle(){
CTTableStyle obj = CTTableStyle.Factory.newInstance();
XSLFTableStyle style = new XSLFTableStyle(obj);
}
}

View File

@ -289,6 +289,17 @@ public class TestXSLFTextParagraph extends TestCase {
p.setBullet(false);
assertFalse(p.isBullet());
p.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_BOTH, 1);
double tabStop = p.getTabStop(0);
assertEquals(0.0, tabStop);
p.addTabStop(100.);
assertEquals(100., p.getTabStop(0));
assertEquals(72.0, p.getDefaultTabSize());
}
public void testLineBreak(){

View File

@ -56,5 +56,16 @@ public class TestXSLFTextRun extends TestCase {
r.setFontSize(13.0);
assertEquals(13.0, r.getFontSize());
assertEquals(false, r.isSuperscript());
r.setSuperscript(true);
assertEquals(true, r.isSuperscript());
r.setSuperscript(false);
assertEquals(false, r.isSuperscript());
assertEquals(false, r.isSubscript());
r.setSubscript(true);
assertEquals(true, r.isSubscript());
r.setSubscript(false);
assertEquals(false, r.isSubscript());
}
}

View File

@ -337,4 +337,10 @@ public final class TestXWPFDocument extends TestCase {
doc.getPackage().revert();
}
public void testSettings(){
XWPFSettings settings = new XWPFSettings();
settings.setZoomPercent(50);
assertEquals(50, settings.getZoomPercent());
}
}

View File

@ -26,7 +26,11 @@ import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLatentStyles;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLsdException;
public class TestXWPFStyles extends TestCase {
@ -82,4 +86,36 @@ public class TestXWPFStyles extends TestCase {
assertNotNull(styles);
}
/**
* YK: tests below don't make much sense,
* they exist only to copy xml beans to pi-ooxml-schemas.jar
*/
public void testLanguages(){
XWPFDocument docOut = new XWPFDocument();
XWPFStyles styles = docOut.createStyles();
styles.setEastAsia("Chinese");
styles.setSpellingLanguage("English");
CTFonts def = CTFonts.Factory.newInstance();
styles.setDefaultFonts(def);
}
public void testType() {
CTStyle ctStyle = CTStyle.Factory.newInstance();
XWPFStyle style = new XWPFStyle(ctStyle);
style.setType(STStyleType.PARAGRAPH);
assertEquals(STStyleType.PARAGRAPH, style.getType());
}
public void testLatentStyles() {
CTLatentStyles latentStyles = CTLatentStyles.Factory.newInstance();
CTLsdException ex = latentStyles.addNewLsdException();
ex.setName("ex1");
XWPFLatentStyles ls = new XWPFLatentStyles(latentStyles);
assertEquals(true, ls.isLatentStyle("ex1"));
}
}