- Timestamp:
- 07/08/10 03:00:13 (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/convert/out/pdf/viaXSLFO/Conversion.java
r1127 r1135 33 33 import org.docx4j.fonts.PhysicalFonts; 34 34 import org.docx4j.jaxb.Context; 35 import org.docx4j.jaxb.NamespacePrefixMapperUtils; 35 36 import org.docx4j.model.PropertyResolver; 36 37 import org.docx4j.model.TransformState; … … 41 42 import org.docx4j.model.properties.paragraph.Indent; 42 43 import org.docx4j.model.properties.run.Font; 44 import org.docx4j.model.structure.SectionWrapper; 45 import org.docx4j.model.structure.jaxb.ObjectFactory; 46 import org.docx4j.model.structure.jaxb.Sections; 47 import org.docx4j.model.structure.jaxb.Sections.Section; 43 48 import org.docx4j.model.table.TableModel.TableModelTransformState; 44 49 import org.docx4j.openpackaging.exceptions.Docx4JException; 45 50 import org.docx4j.openpackaging.packages.WordprocessingMLPackage; 51 import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 46 52 import org.docx4j.wml.Ftr; 47 53 import org.docx4j.wml.Hdr; … … 49 55 import org.docx4j.wml.RFonts; 50 56 import org.docx4j.wml.RPr; 57 import org.docx4j.wml.SectPr; 51 58 import org.docx4j.wml.Tbl; 52 59 import org.docx4j.wml.Tc; … … 261 268 */ 262 269 //Document domDoc = XmlPackage.getFlatDomDocument(wordMLPackage); 263 Document domDoc = XmlUtils.marshaltoW3CDomDocument(wordMLPackage.getMainDocumentPart().getJaxbElement()); 270 //Document domDoc = XmlUtils.marshaltoW3CDomDocument(wordMLPackage.getMainDocumentPart().getJaxbElement()); 271 272 Sections sections = createSectionContainers(wordMLPackage); 273 Document domDoc = XmlUtils.marshaltoW3CDomDocument(sections, Context.jcSectionModel); 264 274 265 275 java.util.HashMap<String, Object> settings = new java.util.HashMap<String, Object>(); … … 330 340 331 341 } 342 343 private Sections createSectionContainers(WordprocessingMLPackage wordMLPackage) { 344 345 ObjectFactory factory = new ObjectFactory(); 346 347 Sections sections = factory.createSections(); 348 Section section = factory.createSectionsSection(); 349 section.setName("s1"); // name must match fo master 350 351 sections.getSection().add(section); 352 353 org.docx4j.wml.Document doc = (org.docx4j.wml.Document)wordMLPackage.getMainDocumentPart().getJaxbElement(); 354 355 int i = 2; 356 for (Object o : doc.getBody().getEGBlockLevelElts() ) { 357 358 if (o instanceof org.docx4j.wml.P) { 359 if (((org.docx4j.wml.P)o).getPPr() != null ) { 360 org.docx4j.wml.PPr ppr = ((org.docx4j.wml.P)o).getPPr(); 361 if (ppr.getSectPr()!=null) { 362 section = factory.createSectionsSection(); 363 section.setName("s" +i); // name must match fo master 364 sections.getSection().add(section); 365 i++; 366 } 367 } 368 } 369 section.getAny().add( marshall(o) ); 370 // TODO: since the section model knows nothing about WML, 371 // we have to marshall each object separately. 372 // To fix this, next time wml is generated, include the section model there! 373 } 374 return sections; 375 } 376 377 private Element marshall(Object o) { 378 379 try { 380 org.w3c.dom.Document w3cDoc = 381 XmlUtils.marshaltoW3CDomDocument(o); 382 383 384 /* Force the RelationshipsPart to be marshalled using 385 * the normal non-rels part NamespacePrefixMapper, 386 * since otherwise (because we'd be using 2 namespace 387 * prefix mappers?) we end up with errant xmlns="", 388 * which is wrong and stops Word 2007 from loading the 389 * document. 390 * 391 * Note that xmlPackage.xsd defines: 392 * <xsd:complexType name="CT_XmlData"> 393 <xsd:sequence> 394 <xsd:any processContents="skip" /> 395 </xsd:sequence> 396 * 397 * Note also that marshaltoString uses 398 * just the normal non-rels part NamespacePrefixMapper, 399 * so if/when this is marshalled again, that could 400 * have been causing problems as well?? 401 */ 402 return w3cDoc.getDocumentElement(); 403 } catch (Exception e) { 404 // TODO Auto-generated catch block 405 e.printStackTrace(); 406 } 407 return null; 408 409 } 410 411 332 412 333 413 /* ---------------Xalan XSLT Extension Functions ---------------- */
Note: See TracChangeset
for help on using the changeset viewer.
