• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PPr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.docx4j.wml.PPr的典型用法代码示例。如果您正苦于以下问题:Java PPr类的具体用法?Java PPr怎么用?Java PPr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PPr类属于org.docx4j.wml包,在下文中一共展示了PPr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setTcHidden

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * @Description: 隐藏单元格内容
 */
public void setTcHidden(Tc tc, boolean hidden) {
    List<P> pList = getTcAllP(tc);
    for (P p : pList) {
        PPr ppr = getPPr(p);
        List<Object> objRList = getAllElementFromObject(p, R.class);
        if (objRList == null) {
            continue;
        }
        for (Object objR : objRList) {
            if (objR instanceof R) {
                R r = (R) objR;
                RPr rpr = getRPr(r);
                setRPrVanishStyle(rpr, hidden);
            }
        }
        setParaVanish(ppr, hidden);
    }
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:22,代码来源:Docx4j_工具类_S3_Test.java


示例2: setParagraghBorders

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * @Description: 设置段落边框样式
 */
public void setParagraghBorders(P p, CTBorder topBorder,
        CTBorder bottomBorder, CTBorder leftBorder, CTBorder rightBorder) {
    PPr ppr = getPPr(p);
    PBdr pBdr = new PBdr();
    if (topBorder != null) {
        pBdr.setTop(topBorder);
    }
    if (bottomBorder != null) {
        pBdr.setBottom(bottomBorder);
    }
    if (leftBorder != null) {
        pBdr.setLeft(leftBorder);
    }
    if (rightBorder != null) {
        pBdr.setRight(rightBorder);
    }
    ppr.setPBdr(pBdr);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:22,代码来源:Docx4j_工具类_S3_Test.java


示例3: setFont

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * Use RunFontSelector to determine the correct font for the list item label.
 * 
 * @param context
 * @param foListItemLabelBody
 * @param pPr
 * @param rPr
 * @param text
 */
protected static void setFont(FOConversionContext context, Element foListItemLabelBody, PPr pPr, RPr rPr, String text) {
	
	DocumentFragment result = (DocumentFragment)context.getRunFontSelector().fontSelector(pPr, rPr, text);
	log.debug(XmlUtils.w3CDomNodeToString(result));
	// eg <fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">1)</fo:inline>
	
	// Now get the attribute value
	if (result!=null && result.getFirstChild()!=null) {
		Attr attr = ((Element)result.getFirstChild()).getAttributeNode("font-family");
		if (attr!=null) {
			foListItemLabelBody.setAttribute("font-family", attr.getValue());
		}
	}
			
}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:25,代码来源:XsltFOFunctions.java


示例4: testTblStyle_BasedOnNormal

import org.docx4j.wml.PPr; //导入依赖的package包/类
@Test 
	public void testTblStyle_BasedOnNormal() throws Exception {
		
		// Compat setting says Paragraph style overrides table style		
	
		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
		wordMLPackage.getMainDocumentPart().setContents(
				(Document)XmlUtils.unmarshalString(mdpXml_tblStyle) );
		wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().setContents(
				(Styles)XmlUtils.unmarshalString(styles_in_basedOn_Normal) );
		
		// Use our style!
		List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:p", true);
		PPr ppr = Context.getWmlObjectFactory().createPPr();
		((P)xpathResults.get(0)).setPPr(ppr);
		PStyle ps = Context.getWmlObjectFactory().createPPrBasePStyle();
		ps.setVal("testStyle");
		ppr.setPStyle(ps);
		
		setSetting(wordMLPackage, OVERRIDE);  // table style should get overridden
	
		wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
		
		ParagraphStylesInTableFix.process(wordMLPackage);
		
//		// Revert style and save: 
//		ppr.setPStyle(ps); // doesn't work - wrong ref!
//		wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
		
		Style ours = null;
		for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
			if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
				ours = s;
				break;
			}
		}
		
//		Style s = getStyle(wordMLPackage, STYLE_NAME);
		Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==24); 
	}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:41,代码来源:PStyle12PtInTableGridOverrideTrueTest.java


示例5: testTblStyle_BasedOnNormal

import org.docx4j.wml.PPr; //导入依赖的package包/类
@Test 
	public void testTblStyle_BasedOnNormal() throws Exception {
		
		// A style basedOn Normal is honoured, provided it (not Normal) contributes the font size
	
		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
		wordMLPackage.getMainDocumentPart().setContents(
				(Document)XmlUtils.unmarshalString(mdpXml_tblStyle) );
		wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().setContents(
				(Styles)XmlUtils.unmarshalString(styles_in_basedOn_Normal) );
		
		// Use our style!
		List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:p", true);
		PPr ppr = Context.getWmlObjectFactory().createPPr();
		((P)xpathResults.get(0)).setPPr(ppr);
		PStyle ps = Context.getWmlObjectFactory().createPPrBasePStyle();
		ps.setVal("testStyle");
		ppr.setPStyle(ps);
		
		setSetting(wordMLPackage, OVERRIDE); 

		wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
		
		ParagraphStylesInTableFix.process(wordMLPackage);
		
//		// Revert style and save: 
//		ppr.setPStyle(ps); // doesn't work - wrong ref!
//		wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
		
		Style ours = null;
		for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
			if ("testStyle-TableNormal-BR".equals(s.getStyleId())) {
				ours = s;
				break;
			}
		}
		
//		Style s = getStyle(wordMLPackage, STYLE_NAME);
		Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==EXPECTED_RESULT); 
	}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:41,代码来源:PStyle12PtInTableNormalOverrideFalseTest.java


示例6: createHorizontalLine

import org.docx4j.wml.PPr; //导入依赖的package包/类
public static P createHorizontalLine() {

		org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();

		// Create object for p
		P p = wmlObjectFactory.createP();
		// Create object for pPr
		PPr ppr = wmlObjectFactory.createPPr();
		p.setPPr(ppr);
		// Create object for pBdr
		PPrBase.PBdr pprbasepbdr = wmlObjectFactory.createPPrBasePBdr();
		ppr.setPBdr(pprbasepbdr);
		// Create object for bottom
		CTBorder border = wmlObjectFactory.createCTBorder();
		pprbasepbdr.setBottom(border);
		border.setVal(org.docx4j.wml.STBorder.SINGLE);
		border.setSz(BigInteger.valueOf(6));
		border.setColor("auto");
		border.setSpace(BigInteger.valueOf(1));

		return p;
	}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:23,代码来源:DocxUtil.java


示例7: extractTextFromParagraph

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * Extract text from the paragraph and append it to the provided {@link StringBuilder}.
 *
 * @param stringBuilder
 *            The {@link StringBuilder} to append text to.
 * @param formattingData
 *            Formatting data map to update with ranges of paragraph that are formatted.
 * @param paragraph
 *            The docx4j paragraph object
 * @param paragraphProperties
 *            The docx4j paragraph properties
 * @param styleMap
 *            The extracted styles from the main document
 * @param mainDoc
 *            The main document object
 */
private void extractTextFromParagraph(final StringBuilder stringBuilder, final Map<FormattingType, Set<TextRange>> formattingData,
		final P paragraph, final PPr paragraphProperties, final Map<String, Style> styleMap, final MainDocumentPart mainDoc) {
	for (final Object paragraphChild : paragraph.getContent()) {
		if (paragraphChild instanceof R) {
			final R run = (R) paragraphChild;
			for (final Object runChild : run.getContent()) {
				if (runChild instanceof JAXBElement && ((JAXBElement<?>) runChild).getDeclaredType() == Text.class) {
					final String childText = ((Text) ((JAXBElement<?>) runChild).getValue()).getValue();
					final TextRange childRange = new TextRange(stringBuilder.length(), stringBuilder.length() + childText.length());

					stringBuilder.append(childText);
					extractFormattingData(run, childRange, formattingData, paragraphProperties, styleMap, mainDoc);
				}
			}
		}
	}
}
 
开发者ID:mizitch,项目名称:story-inspector,代码行数:34,代码来源:DocXDocumentExtractor.java


示例8: extractFormattingData

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * Updates the provided formatting data map based on the provided data about the text run.
 *
 * @param run
 *            The provided text run
 * @param childRange
 *            The text range this run covers
 * @param formattingData
 *            The formatting data map to update
 * @param paragraphProperties
 *            The docx4j paragraph properties object
 * @param styleMap
 *            The extracted styles of the main document.
 * @param mainDoc
 *            The main document object
 */
private void extractFormattingData(final R run, final TextRange childRange, final Map<FormattingType, Set<TextRange>> formattingData,
		final PPr paragraphProperties, final Map<String, Style> styleMap, final MainDocumentPart mainDoc) {
	final RPr runProperties = run.getRPr();

	final BooleanDefaultTrue isBold = getRunProperty(runProperties, paragraphProperties, RPr::getB, styleMap, mainDoc);
	final BooleanDefaultTrue isItalics = getRunProperty(runProperties, paragraphProperties, RPr::getI, styleMap, mainDoc);
	final U underlining = getRunProperty(runProperties, paragraphProperties, RPr::getU, styleMap, mainDoc);

	if (isBold != null && isBold.isVal()) {
		formattingData.get(FormattingType.BOLD).add(childRange);
	}

	if (isItalics != null && isItalics.isVal()) {
		formattingData.get(FormattingType.ITALICS).add(childRange);
	}

	if (underlining != null && underlining.getVal() != UnderlineEnumeration.NONE) {
		formattingData.get(FormattingType.UNDERLINE).add(childRange);
	}
}
 
开发者ID:mizitch,项目名称:story-inspector,代码行数:37,代码来源:DocXDocumentExtractor.java


示例9: setAlignment

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * Gets a center aligned PPr for P
 * @return
 */
protected PPr setAlignment(ALIGN align) {
	ObjectFactory wmlObjectFactory = new ObjectFactory();
	PPr ppr = wmlObjectFactory.createPPr();
    Jc jc = wmlObjectFactory.createJc();
    JcEnumeration jcEnumeration = JcEnumeration.CENTER;
    if (align!=null) {
    	switch (align) {
		case LEFT:
			jcEnumeration = JcEnumeration.LEFT;
			break;
		case RIGHT:
			jcEnumeration = JcEnumeration.RIGHT;
			break;
		}
    }
    ppr.setJc(jc); 
    jc.setVal(jcEnumeration);
	return ppr;
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:24,代码来源:PostprocessBase.java


示例10: addNumberingToStyle

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * Adds numbering to the style
 * @param style
 * @param numId the id of numbering definition instance
 * @param ilvl the level
 */
static void addNumberingToStyle(Style style, BigInteger numId, BigInteger ilvl) {
	ObjectFactory factory = Context.getWmlObjectFactory();
	//Create and add <w:pPr> to style
	PPr ppr = factory.createPPr();	    
	style.setPPr(ppr);
	//Create and add <w:numPr>
    NumPr numPr =  factory.createPPrBaseNumPr();
    ppr.setNumPr(numPr);
    // The <w:ilvl> element
    Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
    numPr.setIlvl(ilvlElement);
    ilvlElement.setVal(ilvl);
    // The <w:numId> element
    NumId numIdElement = factory.createPPrBaseNumPrNumId();
    numPr.setNumId(numIdElement);
    numIdElement.setVal(numId);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:24,代码来源:NumberingUtil.java


示例11: setStyleMLA

import org.docx4j.wml.PPr; //导入依赖的package包/类
void setStyleMLA(Style style, boolean justify) {
    ObjectFactory factory = Context.getWmlObjectFactory();
    PPr paragraphProperties = factory.createPPr();
    Jc justification = factory.createJc();
    
    if (justify)
        justification.setVal(JcEnumeration.BOTH);
    else
        justification.setVal(JcEnumeration.CENTER);
    
    paragraphProperties.setJc(justification);
    
    Spacing sp = factory.createPPrBaseSpacing();
    sp.setAfter(BigInteger.ZERO);
    sp.setBefore(BigInteger.ZERO);
    sp.setLine(BigInteger.valueOf(482));
    sp.setLineRule(STLineSpacingRule.AUTO);
    paragraphProperties.setSpacing(sp);
    
    style.setPPr(paragraphProperties);
    
    RPr rpr = new RPr();
    changeFont(rpr, "Times New Roman");
    
    style.setRPr(rpr);
}
 
开发者ID:anubiann00b,项目名称:TextToDocx,代码行数:27,代码来源:Generator.java


示例12: createPageNumParagraph

import org.docx4j.wml.PPr; //导入依赖的package包/类
private P createPageNumParagraph() {
	 CTSimpleField pgnum = factory.createCTSimpleField();
        pgnum.setInstr(" PAGE \\* MERGEFORMAT ");
        RPr RPr = factory.createRPr();
        RPr.setNoProof(new BooleanDefaultTrue());
        PPr ppr = factory.createPPr();
        Jc jc = factory.createJc();
        jc.setVal(JcEnumeration.CENTER);
        ppr.setJc(jc);
        PPrBase.Spacing pprbase = factory.createPPrBaseSpacing();
        pprbase.setBefore(BigInteger.valueOf(240));
        pprbase.setAfter(BigInteger.valueOf(0));
        ppr.setSpacing(pprbase);
      
        R run = factory.createR();
        run.getContent().add(RPr);
        pgnum.getContent().add(run);

        JAXBElement<CTSimpleField> fldSimple = factory.createPFldSimple(pgnum);
        P para = createParagraph();
        para.getContent().add(fldSimple);
        para.setPPr(ppr);  
        return para;
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:25,代码来源:DocxExporter.java


示例13: setParagraphIndInfo

import org.docx4j.wml.PPr; //导入依赖的package包/类
/**
 * @Description: 设置段落缩进信息 1厘米≈567
 */
public void setParagraphIndInfo(P p, String firstLine,
        String firstLineChar, String hanging, String hangingChar,
        String right, String rigthChar, String left, String leftChar) {
    PPr ppr = getPPr(p);
    Ind ind = ppr.getInd();
    if (ind == null) {
        ind = new Ind();
        ppr.setInd(ind);
    }
    if (StringUtils.isNotBlank(firstLine)) {
        ind.setFirstLine(new BigInteger(firstLine));
    }
    if (StringUtils.isNotBlank(firstLineChar)) {
        ind.setFirstLineChars(new BigInteger(firstLineChar));
    }
    if (StringUtils.isNotBlank(hanging)) {
        ind.setHanging(new BigInteger(hanging));
    }
    if (StringUtils.isNotBlank(hangingChar)) {
        ind.setHangingChars(new BigInteger(hangingChar));
    }
    if (StringUtils.isNotBlank(left)) {
        ind.setLeft(new BigInteger(left));
    }
    if (StringUtils.isNotBlank(leftChar)) {
        ind.setLeftChars(new BigInteger(leftChar));
    }
    if (StringUtils.isNotBlank(right)) {
        ind.setRight(new BigInteger(right));
    }
    if (StringUtils.isNotBlank(rigthChar)) {
        ind.setRightChars(new BigInteger(rigthChar));
    }
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:38,代码来源:Docx4j_工具类_S3_Test.java


示例14: createParagraphWithHAlign

import org.docx4j.wml.PPr; //导入依赖的package包/类
/** 
 * 创建段落设置水平对齐方式 
 * @return 
 */  
private P createParagraphWithHAlign() {  
    P p;  
    PPr pPr;  
    p = Docx4j_Helper.factory.createP();  
    pPr=Docx4j_Helper.factory.createPPr();  
    Jc jc =Docx4j_Helper.factory.createJc();  
    jc.setVal(JcEnumeration.CENTER);  
    pPr.setJc(jc);  
    p.setPPr(pPr);  
    return p;  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:16,代码来源:Docx4j_Helper.java


示例15: createParagraghLine

import org.docx4j.wml.PPr; //导入依赖的package包/类
public void createParagraghLine(WordprocessingMLPackage wordMLPackage,
		MainDocumentPart t, ObjectFactory factory,P p,CTBorder topBorder,CTBorder bottomBorder,CTBorder leftBorder,CTBorder rightBorder){
	PPr ppr=new PPr();
	PBdr pBdr=new PBdr();
	pBdr.setTop(topBorder);
	pBdr.setBottom(bottomBorder);
	pBdr.setLeft(leftBorder);
	pBdr.setRight(rightBorder);
	ppr.setPBdr(pBdr);
	p.setPPr(ppr);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:12,代码来源:Docx4J_例子2.java


示例16: setParagraphShdStyle

import org.docx4j.wml.PPr; //导入依赖的package包/类
public void setParagraphShdStyle(ObjectFactory factory, P p, boolean isShd,  
        STShd shdValue, String shdColor) {  
    if (isShd) {  
        PPr ppr = factory.createPPr();  
        CTShd shd = new CTShd();  
        if (shdColor != null) {  
            shd.setColor(shdColor);  
        }  
        if (shdValue != null) {  
            shd.setVal(shdValue);  
        }  
        ppr.setShd(shd);  
        p.setPPr(ppr);  
    }  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:16,代码来源:Docx4j_创建批注_S3_Test.java


示例17: setParagraphSpacing

import org.docx4j.wml.PPr; //导入依赖的package包/类
public void setParagraphSpacing(ObjectFactory factory, P p,  
        boolean isSpace, String before, String after, boolean isLines,  
        String beforeLines, String afterLines, boolean isLineRule,  
        String lineValue, STLineSpacingRule sTLineSpacingRule) {  
    PPr pPr = p.getPPr();  
    if (pPr == null) {  
        pPr = factory.createPPr();  
    }  
    Spacing spacing = new Spacing();  
    if (isSpace) {  
        if (before != null) {  
            // 段前磅数  
            spacing.setBefore(new BigInteger(before));  
        }  
        if (after != null) {  
            // 段后磅数  
            spacing.setAfter(new BigInteger(after));  
        }  
    }  
    if (isLines) {  
        if (beforeLines != null) {  
            // 段前行数  
            spacing.setBeforeLines(new BigInteger(beforeLines));  
        }  
        if (afterLines != null) {  
            // 段后行数  
            spacing.setAfterLines(new BigInteger(afterLines));  
        }  
    }  
    if (isLineRule) {  
        if (lineValue != null) {  
            spacing.setLine(new BigInteger(lineValue));  
        }  
        spacing.setLineRule(sTLineSpacingRule);  
    }  
    pPr.setSpacing(spacing);  
    p.setPPr(pPr);  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:39,代码来源:Docx4j_创建批注_S3_Test.java


示例18: getWmlObjectPpr

import org.docx4j.wml.PPr; //导入依赖的package包/类
public static PPr getWmlObjectPpr(Object object) {
	if (object == null) {
		return null;
	} else if (object instanceof P) {
		return ((P) object).getPPr();
	} else if (object instanceof Child) {
		return getWmlObjectPpr(((Child) object).getParent());
	} else {
		return null;
	}
	//XmlUtils.marshaltoString(object)
	//Context.getWmlObjectFactory().
	//((CTAltChunk)object).getAltChunkPr().g
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:15,代码来源:HtmlToDOCDemo.java


示例19: setWmlPprSetting

import org.docx4j.wml.PPr; //导入依赖的package包/类
public static void setWmlPprSetting(Object source, List<Object> targetList) {
	PPr sourcePpr = getWmlObjectPpr(source);
	if (sourcePpr != null) {
		for (int i = 0, iSize = targetList.size(); i < iSize; i++) {
			PPr ppr = getWmlObjectPpr(targetList.get(i));
			if (ppr != null) {
				ppr.setInd(sourcePpr.getInd());
				ppr.setSpacing(sourcePpr.getSpacing());
			}
		}
	}
	//sourcePpr.getSpacing()
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:14,代码来源:HtmlToDOCDemo.java


示例20: setHorizontalAlignment

import org.docx4j.wml.PPr; //导入依赖的package包/类
public void setHorizontalAlignment(P paragraph, JcEnumeration hAlign) {  
    if (hAlign != null) {  
        PPr pprop = new PPr();  
        Jc align = new Jc();  
        align.setVal(hAlign);  
        pprop.setJc(align);  
        paragraph.setPPr(pprop);  
    }  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:10,代码来源:Docx4j_创建表格_S5_Test.java



注:本文中的org.docx4j.wml.PPr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AggregatedLogDeletionService类代码示例发布时间:2022-05-22
下一篇:
Java OFPortConfigSerializerVer13类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap