You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by cr...@apache.org on 2008/03/01 23:42:10 UTC

svn commit: r632668 - in /forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets: document-to-fo.xsl helper-commonElements.xsl helper-pdfoutline.xsl

Author: crossley
Date: Sat Mar  1 14:42:09 2008
New Revision: 632668

URL: http://svn.apache.org/viewvc?rev=632668&view=rev
Log:
Many touchup issues. See notes in FOR-1072.
Contributed by: Jeremias Maerki
Issue: FOR-1072

Modified:
    forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/document-to-fo.xsl
    forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-commonElements.xsl
    forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-pdfoutline.xsl

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/document-to-fo.xsl
URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/document-to-fo.xsl?rev=632668&r1=632667&r2=632668&view=diff
==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/document-to-fo.xsl (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/document-to-fo.xsl Sat Mar  1 14:42:09 2008
@@ -254,7 +254,7 @@
         <xsl:call-template
                     name="insertPageNumber">
           <xsl:with-param
-                        name="text-align">start</xsl:with-param>
+                        name="text-align">end</xsl:with-param>
         </xsl:call-template>
       </xsl:if>
       <xsl:call-template
@@ -279,11 +279,18 @@
         <xsl:apply-templates
                     select="footer" />
       </fo:block>
-      <xsl:call-template
-                name="insertPageNumber">
-        <xsl:with-param
-                    name="text-align">end</xsl:with-param>
-      </xsl:call-template>
+      <xsl:choose>
+        <xsl:when test="$doublesided = 'true'">
+          <xsl:call-template name="insertPageNumber">
+            <xsl:with-param name="text-align">start</xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="insertPageNumber">
+            <xsl:with-param name="text-align">end</xsl:with-param>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
       <xsl:call-template
                 name="info" />
     </fo:static-content>
@@ -291,8 +298,15 @@
             flow-name="odd-header">
       <fo:block
                 font-size="70%"
-                text-align="start"
                 font-style="italic">
+        <xsl:choose>
+          <xsl:when test="$doublesided = 'true'">
+            <xsl:attribute name="text-align">start</xsl:attribute>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:attribute name="text-align">end</xsl:attribute>
+          </xsl:otherwise>
+        </xsl:choose>
         <xsl:value-of
                     select="header/title" />
       </fo:block>
@@ -307,9 +321,9 @@
                     select="footer" />
       </fo:block>
       <xsl:call-template
-                name="insertPageNumber">
+        name="insertPageNumber">
         <xsl:with-param
-                    name="text-align">start</xsl:with-param>
+          name="text-align">end</xsl:with-param>
       </xsl:call-template>
       <xsl:call-template
                 name="info" />
@@ -398,7 +412,7 @@
   <xsl:template match="body[count(//section) != 0]">
     <xsl:if test="$disable-toc != 'true' and $toc-max-depth > 0">
       <fo:block font-family="sans-serif" font-size="12pt" font-weight="bold"
-        space-after="5pt" space-before="5pt" text-align="justify" width="7.5in">
+        space-after="5pt" space-before="5pt" text-align="justify" width="7.5in" id="__toc__">
         <xsl:call-template name="insertPageBreaks"/>
         <!-- insert i18n stuff here -->
         <xsl:text>Table of contents</xsl:text>
@@ -431,11 +445,16 @@
         </xsl:variable>
         <fo:basic-link internal-destination="{$id}">
           <xsl:value-of
-            select="substring('&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;', 0, 2 * $depth - 1)"/>
-          <fo:inline font-size="11pt">
+          select="substring('&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;', 0, 2 * $depth - 1)"/>
+          <xsl:variable name="section-nr">
             <xsl:number count="section" format="1.1.1.1.1.1.1" level="multiple"/>
-          </fo:inline>
-          <xsl:text> </xsl:text>
+          </xsl:variable>
+          <xsl:if test="not(starts-with(title, $section-nr))">
+            <fo:inline font-size="11pt">
+              <xsl:value-of select="$section-nr"/>
+            </fo:inline>
+            <xsl:text> </xsl:text>
+          </xsl:if>
           <xsl:value-of select="title"/>
           <fo:leader leader-pattern="dots"/>
           <fo:page-number-citation ref-id="{$id}"/>

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-commonElements.xsl
URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-commonElements.xsl?rev=632668&r1=632667&r2=632668&view=diff
==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-commonElements.xsl (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-commonElements.xsl Sat Mar  1 14:42:09 2008
@@ -29,7 +29,7 @@
       <xsl:value-of select="12-number($level)"/>
     </xsl:variable>
     <fo:block font-family="sans-serif" font-size="{$size}pt" font-weight="bold"
-      space-before="12pt" space-after="8pt" margin="0">
+      space-before="12pt" space-after="8pt" margin="0" keep-with-next.within-column="always">
       <xsl:call-template name="insertPageBreaks"/>
       <xsl:attribute name="id">
         <xsl:choose>
@@ -58,8 +58,13 @@
       </xsl:if>
       <xsl:if
         test="$numbersections = 'true' and number($level) &lt; $numbering-max-depth+1">
-        <xsl:number format="1.1.1.1.1.1.1" count="section" level="multiple"/>
-        <xsl:text>. </xsl:text>
+        <xsl:variable name="section-nr">
+          <xsl:number count="section" format="1.1.1.1.1.1.1" level="multiple"/>
+        </xsl:variable>
+        <xsl:if test="not(starts-with(title, $section-nr))">
+          <xsl:value-of select="$section-nr"/>
+          <xsl:text> </xsl:text>
+        </xsl:if>
       </xsl:if>
       <!-- For sections 4  or more nestings deep, indent instead of number -->
       <xsl:if test="number($level) &gt; $numbering-max-depth+1">
@@ -232,7 +237,7 @@
       padding-top="2pt" padding-bottom="1pt" font-size="9pt"
       font-family="sans-serif" space-before="10pt" border-before-style="solid"
       border-start-style="solid" border-end-style="solid" border-color="{$color}"
-      background-color="{$color}" color="#ffffff">
+      background-color="{$color}" color="#ffffff" keep-with-previous.within-column="always" keep-with-next.within-column="always">
       <xsl:copy-of select="@id"/>
       <xsl:call-template name="insertPageBreaks"/>
       <xsl:choose>
@@ -258,7 +263,7 @@
       font-size="9pt" padding-top="2pt" padding-bottom="1pt" color="#ffffff"
       font-family="sans-serif" space-before="10pt" border-before-style="solid"
       border-start-style="solid" border-end-style="solid" border-color="{$color}"
-      background-color="{$color}">
+      background-color="{$color}" keep-with-previous.within-column="always" keep-with-next.within-column="always">
       <xsl:copy-of select="@id"/>
       <xsl:call-template name="insertPageBreaks"/>
       <xsl:choose>
@@ -285,7 +290,7 @@
       font-size="9pt" padding-top="2pt" padding-bottom="1pt" color="#FFFFFF"
       font-family="sans-serif" space-before="10pt" border-before-style="solid"
       border-start-style="solid" border-end-style="solid" border-color="{$color}"
-      background-color="{$color}">
+      background-color="{$color}" keep-with-previous.within-column="always" keep-with-next.within-column="always">
       <xsl:copy-of select="@id"/>
       <xsl:call-template name="insertPageBreaks"/>
       <!-- insert i18n stuff here --> FIXME (
@@ -303,6 +308,10 @@
     <xsl:variable name="color"
       select="$config/colors/color[@name = 'body']/@link"/>
     <xsl:choose>
+      <xsl:when test="not(boolean(href))">
+        <!-- html2document.xsl creates links with name but with no href -> filter those -->
+        <xsl:apply-templates/>
+      </xsl:when>
       <xsl:when test="starts-with(@href, '#')">
         <fo:basic-link color="{$color}" text-decoration="underline"
           internal-destination="{substring(@href,2)}">
@@ -423,14 +432,11 @@
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
-    <xsl:variable name="column-width">
-      <xsl:value-of select="6.25 div number($max-number-columns)"/>in
-      </xsl:variable>
     <fo:table table-layout="fixed" width="100%">
       <xsl:copy-of select="@id"/>
       <fo:table-column>
         <xsl:attribute name="column-width">
-          <xsl:value-of select="$column-width"/>
+          proportional-column-width(1)
         </xsl:attribute>
         <xsl:attribute name="number-columns-repeated">
           <xsl:value-of select="number($max-number-columns)"/>
@@ -438,15 +444,18 @@
       </fo:table-column>
       <!-- End of hack for Fop support (if removing this hack, remember
       you need the <fo:table> element) -->
+      <fo:table-header font-size="10pt" font-family="serif">
+        <xsl:apply-templates select="tr[count(th) &gt; 0]"/>
+      </fo:table-header>
       <fo:table-body font-size="10pt" font-family="serif">
-        <xsl:apply-templates select="tr"/>
+        <xsl:apply-templates select="tr[count(th) = 0]"/>
       </fo:table-body>
     </fo:table>
     <!-- FIXME: Apache Fop does not support the caption element yet.
     This hack will display the table caption accordingly. -->
     <xsl:if test="caption">
       <fo:block font-size="10pt" text-align="left" font-weight="normal"
-        margin-top="5pt">
+        margin-top="5pt" keep-with-next.within-column="always">
         <!-- insert i18n stuff here --> Table
         <xsl:text>
         </xsl:text>

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-pdfoutline.xsl
URL: http://svn.apache.org/viewvc/forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-pdfoutline.xsl?rev=632668&r1=632667&r2=632668&view=diff
==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-pdfoutline.xsl (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.output.pdf/resources/stylesheets/helper-pdfoutline.xsl Sat Mar  1 14:42:09 2008
@@ -23,6 +23,14 @@
         match="document"
         mode="outline">
     <fo:bookmark-tree>
+      <xsl:if test="$disable-toc != 'true' and $toc-max-depth > 0">
+        <fo:bookmark internal-destination="__toc__">
+          <fo:bookmark-title>
+            <!-- insert i18n stuff here -->
+            <xsl:text>Table of contents</xsl:text>
+          </fo:bookmark-title>
+        </fo:bookmark>
+      </xsl:if>
       <xsl:apply-templates
             select="body/section"
             mode="outline" />
@@ -47,11 +55,13 @@
         </xsl:choose>
       </xsl:attribute>
       <fo:bookmark-title>
-        <xsl:number
-                    format="1.1.1.1.1.1.1"
-                    count="section"
-                    level="multiple" />
-<xsl:text> </xsl:text>
+        <xsl:variable name="section-nr">
+          <xsl:number count="section" format="1.1.1.1.1.1.1" level="multiple"/>
+        </xsl:variable>
+        <xsl:if test="not(starts-with(title, $section-nr))">
+          <xsl:value-of select="$section-nr"/>
+          <xsl:text> </xsl:text>
+        </xsl:if>
         <xsl:value-of
                     select="normalize-space(title)" />
       </fo:bookmark-title>