Commit changes to the underlying OPC package
()
| 121 | * Commit changes to the underlying OPC package |
| 122 | */ |
| 123 | public void commit() throws IOException{ |
| 124 | |
| 125 | if(extPart == null && !NEW_EXT_INSTANCE.toString().equals(ext.props.toString())){ |
| 126 | try { |
| 127 | PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/app.xml"); |
| 128 | pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"); |
| 129 | extPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.extended-properties+xml"); |
| 130 | } catch (InvalidFormatException e){ |
| 131 | throw new POIXMLException(e); |
| 132 | } |
| 133 | } |
| 134 | if(custPart == null && !NEW_CUST_INSTANCE.toString().equals(cust.props.toString())){ |
| 135 | try { |
| 136 | PackagePartName prtname = PackagingURIHelper.createPartName("/docProps/custom.xml"); |
| 137 | pkg.addRelationship(prtname, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"); |
| 138 | custPart = pkg.createPart(prtname, "application/vnd.openxmlformats-officedocument.custom-properties+xml"); |
| 139 | } catch (InvalidFormatException e){ |
| 140 | throw new POIXMLException(e); |
| 141 | } |
| 142 | } |
| 143 | if(extPart != null){ |
| 144 | XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS); |
| 145 | |
| 146 | Map<String, String> map = new HashMap<String, String>(); |
| 147 | map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt"); |
| 148 | xmlOptions.setSaveSuggestedPrefixes(map); |
| 149 | |
| 150 | OutputStream out = extPart.getOutputStream(); |
| 151 | ext.props.save(out, xmlOptions); |
| 152 | out.close(); |
| 153 | } |
| 154 | if(custPart != null){ |
| 155 | XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS); |
| 156 | |
| 157 | Map<String, String> map = new HashMap<String, String>(); |
| 158 | map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt"); |
| 159 | xmlOptions.setSaveSuggestedPrefixes(map); |
| 160 | |
| 161 | OutputStream out = custPart.getOutputStream(); |
| 162 | cust.props.save(out, xmlOptions); |
| 163 | out.close(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * The core document properties |
nothing calls this directly
no test coverage detected