本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}