directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r986703 - /directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl
Date Wed, 18 Aug 2010 14:34:11 GMT
Author: felixk
Date: Wed Aug 18 14:34:11 2010
New Revision: 986703

URL: http://svn.apache.org/viewvc?rev=986703&view=rev
Log:
- Fix size of admonition graphic
- Make sure, that an image a least fits the page if no attributes (width, depth, content-height,
...) are set

Modified:
    directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl

Modified: directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl
URL: http://svn.apache.org/viewvc/directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl?rev=986703&r1=986702&r2=986703&view=diff
==============================================================================
--- directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl (original)
+++ directory/apacheds-manuals/trunk/src/docbkx-stylesheet/fo/docbook.xsl Wed Aug 18 14:34:11
2010
@@ -42,6 +42,7 @@ under the License.
     select="2" />
 
   <xsl:param name="use.extensions">1</xsl:param>
+  <xsl:param name="fop1.extensions">1</xsl:param>
 
   <!-- Adjust fonts & styles -->
   <xsl:attribute-set name="monospace.verbatim.properties">
@@ -69,15 +70,15 @@ under the License.
   
     <fo:block id="{$id}"
               xsl:use-attribute-sets="graphical.admonition.properties">
-              <xsl:attribute name="background-color">
-      <xsl:choose>
-        <xsl:when test="name($node)='note'">#D8E4F1</xsl:when>
-        <xsl:when test="name($node)='warning'">#FFCCCC</xsl:when>
-        <!-- xsl:when test="name($node)='caution'"></xsl:when -->
-        <xsl:when test="name($node)='tip'">#DDFFDD</xsl:when>
-        <xsl:when test="name($node)='important'">#FFFFCE</xsl:when>
-        <xsl:otherwise>#D8E4F1</xsl:otherwise>
-      </xsl:choose>
+      <xsl:attribute name="background-color">
+        <xsl:choose>
+          <xsl:when test="name($node)='note'">#D8E4F1</xsl:when>
+          <xsl:when test="name($node)='warning'">#FFCCCC</xsl:when>
+          <!-- xsl:when test="name($node)='caution'"></xsl:when -->
+          <xsl:when test="name($node)='tip'">#DDFFDD</xsl:when>
+          <xsl:when test="name($node)='important'">#FFFFCE</xsl:when>
+          <xsl:otherwise>#D8E4F1</xsl:otherwise>
+        </xsl:choose>
       </xsl:attribute>
   
       <fo:list-block provisional-distance-between-starts="{$graphic.width} + 18pt"
@@ -108,12 +109,226 @@ under the License.
     </fo:block>
   </xsl:template>
 
+  <!-- Size of admonition graphic -->  
+  <xsl:template match="*" mode="admon.graphic.width">
+    <xsl:text>12pt</xsl:text>
+  </xsl:template>
+  
+  
   <!-- Add graphic symbols to admonitions -->
   <xsl:param name="admon.graphics" select="1"/>
   <xsl:param name="admon.graphics.extension">.gif</xsl:param>
   <!-- Hide default admonition title if none set explicitly -->
   <xsl:param name="admon.textlabel">0</xsl:param>
- 
+
+
+  <!-- ==================================================================== -->
+  <!-- Override these templates for FO -->
+  <!-- ==================================================================== -->
+  <xsl:template name="process.image">
+    <!-- When this template is called, the current node should be  -->
+    <!-- a graphic, inlinegraphic, imagedata, or videodata. All    -->
+    <!-- those elements have the same set of attributes, so we can -->
+    <!-- handle them all in one place.                             -->
+
+    <!-- Make sure the image at least fits the page if no attributes are set -->
+    <xsl:param name="fitting.width">100%</xsl:param>
+    <xsl:param name="fitting.height">auto</xsl:param>
+    <xsl:param name="fitting.content.width">scale-to-fit</xsl:param>
+    <xsl:param name="fitting.content.height">100%</xsl:param>
+
+    <xsl:variable name="scalefit">
+      <xsl:choose>
+        <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
+        <xsl:when test="@contentwidth">0</xsl:when>
+        <xsl:when test="@contentdepth and 
+                        @contentdepth != '100%'">0</xsl:when>
+        <xsl:when test="@scale">0</xsl:when>
+        <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when>
+        <xsl:when test="@width or @depth">1</xsl:when>
+        <xsl:otherwise>0</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+  
+    <xsl:variable name="scale">
+      <xsl:choose>
+        <xsl:when test="$ignore.image.scaling != 0">0</xsl:when>
+        <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when>
+        <xsl:when test="@scale">
+          <xsl:value-of select="@scale div 100.0"/>
+        </xsl:when>
+        <xsl:otherwise>1.0</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+  
+    <xsl:variable name="filename">
+      <xsl:choose>
+        <xsl:when test="local-name(.) = 'graphic'
+                        or local-name(.) = 'inlinegraphic'">
+          <!-- handle legacy graphic and inlinegraphic by new template --> 
+          <xsl:call-template name="mediaobject.filename">
+            <xsl:with-param name="object" select="."/>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <!-- imagedata, videodata, audiodata -->
+          <xsl:call-template name="mediaobject.filename">
+            <xsl:with-param name="object" select=".."/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+  
+    <xsl:variable name="content-type">
+      <xsl:if test="@format">
+        <xsl:call-template name="graphic.format.content-type">
+          <xsl:with-param name="format" select="@format"/>
+        </xsl:call-template>
+      </xsl:if>
+    </xsl:variable>
+  
+    <xsl:variable name="bgcolor">
+      <xsl:call-template name="dbfo-attribute">
+        <xsl:with-param name="pis"
+                        select="../processing-instruction('dbfo')"/>
+        <xsl:with-param name="attribute" select="'background-color'"/>
+      </xsl:call-template>
+    </xsl:variable>
+  
+    <fo:external-graphic>
+      <xsl:attribute name="src">
+        <xsl:call-template name="fo-external-image">
+          <xsl:with-param name="filename">
+            <xsl:if test="$img.src.path != '' and
+                          not(starts-with($filename, '/')) and
+                          not(contains($filename, '://'))">
+              <xsl:value-of select="$img.src.path"/>
+            </xsl:if>
+            <xsl:value-of select="$filename"/>
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:attribute>
+  
+  
+      <xsl:attribute name="width">
+        <xsl:choose>
+          <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+          <xsl:when test="contains(@width,'%')">
+            <xsl:value-of select="@width"/>
+          </xsl:when>
+          <xsl:when test="@width and not(@width = '')">
+            <xsl:call-template name="length-spec">
+              <xsl:with-param name="length" select="@width"/>
+              <xsl:with-param name="default.units" select="'px'"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:when test="not(@depth) and $default.image.width != ''">
+            <xsl:call-template name="length-spec">
+              <xsl:with-param name="length" select="$default.image.width"/>
+              <xsl:with-param name="default.units" select="'px'"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$fitting.width"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+  
+      <xsl:attribute name="height">
+        <xsl:choose>
+          <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+          <xsl:when test="contains(@depth,'%')">
+            <xsl:value-of select="@depth"/>
+          </xsl:when>
+          <xsl:when test="@depth">
+            <xsl:call-template name="length-spec">
+              <xsl:with-param name="length" select="@depth"/>
+              <xsl:with-param name="default.units" select="'px'"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$fitting.height"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+  
+      <xsl:attribute name="content-width">
+        <xsl:choose>
+          <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+          <xsl:when test="contains(@contentwidth,'%')">
+            <xsl:value-of select="@contentwidth"/>
+          </xsl:when>
+          <xsl:when test="@contentwidth">
+            <xsl:call-template name="length-spec">
+              <xsl:with-param name="length" select="@contentwidth"/>
+              <xsl:with-param name="default.units" select="'px'"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:when test="number($scale) != 1.0">
+            <xsl:value-of select="$scale * 100"/>
+            <xsl:text>%</xsl:text>
+          </xsl:when>
+          <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$fitting.content.width"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+  
+      <xsl:attribute name="content-height">
+        <xsl:choose>
+          <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
+          <xsl:when test="contains(@contentdepth,'%')">
+            <xsl:value-of select="@contentdepth"/>
+          </xsl:when>
+          <xsl:when test="@contentdepth">
+            <xsl:call-template name="length-spec">
+              <xsl:with-param name="length" select="@contentdepth"/>
+              <xsl:with-param name="default.units" select="'px'"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:when test="number($scale) != 1.0">
+            <xsl:value-of select="$scale * 100"/>
+            <xsl:text>%</xsl:text>
+          </xsl:when>
+          <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$fitting.content.height"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+      
+      <xsl:if test="$content-type != ''">
+        <xsl:attribute name="content-type">
+          <xsl:value-of select="concat('content-type:',$content-type)"/>
+        </xsl:attribute>
+      </xsl:if>
+  
+      <xsl:if test="$bgcolor != ''">
+        <xsl:attribute name="background-color">
+          <xsl:value-of select="$bgcolor"/>
+        </xsl:attribute>
+      </xsl:if>
+  
+      <xsl:if test="@align">
+        <xsl:attribute name="text-align">
+          <xsl:value-of select="@align"/>
+        </xsl:attribute>
+      </xsl:if>
+  
+      <xsl:if test="@valign">
+        <xsl:attribute name="display-align">
+          <xsl:choose>
+            <xsl:when test="@valign = 'top'">before</xsl:when>
+            <xsl:when test="@valign = 'middle'">center</xsl:when>
+            <xsl:when test="@valign = 'bottom'">after</xsl:when>
+            <xsl:otherwise>auto</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </xsl:if>
+    </fo:external-graphic>
+  </xsl:template>
+
   <!-- Add linebreak processing instruction -->
   <xsl:template match="processing-instruction('linebreak')">
     <fo:block/>



Mime
View raw message