Changeset 1087
- Timestamp:
- 02/26/10 14:41:23 (2 years ago)
- Location:
- trunk/docx4j/src/pptx4j/java/org/pptx4j
- Files:
-
- 3 edited
-
convert/out/svginhtml/SvgExporter.java (modified) (6 diffs)
-
convert/out/svginhtml/pptx2svginhtml.xslt (modified) (1 diff)
-
model/TextStyles.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/pptx4j/java/org/pptx4j/convert/out/svginhtml/SvgExporter.java
r1086 r1087 22 22 import org.docx4j.convert.out.html.HtmlExporterNG; 23 23 import org.docx4j.convert.out.html.AbstractHtmlExporter.HtmlSettings; 24 import org.docx4j.dml.CTTextCharacterProperties; 24 25 import org.docx4j.dml.CTTextListStyle; 25 26 import org.docx4j.dml.CTTextParagraphProperties; … … 36 37 import org.docx4j.wml.PPr; 37 38 import org.docx4j.wml.Pict; 39 import org.docx4j.wml.RPr; 40 //import org.docx4j.wml.RPr; 38 41 import org.docx4j.wml.Style; 39 42 import org.plutext.jaxb.svg11.Line; … … 131 134 String pStyleVal; 132 135 136 System.out.println("cNvPrName: " + cNvPrName + "; " + "phType: " + phType ); 137 133 138 if (cNvPrName.toLowerCase().indexOf("subtitle")>-1 134 139 || phType.toLowerCase().indexOf("subtitle")>-1) { … … 139 144 pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Title"; 140 145 } else { 141 pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Body"; 142 } 146 // eg cNvPrName: TextBox 2; phType: 147 pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Other"; 148 } 149 System.out.println("--> " + pStyleVal ); 143 150 144 151 try { … … 291 298 292 299 } 293 294 // public static CTTextListStyle unmarshalFormatting(NodeIterator lstStyleNodeIt ) { 300 301 public static DocumentFragment createBlockForR( 302 PresentationMLPackage pmlPackage, NodeIterator rPrNodeIt, 303 NodeIterator childResults) { 304 305 DocumentFragment docfrag = null; 306 Document d = null; 307 Element span = null; 308 309 try { 310 311 // Create a DOM builder and parse the fragment 312 DocumentBuilderFactory factory = DocumentBuilderFactory 313 .newInstance(); 314 d = factory.newDocumentBuilder().newDocument(); 315 316 span = d.createElement("span"); 317 d.appendChild(span); 318 319 CTTextCharacterProperties textCharProps = (CTTextCharacterProperties) nodeToObjectModel( 320 rPrNodeIt.nextNode(), CTTextCharacterProperties.class); 321 322 RPr rPr = TextStyles.getWmlRPr(textCharProps); 323 324 // Does our rPr contain anything else? 325 StringBuffer inlineStyle = new StringBuffer(); 326 HtmlExporterNG.createCss(pmlPackage, rPr, inlineStyle); 327 if (!inlineStyle.toString().equals("")) { 328 span.setAttribute("style", inlineStyle.toString()); 329 } 330 331 Node n = childResults.nextNode(); 332 XmlUtils.treeCopy((DTMNodeProxy) n, span); 333 334 } catch (Exception e) { 335 e.printStackTrace(); 336 log.error(e); 337 // If something went wrong with the formatting, 338 // still try to display the text! 339 Node n = childResults.nextNode(); 340 XmlUtils.treeCopy((DTMNodeProxy) n, span); 341 } 342 343 // Machinery 344 docfrag = d.createDocumentFragment(); 345 docfrag.appendChild(d.getDocumentElement()); 346 return docfrag; 347 348 } 349 350 // public static CTTextListStyle unmarshalFormatting(NodeIterator lstStyleNodeIt ) { 295 351 // 296 352 // // Get the pPr node as a JAXB object, … … 467 523 468 524 public static Object nodeToObjectModel(Node n, Class declaredType) throws Docx4JException { 525 526 if (n==null) { 527 throw new Docx4JException("null input"); 528 } 529 530 // if (log.isDebugEnabled() ) { 531 // System.out.println("IN: " + XmlUtils.w3CDomNodeToString(n)); 532 // } 533 469 534 Object jaxb=null; 470 535 try { -
trunk/docx4j/src/pptx4j/java/org/pptx4j/convert/out/svginhtml/pptx2svginhtml.xslt
r1085 r1087 155 155 156 156 <xsl:template match="a:r"> 157 <xsl:apply-templates select="a:t"/> 157 <xsl:variable name="rPr" select="a:rPr"/> 158 <xsl:variable name="childResults"><xsl:apply-templates select="a:t"/></xsl:variable> 159 <xsl:copy-of select="java:org.pptx4j.convert.out.svginhtml.SvgExporter.createBlockForR( 160 $wmlPackage, $rPr, 161 $childResults)" /> 158 162 </xsl:template> 159 163 -
trunk/docx4j/src/pptx4j/java/org/pptx4j/model/TextStyles.java
r1061 r1087 33 33 import org.docx4j.UnitsOfMeasurement; 34 34 import org.docx4j.XmlUtils; 35 import org.docx4j.dml.CTTextCharacterProperties; 35 36 import org.docx4j.dml.CTTextListStyle; 36 37 import org.docx4j.dml.CTTextParagraphProperties; … … 45 46 import org.docx4j.openpackaging.parts.PresentationML.MainPresentationPart; 46 47 import org.docx4j.openpackaging.parts.PresentationML.SlideMasterPart; 48 import org.docx4j.wml.BooleanDefaultTrue; 47 49 import org.docx4j.wml.HpsMeasure; 48 50 import org.docx4j.wml.Jc; … … 54 56 import org.docx4j.wml.Style; 55 57 import org.docx4j.wml.Styles; 58 import org.docx4j.wml.U; 59 import org.docx4j.wml.UnderlineEnumeration; 56 60 import org.docx4j.wml.Style.Name; 57 61 import org.pptx4j.pml.CTSlideMasterTextStyles; … … 209 213 // <w:sz w:val="28" /> 210 214 if (lvlPPr.getDefRPr().getSz()!=null) { 211 HpsMeasure sz = factory.createHpsMeasure(); 212 int halfPts = Math.round(lvlPPr.getDefRPr().getSz()/50); 213 sz.setVal( BigInteger.valueOf(halfPts) ); 214 rPr.setSz(sz); 215 rPr.setSz( convertFontSize(lvlPPr.getDefRPr().getSz()) ); 215 216 } 216 217 … … 233 234 return rPr; 234 235 } 236 237 private static HpsMeasure convertFontSize(Integer in) { 238 ObjectFactory factory = Context.getWmlObjectFactory(); 239 HpsMeasure sz = factory.createHpsMeasure(); 240 int halfPts = Math.round(in/50); 241 sz.setVal( BigInteger.valueOf(halfPts) ); 242 return sz; 243 } 244 235 245 // From Main Presentation Part 236 246 public static List<Style> generateWordStylesFromPresentationPart(CTTextListStyle textStyles, String suffix, … … 346 356 } 347 357 348 358 public static RPr getWmlRPr(CTTextCharacterProperties in) { 359 360 ObjectFactory factory = Context.getWmlObjectFactory(); 361 RPr rPr = factory.createRPr(); 362 363 if (in==null) { 364 System.out.println("Was passed null"); 365 return rPr; 366 } 367 368 // <a:rPr i="true" /> 369 if (in.isI()!=null && in.isI()) { 370 rPr.setI( new BooleanDefaultTrue() ); 371 } 372 373 // <a:rPr b="true" 374 if (in.isB()!=null && in.isB()) { 375 rPr.setB( new BooleanDefaultTrue() ); 376 } 377 378 // <a:rPr u="sng" 379 if (in.getU()!=null) { 380 U u = factory.createU(); 381 u.setVal(UnderlineEnumeration.SINGLE); 382 rPr.setU(u); 383 } 384 // <a:rPr sz="4000" 385 if (in.getSz()!=null) { 386 rPr.setSz( 387 convertFontSize(in.getSz() ) ); 388 } 389 390 return rPr; 391 392 } 349 393 }
Note: See TracChangeset
for help on using the changeset viewer.
