/** * Attach a template to this document. * This is just an easy way to access the same method in DocumentSettingsPart * * @param templatePath * @since 6.1.0 */ public void attachTemplate(String templatePath) { DocumentSettingsPart dsp = null; try { dsp = this.getDocumentSettingsPart(true); } catch (InvalidFormatException e) { // shouldn't happen log.error(e.getMessage(), e); } dsp.attachTemplate(templatePath); }
public void addDocPropsExtendedPart() { if (docPropsExtendedPart==null) { try { docPropsExtendedPart = new org.docx4j.openpackaging.parts.DocPropsExtendedPart(); this.addTargetPart(docPropsExtendedPart); docPropsExtendedPart.setJaxbElement(new org.docx4j.docProps.extended.Properties()); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
public void addDocPropsCorePart() { if (docPropsCorePart==null) { try { docPropsCorePart = new org.docx4j.openpackaging.parts.DocPropsCorePart(); this.addTargetPart(docPropsCorePart); docPropsCorePart.setJaxbElement(new CoreProperties()); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
public void addDocPropsCustomPart() { if (docPropsCustomPart==null) { try { docPropsCustomPart = new org.docx4j.openpackaging.parts.DocPropsCustomPart(); docPropsCustomPart.setJaxbElement(new Properties()); this.addTargetPart(docPropsCustomPart); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
/** * Inserts the slide at the specified position in the presentation. * Shifts the element currently at that position (if any) and any subsequent elements to the * right (adds one to their indices). * * @param index * @param slidePart * @throws Pptx4jException * @since 3.0 */ public void addSlide(int index, SlidePart slidePart) throws Pptx4jException { List<SldId> sldIds = this.getJaxbElement().getSldIdLst().getSldId(); int zeroBasedCount = sldIds.size(); if (index< 0 || index>zeroBasedCount) { throw new Pptx4jException("Can't add slide at index " + index + ". (There are " + sldIds.size() + " slides) "); } try { Relationship rel = this.addTargetPart(slidePart, AddPartBehaviour.RENAME_IF_NAME_EXISTS); sldIds.add(index, createSlideIdListEntry(rel)); } catch (InvalidFormatException e) { throw new Pptx4jException(e.getMessage(), e); } }
public static RelationshipsPart createRelationshipsPartForPart( Base sourcePart) { if (sourcePart.relationships != null) return sourcePart.relationships; RelationshipsPart rp = null; try { rp = new RelationshipsPart(sourcePart); } catch (InvalidFormatException e) { // shouldn't happen log.error(e.getMessage(), e); } rp.setPackage(sourcePart.getPackage()); // Make sure content manager knows how to handle .rels sourcePart .getPackage() .getContentTypeManager() .addDefaultContentType( "rels", org.docx4j.openpackaging.contenttype.ContentTypes.RELATIONSHIPS_PART); return rp; }
/** * @since 3.0.0 */ public void setTitle(String title) { if (this.getDocPropsCorePart()==null) { DocPropsCorePart core; try { core = new DocPropsCorePart(); org.docx4j.docProps.core.ObjectFactory coreFactory = new org.docx4j.docProps.core.ObjectFactory(); core.setJaxbElement(coreFactory.createCoreProperties() ); this.addTargetPart(core); } catch (InvalidFormatException e) { log.error(e.getMessage(), e); } } org.docx4j.docProps.core.dc.elements.ObjectFactory of = new org.docx4j.docProps.core.dc.elements.ObjectFactory(); SimpleLiteral literal = of.createSimpleLiteral(); literal.getContent().add(title); this.getDocPropsCorePart().getJaxbElement().setTitle(of.createTitle(literal) ); }
documentSettingsPart = getPkg().getMainDocumentPart().getDocumentSettingsPart(true); } catch (InvalidFormatException e) { log.warn(e.getMessage(), e);
return this.getJaxbElement().getSldIdLst().getSldId().add(createSlideIdListEntry(rel)); } catch (InvalidFormatException e) { throw new Pptx4jException(e.getMessage(), e);
/** * Attach a template to this document. * This is just an easy way to access the same method in DocumentSettingsPart * * @param templatePath * @since 6.1.0 */ public void attachTemplate(String templatePath) { DocumentSettingsPart dsp = null; try { dsp = this.getDocumentSettingsPart(true); } catch (InvalidFormatException e) { // shouldn't happen log.error(e.getMessage(), e); } dsp.attachTemplate(templatePath); }
public void addDocPropsCorePart() { if (docPropsCorePart==null) { try { docPropsCorePart = new org.docx4j.openpackaging.parts.DocPropsCorePart(); this.addTargetPart(docPropsCorePart); docPropsCorePart.setJaxbElement(new CoreProperties()); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
public void addDocPropsCustomPart() { if (docPropsCustomPart==null) { try { docPropsCustomPart = new org.docx4j.openpackaging.parts.DocPropsCustomPart(); docPropsCustomPart.setJaxbElement(new Properties()); this.addTargetPart(docPropsCustomPart); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
public void addDocPropsExtendedPart() { if (docPropsExtendedPart==null) { try { docPropsExtendedPart = new org.docx4j.openpackaging.parts.DocPropsExtendedPart(); this.addTargetPart(docPropsExtendedPart); docPropsExtendedPart.setJaxbElement(new org.docx4j.docProps.extended.Properties()); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
/** * Inserts the slide at the specified position in the presentation. * Shifts the element currently at that position (if any) and any subsequent elements to the * right (adds one to their indices). * * @param index * @param slidePart * @throws Pptx4jException * @since 3.0 */ public void addSlide(int index, SlidePart slidePart) throws Pptx4jException { List<SldId> sldIds = this.getJaxbElement().getSldIdLst().getSldId(); int zeroBasedCount = sldIds.size(); if (index< 0 || index>zeroBasedCount) { throw new Pptx4jException("Can't add slide at index " + index + ". (There are " + sldIds.size() + " slides) "); } try { Relationship rel = this.addTargetPart(slidePart, AddPartBehaviour.RENAME_IF_NAME_EXISTS); sldIds.add(index, createSlideIdListEntry(rel)); } catch (InvalidFormatException e) { throw new Pptx4jException(e.getMessage(), e); } }
public static RelationshipsPart createRelationshipsPartForPart( Base sourcePart) { if (sourcePart.relationships != null) return sourcePart.relationships; RelationshipsPart rp = null; try { rp = new RelationshipsPart(sourcePart); } catch (InvalidFormatException e) { // shouldn't happen log.error(e.getMessage(), e); } rp.setPackage(sourcePart.getPackage()); // Make sure content manager knows how to handle .rels sourcePart .getPackage() .getContentTypeManager() .addDefaultContentType( "rels", org.docx4j.openpackaging.contenttype.ContentTypes.RELATIONSHIPS_PART); return rp; }
/** * @since 3.0.0 */ public void setTitle(String title) { if (this.getDocPropsCorePart()==null) { DocPropsCorePart core; try { core = new DocPropsCorePart(); org.docx4j.docProps.core.ObjectFactory coreFactory = new org.docx4j.docProps.core.ObjectFactory(); core.setJaxbElement(coreFactory.createCoreProperties() ); this.addTargetPart(core); } catch (InvalidFormatException e) { log.error(e.getMessage(), e); } } org.docx4j.docProps.core.dc.elements.ObjectFactory of = new org.docx4j.docProps.core.dc.elements.ObjectFactory(); SimpleLiteral literal = of.createSimpleLiteral(); literal.getContent().add(title); this.getDocPropsCorePart().getJaxbElement().setTitle(of.createTitle(literal) ); }
return this.getJaxbElement().getSldIdLst().getSldId().add(createSlideIdListEntry(rel)); } catch (InvalidFormatException e) { throw new Pptx4jException(e.getMessage(), e);
documentSettingsPart = getPkg().getMainDocumentPart().getDocumentSettingsPart(true); } catch (InvalidFormatException e) { log.warn(e.getMessage(), e);