}\r
};\r
fetchParagraphProperty(fetcher);\r
- return fetcher.getValue() == null ? getDefaultTabSize() : fetcher.getValue();\r
+ return fetcher.getValue() == null ? 0. : fetcher.getValue();\r
+ }\r
+\r
+ public void addTabStop(double value){\r
+ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();\r
+ CTTextTabStopList tabStops = pr.isSetTabLst() ? pr.getTabLst() : pr.addNewTabLst();\r
+ tabStops.addNewTab().setPos(Units.toEMU(value));\r
}\r
\r
/**\r
return fetcher.getValue() == null ? false : fetcher.getValue();\r
}\r
\r
+ /**\r
+ * Set the baseline for both the superscript and subscript fonts.\r
+ * <p>\r
+ * The size is specified using a percentage.\r
+ * Positive values indicate superscript, negative values indicate subscript.\r
+ * </p>\r
+ *\r
+ * @param baselineOffset\r
+ */\r
+ public void setBaselineOffset(double baselineOffset){\r
+ getRPr().setBaseline((int) baselineOffset * 1000);\r
+ }\r
+\r
+ /**\r
+ * Set whether the text in this run is formatted as superscript.\r
+ * Default base line offset is 30%\r
+ *\r
+ * @see #setBaselineOffset(double)\r
+ */\r
+ public void setSuperscript(boolean flag){\r
+ setBaselineOffset(flag ? 30. : 0.);\r
+ }\r
+\r
+ /**\r
+ * Set whether the text in this run is formatted as subscript.\r
+ * Default base line offset is -25%.\r
+ *\r
+ * @see #setBaselineOffset(double)\r
+ */\r
+ public void setSubscript(boolean flag){\r
+ setBaselineOffset(flag ? -25.0 : 0.);\r
+ }\r
+\r
/**\r
* @return whether a run of text will be formatted as a superscript text. Default is false.\r
*/\r
package org.apache.poi.xslf.usermodel;\r
\r
import junit.framework.TestCase;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STPresetColorVal;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
\r
import java.awt.Color;\r
\r
assertEquals(XSLFColor.presetColors.get(colorName), color.getColor());\r
}\r
}\r
+\r
+ public void testSys() {\r
+ CTColor xml = CTColor.Factory.newInstance();\r
+ CTSystemColor sys = xml.addNewSysClr();\r
+ sys.setVal(STSystemColorVal.GRAY_TEXT);\r
+ XSLFColor color = new XSLFColor(xml, null, null);\r
+ assertEquals(Color.black, color.getColor());\r
+\r
+ xml = CTColor.Factory.newInstance();\r
+ sys = xml.addNewSysClr();\r
+ sys.setLastClr(new byte[]{(byte)0xFF, 0, 0});\r
+ color = new XSLFColor(xml, null, null);\r
+ assertEquals(Color.red, color.getColor());\r
+ }\r
+\r
}
\ No newline at end of file
import junit.framework.TestCase;\r
import org.apache.poi.util.Units;\r
import org.apache.poi.xslf.XSLFTestDataSamples;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
\r
import java.awt.Color;\r
\r
\r
}\r
\r
+ public void testShadowEffects(){\r
+ XMLSlideShow ppt = new XMLSlideShow();\r
+ XSLFSlide slide = ppt.createSlide();\r
+ CTStyleMatrix styleMatrix = slide.getTheme().getXmlObject().getThemeElements().getFmtScheme();\r
+ CTEffectStyleList lst = styleMatrix.getEffectStyleLst();\r
+ assertNotNull(lst);\r
+ for(CTEffectStyleItem ef : lst.getEffectStyleList()){\r
+ CTOuterShadowEffect obj = ef.getEffectLst().getOuterShdw();\r
+ }\r
+ }\r
}
\ No newline at end of file
package org.apache.poi.xslf.usermodel;\r
\r
import junit.framework.TestCase;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyle;\r
\r
/**\r
* @author Yegor Kozlov\r
\r
assertEquals(0, tblStyles.getStyles().size());\r
}\r
+\r
+ public void testStyle(){\r
+ CTTableStyle obj = CTTableStyle.Factory.newInstance();\r
+ XSLFTableStyle style = new XSLFTableStyle(obj);\r
+ }\r
}
\ No newline at end of file
\r
p.setBullet(false);\r
assertFalse(p.isBullet());\r
+\r
+ p.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_BOTH, 1);\r
+\r
+ double tabStop = p.getTabStop(0);\r
+ assertEquals(0.0, tabStop);\r
+\r
+ p.addTabStop(100.);\r
+ assertEquals(100., p.getTabStop(0));\r
+\r
+ assertEquals(72.0, p.getDefaultTabSize());\r
+\r
}\r
\r
public void testLineBreak(){\r
r.setFontSize(13.0);\r
assertEquals(13.0, r.getFontSize());\r
\r
+ assertEquals(false, r.isSuperscript());\r
+ r.setSuperscript(true);\r
+ assertEquals(true, r.isSuperscript());\r
+ r.setSuperscript(false);\r
+ assertEquals(false, r.isSuperscript());\r
+\r
+ assertEquals(false, r.isSubscript());\r
+ r.setSubscript(true);\r
+ assertEquals(true, r.isSubscript());\r
+ r.setSubscript(false);\r
+ assertEquals(false, r.isSubscript());\r
}\r
}\r
doc.getPackage().revert();
}
+
+ public void testSettings(){
+ XWPFSettings settings = new XWPFSettings();
+ settings.setZoomPercent(50);
+ assertEquals(50, settings.getZoomPercent());
+ }
}
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 {
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"));
+
+ }
}