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


Java Range.numParagraphs方法代码示例

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


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

示例1: printInfo

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
/**
 * 输出Range
 * 
 * @param range
 */
private void printInfo(Range range) {
	// 获取段落数
	int paraNum = range.numParagraphs();
	System.out.println(paraNum);
	for (int i = 0; i < paraNum; i++) {
		// this.insertInfo(range.getParagraph(i));
		System.out.println("段落" + (i + 1) + ":" + range.getParagraph(i).text());
		if (i == (paraNum - 1)) {
			this.insertInfo(range.getParagraph(i));
		}
	}
	int secNum = range.numSections();
	System.out.println(secNum);
	Section section;
	for (int i = 0; i < secNum; i++) {
		section = range.getSection(i);
		System.out.println(section.getMarginLeft());
		System.out.println(section.getMarginRight());
		System.out.println(section.getMarginTop());
		System.out.println(section.getMarginBottom());
		System.out.println(section.getPageHeight());
		System.out.println(section.text());
	}
}
 
开发者ID:East196,项目名称:maker,代码行数:30,代码来源:HwpfTest.java

示例2: handleHeaderFooter

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
private void handleHeaderFooter(Range[] ranges, String type,
    HWPFDocument document, PicturesSource pictures,
    PicturesTable pictureTable, XHTMLContentHandler xhtml)
    throws SAXException, IOException, TikaException {
  if (countParagraphs(ranges) > 0) {
    xhtml.startElement("div", "class", type);
    for (Range r : ranges) {
      if (r != null) {
        for (int i = 0; i < r.numParagraphs(); i++) {
          Paragraph p = r.getParagraph(i);

          String text = p.text();
          if (text.replaceAll("[\\r\\n\\s]+", "").isEmpty()) {
            // Skip empty header or footer paragraphs
          } else {
            i += handleParagraph(p, 0, r, document,
                FieldsDocumentPart.HEADER, pictures, pictureTable, xhtml);
          }
        }
      }
    }
    xhtml.endElement("div");
  }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:25,代码来源:WordExtractor.java

示例3: getParagraphText

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
protected static String[] getParagraphText( Range r )
{
    String[] ret;
    ret = new String[r.numParagraphs()];
    for ( int i = 0; i < ret.length; i++ )
    {
        Paragraph p = r.getParagraph( i );
        ret[i] = p.text();

        // Fix the line ending
        if ( ret[i].endsWith( "\r" ) )
        {
            ret[i] = ret[i] + "\n";
        }
    }
    return ret;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:18,代码来源:WordExtractor.java

示例4: processParagraphRequest

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
/**
 * Processing of text requests.
 * 
 * @param doc word document
 * @param paragraphRef reference to paragraphs
 * @return list of text values as {@code LinkedList<Value>}
 */
private LinkedList<Value> processParagraphRequest(HWPFDocument doc, String paraRef) {
    LinkedList<Value> valList = new LinkedList<Value>();
    Range docRange = doc.getRange();

    setStartEndParagraph(paraRef, "*");
    if (this.startPara == -1 || this.endPara == -1) {
        this.startPara = 0;
        this.endPara = docRange.numParagraphs() - 1;
    }

    // -1 => all paragraphs requested
    if (this.startPara < docRange.numParagraphs()) {
        if (!(this.endPara < docRange.numParagraphs())) {
            this.endPara = docRange.numParagraphs() - 1;
        }

        for (Integer pPos = this.startPara; pPos <= this.endPara; pPos++) {
            Paragraph p = docRange.getParagraph(pPos);
            Integer subURI = pPos + 1;
            valList.add(getParagraph(p, subURI.toString()));
        }
    }

    return valList;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:33,代码来源:DataWordResource.java

示例5: readList

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
/**
 * 读列表
 * 
 * @param range
 */
private void readList(Range range) {
	int num = range.numParagraphs();
	Paragraph para;
	for (int i = 0; i < num; i++) {
		para = range.getParagraph(i);
		if (para.isInList()) {
			System.out.println("list: " + para.text());
		}
	}
}
 
开发者ID:East196,项目名称:maker,代码行数:16,代码来源:HwpfTest.java

示例6: countParagraphs

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
private static int countParagraphs(Range... ranges) {
  int count = 0;
  for (Range r : ranges) {
    if (r != null) {
      count += r.numParagraphs();
    }
  }
  return count;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:10,代码来源:WordExtractor.java

示例7: getWordParagraphText

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
/**
 * Get the text from the word file, as an array with one String
 *  per paragraph
 */
public static String[] getWordParagraphText(HWPFDocument doc) {
	String[] ret;
	
	// Extract using the model code
	try {
    	Range r = doc.getRange();

		ret = new String[r.numParagraphs()];
		for(int i=0; i<ret.length; i++) {
			Paragraph p = r.getParagraph(i);
			ret[i] = p.text();
			
			// Fix the line ending
			if(ret[i].endsWith("\r")) {
				ret[i] = ret[i] + "\n";
			}
		}
	}
               catch(Exception e) {
		// Something's up with turning the text pieces into paragraphs
		// Fall back to ripping out the text pieces
		ret = new String[1];
		ret[0] = getWordTextFromPieces(doc);
	}
	
	return ret;
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:32,代码来源:MSOfficeBox.java

示例8: dumpParagraphsDom

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
public void dumpParagraphsDom( boolean withText )
{
    Range range = _doc.getOverallRange();
    for ( int p = 0; p < range.numParagraphs(); p++ )
    {
        Paragraph paragraph = range.getParagraph( p );
        System.out.println( p + ":\t" + paragraph.toString() );

        if ( withText )
            System.out.println( paragraph.text() );
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:13,代码来源:HWPFLister.java

示例9: processParagraphes

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
protected void processParagraphes( HWPFDocumentCore wordDocument,
        Element flow, Range range, int currentTableLevel )
{
    final int paragraphs = range.numParagraphs();
    for ( int p = 0; p < paragraphs; p++ )
    {
        Paragraph paragraph = range.getParagraph( p );

        if ( paragraph.isInTable()
                && paragraph.getTableLevel() != currentTableLevel )
        {
            if ( paragraph.getTableLevel() < currentTableLevel )
                throw new IllegalStateException(
                        "Trying to process table cell with higher level ("
                                + paragraph.getTableLevel()
                                + ") than current table level ("
                                + currentTableLevel
                                + ") as inner table part" );

            Table table = range.getTable( paragraph );
            processTable( wordDocument, flow, table );

            p += table.numParagraphs();
            p--;
            continue;
        }

        if ( paragraph.text().equals( "\u000c" ) )
        {
            processPageBreak( wordDocument, flow );
        }

        boolean processed = false;
        if ( paragraph.isInList() )
        {
            try
            {
                HWPFList hwpfList = paragraph.getList();

                String label = AbstractWordUtils.getBulletText(
                        numberingState, hwpfList,
                        (char) paragraph.getIlvl() );

                processParagraph( wordDocument, flow, currentTableLevel,
                        paragraph, label );
                processed = true;
            }
            catch ( Exception exc )
            {
                log.log(
                        POILogger.WARN,
                        "Can't process paragraph as list entry, will be processed without list information",
                        exc );
            }
        }

        if ( processed == false )
        {
            processParagraph( wordDocument, flow, currentTableLevel,
                    paragraph, AbstractWordUtils.EMPTY );
        }
    }

}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:65,代码来源:AbstractWordConverter.java


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