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

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

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

XWPFDocument.getRelations介绍

暂无

代码示例

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

} else if (!getRelations().contains(xwpfPicData)) {

代码示例来源: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: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter

/**
 * @param blipId
 * @return XXX in some case XWPFPicture.getPictureData throw a NullPointerException because the getDocument() of
 *         It's paragraph is null
 */
private XWPFPictureData getPictureData( String blipId )
{
  for ( POIXMLDocumentPart part : document.getRelations() )
  {
    if ( part.getPackageRelationship().getId().equals( blipId ) )
    {
      return (XWPFPictureData) part;
    }
  }
  return null;
}

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

/**
   * @param blipId
   * @return XXX in some case XWPFPicture.getPictureData throw a NullPointerException because the getDocument() of
   *         It's paragraph is null
   */
  public static XWPFPictureData getPictureData( XWPFDocument document, String blipId )
  {
    for ( POIXMLDocumentPart part : document.getRelations() )
    {
      if ( part.getPackageRelationship().getId().equals( blipId ) )
      {
        if ( part instanceof XWPFPictureData )
          return (XWPFPictureData) part;
      }
    }
    return null;
  }
}

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

/**
 * Gets the index of the relation we're trying to create
 * @param relation
 * @return i
 */
private int getRelationIndex(XWPFRelation relation) {
  List<POIXMLDocumentPart> relations = 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: 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: fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core-gae

private static List<ThemeDocument> getThemeDocuments( XWPFDocument document )
{
  List<ThemeDocument> themeDocuments = new ArrayList<ThemeDocument>();
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    if ( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme".equals( relationshipType ) )
    {
      try
      {
        InputStream inputStream = p.getPackagePart().getInputStream();
        ThemeDocument theme = ThemeDocument.Factory.parse( inputStream );
        themeDocuments.add( theme );
      }
      catch ( Throwable e )
      {
        e.printStackTrace();
      }
    }
  }
  return themeDocuments;
}

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

private static List<ThemeDocument> getThemeDocuments( XWPFDocument document )
{
  List<ThemeDocument> themeDocuments = new ArrayList<ThemeDocument>();
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    if ( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme".equals( relationshipType ) )
    {
      try
      {
        InputStream inputStream = p.getPackagePart().getInputStream();
        ThemeDocument theme = ThemeDocument.Factory.parse( inputStream );
        themeDocuments.add( theme );
      }
      catch ( Throwable e )
      {
        e.printStackTrace();
      }
    }
  }
  return themeDocuments;
}

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

private static List<FontsDocument> getFontsDocument( XWPFDocument document )
{
  List<FontsDocument> fontsDocuments = new ArrayList<FontsDocument>();
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    // "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
    if ( XWPFRelation.FONT_TABLE.getRelation().equals( relationshipType ) )
    {
      try
      {
        InputStream inputStream = p.getPackagePart().getInputStream();
        FontsDocument fontsDocument = FontsDocument.Factory.parse( inputStream );
        fontsDocuments.add( fontsDocument );
      }
      catch ( Exception e )
      {
        e.printStackTrace();
      }
    }
  }
  return fontsDocuments;
}

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

private static List<FontsDocument> getFontsDocument( XWPFDocument document )
{
  List<FontsDocument> fontsDocuments = new ArrayList<FontsDocument>();
  for ( POIXMLDocumentPart p : document.getRelations() )
  {
    String relationshipType = p.getPackageRelationship().getRelationshipType();
    // "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
    if ( XWPFRelation.FONT_TABLE.getRelation().equals( relationshipType ) )
    {
      try
      {
        InputStream inputStream = p.getPackagePart().getInputStream();
        FontsDocument fontsDocument = FontsDocument.Factory.parse( inputStream );
        fontsDocuments.add( fontsDocument );
      }
      catch ( Exception e )
      {
        e.printStackTrace();
      }
    }
  }
  return fontsDocuments;
}

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

private void initFootnotes() throws XmlException, IOException {
  for(POIXMLDocumentPart p : getRelations()){
   String relation = p.getPackageRelationship().getRelationshipType();
   if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
     FootnotesDocument footnotesDocument = FootnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
     this.footnotes = (XWPFFootnotes)p;
     this.footnotes.onDocumentRead();
     for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteList()) {
      footnotes.addFootnote(ctFtnEdn);
     }
   } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
     EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
     for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteList()) {
      endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
     }
   }
  }
}

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

} else if (!getRelations().contains(xwpfPicData)) {

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

else if (!getRelations().contains(xwpfPicData))

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

for (POIXMLDocumentPart p : getRelations()) {
  String relation = p.getPackageRelationship().getRelationshipType();
  if (relation.equals(XWPFRelation.STYLES.getRelation())) {

相关文章

XWPFDocument类方法