当前位置: 首页>>代码示例>>Java>>正文


Java XWPFParagraph.getRuns方法代码示例

本文整理汇总了Java中org.apache.poi.xwpf.usermodel.XWPFParagraph.getRuns方法的典型用法代码示例。如果您正苦于以下问题:Java XWPFParagraph.getRuns方法的具体用法?Java XWPFParagraph.getRuns怎么用?Java XWPFParagraph.getRuns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.xwpf.usermodel.XWPFParagraph的用法示例。


在下文中一共展示了XWPFParagraph.getRuns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRunEdges

import org.apache.poi.xwpf.usermodel.XWPFParagraph; //导入方法依赖的package包/类
private List<Pair<RunEdge, RunEdge>> buildRunEdges(XWPFParagraph paragraph) {
      String text = paragraph.getText();
      List<XWPFRun> runs = paragraph.getRuns();

List<Pair<RunEdge, RunEdge>> runEdgeListPairs = new ArrayList<Pair<RunEdge, RunEdge>>();

Matcher matcher = TAG_PATTERN.matcher(text);
while (matcher.find()) {
	runEdgeListPairs.add(ImmutablePair.of(new RunEdge(matcher.start(), matcher.group()),
			new RunEdge(matcher.end(), matcher.group())));
}
if (runEdgeListPairs.isEmpty()) return runEdgeListPairs;

//search then calculate run edge
searchRunEdge(runs, runEdgeListPairs);
for (Pair<RunEdge, RunEdge> pair : runEdgeListPairs) {
	LOGGER.debug(pair.getLeft().toString());
	LOGGER.debug(pair.getRight().toString());
}
      return runEdgeListPairs;
  }
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:22,代码来源:TemplateResolver.java

示例2: getRunContaining

import org.apache.poi.xwpf.usermodel.XWPFParagraph; //导入方法依赖的package包/类
/**
 * Gets the {@link XWPFRun} containing the given text in the given {@link XWPFDocument}.
 * 
 * @param document
 *            the {@link XWPFDocument}
 * @param text
 *            the {@link XWPFRun}
 * @return the {@link XWPFRun} containing the given text in the given {@link XWPFDocument} if any, <code>null</code> otherwise
 */
public static XWPFRun getRunContaining(XWPFDocument document, String text) {
    XWPFRun res = null;

    for (XWPFParagraph paragraph : document.getParagraphs()) {
        for (XWPFRun run : paragraph.getRuns()) {
            if (run.text().contains(text)) {
                res = run;
                break;
            }
        }
    }

    return res;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:24,代码来源:M2DocTestUtils.java

示例3: getRunPos

import org.apache.poi.xwpf.usermodel.XWPFParagraph; //导入方法依赖的package包/类
public Integer getRunPos() {
	XWPFParagraph paragraph = (XWPFParagraph) run.getParent();
	List<XWPFRun> runs = paragraph.getRuns();
	for (int i = 0; i < runs.size(); i++) {
		if (run == runs.get(i)) {
			return i;
		}
	}
	return null;
}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:11,代码来源:RunTemplate.java

示例4: parseRun

import org.apache.poi.xwpf.usermodel.XWPFParagraph; //导入方法依赖的package包/类
/**
 * running string Algorithm
 * 
 * @param paragraph
 * @return
 */
public  List<RunTemplate> parseRun(XWPFParagraph paragraph) {
	if (null  == paragraph) return null;
	List<XWPFRun> runs = paragraph.getRuns();
	if (null == runs || runs.isEmpty()) return null;
	
	List<Pair<RunEdge, RunEdge>> runEdgeListPairs = buildRunEdges(paragraph);
	if (runEdgeListPairs.isEmpty()) return null;
	
	// split and merge
	return mergeRuns(paragraph, runEdgeListPairs);
}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:18,代码来源:TemplateResolver.java

示例5: collectRelationId

import org.apache.poi.xwpf.usermodel.XWPFParagraph; //导入方法依赖的package包/类
/**
 * Collect Relation Id in paragraph.
 *
 * @param inputPicuteIdToOutputmap
 *            the picture ID mapping
 * @param paragraph
 *            paragraph
 * @param outputDoc
 *            outputDoc
 * @throws InvalidFormatException
 *             InvalidFormatException
 */
private void collectRelationId(Map<String, String> inputPicuteIdToOutputmap, XWPFParagraph paragraph,
        XWPFDocument outputDoc) throws InvalidFormatException {
    for (XWPFRun run : paragraph.getRuns()) {
        createPictures(inputPicuteIdToOutputmap, run, outputDoc);
    }
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:19,代码来源:UserContentRawCopy.java


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