Changeset 1095 for trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/MainDocumentPart.java
- Timestamp:
- 02/27/10 06:45:58 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/MainDocumentPart.java
r1027 r1095 55 55 import org.docx4j.wml.Style; 56 56 import org.docx4j.wml.Styles; 57 import org.docx4j.wml.Tc; 57 58 58 59 … … 112 113 //log.debug("style in use: " + styleId ); 113 114 } 114 115 // if (!stylesInUse.contains("Normal") ) { 116 // stylesInUse.add("Normal"); 117 // } 118 // if (!stylesInUse.contains("DefaultParagraphFont") ) { 119 // stylesInUse.add("DefaultParagraphFont"); 120 // } 121 115 122 116 try { 123 117 getStyleDefinitionsPart().createVirtualStylesForDocDefaults(); … … 127 121 } 128 122 123 // Get these first, so we can be sure they are defined... 124 Style defaultParagraphStyle = getStyleDefinitionsPart().getDefaultParagraphStyle(); 125 Style defaultCharacterStyle = getStyleDefinitionsPart().getDefaultCharacterStyle(); 126 129 127 // Styles defined in StyleDefinitionsPart 130 128 Map<String, Style> allStyles = new HashMap<String, Style>(); … … 134 132 //log.debug("live style: " + s.getStyleId() ); 135 133 } 136 styleTree = new StyleTree(stylesInUse, allStyles); 134 styleTree = new StyleTree(stylesInUse, allStyles, 135 defaultParagraphStyle.getStyleId(), 136 defaultCharacterStyle.getStyleId()); 137 137 138 138 } … … 420 420 fontsDiscovered.put(sym.getFont(), sym.getFont()); 421 421 422 } else if ( ((JAXBElement)o).getDeclaredType().getName().equals( 423 "org.docx4j.wml.CTBookmark") ) { 424 // Ignore 422 425 } else if ( log.isDebugEnabled() ){ 423 426 log.debug( XmlUtils.JAXBElementDebug((JAXBElement)o) ); … … 450 453 // } 451 454 455 } else if (o instanceof org.docx4j.wml.ProofErr) { 456 // Ignore eg <w:proofErr w:type="spellStart" /> 452 457 } else { 453 458 log.error( "UNEXPECTED: " + o.getClass().getName() ); 459 log.debug( XmlUtils.marshaltoString(o, true)); 454 460 } 455 461 } … … 476 482 for (Object o : tbl.getEGContentRowContent() ) { 477 483 484 org.docx4j.wml.Tr tr = null; 478 485 if (o instanceof org.docx4j.wml.Tr) { 479 log.debug( "\n in w:tr .. "); 480 org.docx4j.wml.Tr tr = (org.docx4j.wml.Tr)o; 481 for (Object o2 : tr.getEGContentCellContent() ) { 482 if ( o2 instanceof javax.xml.bind.JAXBElement) { 483 // Usual content for w:tr is w:tc 484 if ( ((JAXBElement)o2).getDeclaredType().getName().equals("org.docx4j.wml.Tc") ) { 485 log.debug( "\n in w:tc .. "); 486 org.docx4j.wml.Tc tc = (org.docx4j.wml.Tc)((JAXBElement)o2).getValue(); 487 488 // Look at the paragraphs in the tc 489 traverseMainDocumentRecursive( tc.getEGBlockLevelElts(), 490 fontsDiscovered, stylesInUse); 491 492 } else { 493 // Could be custom markup (custom XML or sdt) 494 log.warn("TODO - not w:tc - handle: " + XmlUtils.JAXBElementDebug((JAXBElement)o2) ); 495 } 496 } else if (o2 instanceof org.docx4j.wml.Tc) { 497 // Again, it could be this or wrapped in a JAXBElement! 498 traverseMainDocumentRecursive( ((org.docx4j.wml.Tc)o2).getEGBlockLevelElts(), 499 fontsDiscovered, stylesInUse); 500 501 } else { 502 // Could be custom markup (custom XML or sdt) 503 log.warn("TODO - not w:tc - handle: " + o2.getClass().getName() ); 504 } 505 } 486 tr = (org.docx4j.wml.Tr)o; 487 } else if (o instanceof javax.xml.bind.JAXBElement 488 && ((JAXBElement)o).getDeclaredType().getName().equals("org.docx4j.wml.Tr")) { 489 tr = (org.docx4j.wml.Tr)((JAXBElement)o).getValue(); 506 490 } else { 507 491 // What? 508 log.warn("TODO - handle: " + o.getClass().getName() ); 492 if (o instanceof javax.xml.bind.JAXBElement) { 493 if ( ((JAXBElement)o).getDeclaredType().getName().equals( 494 "org.docx4j.wml.CTMarkupRange") ) { 495 // Ignore w:bookmarkEnd 496 } else { 497 log.warn("TODO - skipping JAXBElement: " + ((JAXBElement)o).getDeclaredType().getName() ); 498 log.debug( XmlUtils.marshaltoString(o, true)); 499 } 500 } else { 501 log.warn("TODO - skipping: " + o.getClass().getName() ); 502 log.debug( XmlUtils.marshaltoString(o, true)); 503 } 504 continue; 505 } 506 507 for (Object o2 : tr.getEGContentCellContent() ) { 508 509 Tc tc = null; 510 if (o2 instanceof org.docx4j.wml.Tc) { 511 tc = (org.docx4j.wml.Tc)o2; 512 } else if (o2 instanceof javax.xml.bind.JAXBElement 513 && ((JAXBElement)o2).getDeclaredType().getName().equals("org.docx4j.wml.Tc")) { 514 tc = (org.docx4j.wml.Tc)((JAXBElement)o2).getValue(); 515 } else { 516 // What? 517 if (o2 instanceof javax.xml.bind.JAXBElement) { 518 log.warn("TODO - skipping JAXBElement: " + ((JAXBElement)o2).getDeclaredType().getName() ); 519 } else { 520 log.warn("TODO - skipping: " + o2.getClass().getName() ); 521 } 522 log.debug( XmlUtils.marshaltoString(o2, true)); 523 continue; 524 } 525 526 traverseMainDocumentRecursive( tc.getEGBlockLevelElts(), 527 fontsDiscovered, stylesInUse); 509 528 } 510 529
Note: See TracChangeset
for help on using the changeset viewer.
