summaryrefslogtreecommitdiffstats
path: root/scilab/modules/helptools
diff options
context:
space:
mode:
authorCalixte DENIZET <calixte.denizet@ac-rennes.fr>2010-02-20 20:57:01 +0100
committerCalixte DENIZET <calixte.denizet@ac-rennes.fr>2010-02-20 20:57:01 +0100
commitc6ce5230290b5edaeca9aaa95bd866510df3b3c6 (patch)
treefb9644e224260b1dc9515f11ed0482b866bae023 /scilab/modules/helptools
parent4355c3dea9821bec52e7a5aba674db9309b5bf67 (diff)
downloadscilab-c6ce5230290b5edaeca9aaa95bd866510df3b3c6.zip
scilab-c6ce5230290b5edaeca9aaa95bd866510df3b3c6.tar.gz
Fix bug 6630 and improve LaTeX in documentation
Diffstat (limited to 'scilab/modules/helptools')
-rw-r--r--scilab/modules/helptools/schema/extendedStyle.xsl34
-rw-r--r--scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java14
-rw-r--r--scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java27
3 files changed, 52 insertions, 23 deletions
diff --git a/scilab/modules/helptools/schema/extendedStyle.xsl b/scilab/modules/helptools/schema/extendedStyle.xsl
index 1653097..a544af4 100644
--- a/scilab/modules/helptools/schema/extendedStyle.xsl
+++ b/scilab/modules/helptools/schema/extendedStyle.xsl
@@ -7,12 +7,34 @@
7<xsl:include href="STYLE_DOC"/> 7<xsl:include href="STYLE_DOC"/>
8 8
9<xsl:template match="latex:*"> 9<xsl:template match="latex:*">
10 <fo:instream-foreign-object> 10 <xsl:choose>
11 <xsl:copy> 11 <xsl:when test="@align != ''">
12 <xsl:copy-of select="@*"/> 12 <fo:block>
13 <xsl:apply-templates/> 13 <xsl:attribute name="text-align">
14 </xsl:copy> 14 <xsl:value-of select="@align"/>
15 </fo:instream-foreign-object> 15 </xsl:attribute>
16 <fo:instream-foreign-object>
17 <xsl:copy>
18 <xsl:copy-of select="@*"/>
19 <xsl:if test="@align = 'center'">
20 <xsl:attribute name="fwidth">
21 <xsl:value-of select="concat($page.width,',-',$body.start.indent,',-',$page.margin.inner,',-',$page.margin.outer)"/>
22 </xsl:attribute>
23 </xsl:if>
24 <xsl:apply-templates/>
25 </xsl:copy>
26 </fo:instream-foreign-object>
27 </fo:block>
28 </xsl:when>
29 <xsl:otherwise>
30 <fo:instream-foreign-object>
31 <xsl:copy>
32 <xsl:copy-of select="@*"/>
33 <xsl:apply-templates/>
34 </xsl:copy>
35 </fo:instream-foreign-object>
36 </xsl:otherwise>
37 </xsl:choose>
16</xsl:template> 38</xsl:template>
17 39
18</xsl:stylesheet> 40</xsl:stylesheet>
diff --git a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
index a640d5b..130b0f5 100644
--- a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
+++ b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
@@ -313,7 +313,12 @@ public class BuildDocObject extends StyleSheet {
313 throw new FileNotFoundException(COULD_NOT_FIND_STYLE_DOC + this.styleDoc); 313 throw new FileNotFoundException(COULD_NOT_FIND_STYLE_DOC + this.styleDoc);
314 } 314 }
315 315
316 File processedStyle = generateExtendedStyle(); 316 String path = styleDoc;
317 File processedStyle = null;
318 if (!isLatexConverted) {
319 processedStyle = generateExtendedStyle();
320 path = processedStyle.getAbsolutePath();
321 }
317 322
318 if (!new File(this.outputDirectory).isDirectory()) { 323 if (!new File(this.outputDirectory).isDirectory()) {
319 throw new FileNotFoundException("Could not find directory: " + this.outputDirectory); 324 throw new FileNotFoundException("Could not find directory: " + this.outputDirectory);
@@ -332,7 +337,7 @@ public class BuildDocObject extends StyleSheet {
332 } 337 }
333 //args.add("-t"); 338 //args.add("-t");
334 args.add(sourceDocProcessed); 339 args.add(sourceDocProcessed);
335 args.add(processedStyle.getAbsolutePath()); 340 args.add(path);
336 args.add("base.dir=" + this.outputDirectory); 341 args.add("base.dir=" + this.outputDirectory);
337 args.add("html.stylesheet=" + new File(styleSheet).getName()); 342 args.add("html.stylesheet=" + new File(styleSheet).getName());
338 args.addAll(specificArgs); 343 args.addAll(specificArgs);
@@ -347,7 +352,10 @@ public class BuildDocObject extends StyleSheet {
347 /* Delete the master temp file to avoid to be shipped with the rest */ 352 /* Delete the master temp file to avoid to be shipped with the rest */
348 new File(sourceDocProcessed).delete(); 353 new File(sourceDocProcessed).delete();
349 } 354 }
350 processedStyle.delete(); 355
356 if (processedStyle != null) {
357 processedStyle.delete();
358 }
351 359
352 return this.postProcess(); 360 return this.postProcess();
353 361
diff --git a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
index f787f03..15b6256 100644
--- a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
+++ b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
@@ -427,7 +427,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
427 } 427 }
428 File convertedFile = new File(outDir, baseName); 428 File convertedFile = new File(outDir, baseName);
429 429
430 if (!convertedFile.exists()) { 430 if (!convertedFile.exists() || convertedFile.lastModified() < graphicsFile.lastModified()) {
431 reportInfo("Converting TeX '" + graphicsFile + "' to '" 431 reportInfo("Converting TeX '" + graphicsFile + "' to '"
432 + convertedFile + "'..."); 432 + convertedFile + "'...");
433 433
@@ -439,7 +439,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
439 baseName = rootName + "_mml.png"; 439 baseName = rootName + "_mml.png";
440 File convertedFile = new File(outDir, baseName); 440 File convertedFile = new File(outDir, baseName);
441 441
442 if (!convertedFile.exists()) { 442 if (!convertedFile.exists() || convertedFile.lastModified() < graphicsFile.lastModified()) {
443 reportInfo("Converting MathML '" + graphicsFile + "' to '" 443 reportInfo("Converting MathML '" + graphicsFile + "' to '"
444 + convertedFile + "'..."); 444 + convertedFile + "'...");
445 445
@@ -451,7 +451,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
451 baseName = rootName + "_svg.png"; 451 baseName = rootName + "_svg.png";
452 File convertedFile = new File(outDir, baseName); 452 File convertedFile = new File(outDir, baseName);
453 453
454 if (!convertedFile.exists()) { 454 if (!convertedFile.exists() || convertedFile.lastModified() < graphicsFile.lastModified()) {
455 reportInfo("Converting SVG '" + graphicsFile + "' to '" 455 reportInfo("Converting SVG '" + graphicsFile + "' to '"
456 + convertedFile + "'..."); 456 + convertedFile + "'...");
457 457
@@ -463,7 +463,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
463 // Just copy the file --- 463 // Just copy the file ---
464 464
465 File outFile = new File(outDir, baseName); 465 File outFile = new File(outDir, baseName);
466 if (!outFile.exists()) { 466 if (!outFile.exists() || outFile.lastModified() < graphicsFile.lastModified()) {
467 reportInfo("Copying '" + graphicsFile + "' to '" 467 reportInfo("Copying '" + graphicsFile + "' to '"
468 + outFile + "'..."); 468 + outFile + "'...");
469 469
@@ -816,17 +816,16 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
816 int size = 18; 816 int size = 18;
817 Color fg = null, bg = null; 817 Color fg = null, bg = null;
818 int disp = TeXConstants.STYLE_DISPLAY; 818 int disp = TeXConstants.STYLE_DISPLAY;
819 String code = "imagedata"; 819 String code = "imageobject><imagedata";
820 String LaTeX = ""; 820 String LaTeX = "";
821 boolean exported; 821 boolean exported;
822 String attribs; 822 String attribs, align = "";
823 823
824 protected LaTeXElement(Attributes attrs, boolean exported) { 824 protected LaTeXElement(Attributes attrs, boolean exported) {
825 this.exported = exported; 825 this.exported = exported;
826 int n = attrs.getLength(); 826 int n = attrs.getLength();
827 String fgS = "", bgS = ""; 827 String fgS = "", bgS = "";
828 String dispS = "display"; 828 String dispS = "display";
829 String align = "center";
830 829
831 for (int i = 0; i < n; i++) { 830 for (int i = 0; i < n; i++) {
832 String attr = attrs.getValue(i); 831 String attr = attrs.getValue(i);
@@ -834,7 +833,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
834 if ("align".equals(name)) { 833 if ("align".equals(name)) {
835 code += " align=\'" + attr + "\'"; 834 code += " align=\'" + attr + "\'";
836 align = attr; 835 align = attr;
837 } else if ("display".equals(name)) { 836 } else if ("style".equals(name)) {
838 if ("text".equals(attr)) { 837 if ("text".equals(attr)) {
839 disp = TeXConstants.STYLE_TEXT; 838 disp = TeXConstants.STYLE_TEXT;
840 } else if ("script".equals(attr)) { 839 } else if ("script".equals(attr)) {
@@ -860,7 +859,7 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
860 859
861 attribs = " align='" + align + "'"; 860 attribs = " align='" + align + "'";
862 attribs += " size='" + size + "'"; 861 attribs += " size='" + size + "'";
863 attribs += " display='" + dispS + "'"; 862 attribs += " style='" + dispS + "'";
864 if (bg != null) { 863 if (bg != null) {
865 attribs += " bg='" + bgS + "'"; 864 attribs += " bg='" + bgS + "'";
866 } 865 }
@@ -880,14 +879,14 @@ public class CopyConvert extends DefaultHandler implements ErrorHandler {
880 } 879 }
881 out.write("latex" + attribs + " xmlns=\"http://forge.scilab.org/p/jlatexmath\"><![CDATA[" + LaTeX + "]]></latex>"); 880 out.write("latex" + attribs + " xmlns=\"http://forge.scilab.org/p/jlatexmath\"><![CDATA[" + LaTeX + "]]></latex>");
882 } 881 }
883 882
884
885 protected void generatePNG() { 883 protected void generatePNG() {
886 TeXFormula tf = new TeXFormula(LaTeX); 884 TeXFormula tf = new TeXFormula(LaTeX);
887 File f = new File(outDir, "graphics-" + (++graphicsCounter) + "_latex.png"); 885 File f = new File(outDir, "graphics-" + (++graphicsCounter) + "_latex.png");
888 tf.createPNG(disp, size, f.getPath(), bg, fg); 886 reportInfo("Converting LaTeX formula to " + f + "'...");
887 tf.createPNG(disp, size, f.getPath(), bg, fg);
889 888
890 out.write(code + " fileref='graphics-" + graphicsCounter + "_latex.png'/>"); 889 out.write(code + " fileref='graphics-" + graphicsCounter + "_latex.png'/></imageobject>");
891 } 890 }
892 } 891 }
893 892