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

Java Br类代码示例

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

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



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

示例1: setNewTcContent

import org.docx4j.wml.Br; //导入依赖的package包/类
/** 
 * 设置单元格内容 
 *  
 * @param tc 
 * @param content 
 */  
public static void setNewTcContent(Tc tc, String content) {  
    P p = factory.createP();  
    tc.getContent().add(p);  
    R run = factory.createR();  
    p.getContent().add(run);  
    if (content != null) {  
        String[] contentArr = content.split("\n");  
        Text text = factory.createText();  
        text.setSpace("preserve");  
        text.setValue(contentArr[0]);  
        run.getContent().add(text);  
  
        for (int i = 1, len = contentArr.length; i < len; i++) {  
            Br br = factory.createBr();  
            run.getContent().add(br);// 换行  
            text = factory.createText();  
            text.setSpace("preserve");  
            text.setValue(contentArr[i]);  
            run.getContent().add(text);  
        }  
    }  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:29,代码来源:Docx4j_替换模板.java


示例2: createPageBreak

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

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

		// Create object for p
		P p = wmlObjectFactory.createP();
		// Create object for r
		R r = wmlObjectFactory.createR();
		p.getContent().add(r);
		// Create object for br
		Br br = wmlObjectFactory.createBr();
		r.getContent().add(br);
		br.setType(org.docx4j.wml.STBrType.PAGE);

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


示例3: newPage

import org.docx4j.wml.Br; //导入依赖的package包/类
@Override
protected void newPage() {		
	flushNow();
	Br objBr = new Br();
	objBr.setType(STBrType.PAGE);
	P para = createParagraph();
	para.getContent().add(objBr);
	wordMLPackage.getMainDocumentPart().getContent().add(para);
	if (bean.getReportLayout().isHeaderOnEveryPage()) {
		try {
			printHeaderBand();	
			newRow = true;		
		} catch (QueryException e) {				
			e.printStackTrace();
		}
	}
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:18,代码来源:DocxExporter.java


示例4: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
public void addPageBreak(WordprocessingMLPackage wordMLPackage,
		ObjectFactory factory, STBrType sTBrType) {
	MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
	Br breakObj = new Br();
	breakObj.setType(sTBrType);
	P paragraph = factory.createP();
	paragraph.getContent().add(breakObj);
	documentPart.addObject(paragraph);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:10,代码来源:Docx4J_例子2.java


示例5: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
public void addPageBreak(WordprocessingMLPackage wordMLPackage,  
        ObjectFactory factory) {  
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();  
    Br breakObj = new Br();  
    breakObj.setType(STBrType.PAGE);  
    P paragraph = factory.createP();  
    paragraph.getContent().add(breakObj);  
    documentPart.addObject(paragraph);  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:10,代码来源:Docx4J_简单例子2.java


示例6: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
/**
 * 向文档添加一个换行符
 */
private static void addPageBreak() {
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
 
    Br breakObj = new Br();
    breakObj.setType(STBrType.PAGE);
 
    P paragraph = factory.createP();
    paragraph.getContent().add(breakObj);
    documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:14,代码来源:AddingAPageBreak.java


示例7: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
/**
 * Adds a page break to the document.
 *
 * @param documentPart
 */
private static void addPageBreak(MainDocumentPart documentPart) {
    Br breakObj = new Br();
    breakObj.setType(STBrType.PAGE);
    P paragraph = factory.createP();
    paragraph.getContent().add(breakObj);
    documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:13,代码来源:AddingPageNrToFooter.java


示例8: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
public void addPageBreak(WordprocessingMLPackage wordMLPackage,
		ObjectFactory factory) {
	MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
	Br breakObj = new Br();
	breakObj.setType(STBrType.PAGE);
	P paragraph = factory.createP();
	paragraph.getContent().add(breakObj);
	documentPart.addObject(paragraph);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:10,代码来源:Docx4J_简单例子.java


示例9: replaceLineBreaks

import org.docx4j.wml.Br; //导入依赖的package包/类
private void replaceLineBreaks(ParagraphWrapper paragraphWrapper) {
  Br lineBreak = Context.getWmlObjectFactory().createBr();
  R run = RunUtil.create(lineBreak);
  while (paragraphWrapper.getText().contains(this.lineBreakPlaceholder)) {
    replace(paragraphWrapper, this.lineBreakPlaceholder, run);
  }
}
 
开发者ID:thombergs,项目名称:docx-stamper,代码行数:8,代码来源:PlaceholderReplacer.java


示例10: lineBreaksAreReplaced

import org.docx4j.wml.Br; //导入依赖的package包/类
private void lineBreaksAreReplaced(WordprocessingMLPackage document) {
    P paragraph = (P) document.getMainDocumentPart().getContent().get(2);
    Assert.assertTrue(new ParagraphWrapper(paragraph).getText().contains("This paragraph should be"));
    Assert.assertTrue(new ParagraphWrapper(paragraph).getText().contains("split in"));
    Assert.assertTrue(new ParagraphWrapper(paragraph).getText().contains("three lines"));

    Assert.assertEquals(R.class, paragraph.getContent().get(1).getClass());
    Assert.assertEquals(Br.class, ((R)paragraph.getContent().get(1)).getContent().get(0).getClass());

    Assert.assertEquals(R.class, paragraph.getContent().get(3).getClass());
    Assert.assertEquals(Br.class, ((R)paragraph.getContent().get(3)).getContent().get(0).getClass());
}
 
开发者ID:thombergs,项目名称:docx-stamper,代码行数:13,代码来源:LineBreakReplacementTest.java


示例11: addParagraphsToRun

import org.docx4j.wml.Br; //导入依赖的package包/类
private void addParagraphsToRun(R r, String text) {
    org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory();
    String[] parts = text.split("\n");
    for (int i = 0; i < parts.length; i++) {
        String part = parts[i];
        Text t = factory.createText();
        //P p = factory.createP() ;
        t.setValue(part);
        //p.getContent().add(t);
        r.getContent().add(t);
        Br br = factory.createBr();
        r.getContent().add(br);
    }
    r.getContent().remove(0);
}
 
开发者ID:cornerpirate,项目名称:ReportCompilerSource,代码行数:16,代码来源:ExportToWord.java


示例12: addPageBreak

import org.docx4j.wml.Br; //导入依赖的package包/类
/**
 * @Description: 段落添加Br 页面Break(分页符)
 */
public void addPageBreak(P para, STBrType sTBrType) {
    Br breakObj = new Br();
    breakObj.setType(sTBrType);
    para.getContent().add(breakObj);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:9,代码来源:Docx4j_工具类_S3_Test.java


示例13: toNode

import org.docx4j.wml.Br; //导入依赖的package包/类
@Override
public Node toNode(AbstractWmlConversionContext context, Object unmarshalledNode, 
		Node modelContent, TransformState state, Document doc)
		throws TransformerException {
	
	Br modelData = (Br)unmarshalledNode;
	Element ret;
	
	if (modelData.getType()!=null 
			&& modelData.getType().equals(STBrType.PAGE)) {
	
		ret = doc.createElementNS(XSL_FO, "block");
		ret.setAttribute("break-before", "page");
	
	} else {
		
		/* w:br is converted to fo:block with @line-height="0pt", to get rid of
		 * unwanted vertical whitespace.  If effect, it results in a carriage return.
		 * 
		 * However, some users use contiguous w:br to create vertical spacing
		 * which works in Word.  But FOP only does a single carriage return
		 * for contiguous fo:block/@line-height="0pt"
		 * 
		 * So we need to work around this.  Possible approaches:
		 * 
		 * 1. pre-process to convert the w:br to a w:p.  This is difficult,
		 *    for example, numbering.
		 * 
		 * 2. set TransformState, so the attribute is not set for the 2nd w:br
		 * 
		 * 3. set some custom attribute on the br
		 * 
		 * 4. post-process the XSL FO, so in contiguous fo:block/@line-height="0pt"
		 *    the attributes on 2nd and subsequent are changed.
		 *    
		 *    eg in org/docx4j/convert/out/fo/renderers/AbstractFORenderer_POSTPROCESSING.xslt
		 *     
		 * It turns out the easiest approach is to catch the special case in the XSLT
		 * 
		 */
	
		ret = doc.createElementNS(XSL_FO, "block");  // yuck .. block/inline/block
		// see http://stackoverflow.com/a/3664468/1031689 answer
		// at http://stackoverflow.com/questions/3661483/inserting-a-line-break-in-a-pdf-generated-from-xsl-fo-using-xslvalue-of
		ret.setAttribute("linefeed-treatment", "preserve");
		ret.setAttribute("white-space-treatment", "preserve");
		//ret.setAttribute("space-after", "0in"); // doesn't help
		ret.setAttribute("line-height", "0pt"); // suits FOP 1.1
		ret.setTextContent("\n");
	}
	return ret;
}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:53,代码来源:BrWriter.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java HierarchicalConfiguration类代码示例发布时间:2022-05-22
下一篇:
Java IEncodedStorage类代码示例发布时间: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