]> granicus.if.org Git - docbook-dsssl/commitdiff
fix issue #103 change header table to be more customizable
authorbobstayton <bobs@sagehill.net>
Tue, 24 Jul 2018 07:38:29 +0000 (00:38 -0700)
committerbobstayton <bobs@sagehill.net>
Mon, 1 Oct 2018 19:32:17 +0000 (12:32 -0700)
xsl/fo/pagesetup.xsl

index 31388240f13036e0bc8a7e2a009dc28fe203bb80..9989a007946d168b434d292eed499b9a9f39998e 100644 (file)
           <xsl:attribute name="block-progression-dimension.minimum">
             <xsl:value-of select="$header.table.height"/>
           </xsl:attribute>
-          <fo:table-cell text-align="start"
-                         display-align="before">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="header.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="$direction.align.start"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="header.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
               </xsl:call-template>
             </fo:block>
           </fo:table-cell>
-          <fo:table-cell text-align="center"
-                         display-align="before">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="header.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="center"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="header.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
               </xsl:call-template>
             </fo:block>
           </fo:table-cell>
-          <fo:table-cell text-align="right"
-                         display-align="before">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="header.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="$direction.align.end"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="header.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
     </fo:table>
   </xsl:variable>
 
+<xsl:template name="header.table.cell.properties">
+  <xsl:param name="position" select="''"/>
+  <xsl:param name="pageclass" select="''"/>
+  <xsl:param name="sequence" select="''"/>
+  <xsl:param name="gentext-key" select="''"/>
+
+  <xsl:choose>
+    <xsl:when test="$position = 'left'">
+      <xsl:attribute name="text-align">left</xsl:attribute>
+      <xsl:attribute name="display-align">before</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="$position = 'center'">
+      <xsl:attribute name="text-align">center</xsl:attribute>
+      <xsl:attribute name="display-align">before</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="$position = 'right'">
+      <xsl:attribute name="text-align">right</xsl:attribute>
+      <xsl:attribute name="display-align">before</xsl:attribute>
+    </xsl:when>
+  </xsl:choose>
+
+  <xsl:if test="$fop.extensions = 0">
+    <xsl:attribute name="relative-align">baseline</xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<!-- controls whether the header content assembled in
+     'header.table' template is actually output -->
+<xsl:template name="header.output.control">
+  <xsl:param name="candidate"/>
+  <xsl:param name="position" select="''"/>
+  <xsl:param name="pageclass" select="''"/>
+  <xsl:param name="sequence" select="''"/>
+  <xsl:param name="gentext-key" select="''"/>
+
   <!-- Really output a header? -->
   <xsl:choose>
     <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
           <xsl:attribute name="block-progression-dimension.minimum">
             <xsl:value-of select="$footer.table.height"/>
           </xsl:attribute>
-          <fo:table-cell text-align="start"
-                         display-align="after">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="footer.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="$direction.align.start"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="footer.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
               </xsl:call-template>
             </fo:block>
           </fo:table-cell>
-          <fo:table-cell text-align="center"
-                         display-align="after">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="footer.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="center"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="footer.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
               </xsl:call-template>
             </fo:block>
           </fo:table-cell>
-          <fo:table-cell text-align="end"
-                         display-align="after">
-            <xsl:if test="$fop.extensions = 0">
-              <xsl:attribute name="relative-align">baseline</xsl:attribute>
-            </xsl:if>
+          <fo:table-cell>
+            <xsl:call-template name="footer.table.cell.properties">
+              <xsl:with-param name="pageclass" select="$pageclass"/>
+              <xsl:with-param name="sequence" select="$sequence"/>
+              <xsl:with-param name="position" select="$direction.align.end"/>
+              <xsl:with-param name="gentext-key" select="$gentext-key"/>
+            </xsl:call-template>
             <fo:block>
               <xsl:call-template name="footer.content">
                 <xsl:with-param name="pageclass" select="$pageclass"/>
     </fo:table>
   </xsl:variable>
 
+  <!-- Really output a footer? -->
+  <xsl:call-template name="footer.output.control">
+    <xsl:with-param name="candidate" select="$candidate"/>
+    <xsl:with-param name="pageclass" select="$pageclass"/>
+    <xsl:with-param name="sequence" select="$sequence"/>
+    <xsl:with-param name="gentext-key" select="$gentext-key"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="footer.table.cell.properties">
+  <xsl:param name="position" select="''"/>
+  <xsl:param name="pageclass" select="''"/>
+  <xsl:param name="sequence" select="''"/>
+  <xsl:param name="gentext-key" select="''"/>
+
+  <xsl:choose>
+    <xsl:when test="$position = 'left'">
+      <xsl:attribute name="text-align">left</xsl:attribute>
+      <xsl:attribute name="display-align">after</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="$position = 'center'">
+      <xsl:attribute name="text-align">center</xsl:attribute>
+      <xsl:attribute name="display-align">after</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="$position = 'right'">
+      <xsl:attribute name="text-align">right</xsl:attribute>
+      <xsl:attribute name="display-align">after</xsl:attribute>
+    </xsl:when>
+  </xsl:choose>
+
+  <xsl:if test="$fop.extensions = 0">
+    <xsl:attribute name="relative-align">baseline</xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<!-- controls whether the footer content assembled in
+     'footer.table' template is actually output -->
+<xsl:template name="footer.output.control">
+  <xsl:param name="candidate"/>
+  <xsl:param name="position" select="''"/>
+  <xsl:param name="pageclass" select="''"/>
+  <xsl:param name="sequence" select="''"/>
+  <xsl:param name="gentext-key" select="''"/>
+
   <!-- Really output a footer? -->
   <xsl:choose>
-    <xsl:when test="$pageclass='titlepage' and $gentext-key='book'
+    <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
                     and $sequence='first'">
-      <!-- no, book titlepages have no footers at all -->
+      <!-- no, book titlepages have no footer at all -->
     </xsl:when>
     <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">
       <!-- no output -->