<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text">
	<xsl:output method="xml"/>
        <xsl:output encoding="UTF-8"/>
	<!-- Identity transformation -->
	<xsl:template match="/">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="@*|*|processing-instruction()|comment()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="text:outline-style">
		<!-- Add new paragraph styles here -->
		<xsl:call-template name="make-styles"/>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">p</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">bq</xsl:with-param>
			<xsl:with-param name="type"/>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">dd</xsl:with-param>
			<xsl:with-param name="type"/>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">dt</xsl:with-param>
			<xsl:with-param name="type"/>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">#</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">i</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">I</xsl:with-param>
		</xsl:call-template>
 

		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">a</xsl:with-param>
		</xsl:call-template>

		<xsl:call-template name="make-styles">
			<xsl:with-param name="family">li</xsl:with-param>
			<xsl:with-param name="type">A</xsl:with-param>
		</xsl:call-template>

		<xsl:copy-of select="."/>

		<!-- Add new list styles here -->
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
			<xsl:with-param name="type" select="'*'"/>
			<xsl:with-param name="family">li</xsl:with-param>
                </xsl:call-template>
		
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
                        <xsl:with-param name="type">#</xsl:with-param>
			<xsl:with-param name="family">li</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
                        <xsl:with-param name="type">a</xsl:with-param>
			<xsl:with-param name="family">li</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
                        <xsl:with-param name="type">A</xsl:with-param>
			<xsl:with-param name="family">li</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
                        <xsl:with-param name="type">i</xsl:with-param>
			<xsl:with-param name="family">li</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="make-list">
			<xsl:with-param name="level" select="5"/>
                        <xsl:with-param name="type">I</xsl:with-param>
			<xsl:with-param name="family">li</xsl:with-param>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="make-styles">
		<xsl:param name="family">li</xsl:param>
		<xsl:param name="type">*</xsl:param>
		<xsl:param name="level">5</xsl:param>
		<xsl:param name="style-name" select="concat($family, $level, $type)"/>
		<xsl:choose>
			<xsl:when test="$level = 0">
				<!--We're done-->
			</xsl:when>
			<xsl:otherwise>
				<!--Recurse-->
				<xsl:call-template name="make-styles">
					<xsl:with-param name="level" select="$level - 1"/>
					<xsl:with-param name="type" select="$type"/>
					<xsl:with-param name="family" select="$family"/>
				</xsl:call-template>
				
				<style:style style:name="{$style-name}" style:family="paragraph" style:parent-style-name="Default" style:list-style-name="{$style-name}">
                                  <xsl:choose>
                                    <xsl:when test="$family = 'dt'">
                                      <xsl:attribute name="style:next-style-name"><xsl:value-of select="concat('dd',$level)"/></xsl:attribute>
                                      <style:properties 
                                        text:space-before="{($level - 1)}cm" 
                                        fo:margin-left="{($level - 1)}cm" 
                                        fo:margin-right="0cm" 
                                        fo:text-indent="0cm" 
                                         fo:font-weight="bold"
                                        style:auto-text-indent="false"/>
                                       
                                        
                                    </xsl:when>
                                    <xsl:when test="$family = 'bq'">
                                      <style:properties 
                                        text:space-before="{$level}cm" 
                                        fo:margin-left="{$level}cm" 
                                        fo:margin-right="0cm" 
                                        fo:text-indent="0cm" 
                                        fo:font-style="italic"
                                        style:auto-text-indent="false"/>
                                    </xsl:when>
                                    <xsl:when test="$type = 'p' or $family='dd'">       
                                      <style:properties 
                                        text:space-before="{($level)}cm" 
                                        fo:margin-left="{($level)}cm" 
                                        fo:margin-right="0cm" 
                                        fo:text-indent="0cm" 
                                        style:auto-text-indent="false"/>
                                    </xsl:when>
                                
                                  </xsl:choose>
                                </style:style>
			
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template name="make-list">
		<xsl:param name="level"/>
		<xsl:param name="family"/>
		<xsl:param name="type"/>
		
		<xsl:variable name="style-name" select="concat($family,$level,$type)"/>
		<xsl:choose>
			<xsl:when test="$level = 0">
	       	
			</xsl:when>
			<xsl:otherwise>
				<!--Recurse-->
				<xsl:call-template name="make-list">
					<xsl:with-param name="level" select="$level - 1"/>
					<xsl:with-param name="family" select="$family"/>
					<xsl:with-param name="type" select="$type"/>
				
				</xsl:call-template>
				<!-- make a list style but make all the levels the same! -->
				<text:list-style style:name="{$style-name}">
				
					<xsl:call-template name="list-item">
						<xsl:with-param name="level" select="$level"/>
						<xsl:with-param name="family" select="$family"/>
						<xsl:with-param name="type" select="$type"/>
					
						
					</xsl:call-template>
				</text:list-style>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="list-item">
		<xsl:param name="type"/>
		<xsl:param name="level"/>
		<xsl:param name="family"/>
	
		<xsl:param name="iteration">10</xsl:param>
		<xsl:choose>
			<xsl:when test="$iteration=0"/>
			<xsl:otherwise>
				<xsl:call-template name="list-item">
					<xsl:with-param name="level" select="$level"/>
					<xsl:with-param name="family" select="$family"/>
				
					<xsl:with-param name="type" select="$type"/>
					<xsl:with-param name="iteration" select="$iteration - 1"/>
				</xsl:call-template>
				<xsl:choose>
					<xsl:when test="$type = '*'">
					  <text:list-level-style-bullet text:level="{$iteration}"
						text:style-name="Bullet Symbols" 
						text:bullet-char="&#8226;">
                                              <style:properties text:space-before="{($level -1)}cm" 
						text:min-label-width="1cm"
						style:font-name="StarSymbol"/>
					</text:list-level-style-bullet>
					</xsl:when>
				
				
					<xsl:when test="$type = '#'">
						<text:list-level-style-number
							 text:level="{$iteration}"
							 style-name="Numbering Symbols"
							 style:num-prefix=""
							 style:num-suffix="."
							 style:num-format="1"
							 text:start-value="1">
							<style:properties 
								text:min-label-width="1cm"
								text:space-before="{($level - 1)}cm"
								 />
						</text:list-level-style-number>
					</xsl:when>

					<xsl:otherwise>
	<text:list-level-style-number text:level="{$iteration}" text:style-name="Numbering Symbols" style:num-suffix="." style:num-format="{$type}" text:start-value="1">
						<style:properties text:min-label-width="1cm" 
						 text:space-before="{($level -1)}cm"
					 />
					</text:list-level-style-number>


</xsl:otherwise>


				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
</xsl:template>
</xsl:stylesheet>
