]> source.dussan.org Git - poi.git/commitdiff
applied patch #46229 by Gisella Bronsetti: initial implementation of XWPFParagraph
authorYegor Kozlov <yegor@apache.org>
Thu, 20 Nov 2008 18:22:20 +0000 (18:22 +0000)
committerYegor Kozlov <yegor@apache.org>
Thu, 20 Nov 2008 18:22:20 +0000 (18:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@719316 13f79535-47bb-0310-9956-ffa450edef68

src/examples/src/org/apache/poi/xwpf/usermodel/SimpleDocument.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java [new file with mode: 0755]
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java

index 29d502f9bc97bd9ec75de37c18d2bdd0429c71c3..363bc8716d782c9fd9940d5e65719a6cc4de54a6 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.xwpf.usermodel;\r
-\r
-import java.io.FileOutputStream;\r
-\r
-/**\r
- * A simple WOrdprocessingML document created by POI XWPF API\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class SimpleDocument {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-        XWPFDocument doc = new XWPFDocument();\r
-\r
-        XWPFParagraph p1 = doc.createParagraph();\r
-        p1.setAlignment(ParagraphAlignment.CENTER);\r
-\r
-        XWPFRun r1 = p1.createRun();\r
-        r1.setBold(true);\r
-        r1.setText("The quick brown fox");\r
-\r
-        XWPFParagraph p2 = doc.createParagraph();\r
-        p2.setAlignment(ParagraphAlignment.RIGHT);\r
-\r
-        XWPFRun r2 = p2.createRun();\r
-        r2.setBold(false);\r
-        r2.setText("jumped over the lazy dog");\r
-\r
-        FileOutputStream out = new FileOutputStream("simple.docx");\r
-        doc.write(out);\r
-        out.close();\r
-\r
-    }\r
-}\r
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.xwpf.usermodel;
+
+import java.io.FileOutputStream;
+import java.math.BigInteger;
+
+/**
+ * A simple WOrdprocessingML document created by POI XWPF API
+ *
+ * @author Yegor Kozlov
+ */
+public class SimpleDocument {
+
+    public static void main(String[] args) throws Exception {
+        XWPFDocument doc = new XWPFDocument();
+
+        XWPFParagraph p1 = doc.createParagraph();
+        p1.setAlignment(ParagraphAlignment.CENTER);
+        p1.setBorderBottom(Borders.DOUBLE);
+        p1.setBorderTop(Borders.DOUBLE);
+
+        p1.setBorderRight(Borders.DOUBLE);
+        p1.setBorderLeft(Borders.DOUBLE);
+        p1.setBorderBetween(Borders.SINGLE);
+
+        p1.setVerticalAlignment(TextAlignment.TOP);
+
+        XWPFRun r1 = p1.createRun();
+        r1.setBold(true);
+        r1.setText("The quick brown fox");
+        r1.setBold(true);
+        r1.setFontFamily("Courier");
+        r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
+        r1.setTextPosition(new BigInteger("100"));
+
+        XWPFParagraph p2 = doc.createParagraph();
+        p2.setAlignment(ParagraphAlignment.RIGHT);
+
+        //BORDERS
+        p2.setBorderBottom(Borders.DOUBLE);
+        p2.setBorderTop(Borders.DOUBLE);
+        p2.setBorderRight(Borders.DOUBLE);
+        p2.setBorderLeft(Borders.DOUBLE);
+        p2.setBorderBetween(Borders.SINGLE);
+
+        XWPFRun r2 = p2.createRun();
+        r2.setText("jumped over the lazy dog");
+        r2.setStrike(true);
+        r2.setFontSize(new BigInteger("20"));
+
+        XWPFRun r3 = p2.createRun();
+        r3.setText("and went away");
+        r3.setStrike(true);
+        r3.setFontSize(new BigInteger("20"));
+        r3.setSubscript(VerticalAlign.SUPERSCRIPT);
+
+
+        XWPFParagraph p3 = doc.createParagraph();
+        p3.setWordWrap(true);
+        p3.setPageBreak(true);
+        p3.setAlignment(ParagraphAlignment.DISTRIBUTE);
+        p3.setIndentationFirstLine(new BigInteger("600"));
+        p3.setSpacingAfter(new BigInteger("250"));
+        p3.setSpacingBefore(new BigInteger("250"));
+
+        XWPFRun r4 = p3.createRun();
+        r4.setTextPosition(new BigInteger("20"));
+        r4.setText("To be, or not to be: that is the question: "
+                + "Whether 'tis nobler in the mind to suffer "
+                + "The slings and arrows of outrageous fortune, "
+                + "Or to take arms against a sea of troubles, "
+                + "And by opposing end them? To die: to sleep; "
+                + "No more; and by a sleep to say we end "
+                + "The heart-ache and the thousand natural shocks "
+                + "That flesh is heir to, 'tis a consummation "
+                + "Devoutly to be wish'd. To die, to sleep; "
+                + "To sleep: perchance to dream: ay, there's the rub; "
+                + ".......");
+        r4.setItalic(true);
+
+
+        XWPFRun r5 = p3.createRun();
+        r5.setTextPosition(new BigInteger("-10"));
+        r5.setText("For in that sleep of death what dreams may come"
+                + "When we have shuffled off this mortal coil,"
+                + "Must give us pause: there's the respect"
+                + "That makes calamity of so long life;"
+                + "For who would bear the whips and scorns of time,"
+                + "The oppressor's wrong, the proud man's contumely,"
+                + "The pangs of despised love, the law's delay,"
+                + "The insolence of office and the spurns" + ".......");
+
+
+        FileOutputStream out = new FileOutputStream("simple.docx");
+        doc.write(out);
+        out.close();
+
+    }
+}
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/Borders.java
new file mode 100755 (executable)
index 0000000..fd0b635
--- /dev/null
@@ -0,0 +1,626 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+package org.apache.poi.xwpf.usermodel;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+/**\r
+ * Specifies all types of borders which can be specified for WordprocessingML\r
+ * objects which have a border. Borders can be separated into two types:\r
+ * <ul> \r
+ * <li> Line borders: which specify a pattern to be used when drawing a line around the\r
+ * specified object.\r
+ * </li> \r
+ * <li> Art borders: which specify a repeated image to be used\r
+ * when drawing a border around the specified object. Line borders may be\r
+ * specified on any object which allows a border, however, art borders may only\r
+ * be used as a border at the page level - the borders under the pgBorders\r
+ * element\r
+ *</li>\r
+ * </ul>\r
+ * @author Gisella Bronzetti\r
+ */\r
+public enum Borders {\r
+\r
+    NIL(1),\r
+\r
+    NONE(2),\r
+\r
+    /**\r
+     * Specifies a line border consisting of a single line around the parent\r
+     * object.\r
+     */\r
+    SINGLE(3),\r
+\r
+    THICK(4),\r
+\r
+    DOUBLE(5),\r
+\r
+    DOTTED(6),\r
+\r
+    DASHED(7),\r
+\r
+    DOT_DASH(8),\r
+\r
+    DOT_DOT_DASH(9),\r
+\r
+    TRIPLE(10),\r
+\r
+    THIN_THICK_SMALL_GAP(11),\r
+\r
+    THICK_THIN_SMALL_GAP(12),\r
+\r
+    THIN_THICK_THIN_SMALL_GAP(13),\r
+\r
+    THIN_THICK_MEDIUM_GAP(14),\r
+\r
+    THICK_THIN_MEDIUM_GAP(15),\r
+\r
+    THIN_THICK_THIN_MEDIUM_GAP(16),\r
+\r
+    THIN_THICK_LARGE_GAP(17),\r
+\r
+    THICK_THIN_LARGE_GAP(18),\r
+\r
+    THIN_THICK_THIN_LARGE_GAP(19),\r
+\r
+    WAVE(20),\r
+\r
+    DOUBLE_WAVE(21),\r
+\r
+    DASH_SMALL_GAP(22),\r
+\r
+    DASH_DOT_STROKED(23),\r
+\r
+    THREE_D_EMBOSS(24),\r
+\r
+    THREE_D_ENGRAVE(25),\r
+\r
+    OUTSET(26),\r
+\r
+    INSET(27),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of an apple\r
+     */\r
+    APPLES(28),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a shell pattern\r
+     */\r
+    ARCHED_SCALLOPS(29),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a baby pacifier\r
+     */\r
+    BABY_PACIFIER(30),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a baby rattle\r
+     */\r
+    BABY_RATTLE(31),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a set of\r
+     * balloons\r
+     */\r
+    BALLOONS_3_COLORS(32),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a hot air\r
+     * balloon\r
+     */\r
+    BALLOONS_HOT_AIR(33),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background.\r
+     */\r
+    BASIC_BLACK_DASHES(34),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black dot on\r
+     * a white background.\r
+     */\r
+    BASIC_BLACK_DOTS(35),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background\r
+     */\r
+    BASIC_BLACK_SQUARES(36),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background.\r
+     */\r
+    BASIC_THIN_LINES(37),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background.\r
+     */\r
+    BASIC_WHITE_DASHES(38),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a white dot on\r
+     * a black background.\r
+     */\r
+    BASIC_WHITE_DOTS(39),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background.\r
+     */\r
+    BASIC_WHITE_SQUARES(40),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background.\r
+     */\r
+    BASIC_WIDE_INLINE(41),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background\r
+     */\r
+    BASIC_WIDE_MIDLINE(42),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a black and\r
+     * white background\r
+     */\r
+    BASIC_WIDE_OUTLINE(43),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of bats\r
+     */\r
+    BATS(44),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of birds\r
+     */\r
+    BIRDS(45),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of birds flying\r
+     */\r
+    BIRDS_FLIGHT(46),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a cabin\r
+     */\r
+    CABINS(47),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a piece of cake\r
+     */\r
+    CAKE_SLICE(48),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of candy corn\r
+     */\r
+    CANDY_CORN(49),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a knot work\r
+     * pattern\r
+     */\r
+    CELTIC_KNOTWORK(50),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a banner.\r
+     * <p>\r
+     * If the border is on the left or right, no border is displayed.\r
+     * </p>\r
+     */\r
+    CERTIFICATE_BANNER(51),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a chain link\r
+     * pattern.\r
+     */\r
+    CHAIN_LINK(52),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a champagne\r
+     * bottle\r
+     */\r
+    CHAMPAGNE_BOTTLE(53),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of a compass\r
+     */\r
+    CHECKED_BAR_BLACK(54),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeating image of a colored\r
+     * pattern.\r
+     */\r
+    CHECKED_BAR_COLOR(55),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a checkerboard\r
+     */\r
+    CHECKERED(56),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a Christmas\r
+     * tree\r
+     */\r
+    CHRISTMAS_TREE(57),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of lines and\r
+     * circles\r
+     */\r
+    CIRCLES_LINES(58),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a rectangular\r
+     * pattern\r
+     */\r
+    CIRCLES_RECTANGLES(59),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a wave\r
+     */\r
+    CLASSICAL_WAVE(60),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a clock\r
+     */\r
+    CLOCKS(61),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of a compass\r
+     */\r
+    COMPASS(62),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of confetti\r
+     */\r
+    CONFETTI(63),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of confetti\r
+     */\r
+    CONFETTI_GRAYS(64),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of confetti\r
+     */\r
+    CONFETTI_OUTLINE(65),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of confetti\r
+     * streamers\r
+     */\r
+    CONFETTI_STREAMERS(66),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of confetti\r
+     */\r
+    CONFETTI_WHITE(67),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image\r
+     */\r
+    CORNER_TRIANGLES(68),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a dashed line\r
+     */\r
+    COUPON_CUTOUT_DASHES(69),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a dotted line\r
+     */\r
+    COUPON_CUTOUT_DOTS(70),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a maze-like\r
+     * pattern\r
+     */\r
+    CRAZY_MAZE(71),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a butterfly\r
+     */\r
+    CREATURES_BUTTERFLY(72),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a fish\r
+     */\r
+    CREATURES_FISH(73),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of insects.\r
+     */\r
+    CREATURES_INSECTS(74),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of a ladybug\r
+     */\r
+    CREATURES_LADY_BUG(75),\r
+\r
+    /**\r
+     * Specifies an art border consisting of repeating images of a cross-stitch\r
+     * pattern\r
+     */\r
+    CROSS_STITCH(76),\r
+\r
+    /**\r
+     * Specifies an art border consisting of a repeated image of Cupid\r
+     */\r
+    CUP(77),\r
+\r
+    DECO_ARCH(78),\r
+\r
+    DECO_ARCH_COLOR(79),\r
+\r
+    DECO_BLOCKS(80),\r
+\r
+    DIAMONDS_GRAY(81),\r
+\r
+    DOUBLE_D(82),\r
+\r
+    DOUBLE_DIAMONDS(83),\r
+\r
+    EARTH_1(84),\r
+\r
+    EARTH_2(85),\r
+\r
+    ECLIPSING_SQUARES_1(86),\r
+\r
+    ECLIPSING_SQUARES_2(87),\r
+\r
+    EGGS_BLACK(88),\r
+\r
+    FANS(89),\r
+\r
+    FILM(90),\r
+\r
+    FIRECRACKERS(91),\r
+\r
+    FLOWERS_BLOCK_PRINT(92),\r
+\r
+    FLOWERS_DAISIES(93),\r
+\r
+    FLOWERS_MODERN_1(94),\r
+\r
+    FLOWERS_MODERN_2(95),\r
+\r
+    FLOWERS_PANSY(96),\r
+\r
+    FLOWERS_RED_ROSE(97),\r
+\r
+    FLOWERS_ROSES(98),\r
+\r
+    FLOWERS_TEACUP(99),\r
+\r
+    FLOWERS_TINY(100),\r
+\r
+    GEMS(101),\r
+\r
+    GINGERBREAD_MAN(102),\r
+\r
+    GRADIENT(103),\r
+\r
+    HANDMADE_1(104),\r
+\r
+    HANDMADE_2(105),\r
+\r
+    HEART_BALLOON(106),\r
+\r
+    HEART_GRAY(107),\r
+\r
+    HEARTS(108),\r
+\r
+    HEEBIE_JEEBIES(109),\r
+\r
+    HOLLY(110),\r
+\r
+    HOUSE_FUNKY(111),\r
+\r
+    HYPNOTIC(112),\r
+\r
+    ICE_CREAM_CONES(113),\r
+\r
+    LIGHT_BULB(114),\r
+\r
+    LIGHTNING_1(115),\r
+\r
+    LIGHTNING_2(116),\r
+\r
+    MAP_PINS(117),\r
+\r
+    MAPLE_LEAF(118),\r
+\r
+    MAPLE_MUFFINS(119),\r
+\r
+    MARQUEE(120),\r
+\r
+    MARQUEE_TOOTHED(121),\r
+\r
+    MOONS(122),\r
+\r
+    MOSAIC(123),\r
+\r
+    MUSIC_NOTES(124),\r
+\r
+    NORTHWEST(125),\r
+\r
+    OVALS(126),\r
+\r
+    PACKAGES(127),\r
+\r
+    PALMS_BLACK(128),\r
+\r
+    PALMS_COLOR(129),\r
+\r
+    PAPER_CLIPS(130),\r
+\r
+    PAPYRUS(131),\r
+\r
+    PARTY_FAVOR(132),\r
+\r
+    PARTY_GLASS(133),\r
+\r
+    PENCILS(134),\r
+\r
+    PEOPLE(135),\r
+\r
+    PEOPLE_WAVING(136),\r
+\r
+    PEOPLE_HATS(137),\r
+\r
+    POINSETTIAS(138),\r
+\r
+    POSTAGE_STAMP(139),\r
+\r
+    PUMPKIN_1(140),\r
+\r
+    PUSH_PIN_NOTE_2(141),\r
+\r
+    PUSH_PIN_NOTE_1(142),\r
+\r
+    PYRAMIDS(143),\r
+\r
+    PYRAMIDS_ABOVE(144),\r
+\r
+    QUADRANTS(145),\r
+\r
+    RINGS(146),\r
+\r
+    SAFARI(147),\r
+\r
+    SAWTOOTH(148),\r
+\r
+    SAWTOOTH_GRAY(149),\r
+\r
+    SCARED_CAT(150),\r
+\r
+    SEATTLE(151),\r
+\r
+    SHADOWED_SQUARES(152),\r
+\r
+    SHARKS_TEETH(153),\r
+\r
+    SHOREBIRD_TRACKS(154),\r
+\r
+    SKYROCKET(155),\r
+\r
+    SNOWFLAKE_FANCY(156),\r
+\r
+    SNOWFLAKES(157),\r
+\r
+    SOMBRERO(158),\r
+\r
+    SOUTHWEST(159),\r
+\r
+    STARS(160),\r
+\r
+    STARS_TOP(161),\r
+\r
+    STARS_3_D(162),\r
+\r
+    STARS_BLACK(163),\r
+\r
+    STARS_SHADOWED(164),\r
+\r
+    SUN(165),\r
+\r
+    SWIRLIGIG(166),\r
+\r
+    TORN_PAPER(167),\r
+\r
+    TORN_PAPER_BLACK(168),\r
+\r
+    TREES(169),\r
+\r
+    TRIANGLE_PARTY(170),\r
+\r
+    TRIANGLES(171),\r
+\r
+    TRIBAL_1(172),\r
+\r
+    TRIBAL_2(173),\r
+\r
+    TRIBAL_3(174),\r
+\r
+    TRIBAL_4(175),\r
+\r
+    TRIBAL_5(176),\r
+\r
+    TRIBAL_6(177),\r
+\r
+    TWISTED_LINES_1(178),\r
+\r
+    TWISTED_LINES_2(179),\r
+\r
+    VINE(180),\r
+\r
+    WAVELINE(181),\r
+\r
+    WEAVING_ANGLES(182),\r
+\r
+    WEAVING_BRAID(183),\r
+\r
+    WEAVING_RIBBON(184),\r
+\r
+    WEAVING_STRIPS(185),\r
+\r
+    WHITE_FLOWERS(186),\r
+\r
+    WOODWORK(187),\r
+\r
+    X_ILLUSIONS(188),\r
+\r
+    ZANY_TRIANGLES(189),\r
+\r
+    ZIG_ZAG(190),\r
+\r
+    ZIG_ZAG_STITCH(191);\r
+\r
+    private final int value;\r
+\r
+    private Borders(int val) {\r
+       value = val;\r
+    }\r
+\r
+    public int getValue() {\r
+       return value;\r
+    }\r
+\r
+    private static Map<Integer, Borders> imap = new HashMap<Integer, Borders>();\r
+    static {\r
+       for (Borders p : values()) {\r
+           imap.put(p.getValue(), p);\r
+       }\r
+    }\r
+\r
+    public static Borders valueOf(int type) {\r
+       Borders pBorder = imap.get(type);\r
+       if (pBorder == null)\r
+           throw new IllegalArgumentException("Unknown paragraph border: "\r
+                   + type);\r
+       return pBorder;\r
+    }\r
+\r
+}\r
index f0dc207081e364f1f75a45c66dbfa9645e7d7275..e5e7fd4f58682ad6c52f57c63dbc00540ad427ea 100644 (file)
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPicture;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTextAlignment;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
+
 /**
  * Sketch of XWPF paragraph class
  */
-public class XWPFParagraph
-{
+public class XWPFParagraph {
     private CTP paragraph;
-    protected XWPFDocument document; // XXX: we'd like to have access to document's hyperlink, comments and other tables
+    protected XWPFDocument document; // XXX: we'd like to have access to
+    // document's hyperlink, comments and
+    // other tables
     /**
      * TODO - replace with RichText String
      */
     private StringBuffer text = new StringBuffer();
     private StringBuffer pictureText = new StringBuffer();
-    
-    protected XWPFParagraph(CTP prgrph, XWPFDocument docRef)
-    {
+
+    protected XWPFParagraph(CTP prgrph, XWPFDocument docRef) {
         this.paragraph = prgrph;
         this.document = docRef;
 
-        if(!isEmpty()) {
+        if (!isEmpty()) {
             // All the runs to loop over
             // TODO - replace this with some sort of XPath expression
-            //  to directly find all the CTRs, in the right order
+            // to directly find all the CTRs, in the right order
             ArrayList<CTR> rs = new ArrayList<CTR>();
             CTR[] tmp;
 
             // Get the main text runs
             tmp = paragraph.getRArray();
-            for(int i=0; i<tmp.length; i++) {
+            for (int i = 0; i < tmp.length; i++) {
                 rs.add(tmp[i]);
             }
 
             // Not sure quite what these are, but they hold
-            //  more text runs
+            // more text runs
             CTSdtRun[] sdts = paragraph.getSdtArray();
-            for(int i=0; i<sdts.length; i++) {
+            for (int i = 0; i < sdts.length; i++) {
                 CTSdtContentRun run = sdts[i].getSdtContent();
                 tmp = run.getRArray();
-                for(int j=0; j<tmp.length; j++) {
+                for (int j = 0; j < tmp.length; j++) {
                     rs.add(tmp[j]);
                 }
             }
 
-
             // Get text of the paragraph
             for (int j = 0; j < rs.size(); j++) {
                 // Grab the text and tabs of the paragraph
                 // Do so in a way that preserves the ordering
                 XmlCursor c = rs.get(j).newCursor();
-                c.selectPath( "./*" );
-                while(c.toNextSelection()) {
+                c.selectPath("./*");
+                while (c.toNextSelection()) {
                     XmlObject o = c.getObject();
-                    if(o instanceof CTText) {
-                        text.append( ((CTText)o).getStringValue() );
+                    if (o instanceof CTText) {
+                        text.append(((CTText) o).getStringValue());
                     }
-                    if(o instanceof CTPTab) {
+                    if (o instanceof CTPTab) {
                         text.append("\t");
                     }
                 }
 
                 // Loop over pictures inside our
-                //  paragraph, looking for text in them
+                // paragraph, looking for text in them
                 CTPicture[] picts = rs.get(j).getPictArray();
                 for (int k = 0; k < picts.length; k++) {
-                    XmlObject[] t = picts[k].selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
+                    XmlObject[] t = picts[k]
+                            .selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
                     for (int m = 0; m < t.length; m++) {
                         NodeList kids = t[m].getDomNode().getChildNodes();
                         for (int n = 0; n < kids.getLength(); n++) {
@@ -101,39 +121,40 @@ public class XWPFParagraph
             }
         }
     }
-    
+
     public CTP getCTP() {
         return paragraph;
     }
 
     public boolean isEmpty() {
-       return !paragraph.getDomNode().hasChildNodes();
+        return !paragraph.getDomNode().hasChildNodes();
     }
 
     public XWPFDocument getDocument() {
         return document;
     }
-    
+
     /**
-     * Return the textual content of the paragraph, 
-     *  including text from pictures in it.
+     * Return the textual content of the paragraph, including text from pictures
+     * in it.
      */
     public String getText() {
         return getParagraphText() + getPictureText();
     }
+
     /**
-     * Returns the text of the paragraph, but not
-     *  of any objects in the paragraph
+     * Returns the text of the paragraph, but not of any objects in the
+     * paragraph
      */
     public String getParagraphText() {
         return text.toString();
     }
+
     /**
-     * Returns any text from any suitable
-     *  pictures in the paragraph
+     * Returns any text from any suitable pictures in the paragraph
      */
     public String getPictureText() {
-       return pictureText.toString();
+        return pictureText.toString();
     }
 
     /**
@@ -141,43 +162,776 @@ public class XWPFParagraph
      *
      * @return a new text run
      */
-    public XWPFRun createRun(){
+    public XWPFRun createRun() {
         return new XWPFRun(paragraph.addNewR(), this);
     }
 
     /**
-     * Returns the paragraph alignment which shall be applied to text in this paragraph.
-     *
-     * <p>
-     * If this element is not set on a given paragraph, its value is determined by the setting previously
-     * set at any level of the style hierarchy (i.e. that previous setting remains unchanged).
-     * If this setting is never specified in the style hierarchy, then no alignment is applied to the paragraph.
+     * Returns the paragraph alignment which shall be applied to text in this
+     * paragraph.
+     * <p/>
+     * <p/>
+     * If this element is not set on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no alignment is applied to the
+     * paragraph.
      * </p>
      *
      * @return the paragraph alignment of this paragraph.
      */
-    public ParagraphAlignment getAlignment(){
+    public ParagraphAlignment getAlignment() {
         CTPPr pr = paragraph.getPPr();
-        return pr == null || !pr.isSetJc() ? ParagraphAlignment.LEFT :
-                ParagraphAlignment.valueOf(pr.getJc().getVal().intValue());
+        return pr == null || !pr.isSetJc() ? ParagraphAlignment.LEFT
+                ParagraphAlignment.valueOf(pr.getJc().getVal().intValue());
     }
 
     /**
-     * Specifies the paragraph alignment which shall be applied to text in this paragraph.
-     *
-     * <p>
-     * If this element is not set on a given paragraph, its value is determined by the setting previously
-     * set at any level of the style hierarchy (i.e. that previous setting remains unchanged).
-     * If this setting is never specified in the style hierarchy, then no alignment is applied to the paragraph.
+     * Specifies the paragraph alignment which shall be applied to text in this
+     * paragraph.
+     * <p/>
+     * <p/>
+     * If this element is not set on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no alignment is applied to the
+     * paragraph.
      * </p>
      *
      * @param align the paragraph alignment to apply to this paragraph.
      */
-    public void setAlignment(ParagraphAlignment align){
-        CTPPr pr = paragraph.isSetPPr() ? paragraph.getPPr() : paragraph.addNewPPr();
+    public void setAlignment(ParagraphAlignment align) {
+        CTPPr pr = paragraph.isSetPPr() ? paragraph.getPPr() : paragraph
+                .addNewPPr();
         CTJc jc = pr.isSetJc() ? pr.getJc() : pr.addNewJc();
         STJc.Enum en = STJc.Enum.forInt(align.getValue());
         jc.setVal(en);
     }
 
+    /**
+     * Returns the text vertical alignment which shall be applied to text in
+     * this paragraph.
+     * <p/>
+     * If the line height (before any added spacing) is larger than one or more
+     * characters on the line, all characters will be aligned to each other as
+     * specified by this element.
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then the vertical alignment of all
+     * characters on the line shall be automatically determined by the consumer.
+     * </p>
+     *
+     * @return the vertical alignment of this paragraph.
+     */
+    public TextAlignment getVerticalAlignment() {
+        CTPPr pr = paragraph.getPPr();
+        return pr == null || !pr.isSetTextAlignment() ? TextAlignment.AUTO
+                : TextAlignment.valueOf(pr.getTextAlignment().getVal()
+                .intValue());
+    }
+
+    /**
+     * Specifies the text vertical alignment which shall be applied to text in
+     * this paragraph.
+     * <p/>
+     * If the line height (before any added spacing) is larger than one or more
+     * characters on the line, all characters will be aligned to each other as
+     * specified by this element.
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then the vertical alignment of all
+     * characters on the line shall be automatically determined by the consumer.
+     * </p>
+     *
+     * @param valign the paragraph vertical alignment to apply to this
+     *               paragraph.
+     */
+    public void setVerticalAlignment(TextAlignment valign) {
+        CTPPr pr = paragraph.isSetPPr() ? paragraph.getPPr() : paragraph
+                .addNewPPr();
+        CTTextAlignment textAlignment = pr.isSetTextAlignment() ? pr
+                .getTextAlignment() : pr.addNewTextAlignment();
+        STTextAlignment.Enum en = STTextAlignment.Enum
+                .forInt(valign.getValue());
+        textAlignment.setVal(en);
+    }
+
+    /**
+     * Specifies the border which shall be displayed above a set of paragraphs
+     * which have the same set of paragraph border settings.
+     * <p/>
+     * <p/>
+     * To determine if any two adjoining paragraphs shall have an individual top
+     * and bottom border or a between border, the set of borders on the two
+     * adjoining paragraphs are compared. If the border information on those two
+     * paragraphs is identical for all possible paragraphs borders, then the
+     * between border is displayed. Otherwise, the final paragraph shall use its
+     * bottom border and the following paragraph shall use its top border,
+     * respectively. If this border specifies a space attribute, that value
+     * determines the space above the text (ignoring any spacing above) which
+     * should be left before this border is drawn, specified in points.
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no between border shall be applied
+     * above identical paragraphs.
+     * </p>
+     * <b>This border can only be a line border.</b>
+     *
+     * @param border
+     * @see Borders for a list of all types of borders
+     */
+    public void setBorderTop(Borders border) {
+        CTPBdr ct = getCTPBrd(true);
+        CTBorder pr = ct.isSetTop() ? ct.getTop() : ct.addNewTop();
+        if (border.getValue() == Borders.NONE.getValue())
+            ct.unsetTop();
+        else
+            pr.setVal(STBorder.Enum.forInt(border.getValue()));
+    }
+
+    /**
+     * Specifies the border which shall be displayed above a set of paragraphs
+     * which have the same set of paragraph border settings.
+     *
+     * @return paragraphBorder - the top border for the paragraph
+     * @see #setBorderTop(Borders)
+     * @see Borders a list of all types of borders
+     */
+    public Borders getBorderTop() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct;
+        if (border != null) {
+            ct = border.getTop();
+            STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
+            return Borders.valueOf(ptrn.intValue());
+        }
+        return Borders.NONE;
+    }
+
+    /**
+     * Specifies the border which shall be displayed below a set of paragraphs
+     * which have the same set of paragraph border settings.
+     * <p/>
+     * To determine if any two adjoining paragraphs shall have an individual top
+     * and bottom border or a between border, the set of borders on the two
+     * adjoining paragraphs are compared. If the border information on those two
+     * paragraphs is identical for all possible paragraphs borders, then the
+     * between border is displayed. Otherwise, the final paragraph shall use its
+     * bottom border and the following paragraph shall use its top border,
+     * respectively. If this border specifies a space attribute, that value
+     * determines the space after the bottom of the text (ignoring any space
+     * below) which should be left before this border is drawn, specified in
+     * points.
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no between border shall be applied
+     * below identical paragraphs.
+     * </p>
+     * <b>This border can only be a line border.</b>
+     *
+     * @param border
+     * @see Borders a list of all types of borders
+     */
+    public void setBorderBottom(Borders border) {
+        CTPBdr ct = getCTPBrd(true);
+        CTBorder pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
+        if (border.getValue() == Borders.NONE.getValue())
+            ct.unsetBottom();
+        else
+            pr.setVal(STBorder.Enum.forInt(border.getValue()));
+    }
+
+    /**
+     * Specifies the border which shall be displayed below a set of
+     * paragraphs which have the same set of paragraph border settings.
+     *
+     * @return paragraphBorder - the bottom border for the paragraph
+     * @see #setBorderBottom(Borders)
+     * @see Borders a list of all types of borders
+     */
+    public Borders getBorderBottom() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct = null;
+        if (border != null) {
+            ct = border.getBottom();
+        }
+        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
+        return Borders.valueOf(ptrn.intValue());
+    }
+
+    /**
+     * Specifies the border which shall be displayed on the left side of the
+     * page around the specified paragraph.
+     * <p/>
+     * To determine if any two adjoining paragraphs should have a left border
+     * which spans the full line height or not, the left border shall be drawn
+     * between the top border or between border at the top (whichever would be
+     * rendered for the current paragraph), and the bottom border or between
+     * border at the bottom (whichever would be rendered for the current
+     * paragraph).
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no left border shall be applied.
+     * </p>
+     * <b>This border can only be a line border.</b>
+     *
+     * @param border
+     * @see Borders for a list of all possible borders
+     */
+    public void setBorderLeft(Borders border) {
+        CTPBdr ct = getCTPBrd(true);
+        CTBorder pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
+        if (border.getValue() == Borders.NONE.getValue())
+            ct.unsetLeft();
+        else
+            pr.setVal(STBorder.Enum.forInt(border.getValue()));
+    }
+
+    /**
+     * Specifies the border which shall be displayed on the left side of the
+     * page around the specified paragraph.
+     *
+     * @return ParagraphBorder - the left border for the paragraph
+     * @see #setBorderLeft(Borders)
+     * @see Borders for a list of all possible borders
+     */
+    public Borders getBorderLeft() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct = null;
+        if (border != null) {
+            ct = border.getLeft();
+        }
+        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
+        return Borders.valueOf(ptrn.intValue());
+    }
+
+    /**
+     * Specifies the border which shall be displayed on the right side of the
+     * page around the specified paragraph.
+     * <p/>
+     * To determine if any two adjoining paragraphs should have a right border
+     * which spans the full line height or not, the right border shall be drawn
+     * between the top border or between border at the top (whichever would be
+     * rendered for the current paragraph), and the bottom border or between
+     * border at the bottom (whichever would be rendered for the current
+     * paragraph).
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no right border shall be applied.
+     * </p>
+     * <b>This border can only be a line border.</b>
+     *
+     * @param border
+     * @see Borders for a list of all possible borders
+     */
+    public void setBorderRight(Borders border) {
+        CTPBdr ct = getCTPBrd(true);
+        CTBorder pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
+        if (border.getValue() == Borders.NONE.getValue())
+            ct.unsetRight();
+        else
+            pr.setVal(STBorder.Enum.forInt(border.getValue()));
+    }
+
+    /**
+     * Specifies the border which shall be displayed on the right side of the
+     * page around the specified paragraph.
+     *
+     * @return ParagraphBorder - the right border for the paragraph
+     * @see #setBorderRight(Borders)
+     * @see Borders for a list of all possible borders
+     */
+    public Borders getBorderRight() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct = null;
+        if (border != null) {
+            ct = border.getRight();
+        }
+        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
+        return Borders.valueOf(ptrn.intValue());
+    }
+
+    /**
+     * Specifies the border which shall be displayed between each paragraph in a
+     * set of paragraphs which have the same set of paragraph border settings.
+     * <p/>
+     * To determine if any two adjoining paragraphs should have a between border
+     * or an individual top and bottom border, the set of borders on the two
+     * adjoining paragraphs are compared. If the border information on those two
+     * paragraphs is identical for all possible paragraphs borders, then the
+     * between border is displayed. Otherwise, each paragraph shall use its
+     * bottom and top border, respectively. If this border specifies a space
+     * attribute, that value is ignored - this border is always located at the
+     * bottom of each paragraph with an identical following paragraph, taking
+     * into account any space after the line pitch.
+     * </p>
+     * <p/>
+     * If this element is omitted on a given paragraph, its value is determined
+     * by the setting previously set at any level of the style hierarchy (i.e.
+     * that previous setting remains unchanged). If this setting is never
+     * specified in the style hierarchy, then no between border shall be applied
+     * between identical paragraphs.
+     * </p>
+     * <b>This border can only be a line border.</b>
+     *
+     * @param border
+     * @see Borders for a list of all possible borders
+     */
+    public void setBorderBetween(Borders border) {
+        CTPBdr ct = getCTPBrd(true);
+        CTBorder pr = ct.isSetBetween() ? ct.getBetween() : ct.addNewBetween();
+        if (border.getValue() == Borders.NONE.getValue())
+            ct.unsetBetween();
+        else
+            pr.setVal(STBorder.Enum.forInt(border.getValue()));
+    }
+
+    /**
+     * Specifies the border which shall be displayed between each paragraph in a
+     * set of paragraphs which have the same set of paragraph border settings.
+     *
+     * @return ParagraphBorder - the between border for the paragraph
+     * @see #setBorderBetween(Borders)
+     * @see Borders for a list of all possible borders
+     */
+    public Borders getBorderBetween() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct = null;
+        if (border != null) {
+            ct = border.getBetween();
+        }
+        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
+        return Borders.valueOf(ptrn.intValue());
+    }
+
+    /**
+     * Specifies that when rendering this document in a paginated
+     * view, the contents of this paragraph are rendered on the start of a new
+     * page in the document.
+     * <p/>
+     * If this element is omitted on a given paragraph,
+     * its value is determined by the setting previously set at any level of the
+     * style hierarchy (i.e. that previous setting remains unchanged). If this
+     * setting is never specified in the style hierarchy, then this property
+     * shall not be applied. Since the paragraph is specified to start on a new
+     * page, it begins page two even though it could have fit on page one.
+     * </p>
+     *
+     * @param pageBreak -
+     *                  boolean value
+     */
+    public void setPageBreak(boolean pageBreak) {
+        CTPPr ppr = getCTPPr();
+        CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
+                .getPageBreakBefore() : ppr.addNewPageBreakBefore();
+        if (pageBreak)
+            ct_pageBreak.setVal(STOnOff.TRUE);
+        else
+            ct_pageBreak.setVal(STOnOff.FALSE);
+    }
+
+    /**
+     * Specifies that when rendering this document in a paginated
+     * view, the contents of this paragraph are rendered on the start of a new
+     * page in the document.
+     * <p/>
+     * If this element is omitted on a given paragraph,
+     * its value is determined by the setting previously set at any level of the
+     * style hierarchy (i.e. that previous setting remains unchanged). If this
+     * setting is never specified in the style hierarchy, then this property
+     * shall not be applied. Since the paragraph is specified to start on a new
+     * page, it begins page two even though it could have fit on page one.
+     * </p>
+     *
+     * @return boolean - if page break is set
+     */
+    public boolean isPageBreak() {
+        CTPPr ppr = getCTPPr();
+        CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
+                .getPageBreakBefore() : null;
+        if (ct_pageBreak != null
+                && ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE)
+            return true;
+        else
+            return false;
+    }
+
+    /**
+     * Specifies the spacing that should be added after the last line in this
+     * paragraph in the document in absolute units.
+     * <p/>
+     * If the afterLines attribute or the afterAutoSpacing attribute is also
+     * specified, then this attribute value is ignored.
+     * </p>
+     *
+     * @param spaces -
+     *               a positive whole number, whose contents consist of a
+     *               measurement in twentieths of a point.
+     */
+    public void setSpacingAfter(BigInteger spaces) {
+        CTSpacing spacing = getCTSpacing(true);
+        if (spacing != null)
+            spacing.setAfter(spaces);
+    }
+
+    /**
+     * Specifies the spacing that should be added after the last line in this
+     * paragraph in the document in absolute units.
+     *
+     * @return bigInteger - value representing the spacing after the paragraph
+     */
+    public BigInteger getSpacingAfter() {
+        CTSpacing spacing = getCTSpacing(false);
+        return spacing.isSetAfter() ? spacing.getAfter() : null;
+    }
+
+    /**
+     * Specifies the spacing that should be added after the last line in this
+     * paragraph in the document in line units.
+     * <b>The value of this attribute is
+     * specified in one hundredths of a line.
+     * </b>
+     * <p/>
+     * If the afterAutoSpacing attribute
+     * is also specified, then this attribute value is ignored. If this setting
+     * is never specified in the style hierarchy, then its value shall be zero
+     * (if needed)
+     * </p>
+     *
+     * @param spaces -
+     *               a positive whole number, whose contents consist of a
+     *               measurement in twentieths of a
+     */
+    public void setSpacingAfterLines(BigInteger spaces) {
+        CTSpacing spacing = getCTSpacing(true);
+        spacing.setAfterLines(spaces);
+    }
+
+
+    /**
+     * Specifies the spacing that should be added after the last line in this
+     * paragraph in the document in absolute units.
+     *
+     * @return bigInteger - value representing the spacing after the paragraph
+     * @see #setSpacingAfterLines(BigInteger)
+     */
+    public BigInteger getSpacingAfterLines() {
+        CTSpacing spacing = getCTSpacing(false);
+        return spacing.isSetAfterLines() ? spacing.getAfterLines() : null;
+    }
+
+    /**
+     * Specifies the spacing that should be added above the first line in this
+     * paragraph in the document in absolute units.
+     * <p/>
+     * If the beforeLines attribute or the beforeAutoSpacing attribute is also
+     * specified, then this attribute value is ignored.
+     * </p>
+     *
+     * @param spaces
+     */
+    public void setSpacingBefore(BigInteger spaces) {
+        CTSpacing spacing = getCTSpacing(true);
+        spacing.setBefore(spaces);
+    }
+
+    /**
+     * Specifies the spacing that should be added above the first line in this
+     * paragraph in the document in absolute units.
+     *
+     * @return
+     * @see #setSpacingBefore(BigInteger)
+     */
+    public BigInteger getSpacingBefore() {
+        CTSpacing spacing = getCTSpacing(false);
+        return spacing.isSetBefore() ? spacing.getBefore() : null;
+    }
+
+    /**
+     * Specifies the spacing that should be added before the first line in this
+     * paragraph in the document in line units. <b> The value of this attribute
+     * is specified in one hundredths of a line. </b>
+     * <p/>
+     * If the beforeAutoSpacing attribute is also specified, then this attribute
+     * value is ignored. If this setting is never specified in the style
+     * hierarchy, then its value shall be zero.
+     * </p>
+     *
+     * @param spaces
+     */
+    public void setSpacingBeforeLines(BigInteger spaces) {
+        CTSpacing spacing = getCTSpacing(true);
+        spacing.setBeforeLines(spaces);
+    }
+
+    /**
+     * Specifies the spacing that should be added before the first line in this paragraph in the
+     * document in line units.
+     * The value of this attribute is specified in one hundredths of a line.
+     *
+     * @return
+     * @see #setSpacingBeforeLines(BigInteger)
+     */
+    public BigInteger getSpacingBeforeLines() {
+        CTSpacing spacing = getCTSpacing(false);
+        return spacing.isSetBeforeLines() ? spacing.getBeforeLines() : null;
+    }
+
+    /**
+     * Specifies the indentation which shall be placed between the left text
+     * margin for this paragraph and the left edge of that paragraph's content
+     * in a left to right paragraph, and the right text margin and the right
+     * edge of that paragraph's text in a right to left paragraph
+     * <p/>
+     * If this attribute is omitted, its value shall be assumed to be zero.
+     * Negative values are defined such that the text is moved past the text margin,
+     * positive values move the text inside the text margin.
+     * </p>
+     *
+     * @param indentation
+     */
+    public void setIndentationLeft(BigInteger indentation) {
+        CTInd indent = getCTInd(true);
+        indent.setLeft(indentation);
+    }
+
+    /**
+     * Specifies the indentation which shall be placed between the left text
+     * margin for this paragraph and the left edge of that paragraph's content
+     * in a left to right paragraph, and the right text margin and the right
+     * edge of that paragraph's text in a right to left paragraph
+     * <p/>
+     * If this attribute is omitted, its value shall be assumed to be zero.
+     * Negative values are defined such that the text is moved past the text margin,
+     * positive values move the text inside the text margin.
+     * </p>
+     *
+     * @return indentation or null if indentation is not set
+     */
+    public BigInteger getIndentationLeft() {
+        CTInd indentation = getCTInd(false);
+        return indentation.isSetLeft() ? indentation.getLeft()
+                : new BigInteger("0");
+    }
+
+    /**
+     * Specifies the indentation which shall be placed between the right text
+     * margin for this paragraph and the right edge of that paragraph's content
+     * in a left to right paragraph, and the right text margin and the right
+     * edge of that paragraph's text in a right to left paragraph
+     * <p/>
+     * If this attribute is omitted, its value shall be assumed to be zero.
+     * Negative values are defined such that the text is moved past the text margin,
+     * positive values move the text inside the text margin.
+     * </p>
+     *
+     * @param indentation
+     */
+    public void setIndentationRight(BigInteger indentation) {
+        CTInd indent = getCTInd(true);
+        indent.setRight(indentation);
+    }
+
+    /**
+     * Specifies the indentation which shall be placed between the right text
+     * margin for this paragraph and the right edge of that paragraph's content
+     * in a left to right paragraph, and the right text margin and the right
+     * edge of that paragraph's text in a right to left paragraph
+     * <p/>
+     * If this attribute is omitted, its value shall be assumed to be zero.
+     * Negative values are defined such that the text is moved past the text margin,
+     * positive values move the text inside the text margin.
+     * </p>
+     *
+     * @return indentation or null if indentation is not set
+     */
+
+    public BigInteger getIndentationRight() {
+        CTInd indentation = getCTInd(false);
+        return indentation.isSetRight() ? indentation.getRight()
+                : new BigInteger("0");
+    }
+
+    /**
+     * Specifies the indentation which shall be removed from the first line of
+     * the parent paragraph, by moving the indentation on the first line back
+     * towards the beginning of the direction of text flow.
+     * This indentation is specified relative to the paragraph indentation which is specified for
+     * all other lines in the parent paragraph.
+     * <p/>
+     * The firstLine and hanging attributes are mutually exclusive, if both are specified, then the
+     * firstLine value is ignored.
+     * </p>
+     *
+     * @param indentation
+     */
+
+    public void setIndentationHanging(BigInteger indentation) {
+        CTInd indent = getCTInd(true);
+        indent.setHanging(indentation);
+    }
+
+    /**
+     * Specifies the indentation which shall be removed from the first line of
+     * the parent paragraph, by moving the indentation on the first line back
+     * towards the beginning of the direction of text flow.
+     * This indentation is
+     * specified relative to the paragraph indentation which is specified for
+     * all other lines in the parent paragraph.
+     * The firstLine and hanging
+     * attributes are mutually exclusive, if both are specified, then the
+     * firstLine value is ignored.
+     *
+     * @return indentation or null if indentation is not set
+     */
+    public BigInteger getIndentationHanging() {
+        CTInd indentation = getCTInd(false);
+        return indentation.isSetHanging() ? indentation.getHanging() : null;
+    }
+
+    /**
+     * Specifies the additional indentation which shall be applied to the first
+     * line of the parent paragraph. This additional indentation is specified
+     * relative to the paragraph indentation which is specified for all other
+     * lines in the parent paragraph.
+     * The firstLine and hanging attributes are
+     * mutually exclusive, if both are specified, then the firstLine value is
+     * ignored.
+     * If the firstLineChars attribute is also specified, then this
+     * value is ignored. If this attribute is omitted, then its value shall be
+     * assumed to be zero (if needed).
+     *
+     * @param indentation
+     */
+    public void setIndentationFirstLine(BigInteger indentation) {
+        CTInd indent = getCTInd(true);
+        indent.setFirstLine(indentation);
+    }
+
+    /**
+     * Specifies the additional indentation which shall be applied to the first
+     * line of the parent paragraph. This additional indentation is specified
+     * relative to the paragraph indentation which is specified for all other
+     * lines in the parent paragraph.
+     * The firstLine and hanging attributes are
+     * mutually exclusive, if both are specified, then the firstLine value is
+     * ignored.
+     * If the firstLineChars attribute is also specified, then this
+     * value is ignored.
+     * If this attribute is omitted, then its value shall be
+     * assumed to be zero (if needed).
+     *
+     * @return indentation or null if indentation is not set
+     */
+    public BigInteger getIndentationFirstLine() {
+        CTInd indentation = getCTInd(false);
+        return indentation.isSetFirstLine() ? indentation.getFirstLine()
+                : new BigInteger("0");
+    }
+
+    /**
+     * This element specifies whether a consumer shall break Latin text which
+     * exceeds the text extents of a line by breaking the word across two lines
+     * (breaking on the character level) or by moving the word to the following
+     * line (breaking on the word level).
+     *
+     * @param wrap - boolean
+     */
+    public void setWordWrap(boolean wrap) {
+        CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
+                .getWordWrap() : getCTPPr().addNewWordWrap();
+        if (wrap)
+            wordWrap.setVal(STOnOff.TRUE);
+        else
+            wordWrap.unsetVal();
+    }
+
+    /**
+     * This element specifies whether a consumer shall break Latin text which
+     * exceeds the text extents of a line by breaking the word across two lines
+     * (breaking on the character level) or by moving the word to the following
+     * line (breaking on the word level).
+     *
+     * @return boolean
+     */
+    public boolean isWordWrap() {
+        CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
+                .getWordWrap() : null;
+        if (wordWrap != null) {
+            return (wordWrap.getVal() == STOnOff.ON
+                    || wordWrap.getVal() == STOnOff.TRUE || wordWrap.getVal() == STOnOff.X_1) ? true
+                    : false;
+        } else
+            return false;
+    }
+
+    /**
+     * Get a <b>copy</b> of the currently used CTPBrd, if none is used, return
+     * a new instance.
+     */
+    private CTPBdr getCTPBrd(boolean create) {
+        CTPPr pr = getCTPPr();
+        if (pr != null) {
+            CTPBdr ct = pr.isSetPBdr() ? pr.getPBdr() : null;
+            if (create && ct == null)
+                ct = pr.addNewPBdr();
+            return ct;
+        }
+        return null;
+    }
+
+    /**
+     * Get a <b>copy</b> of the currently used CTSpacing, if none is used,
+     * return a new instance.
+     */
+    private CTSpacing getCTSpacing(boolean create) {
+        CTPPr pr = getCTPPr();
+        if (pr != null) {
+            CTSpacing ct = pr.isSetSpacing() ? pr.getSpacing() : null;
+            if (create && ct == null)
+                ct = pr.addNewSpacing();
+            return ct;
+        }
+        return null;
+    }
+
+    /**
+     * Get a <b>copy</b> of the currently used CTPInd, if none is used, return
+     * a new instance.
+     */
+    private CTInd getCTInd(boolean create) {
+        CTPPr pr = getCTPPr();
+        if (pr != null) {
+            CTInd ct = pr.isSetInd() ? pr.getInd() : null;
+            if (create && ct == null)
+                ct = pr.addNewInd();
+            return ct;
+        }
+        return null;
+    }
+
+    private CTPPr getCTPPr() {
+        CTPPr pr = paragraph.getPPr() == null ? paragraph.addNewPPr()
+                : paragraph.getPPr();
+        return pr;
+    }
+
 }
index 7af82bdbfc990c4b4ea1e2901d50c33ded43a1fd..8933b494cf365be6b47d5e6f8e2a076e19f6a42b 100755 (executable)
@@ -307,7 +307,7 @@ public class XWPFRun {
      */
     public BigInteger getFontSize() {
         CTRPr pr = run.getRPr();
-        return (pr != null && pr.isSetSz()) ? pr.getSz().getVal() : null;
+        return (pr != null && pr.isSetSz()) ? pr.getSz().getVal().divide(new BigInteger("2")) : null;
     }
 
     /**
@@ -325,7 +325,7 @@ public class XWPFRun {
     public void setFontSize(BigInteger size) {
         CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
         CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz();
-        ctSize.setVal(size);
+        ctSize.setVal(size.multiply(new BigInteger("2")));
     }
 
     /**
index 65fb7f3312be2ebc10a9f5060569082844869fca..c43f3ebd1f057710475e8af61bc9b4392a859011 100644 (file)
 package org.apache.poi.xwpf.usermodel;
 
 import java.io.File;
-
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import java.math.BigInteger;
 
 import junit.framework.TestCase;
 
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTextAlignment;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
+import org.apache.poi.POIXMLDocument;
+
 /**
  * Tests for XWPF Paragraphs
  */
 public class TestXWPFParagraph extends TestCase {
-       /**
-        * A simple file
-        */
-       private XWPFDocument xml;
-       private File file;
-       
-       protected void setUp() throws Exception {
-               super.setUp();
-               
-               file = new File(
-                               System.getProperty("HWPF.testdata.path") +
-                               File.separator + "ThreeColHead.docx"
-               );
-               assertTrue(file.exists());
-               xml = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-       }
-       
-       /**
-        * Check that we get the right paragraph from the header
-        */
-       public void testHeaderParagraph() throws Exception {
-               XWPFHeader hdr = xml.getHeaderFooterPolicy().getDefaultHeader();
-               assertNotNull(hdr);
-               
-               XWPFParagraph[] ps = hdr.getParagraphs();
-               assertEquals(1, ps.length);
-               XWPFParagraph p = ps[0];
-               
-               assertEquals(5, p.getCTP().getRArray().length);
-               assertEquals(
-                               "First header column!\tMid header\tRight header!",
-                               p.getText()
-               );
-       }
-       
-       /**
-        * Check that we get the right paragraphs from the document
-        */
-       public void testDocumentParagraph() throws Exception {
-               XWPFParagraph[] ps = xml.getParagraphs();
-               assertEquals(10, ps.length);
-               
-               assertFalse(ps[0].isEmpty());
-               assertEquals(
-                               "This is a sample word document. It has two pages. It has a three column heading, but no footer.",
-                               ps[0].getText()
-               );
-               
-               assertTrue(ps[1].isEmpty());
-               assertEquals("", ps[1].getText());
-               
-               assertFalse(ps[2].isEmpty());
-               assertEquals(
-                               "HEADING TEXT",
-                               ps[2].getText()
-               );
-               
-               assertTrue(ps[3].isEmpty());
-               assertEquals("", ps[3].getText());
-               
-               assertFalse(ps[4].isEmpty());
-               assertEquals(
-                               "More on page one",
-                               ps[4].getText()
-               );
-       }
+    /**
+     * A simple file
+     */
+    private XWPFDocument xml;
+    private File file;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        file = new File(
+                System.getProperty("HWPF.testdata.path") +
+                File.separator + "ThreeColHead.docx"
+        );
+        assertTrue(file.exists());
+        xml = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
+    }
+
+    /**
+     * Check that we get the right paragraph from the header
+     */
+    public void testHeaderParagraph() throws Exception {
+        XWPFHeader hdr = xml.getHeaderFooterPolicy().getDefaultHeader();
+        assertNotNull(hdr);
+
+        XWPFParagraph[] ps = hdr.getParagraphs();
+        assertEquals(1, ps.length);
+        XWPFParagraph p = ps[0];
+
+        assertEquals(5, p.getCTP().getRArray().length);
+        assertEquals("First header column!\tMid header\tRight header!", p
+                .getText());
+    }
+
+    /**
+     * Check that we get the right paragraphs from the document
+     */
+    public void testDocumentParagraph() throws Exception {
+        XWPFParagraph[] ps = xml.getParagraphs();
+        assertEquals(10, ps.length);
+
+        assertFalse(ps[0].isEmpty());
+        assertEquals(
+                "This is a sample word document. It has two pages. It has a three column heading, but no footer.",
+                ps[0].getText());
+
+        assertTrue(ps[1].isEmpty());
+        assertEquals("", ps[1].getText());
+
+        assertFalse(ps[2].isEmpty());
+        assertEquals("HEADING TEXT", ps[2].getText());
+
+        assertTrue(ps[3].isEmpty());
+        assertEquals("", ps[3].getText());
+
+        assertFalse(ps[4].isEmpty());
+        assertEquals("More on page one", ps[4].getText());
+    }
+
+    public void testSetGetBorderTop() {
+        //new clean instance of paragraph
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+        //bordi
+        CTPBdr bdr = ppr.addNewPBdr();
+        CTBorder borderTop = bdr.addNewTop();
+        borderTop.setVal(STBorder.APPLES);
+        bdr.setTop(borderTop);
+        assertEquals(Borders.APPLES, p.getBorderTop());
+        p.setBorderTop(Borders.SINGLE);
+        assertEquals(STBorder.SINGLE, borderTop.getVal());
+    }
+
+    public void testSetGetAlignment() {
+        //new clean instance of paragraph
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+
+        CTJc align = ppr.addNewJc();
+        align.setVal(STJc.CENTER);
+        assertEquals(ParagraphAlignment.CENTER, p.getAlignment());
+
+        p.setAlignment(ParagraphAlignment.BOTH);
+        assertEquals(STJc.BOTH, ppr.getJc().getVal());
+    }
+
+    public void testSetGetSpacing() {
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+
+        //TEST ALL OTHERS POSSIBLE COMBINATIONS
+        CTSpacing spacing = ppr.addNewSpacing();
+        spacing.setAfter(new BigInteger("10"));
+        assertEquals(10, p.getSpacingAfter().longValue());
+
+        p.setSpacingAfter(new BigInteger("100"));
+        assertEquals(100, spacing.getAfter().longValue());
+    }
+
+    public void testSetGetVerticalAlignment() {
+        //new clean instance of paragraph
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+
+        CTTextAlignment txtAlign = ppr.addNewTextAlignment();
+        txtAlign.setVal(STTextAlignment.CENTER);
+        assertEquals(TextAlignment.CENTER, p.getVerticalAlignment());
+
+        p.setVerticalAlignment(TextAlignment.BOTTOM);
+        assertEquals(STTextAlignment.BOTTOM, ppr.getTextAlignment().getVal());
+    }
+
+    public void testSetGetWordWrap() {
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+
+        CTOnOff wordWrap = ppr.addNewWordWrap();
+        wordWrap.setVal(STOnOff.FALSE);
+        assertEquals(false, p.isWordWrap());
+
+        p.setWordWrap(true);
+        assertEquals(STOnOff.TRUE, ppr.getWordWrap().getVal());
+    }
+
+
+    public void testSetGetPageBreak() {
+        XWPFDocument doc = new XWPFDocument();
+        XWPFParagraph p = doc.createParagraph();
+
+        CTP ctp = p.getCTP();
+        CTPPr ppr = ctp.addNewPPr();
+
+        CTOnOff pageBreak = ppr.addNewPageBreakBefore();
+        pageBreak.setVal(STOnOff.FALSE);
+        assertEquals(false, p.isPageBreak());
+
+        p.setPageBreak(true);
+        assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal());
+    }
+
+
 }
index abe3a613c413425945c1c0a7fb143d5f9bccd135..8f8c6041261f09ddb1cb2ccb66730c192f4ac3c0 100755 (executable)
@@ -35,101 +35,106 @@ public class TestXWPFRun extends TestCase {
     public XWPFParagraph p;
 
     protected void setUp() {
-       XWPFDocument doc = new XWPFDocument();
-       p = doc.createParagraph();
+        XWPFDocument doc = new XWPFDocument();
+        p = doc.createParagraph();
 
-       this.ctRun = CTR.Factory.newInstance();
+        this.ctRun = CTR.Factory.newInstance();
 
     }
 
     public void testSetGetBold() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewB().setVal(STOnOff.TRUE);
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewB().setVal(STOnOff.TRUE);
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(true, run.isBold());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(true, run.isBold());
 
-       run.setBold(false);
-       assertEquals(STOnOff.FALSE, rpr.getB().getVal());
+        run.setBold(false);
+        assertEquals(STOnOff.FALSE, rpr.getB().getVal());
     }
 
     public void testSetGetItalic() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewI().setVal(STOnOff.TRUE);
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewI().setVal(STOnOff.TRUE);
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(true, run.isItalic());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(true, run.isItalic());
 
-       run.setItalic(false);
-       assertEquals(STOnOff.FALSE, rpr.getI().getVal());
+        run.setItalic(false);
+        assertEquals(STOnOff.FALSE, rpr.getI().getVal());
     }
 
     public void testSetGetStrike() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewStrike().setVal(STOnOff.TRUE);
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewStrike().setVal(STOnOff.TRUE);
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(true, run.isStrike());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(true, run.isStrike());
 
-       run.setStrike(false);
-       assertEquals(STOnOff.FALSE, rpr.getStrike().getVal());
+        run.setStrike(false);
+        assertEquals(STOnOff.FALSE, rpr.getStrike().getVal());
     }
 
     public void testSetGetUnderline() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewU().setVal(STUnderline.DASH);
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewU().setVal(STUnderline.DASH);
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(UnderlinePatterns.DASH.getValue(), run.getUnderline()
-               .getValue());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(UnderlinePatterns.DASH.getValue(), run.getUnderline()
+                .getValue());
 
-       run.setUnderline(UnderlinePatterns.NONE);
-       assertEquals(STUnderline.NONE.intValue(), rpr.getU().getVal()
-               .intValue());
+        run.setUnderline(UnderlinePatterns.NONE);
+        assertEquals(STUnderline.NONE.intValue(), rpr.getU().getVal()
+                .intValue());
     }
 
+
     public void testSetGetVAlign() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewVertAlign().setVal(STVerticalAlignRun.SUBSCRIPT);
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewVertAlign().setVal(STVerticalAlignRun.SUBSCRIPT);
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(VerticalAlign.SUBSCRIPT, run.getSubscript());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(VerticalAlign.SUBSCRIPT, run.getSubscript());
 
-       run.setSubscript(VerticalAlign.BASELINE);
-       assertEquals(STVerticalAlignRun.BASELINE, rpr.getVertAlign().getVal());
+        run.setSubscript(VerticalAlign.BASELINE);
+        assertEquals(STVerticalAlignRun.BASELINE, rpr.getVertAlign().getVal());
     }
 
+
     public void testSetGetFontFamily() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewRFonts().setAscii("Times New Roman");
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewRFonts().setAscii("Times New Roman");
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals("Times New Roman", run.getFontFamily());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals("Times New Roman", run.getFontFamily());
 
-       run.setFontFamily("Verdana");
-       assertEquals("Verdana", rpr.getRFonts().getAscii());
+        run.setFontFamily("Verdana");
+        assertEquals("Verdana", rpr.getRFonts().getAscii());
     }
 
+
     public void testSetGetFontSize() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewSz().setVal(new BigInteger("4000"));
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewSz().setVal(new BigInteger("14"));
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(4000, run.getFontSize().longValue());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(7, run.getFontSize().longValue());
 
-       run.setFontSize(new BigInteger("2400"));
-       assertEquals(2400, rpr.getSz().getVal().longValue());
+        run.setFontSize(new BigInteger("24"));
+        assertEquals(48, rpr.getSz().getVal().longValue());
     }
 
+
     public void testSetGetTextForegroundBackground() {
-       CTRPr rpr = ctRun.addNewRPr();
-       rpr.addNewPosition().setVal(new BigInteger("4000"));
+        CTRPr rpr = ctRun.addNewRPr();
+        rpr.addNewPosition().setVal(new BigInteger("4000"));
 
-       XWPFRun run = new XWPFRun(ctRun, p);
-       assertEquals(4000, run.getTextPosition().longValue());
+        XWPFRun run = new XWPFRun(ctRun, p);
+        assertEquals(4000, run.getTextPosition().longValue());
 
-       run.setTextPosition(new BigInteger("2400"));
-       assertEquals(2400, rpr.getPosition().getVal().longValue());
+        run.setTextPosition(new BigInteger("2400"));
+        assertEquals(2400, rpr.getPosition().getVal().longValue());
     }
 
 }
+