Search in sources :

Example 16 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setDoubleStrikethrough.

/**
     * Specifies that the contents of this run shall be displayed with a
     * double horizontal line through the center of the line.
     *
     * @see #setStrikeThrough(boolean) for the rules about this
     */
public void setDoubleStrikethrough(boolean value) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike();
    dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTOnOff(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)

Example 17 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setFontFamily.

/**
     * Specifies the fonts which shall be used to display the text contents of
     * this run. The default handling for fcr == null is to overwrite the
     * ascii font char range with the given font family and also set all not
     * specified font ranges
     *
     * @param fontFamily
     * @param fcr        FontCharRange or null for default handling
     */
public void setFontFamily(String fontFamily, FontCharRange fcr) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
    if (fcr == null) {
        fonts.setAscii(fontFamily);
        if (!fonts.isSetHAnsi()) {
            fonts.setHAnsi(fontFamily);
        }
        if (!fonts.isSetCs()) {
            fonts.setCs(fontFamily);
        }
        if (!fonts.isSetEastAsia()) {
            fonts.setEastAsia(fontFamily);
        }
    } else {
        switch(fcr) {
            case ascii:
                fonts.setAscii(fontFamily);
                break;
            case cs:
                fonts.setCs(fontFamily);
                break;
            case eastAsia:
                fonts.setEastAsia(fontFamily);
                break;
            case hAnsi:
                fonts.setHAnsi(fontFamily);
                break;
        }
    }
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTFonts(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts)

Example 18 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setUnderline.

/**
     * Specifies that the contents of this run should be displayed along with an
     * underline appearing directly below the character heigh
     * <p/>
     * <p/>
     * If this element is not present, the default value is to leave the
     * formatting applied at previous level in the style hierarchy. If this
     * element is never applied in the style hierarchy, then an underline shall
     * not be applied to the contents of this run.
     * </p>
     *
     * @param value -
     *              underline type
     * @see UnderlinePatterns : all possible patterns that could be applied
     */
public void setUnderline(UnderlinePatterns value) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTUnderline underline = (pr.getU() == null) ? pr.addNewU() : pr.getU();
    underline.setVal(STUnderline.Enum.forInt(value.getValue()));
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTUnderline(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTUnderline)

Example 19 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFRun method setStrikeThrough.

/**
     * Specifies that the contents of this run shall be displayed with a single
     * horizontal line through the center of the line.
     * <p/>
     * This formatting property is a toggle property, which specifies that its
     * behaviour differs between its use within a style definition and its use as
     * direct formatting. When used as part of a style definition, setting this
     * property shall toggle the current state of that property as specified up
     * to this point in the hierarchy (i.e. applied to not applied, and vice
     * versa). Setting it to false (or an equivalent) shall result in the
     * current setting remaining unchanged. However, when used as direct
     * formatting, setting this property to true or false shall set the absolute
     * state of the resulting property.
     * </p>
     * <p/>
     * If this element is not present, the default value is to leave the
     * formatting applied at previous level in the style hierarchy. If this
     * element is never applied in the style hierarchy, then strikethrough shall
     * not be applied to the contents of this run.
     * </p>
     *
     * @param value <code>true</code> if the strike property is applied to
     *              this run
     */
public void setStrikeThrough(boolean value) {
    CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
    CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
    strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
Also used : CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTOnOff(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)

Example 20 with CTRPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr in project poi by apache.

the class XWPFHeaderFooterPolicy method getWatermarkParagraph.

/*
     * This is the default Watermark paragraph; the only variable is the text message
     * TODO: manage all the other variables
     */
private XWPFParagraph getWatermarkParagraph(String text, int idx) {
    CTP p = CTP.Factory.newInstance();
    byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
    byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
    p.setRsidP(rsidr);
    p.setRsidRDefault(rsidrdefault);
    CTPPr pPr = p.addNewPPr();
    pPr.addNewPStyle().setVal("Header");
    // start watermark paragraph
    CTR r = p.addNewR();
    CTRPr rPr = r.addNewRPr();
    rPr.addNewNoProof();
    CTPicture pict = r.addNewPict();
    CTGroup group = CTGroup.Factory.newInstance();
    CTShapetype shapetype = group.addNewShapetype();
    shapetype.setId("_x0000_t136");
    shapetype.setCoordsize("1600,21600");
    shapetype.setSpt(136);
    shapetype.setAdj("10800");
    shapetype.setPath2("m@7,0l@8,0m@5,21600l@6,21600e");
    CTFormulas formulas = shapetype.addNewFormulas();
    formulas.addNewF().setEqn("sum #0 0 10800");
    formulas.addNewF().setEqn("prod #0 2 1");
    formulas.addNewF().setEqn("sum 21600 0 @1");
    formulas.addNewF().setEqn("sum 0 0 @2");
    formulas.addNewF().setEqn("sum 21600 0 @3");
    formulas.addNewF().setEqn("if @0 @3 0");
    formulas.addNewF().setEqn("if @0 21600 @1");
    formulas.addNewF().setEqn("if @0 0 @2");
    formulas.addNewF().setEqn("if @0 @4 21600");
    formulas.addNewF().setEqn("mid @5 @6");
    formulas.addNewF().setEqn("mid @8 @5");
    formulas.addNewF().setEqn("mid @7 @8");
    formulas.addNewF().setEqn("mid @6 @7");
    formulas.addNewF().setEqn("sum @6 0 @5");
    CTPath path = shapetype.addNewPath();
    path.setTextpathok(STTrueFalse.T);
    path.setConnecttype(STConnectType.CUSTOM);
    path.setConnectlocs("@9,0;@10,10800;@11,21600;@12,10800");
    path.setConnectangles("270,180,90,0");
    CTTextPath shapeTypeTextPath = shapetype.addNewTextpath();
    shapeTypeTextPath.setOn(STTrueFalse.T);
    shapeTypeTextPath.setFitshape(STTrueFalse.T);
    CTHandles handles = shapetype.addNewHandles();
    CTH h = handles.addNewH();
    h.setPosition("#0,bottomRight");
    h.setXrange("6629,14971");
    CTLock lock = shapetype.addNewLock();
    lock.setExt(STExt.EDIT);
    CTShape shape = group.addNewShape();
    shape.setId("PowerPlusWaterMarkObject" + idx);
    shape.setSpid("_x0000_s102" + (4 + idx));
    shape.setType("#_x0000_t136");
    shape.setStyle("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin");
    shape.setWrapcoords("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068");
    shape.setFillcolor("black");
    shape.setStroked(STTrueFalse.FALSE);
    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:&quot;Cambria&quot;;font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p, doc);
}
Also used : CTR(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR) XWPFParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph) CTLock(com.microsoft.schemas.office.office.CTLock) CTShape(com.microsoft.schemas.vml.CTShape) CTFormulas(com.microsoft.schemas.vml.CTFormulas) CTPath(com.microsoft.schemas.vml.CTPath) CTTextPath(com.microsoft.schemas.vml.CTTextPath) CTRPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr) CTShapetype(com.microsoft.schemas.vml.CTShapetype) CTHandles(com.microsoft.schemas.vml.CTHandles) CTPPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr) CTH(com.microsoft.schemas.vml.CTH) CTGroup(com.microsoft.schemas.vml.CTGroup) CTPicture(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPicture) CTP(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)

Aggregations

CTRPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr)31 CTOnOff (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff)10 Test (org.junit.Test)9 BigInteger (java.math.BigInteger)4 CTFonts (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts)3 CTColor (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor)2 CTHpsMeasure (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure)2 CTR (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR)2 CTLock (com.microsoft.schemas.office.office.CTLock)1 CTFormulas (com.microsoft.schemas.vml.CTFormulas)1 CTGroup (com.microsoft.schemas.vml.CTGroup)1 CTH (com.microsoft.schemas.vml.CTH)1 CTHandles (com.microsoft.schemas.vml.CTHandles)1 CTPath (com.microsoft.schemas.vml.CTPath)1 CTShape (com.microsoft.schemas.vml.CTShape)1 CTShapetype (com.microsoft.schemas.vml.CTShapetype)1 CTTextPath (com.microsoft.schemas.vml.CTTextPath)1 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)1 XmlString (org.apache.xmlbeans.XmlString)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1