Changeset 1754 for trunk/docx4j/src/main/java
- Timestamp:
- 01/24/12 01:35:16 (4 months ago)
- Location:
- trunk/docx4j/src/main/java/org/docx4j
- Files:
-
- 5 edited
-
convert/out/html/AbstractHtmlExporter.java (modified) (3 diffs)
-
model/ImmutablePropertyResolver.java (modified) (1 diff)
-
model/PropertyResolver.java (modified) (6 diffs)
-
model/properties/PropertyFactory.java (modified) (2 diffs)
-
openpackaging/parts/WordprocessingML/NumberingDefinitionsPart.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/convert/out/html/AbstractHtmlExporter.java
r1637 r1754 12 12 import org.apache.log4j.Logger; 13 13 import org.docx4j.UnitsOfMeasurement; 14 import org.docx4j.XmlUtils; 14 15 import org.docx4j.convert.out.AbstractConversionSettings; 15 16 import org.docx4j.convert.out.Output; … … 157 158 */ 158 159 public static DocumentFragment getNumberXmlNode(WordprocessingMLPackage wmlPackage, 160 NodeIterator pPrNodeIt, 159 161 String pStyleVal, String numId, String levelId) { 160 162 … … 199 201 // } 200 202 201 NumberingDefinitionsPart ndp = wmlPackage.getMainDocumentPart().getNumberingDefinitionsPart(); 202 Ind ind = ndp.getInd(numId, levelId); 203 if (ind!=null && ind.getHanging()!=null) { 204 String hanging = UnitsOfMeasurement.twipToBest(ind.getHanging().intValue()); 205 styleVal="position: absolute; left:-" + hanging + "; max-width: " + hanging +";"; 203 PPr pPr = null; 204 if (pPrNodeIt!=null) { 205 Node n = pPrNodeIt.nextNode(); 206 if (n!=null) { 207 log.debug( XmlUtils.w3CDomNodeToString(n) ); 208 Unmarshaller u = Context.jc.createUnmarshaller(); 209 u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); 210 pPr = (PPr)u.unmarshal(n); 211 } 212 } 213 if (pPr.getInd()==null) { 214 215 NumberingDefinitionsPart ndp = wmlPackage.getMainDocumentPart().getNumberingDefinitionsPart(); 216 Ind ind = ndp.getInd(numId, levelId); 217 if (ind!=null && ind.getHanging()!=null) { 218 String hanging = UnitsOfMeasurement.twipToBest(ind.getHanging().intValue()); 219 styleVal="position: absolute; left:-" + hanging + "; max-width: " + hanging +";"; 220 } 221 // TODO: position bullets correctly where there is no hanging 222 // TODO: The suff element tells us what separates the number from 223 // the text (tab, space or nothing). If its a tab, 224 // we'll need to know the tab values here. Currently, we're 225 // assuming hanging overrides all that. 226 } else { 227 228 Ind ind = pPr.getInd(); 229 if (ind!=null && ind.getHanging()!=null) { 230 String hanging = UnitsOfMeasurement.twipToBest(ind.getHanging().intValue()); 231 styleVal="position: absolute; left:-" + hanging + "; max-width: " + hanging +";"; 232 } 233 206 234 } 207 // TODO: position bullets correctly where there is no hanging208 // TODO: The suff element tells us what separates the number from209 // the text (tab, space or nothing). If its a tab,210 // we'll need to know the tab values here. Currently, we're211 // assuming hanging overrides all that.212 235 213 236 // Set the font -
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()); -
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/NumberingDefinitionsPart.java
r1726 r1754 142 142 143 143 // instantiate the list number definitions 144 //foreach (XmlNode numNode in numberNodes)145 144 for( Numbering.Num numNode : numbering.getNum() ) 146 145 { … … 235 234 // Operating on the docx4j.listnumbering plane, 236 235 // not the JAXB plane.. 237 ListNumberingDefinition lnd = instanceListDefinitions.get(numId );236 ListNumberingDefinition lnd = getInstanceListDefinitions().get(numId ); 238 237 if (lnd==null) { 239 238 log.debug("couldn't find list for numId: " + numId);
Note: See TracChangeset
for help on using the changeset viewer.
