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


Java Range.getParagraph方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: writePDFFromDoc

import org.apache.poi.hwpf.usermodel.Range; //导入方法依赖的package包/类
public static void writePDFFromDoc(
  final String docFilePath,
  final String pdfFilePath) throws SSErr{
  
  try{
    final Document        document = new Document();
    final POIFSFileSystem fs       = new POIFSFileSystem(openFileForRead(docFilePath));
    final HWPFDocument    word     = new HWPFDocument  (fs);
    final WordExtractor   we       = new WordExtractor (word);
    final OutputStream    out      = openOrCreateFileWithPathForWrite(pdfFilePath);
    final PdfWriter       writer   = PdfWriter.getInstance(document, out);
    final Range           range    = word.getRange();
    
    document.open();
    writer.setPageEmpty(true);
    document.newPage();
    writer.setPageEmpty(true);
    
    String[] paragraphs = we.getParagraphText();
    
    for (int i = 0; i < paragraphs.length; i++) {
      
      org.apache.poi.hwpf.usermodel.Paragraph pr = range.getParagraph(i);
      // CharacterRun run = pr.getCharacterRun(i);
      // run.setBold(true);
      // run.setCapitalized(true);
      // run.setItalic(true);
      paragraphs[i] = paragraphs[i].replaceAll("\\cM?\r?\n", "");
      System.out.println("Length:" + paragraphs[i].length());
      System.out.println("Paragraph" + i + ": " + paragraphs[i].toString());
      
      // add the paragraph to the document
      document.add(new Paragraph(paragraphs[i]));
    }
    
    document.close();
  }catch(Exception error){
    SSServErrReg.regErrThrow(error);
  }
}
 
开发者ID:learning-layers,项目名称:SocialSemanticServer,代码行数:41,代码来源:SSFileU.java

示例8: 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.getParagraph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。