- Timestamp:
- 09/02/11 07:16:44 (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/Base.java
r1648 r1649 27 27 import org.docx4j.openpackaging.contenttype.ContentType; 28 28 import org.docx4j.openpackaging.contenttype.ObjectFactory; 29 import org.docx4j.openpackaging.exceptions.Docx4JException; 29 30 import org.docx4j.openpackaging.exceptions.InvalidFormatException; 30 31 import org.docx4j.openpackaging.packages.OpcPackage; … … 32 33 import org.docx4j.openpackaging.parts.PartName; 33 34 import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 35 import org.docx4j.openpackaging.parts.relationships.RelationshipsPart.AddPartBehaviour; 34 36 import org.docx4j.relationships.Relationship; 35 37 … … 171 173 // } 172 174 175 /** 176 * Convenience method to add a part to this Part's 177 * relationships. The package must be set on this 178 * part in order for this to work. 179 * 180 * @since 2.7.1 181 * 182 * @param targetpart The part to add to this part's relationships 183 * @param mode whether to overwrite, rename or abort if the part name already exists 184 * @param proposedRelId 185 * @return 186 * @throws InvalidFormatException 187 */ 188 public Relationship addTargetPart(Part targetpart, AddPartBehaviour mode 189 ) throws InvalidFormatException { 190 return addTargetPart(targetpart, mode, null); 191 } 173 192 174 193 /** … … 187 206 */ 188 207 public Relationship addTargetPart(Part targetpart) throws InvalidFormatException { 189 return this.addTargetPart(targetpart, null);190 } 191 208 return this.addTargetPart(targetpart, AddPartBehaviour.OVERWRITE_IF_NAME_EXISTS, null); 209 } 210 192 211 /** 193 212 * Convenience method to add a part to this Part's … … 207 226 ) throws InvalidFormatException { 208 227 228 return addTargetPart( targetpart, AddPartBehaviour.OVERWRITE_IF_NAME_EXISTS, proposedRelId); 229 } 230 231 232 /** 233 * Convenience method to add a part to this Part's 234 * relationships. The package must be set on this 235 * part in order for this to work. 236 * 237 * The added part will replace any existing part 238 * with the same name (ie same target in the rels 239 * part). In other words, if you want to use the 240 * one image as the target of 2 rels, don't use 241 * this method. 242 * 243 * @since 2.7.1 244 * 245 * @param targetpart The part to add to this part's relationships 246 * @param mode whether to overwrite, rename or abort if the part name already exists 247 * @param proposedRelId 248 * @return 249 * @throws InvalidFormatException 250 */ 251 public Relationship addTargetPart(Part targetpart, AddPartBehaviour mode, String proposedRelId 252 ) throws InvalidFormatException { 253 209 254 if ( this.getPackage()==null ) { 210 255 throw new InvalidFormatException("Package not set; if you are adding part2 to part1, make sure part1 is added first."); … … 215 260 216 261 // Now add the targetpart to the relationships 217 Relationship rel = this.getRelationshipsPart().addPart(targetpart, true,262 Relationship rel = this.getRelationshipsPart().addPart(targetpart, mode, 218 263 getPackage().getContentTypeManager(), proposedRelId); 219 264 … … 227 272 228 273 } 229 230 231 274 232 275 }
Note: See TracChangeset
for help on using the changeset viewer.
