gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-25 09:09:05 28 4
gpt4 key购买 nike

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

XWPFRelation.getRelation介绍

暂无

代码示例

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

private int getRelationIndex(XWPFRelation relation) {
  int i = 1;
  for (RelationPart rp : doc.getRelationParts()) {
    if (rp.getRelationship().getRelationshipType().equals(relation.getRelation())) {
      i++;
    }
  }
  return i;
}

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

/**
 * Gets the index of the relation we're trying to create
 *
 * @param relation
 * @return i
 */
private int getRelationIndex(XWPFRelation relation) {
  int i = 1;
  for (RelationPart rp : getRelationParts()) {
    if (rp.getRelationship().getRelationshipType().equals(relation.getRelation())) {
      i++;
    }
  }
  return i;
}

代码示例来源: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

private void initFootnotes() throws XmlException, IOException {
  for (RelationPart rp : getRelationParts()) {
    POIXMLDocumentPart p = rp.getDocumentPart();
    String relation = rp.getRelationship().getRelationshipType();
    if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
      this.footnotes = (XWPFFootnotes) p;
      this.footnotes.onDocumentRead();
      this.footnotes.setIdManager(footnoteIdManager);
    } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) {
      this.endnotes = (XWPFEndnotes) p;
      this.endnotes.onDocumentRead();
      this.endnotes.setIdManager(footnoteIdManager);
    }
  }
}

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

/**
 * Returns the styles object used
 */
@Internal
public CTStyles getStyle() throws XmlException, IOException {
  PackagePart[] parts;
  try {
    parts = getRelatedByType(XWPFRelation.STYLES.getRelation());
  } catch (InvalidFormatException e) {
    throw new IllegalStateException(e);
  }
  if (parts.length != 1) {
    throw new IllegalStateException("Expecting one Styles document part, but found " + parts.length);
  }
  StylesDocument sd = StylesDocument.Factory.parse(parts[0].getInputStream(), DEFAULT_XML_OPTIONS);
  return sd.getStyles();
}

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

POIXMLDocumentPart p = rp.getDocumentPart();
String relation = rp.getRelationship().getRelationshipType();
if (relation.equals(XWPFRelation.STYLES.getRelation())) {
  this.styles = (XWPFStyles) p;
  this.styles.onDocumentRead();
} else if (relation.equals(XWPFRelation.NUMBERING.getRelation())) {
  this.numbering = (XWPFNumbering) p;
  this.numbering.onDocumentRead();
} else if (relation.equals(XWPFRelation.FOOTER.getRelation())) {
  XWPFFooter footer = (XWPFFooter) p;
  footers.add(footer);
  footer.onDocumentRead();
} else if (relation.equals(XWPFRelation.HEADER.getRelation())) {
  XWPFHeader header = (XWPFHeader) p;
  headers.add(header);
  header.onDocumentRead();
} else if (relation.equals(XWPFRelation.COMMENT.getRelation())) {
} else if (relation.equals(XWPFRelation.SETTINGS.getRelation())) {
  settings = (XWPFSettings) p;
  settings.onDocumentRead();
} else if (relation.equals(XWPFRelation.IMAGES.getRelation())) {
  XWPFPictureData picData = (XWPFPictureData) p;
  picData.onDocumentRead();
  registerPackagePictureData(picData);
  pictures.add(picData);
} else if (relation.equals(XWPFRelation.CHART.getRelation())) {
} else if (relation.equals(XWPFRelation.GLOSSARY_DOCUMENT.getRelation())) {

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

private Map<String, String> loadHyperlinkRelationships(PackagePart bodyPart) {
  Map<String, String> hyperlinks = new HashMap<>();
  try {
    PackageRelationshipCollection prc = bodyPart.getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation());
    for (int i = 0; i < prc.size(); i++) {
      PackageRelationship pr = prc.getRelationship(i);
      if (pr == null) {
        continue;
      }
      String id = pr.getId();
      String url = (pr.getTargetURI() == null) ? null : pr.getTargetURI().toString();
      if (id != null && url != null) {
        hyperlinks.put(id, url);
      }
    }
  } catch (InvalidFormatException e) {
    LOG.warn("Invalid format", e);
  }
  return hyperlinks;
}

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

private XWPFNumbering loadNumbering(PackagePart packagePart) {
  try {
    PackageRelationshipCollection numberingParts = packagePart.getRelationshipsByType(XWPFRelation.NUMBERING.getRelation());
    if (numberingParts.size() > 0) {
      PackageRelationship numberingRelationShip = numberingParts.getRelationship(0);
      if (numberingRelationShip == null) {
        return null;
      }
      PackagePart numberingPart = container.getPart(numberingRelationShip);
      if (numberingPart == null) {
        return null;
      }
      return new XWPFNumbering(numberingPart);
    }
  } catch (IOException | OpenXML4JException e) {
    LOG.warn("Couldn't load numbering", e);
  }
  return null;
}

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

if (pos >= 0 && pos <= paragraph.getRuns().size()) {
  PackageRelationship relationship = paragraph.getDocument().getPackagePart()
      .addExternalRelationship(link, XWPFRelation.HYPERLINK.getRelation());
  CTHyperlink hyperlink = paragraph.getCTP().insertNewHyperlink(pos);
  hyperlink.setId(relationship.getId());

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

private XWPFStylesShim loadStyles(PackagePart packagePart) throws InvalidFormatException, TikaException, IOException, SAXException {
  PackageRelationshipCollection stylesParts =
      packagePart.getRelationshipsByType(XWPFRelation.STYLES.getRelation());
  if (stylesParts.size() > 0) {
    PackageRelationship stylesRelationShip = stylesParts.getRelationship(0);
    if (stylesRelationShip == null) {
      return null;
    }
    PackagePart stylesPart = packagePart.getRelatedPart(stylesRelationShip);
    if (stylesPart == null) {
      return null;
    }
    return new XWPFStylesShim(stylesPart, context);
  }
  return null;
}

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

private XWPFNumbering loadNumbering(PackagePart packagePart) {
  try {
    PackageRelationshipCollection numberingParts = packagePart.getRelationshipsByType(XWPFRelation.NUMBERING.getRelation());
    if (numberingParts.size() > 0) {
      PackageRelationship numberingRelationShip = numberingParts.getRelationship(0);
      if (numberingRelationShip == null) {
        return null;
      }
      PackagePart numberingPart = packagePart.getRelatedPart(numberingRelationShip);
      if (numberingPart == null) {
        return null;
      }
      return new XWPFNumberingShim(numberingPart);
    }
  } catch (IOException | OpenXML4JException e) {
    //swallow
  }
  return null;
}

代码示例来源: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

PackageRelationshipCollection headersPRC = documentPart.getRelationshipsByType(XWPFRelation.HEADER.getRelation());
  if (headersPRC != null) {
    for (int i = 0; i < headersPRC.size(); i++) {
}) {
  try {
    PackageRelationshipCollection prc = documentPart.getRelationshipsByType(rel.getRelation());
    if (prc != null) {
      for (int i = 0; i < prc.size(); i++) {

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

PackageRelationshipCollection headersPRC = documentPart.getRelationshipsByType(XWPFRelation.HEADER.getRelation());
    if (headersPRC != null) {
      for (int i = 0; i < headersPRC.size(); i++) {
    AbstractOOXMLExtractor.RELATION_DIAGRAM_DATA,
    XSSFRelation.CHART.getRelation(),
    XWPFRelation.FOOTNOTE.getRelation(),
    XWPFRelation.COMMENT.getRelation(),
    XWPFRelation.FOOTER.getRelation(),
    XWPFRelation.ENDNOTE.getRelation(),
}) {
      rel.equals(XWPFRelation.FOOTER.getRelation())) {
    continue;

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

Map<String, String> linkedRelationships = new HashMap<>();
try {
  PackageRelationshipCollection prc = bodyPart.getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation());
  for (int i = 0; i < prc.size(); i++) {
    PackageRelationship pr = prc.getRelationship(i);

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

private int getRelationIndex(XWPFRelation relation) {
  List<POIXMLDocumentPart> relations = doc.getRelations();
  int i = 1;
  for (Iterator<POIXMLDocumentPart> it = relations.iterator(); it.hasNext() ; ) {
    POIXMLDocumentPart item = it.next();
    if (item.getPackageRelationship().getRelationshipType().equals(relation.getRelation())) {
      i++;    
    }
  }
  return i;
}

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

private int getRelationIndex(XWPFRelation relation) {
  int i = 1;
  for (RelationPart rp : doc.getRelationParts()) {
    if (rp.getRelationship().getRelationshipType().equals(relation.getRelation())) {
      i++;
    }
  }
  return i;
}

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

private static XWPFSettings getSettings( XWPFDocument document )
{
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    if ( relationshipType.equals( XWPFRelation.SETTINGS.getRelation() ) )
    {
      return (XWPFSettings) p;
    }
  }
  return null;
}

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

private static XWPFSettings getSettings( XWPFDocument document )
{
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    if ( relationshipType.equals( XWPFRelation.SETTINGS.getRelation() ) )
    {
      return (XWPFSettings) p;
    }
  }
  return null;
}

代码示例来源: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);
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com