} else if (!getRelations().contains(xwpfPicData)) {
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; }
/** * @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; }
/** * @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; } }
/** * 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; }
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; }
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; }
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; }
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; }
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; }
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; }
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)); } } } }
} else if (!getRelations().contains(xwpfPicData)) {
else if (!getRelations().contains(xwpfPicData))
for (POIXMLDocumentPart p : getRelations()) { String relation = p.getPackageRelationship().getRelationshipType(); if (relation.equals(XWPFRelation.STYLES.getRelation())) {