Changeset 1514 for trunk/docx4j/src/main/java/org/docx4j/openpackaging
- Timestamp:
- 05/29/11 11:33:42 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/DrawingML/DiagramDataPart.java
r1511 r1514 24 24 import java.util.HashMap; 25 25 import java.util.List; 26 import java.util.UUID; 26 27 27 28 import org.apache.log4j.Logger; … … 76 77 */ 77 78 protected static void setFriendlyIds(Object jaxbElement) { 78 79 79 80 map = new HashMap<String, String>(); 80 81 … … 109 110 String from = pt.getModelId(); 110 111 111 // Everything goes invisible in Word 2007 if you map these, 112 // Everything goes invisible in Word 2007 if you map these 113 // to an int (rather than a guid), 112 114 // and images disappear (not shown as broken) 113 115 if (pt.getType()!=null … … 118 120 } 119 121 122 // String to = generateNiceGuid(index); 120 123 String to = "" + index; 121 124 index++; … … 127 130 CTCxn cxn = (CTCxn)o; 128 131 String from = cxn.getModelId(); 132 // String to = generateNiceGuid(index); 129 133 String to = "" + index; 130 134 index++; … … 179 183 private static String generateNiceGuid(int index) { 180 184 185 /* It seems that if there are more than about 100 186 * items, Word won't open a docx with friendly ids 187 * of the following form: 188 * 189 if (index<10) { 190 return "{00000000-0000-0000-0000-00000000000" + index + "}"; 191 } else if (index<100) { 192 return "{00000000-0000-0000-0000-0000000000" + index + "}"; 193 } else { 194 return "{00000000-0000-0000-0000-000000000" + index + "}"; 195 } 196 197 * Speculate that this is because M$ internally 198 * uses some broken equality test. 199 * 200 * The following works better ... 201 */ 202 203 181 204 if (index<10) { 182 return "{0000000 0-0000-0000-0000-00000000000" + index + "}";205 return "{0000000" + index + "-0000-0000-0000-000000000000}"; 183 206 } else if (index<100) { 184 return "{000000 00-0000-0000-0000-0000000000" + index + "}";207 return "{000000" + index + "-0000-0000-0000-000000000000}"; 185 208 } else { 186 return "{00000 000-0000-0000-0000-000000000" + index + "}";209 return "{00000" + index + "-0000-0000-0000-000000000000}"; 187 210 } 211 212 // This works as well... 213 // return "{" + UUID.randomUUID().toString().toUpperCase() + "}"; 214 188 215 189 216 } … … 213 240 @Override 214 241 public List<Object> apply(Object o) { 215 242 216 243 if (o instanceof CTPt) { 217 244 … … 219 246 220 247 pt.setModelId( 221 map .get(pt.getModelId() ));248 mapGet(map, pt.getModelId() )); 222 249 223 250 if (pt.getPrSet()!=null) { … … 225 252 if (pr.getPresAssocID()!=null) { 226 253 pr.setPresAssocID( 227 map .get(pr.getPresAssocID() ));254 mapGet(map, pr.getPresAssocID() )); 228 255 } 229 256 } … … 231 258 if (!pt.getCxnId().equals("0")) { 232 259 pt.setCxnId( 233 map .get(pt.getCxnId() ));260 mapGet(map, pt.getCxnId() )); 234 261 } 235 262 } … … 239 266 CTCxn cxn = (CTCxn)o; 240 267 if (cxn.getModelId()!=null) { 241 cxn.setModelId(map .get(cxn.getModelId()));242 } 243 244 cxn.setSrcId(map .get(cxn.getSrcId()));268 cxn.setModelId(mapGet(map,cxn.getModelId())); 269 } 270 271 cxn.setSrcId(mapGet(map, cxn.getSrcId())); 245 272 cxn.setDestId( mapGet(map,cxn.getDestId() )); 246 273 247 274 if (!cxn.getSibTransId().equals("0")) { 248 275 cxn.setSibTransId( 249 map .get(cxn.getSibTransId() ));276 mapGet(map, cxn.getSibTransId() )); 250 277 } 251 278 if (!cxn.getParTransId().equals("0")) { 252 279 cxn.setParTransId( 253 map .get(cxn.getParTransId() ));280 mapGet(map, cxn.getParTransId() )); 254 281 } 255 282 // if (cxn.getPresId()!=null) { … … 309 336 .load(new java.io.File( 310 337 System.getProperty("user.dir") 311 + "/SmartArt/ root-only.docx"));338 + "/SmartArt/complex-nopic.docx")); 312 339 313 340 Relationship r = wordMLPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByType(Namespaces.DRAWINGML_DIAGRAM_DATA); … … 337 364 SaveToZipFile saver = new SaveToZipFile(wordMLPackage); 338 365 saver.save(System.getProperty("user.dir") 339 + "/SmartArt/ root-only-OUT.docx");366 + "/SmartArt/complex-nopic-OUT.docx"); 340 367 341 368 }
Note: See TracChangeset
for help on using the changeset viewer.
