public CustomXmlDataStorage factory() { try { return new CustomXmlDataStorageImpl(); } catch (InvalidFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
/** * Throws an exception if the specified URI is absolute. * * @param partUri * The URI to check. * @throws InvalidFormatException * Throws if the specified URI is absolute. */ private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException { if (partUri.isAbsolute()) { log.error( "" ); throw new InvalidFormatException("Absolute URI forbidden: " + partUri); } }
/** * 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); }
/** * @return the customXmlDataStorageClass */ static public CustomXmlDataStorage getCustomXmlDataStorageClass() { try { if (customXmlDataStorageClass==null) { customXmlDataStorageClass = new CustomXmlDataStorageImpl(); } return customXmlDataStorageClass; } catch (InvalidFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
/** * Throws an exception if the specified URI is empty. [M1.1] * * @param partURI * Part URI to check. * @throws InvalidFormatException * If the specified URI is empty. */ private static void throwExceptionIfEmptyURI(URI partURI) throws InvalidFormatException { if (partURI == null) { throw new IllegalArgumentException("partURI"); } String uriPath = partURI.getPath(); if (uriPath.length() == 0 || ((uriPath.length() == 1) && (uriPath.charAt(0) == URIHelper.FORWARD_SLASH_CHAR))) { throw new InvalidFormatException( "A part name shall not be empty [M1.1]: " + partURI.getPath()); } }
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); } } }
} catch (InvalidFormatException e) { e.printStackTrace();
/** * Throws an exception if the specified part name doesn't start with a * forward slash character '/'. [M1.4] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name doesn't start with a forward slash * character '/'. */ private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(0) != URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall start with a forward slash ('/') character [M1.4]: " + partUri.getPath()); } }
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); } } }
} catch (InvalidFormatException e1) { e1.printStackTrace();
/** * Throws an exception if the specified part name ends with a forward slash * character '/'. [M1.5] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name ends with a forwar slash character * '/'. */ private static void throwExceptionIfPartNameEndsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(uriPath.length() - 1) == URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have a forward slash as the last character [M1.5]: " + partUri.getPath()); } }
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); } } }
} catch (InvalidFormatException e) { e.printStackTrace();
/** * Create an OPC compliant part name by throwing an exception if the * specified name is not valid. * * @param partName * The part name to validate. * @return The correspondant part name if valid, else <code>null</code>. * @throws InvalidFormatException * Throws if the specified part name is not OPC compliant. * @see #createPartName(URI) */ public static PartName createPartName(String partName) throws InvalidFormatException { URI partNameURI; try { partNameURI = new URI(partName); } catch (URISyntaxException e) { throw new InvalidFormatException(e.getMessage()); } return createPartName(partNameURI); }
/** * 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); } }
out.addTargetPart(documentPart); } catch (InvalidFormatException e) { e.printStackTrace(); e.printStackTrace(); } catch (Exception e) {
throw new InvalidFormatException("The segment " + segment + " contain invalid encoded character !"); throw new InvalidFormatException( "A segment shall not contain percent-encoded forward slash ('/'), or backward slash ('\') characters. [M1.7]"); throw new InvalidFormatException( "A segment shall not contain percent-encoded unreserved characters. [M1.8]"); throw new InvalidFormatException( "A segment shall not hold any characters other than pchar characters. [M1.6]");
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; }
public CustomXmlDataStorage factory() { try { return new CustomXmlDataStorageImpl(); } catch (InvalidFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
if (segments.length <= 1 || !segments[0].equals("")) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have empty segments [M1.3]: " + partUri.getPath()); if (seg == null || "".equals(seg)) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have empty segments [M1.3]: " + partUri.getPath()); throw new InvalidFormatException( "A segment shall not end with a dot ('.') character [M1.9]: " + partUri.getPath()); throw new InvalidFormatException( "A segment shall include at least one non-dot character. [M1.10]: " + partUri.getPath());