Changeset 1754 for trunk/docx4j/src/main/java/org/docx4j/model
- Timestamp:
- 01/24/12 01:35:16 (4 months ago)
- Location:
- trunk/docx4j/src/main/java/org/docx4j/model
- Files:
-
- 3 edited
-
ImmutablePropertyResolver.java (modified) (1 diff)
-
PropertyResolver.java (modified) (6 diffs)
-
properties/PropertyFactory.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/model/ImmutablePropertyResolver.java
r864 r1754 24 24 } 25 25 26 public ImmutablePropertyResolver(StyleDefinitionsPart styleDefinitionsPart,27 ThemePart themePart,28 NumberingDefinitionsPart numberingDefinitionsPart)29 throws Docx4JException {30 super(styleDefinitionsPart, themePart, numberingDefinitionsPart);31 }26 // public ImmutablePropertyResolver(StyleDefinitionsPart styleDefinitionsPart, 27 // ThemePart themePart, 28 // NumberingDefinitionsPart numberingDefinitionsPart) 29 // throws Docx4JException { 30 // super(styleDefinitionsPart, themePart, numberingDefinitionsPart); 31 // } 32 32 33 33 protected void applyPPr(PPr src, PPr dest) { -
trunk/docx4j/src/main/java/org/docx4j/model/PropertyResolver.java
r1665 r1754 17 17 import org.docx4j.model.properties.PropertyFactory; 18 18 import org.docx4j.model.properties.paragraph.AbstractParagraphProperty; 19 import org.docx4j.model.properties.paragraph.Indent; 19 20 import org.docx4j.model.properties.run.AbstractRunProperty; 20 21 import org.docx4j.openpackaging.exceptions.Docx4JException; … … 107 108 private StyleDefinitionsPart styleDefinitionsPart; 108 109 110 private WordprocessingMLPackage wordMLPackage; 109 111 110 112 /** … … 133 135 public PropertyResolver(WordprocessingMLPackage wordMLPackage) throws Docx4JException { 134 136 137 this.wordMLPackage = wordMLPackage; 138 135 139 MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); 136 140 … … 141 145 } 142 146 143 public PropertyResolver(StyleDefinitionsPart styleDefinitionsPart,144 ThemePart themePart,145 NumberingDefinitionsPart numberingDefinitionsPart) throws Docx4JException {146 147 this.styleDefinitionsPart= styleDefinitionsPart;148 this.themePart = themePart;149 this.numberingDefinitionsPart = numberingDefinitionsPart;150 init();151 }147 // public PropertyResolver(StyleDefinitionsPart styleDefinitionsPart, 148 // ThemePart themePart, 149 // NumberingDefinitionsPart numberingDefinitionsPart) throws Docx4JException { 150 // 151 // this.styleDefinitionsPart= styleDefinitionsPart; 152 // this.themePart = themePart; 153 // this.numberingDefinitionsPart = numberingDefinitionsPart; 154 // init(); 155 // } 152 156 153 157 String defaultParagraphStyleId; // "Normal" in English, but ... … … 918 922 protected void applyPPr(PPr pPrToApply, PPr effectivePPr) { 919 923 924 log.debug( "apply " + XmlUtils.marshaltoString(pPrToApply, true, true) 925 + "\n\r to " + XmlUtils.marshaltoString(effectivePPr, true, true) ); 926 920 927 if (pPrToApply==null) { 921 928 return; 922 929 } 923 930 924 List<Property> properties = PropertyFactory.createProperties(null, pPrToApply); // wmlPackage null 925 931 List<Property> properties = PropertyFactory.createProperties(wordMLPackage, pPrToApply); 926 932 for( Property p : properties ) { 927 933 if (p!=null) { … … 931 937 } 932 938 933 939 log.debug( "result " + XmlUtils.marshaltoString(effectivePPr, true, true) ); 940 934 941 } 935 942 -
trunk/docx4j/src/main/java/org/docx4j/model/properties/PropertyFactory.java
r1700 r1754 25 25 26 26 import org.apache.log4j.Logger; 27 import org.docx4j.XmlUtils; 27 28 import org.docx4j.model.properties.paragraph.Indent; 28 29 import org.docx4j.model.properties.paragraph.Justification; … … 396 397 // if (pPr.getMirrorIndents() != null) 397 398 // dest.setMirrorIndents(pPr.getMirrorIndents()); 398 Ind ind = null; 399 if (pPr.getNumPr() != null) { 399 400 /* 401 * Where a p has indentation specified by both w:numPr and direct w:ind, eg: 402 * 403 <w:p> 404 <w:pPr> 405 <w:numPr> 406 <w:ilvl w:val="0"/> 407 <w:numId w:val="2"/> 408 </w:numPr> 409 <w:ind w:left="0" w:firstLine="0"/> 410 </w:pPr> 411 412 we want to ensure that the direct values are given effect. 413 414 ie indent on direct pPr trumps indent in pPr in numbering, which trumps indent 415 specified in a style. 416 417 */ 418 Indent indent = null; 419 boolean numberingIndent = false; 420 if (pPr.getNumPr() == null) { 421 log.debug("No numPr.. ") ; 422 } else { 400 423 // Numbering is mostly handled directly in the HTML & PDF stylesheets 401 424 properties.add(new NumberingProperty(pPr.getNumPr())); 402 // but we do want to override w:ind above 403 if (pPr.getNumPr()!=null) { 404 if (wmlPackage instanceof WordprocessingMLPackage) { 405 NumberingDefinitionsPart ndp = ((WordprocessingMLPackage)wmlPackage).getMainDocumentPart().getNumberingDefinitionsPart(); 406 if (ndp != null) { 407 ind = ndp.getInd(pPr.getNumPr()); 408 if (ind!=null) { 409 properties.add(new Indent(ind)); 425 // but we do want to get w:ind (in case not set elsewhere) 426 if (wmlPackage instanceof WordprocessingMLPackage) { 427 NumberingDefinitionsPart ndp 428 = ((WordprocessingMLPackage)wmlPackage).getMainDocumentPart().getNumberingDefinitionsPart(); 429 if (ndp == null) { 430 log.debug("No NDP?.. ") ; 431 } else { 432 Ind ind = ndp.getInd(pPr.getNumPr()); 433 if (ind==null) { 434 log.debug("No Indent in numbering.. ") ; 435 } else { 436 log.debug("Indent from numbering: " + XmlUtils.marshaltoString(ind, true, true)) ; 437 indent = new Indent(ind); 438 properties.add(indent); 410 439 log.debug("Using w:ind from list level"); 440 numberingIndent = true; 411 441 } 412 } 442 } 443 } else { 444 log.info(wmlPackage + " " + wmlPackage.getClass().getName() ) ; 445 } 446 } 447 448 // Give effect to the prioritisation 449 if (pPr.getInd() != null) { 450 log.debug("Indent from ppr: " + XmlUtils.marshaltoString(pPr.getInd(), true, true)) ; 451 if (indent!=null) { 452 properties.remove(indent); 413 453 } 454 properties.add(new Indent(pPr.getInd())); 414 455 } 415 } 416 if (ind==null) { 417 if (pPr.getInd() != null) 418 properties.add(new Indent(pPr.getInd())); 419 } 456 420 457 // if (pPr.getOutlineLvl() != null) 421 458 // dest.setOutlineLvl(pPr.getOutlineLvl());
Note: See TracChangeset
for help on using the changeset viewer.
