org.apache.poi.xwpf.usermodel.XWPFDocument.getPackagePart()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(382)

本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFDocument.getPackagePart()方法的一些代码示例,展示了XWPFDocument.getPackagePart()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFDocument.getPackagePart()方法的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFDocument
类名称:XWPFDocument
方法名:getPackagePart

XWPFDocument.getPackagePart介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Get the document's embedded files.
 */
@Override
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
  List<PackagePart> embedds = new LinkedList<>();
  // Get the embeddings for the workbook
  PackagePart part = getPackagePart();
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  return embedds;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * commit and saves the document
 */
@Override
protected void commit() throws IOException {
  XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
  xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document"));
  PackagePart part = getPackagePart();
  OutputStream out = part.getOutputStream();
  ctDocument.save(out, xmlOptions);
  out.close();
}

代码示例来源:origin: org.apache.poi/poi-ooxml

private void initHyperlinks() {
  // Get the hyperlinks
  // TODO: make me optional/separated in private function
  try {
    for (PackageRelationship rel : getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation())) {
      hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
    }
  } catch (InvalidFormatException e) {
    throw new POIXMLException(e);
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

protected void onDocumentRead() throws IOException {
  try {
    DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
    ctDocument = doc.getDocument();

代码示例来源:origin: apache/tika

/**
 * Include main body and anything else that can
 * have an attachment/embedded object
 */
@Override
protected List<PackagePart> getMainDocumentParts() {
  List<PackagePart> parts = new ArrayList<PackagePart>();
  parts.add(document.getPackagePart());
  addRelatedParts(document.getPackagePart(), parts);
  return parts;
}

代码示例来源:origin: Sayi/poi-tl

PackageRelationship relationship = paragraph.getDocument().getPackagePart()
    .addExternalRelationship(link, XWPFRelation.HYPERLINK.getRelation());
CTHyperlink hyperlink = paragraph.getCTP().insertNewHyperlink(pos);

代码示例来源:origin: Sayi/poi-tl

public XWPFHyperlinkRun createHyperLinkRun(String link) {
  PackageRelationship relationship = paragraph.getDocument().getPackagePart()
      .addExternalRelationship(link, XWPFRelation.HYPERLINK.getRelation());
  CTHyperlink hyperlink = paragraph.getCTP().addNewHyperlink();
  hyperlink.setId(relationship.getId());
  CTR ctr = hyperlink.addNewR();
  XWPFHyperlinkRun xwpfRun = new XWPFHyperlinkRun(hyperlink, ctr, (IRunBody) paragraph);
  getRuns().add(xwpfRun);
  getIRuns().add(xwpfRun);
  return xwpfRun;
}

代码示例来源:origin: apache/tika

RELATION_DIAGRAM_DATA,
"diagram-data",
document.getPackagePart(),
metadata,
new OOXMLWordAndPowerPointTextHandler(
XSSFRelation.CHART.getRelation(),
"chart",
document.getPackagePart(),
metadata,
new OOXMLWordAndPowerPointTextHandler(

代码示例来源:origin: org.apache.tika/tika-parsers

/**
 * Include main body and anything else that can
 * have an attachment/embedded object
 */
@Override
protected List<PackagePart> getMainDocumentParts() {
  List<PackagePart> parts = new ArrayList<PackagePart>();
  parts.add(document.getPackagePart());
  addRelatedParts(document.getPackagePart(), parts);
  return parts;
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-parsers

/**
 * Include main body and anything else that can
 * have an attachment/embedded object
 */
@Override
protected List<PackagePart> getMainDocumentParts() {
  List<PackagePart> parts = new ArrayList<PackagePart>();
  parts.add(document.getPackagePart());
  addRelatedParts(document.getPackagePart(), parts);
  return parts;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Get the document's embedded files.
 */
@Override
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
  List<PackagePart> embedds = new LinkedList<>();
  // Get the embeddings for the workbook
  PackagePart part = getPackagePart();
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  return embedds;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Get the document's embedded files.
 */
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
  List<PackagePart> embedds = new LinkedList<PackagePart>();
  // Get the embeddings for the workbook
  PackagePart part = getPackagePart();
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  for (PackageRelationship rel : getPackagePart().getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
    embedds.add(part.getRelatedPart(rel));
  }
  return embedds;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * commit and saves the document
 */
@Override
protected void commit() throws IOException {
  XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
  xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document"));
  Map<String, String> map = new HashMap<String, String>();
  map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
  map.put("urn:schemas-microsoft-com:office:office", "o");
  map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
  map.put("urn:schemas-microsoft-com:vml", "v");
  map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
  map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
  map.put("urn:schemas-microsoft-com:office:word", "w10");
  map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
  map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
  xmlOptions.setSaveSuggestedPrefixes(map);
  PackagePart part = getPackagePart();
  OutputStream out = part.getOutputStream();
  ctDocument.save(out, xmlOptions);
  out.close();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * commit and saves the document
 */
@Override
protected void commit() throws IOException {
  XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
  xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document"));
  PackagePart part = getPackagePart();
  OutputStream out = part.getOutputStream();
  ctDocument.save(out, xmlOptions);
  out.close();
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

private void initHyperlinks(){
  // Get the hyperlinks
  // TODO: make me optional/separated in private function
  try {
    Iterator<PackageRelationship> relIter =
      getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
    while(relIter.hasNext()) {
      PackageRelationship rel = relIter.next();
      hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
    }
  } catch (InvalidFormatException e){
    throw new POIXMLException(e);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

private void initHyperlinks() {
  // Get the hyperlinks
  // TODO: make me optional/separated in private function
  try {
    for (PackageRelationship rel : getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation())) {
      hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
    }
  } catch (InvalidFormatException e) {
    throw new POIXMLException(e);
  }
}

代码示例来源:origin: org.apache.tika/tika-parsers

RELATION_DIAGRAM_DATA,
"diagram-data",
document.getPackagePart(),
metadata,
new OOXMLWordAndPowerPointTextHandler(
XSSFRelation.CHART.getRelation(),
"chart",
document.getPackagePart(),
metadata,
new OOXMLWordAndPowerPointTextHandler(

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

PackagePartName partName = picDataPart.getPartName();
String relation = relDesc.getRelation();
PackageRelationship relShip = getPackagePart().addRelationship(partName,targetMode,relation);
String id = relShip.getId();
addRelation(id,xwpfPicData);

代码示例来源:origin: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.xhtml

String src = document.getPackagePart().getRelationships().getRelationshipByID(link).getTargetURI().toString();
attributes = SAXHelper.addAttrValue( null, SRC_ATTR, src );

代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.poi.xwpf.converter.xhtml

String src = document.getPackagePart().getRelationships().getRelationshipByID(link).getTargetURI().toString();
attributes = SAXHelper.addAttrValue( null, SRC_ATTR, src );

相关文章

XWPFDocument类方法