[Libreoffice-commits] .: 6 commits - filter/Library_xsltfilter.mk filter/source libxslt/libxsltversion.mk libxslt/makefile.mk libxslt/prj scp2/source solenv/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Sep 9 22:57:50 PDT 2012


 filter/Library_xsltfilter.mk                                  |    1 
 filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl |  976 ++++------
 filter/source/xsltfilter/LibXSLTTransformer.cxx               |    6 
 libxslt/libxsltversion.mk                                     |    3 
 libxslt/makefile.mk                                           |    1 
 libxslt/prj/d.lst                                             |    2 
 scp2/source/ooo/file_library_ooo.scp                          |   18 
 scp2/source/ooo/module_hidden_ooo.scp                         |   11 
 solenv/inc/libs.mk                                            |    6 
 9 files changed, 530 insertions(+), 494 deletions(-)

New commits:
commit 1c467763f4ca4bc1caaa3111f0ed85f388e6fe01
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Sat Sep 8 22:26:50 2012 +0200

    build and deliver internal libexslt. Use LIBEXSLT_LIBS is system xslt is used
    
    Change-Id: I7ab624bc4877af51d4182ab213ef49cd8c5bb2a4

diff --git a/filter/Library_xsltfilter.mk b/filter/Library_xsltfilter.mk
index 9688d59..94fca81 100644
--- a/filter/Library_xsltfilter.mk
+++ b/filter/Library_xsltfilter.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Library_use_libraries,xsltfilter,\
 $(eval $(call gb_Library_use_externals,xsltfilter,\
 	libxml2 \
 	libxslt \
+	libexslt \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,xsltfilter,\
diff --git a/libxslt/libxsltversion.mk b/libxslt/libxsltversion.mk
index c80c0e9..e7fe5e5 100644
--- a/libxslt/libxsltversion.mk
+++ b/libxslt/libxsltversion.mk
@@ -26,8 +26,11 @@
 #*************************************************************************
 # major 
 LIBXSLT_MAJOR=1
+LIBEXSLT_MAJOR=0
 # minor 
 LIBXSLT_MINOR=1
+LIBEXSLT_MINOR=8
 # micro 
 LIBXSLT_MICRO=26
+LIBEXSLT_MICRO=15
 
diff --git a/libxslt/makefile.mk b/libxslt/makefile.mk
index 670ebb9..9d4deff 100644
--- a/libxslt/makefile.mk
+++ b/libxslt/makefile.mk
@@ -159,6 +159,7 @@ BUILD_DIR=$(CONFIGURE_DIR)
 .ENDIF
 
 OUT2INC=libxslt$/*.h
+OUT2INC+=libexslt$/*.h
 
 .IF "$(OS)"=="MACOSX"
 OUT2LIB+=libxslt$/.libs$/libxslt.*.dylib
diff --git a/libxslt/prj/d.lst b/libxslt/prj/d.lst
index f3613b0..892df7b 100644
--- a/libxslt/prj/d.lst
+++ b/libxslt/prj/d.lst
@@ -1,5 +1,7 @@
 mkdir: %_DEST%\inc\external\libxslt
+mkdir: %_DEST%\inc\external\libexslt
 ..\%__SRC%\inc\*.h %_DEST%\inc\external\libxslt\*.h
+..\%__SRC%\inc\exslt*.h %_DEST%\inc\external\libexslt\*.h
 ..\%__SRC%\lib\libxslt.1.dylib %_DEST%\lib\libxslt.1.dylib
 symlink: %_DEST%\lib\libxslt.1.dylib %_DEST%\lib\libxslt.dylib
 ...\%__SRC%\lib\libexslt.so %_DEST%\lib\libexslt.so
diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp
index 928174b..8a20d07 100644
--- a/scp2/source/ooo/file_library_ooo.scp
+++ b/scp2/source/ooo/file_library_ooo.scp
@@ -1470,6 +1470,24 @@ File gid_File_Lib_Xslt
    #endif
   #endif
 End
+File gid_File_Lib_eXslt
+    LIB_FILE_BODY;
+    Styles = (PACKED);
+    Dir = SCP2_OOO_BIN_DIR;
+  #ifdef UNX
+    #ifdef MACOSX
+       Name = STRING(CONCAT4(libexslt,.,0,UNXSUFFIX));
+    #else
+       Name = STRING(CONCAT4(libexslt,UNXSUFFIX,.,0));
+    #endif
+  #else
+   #ifdef _gcc3
+    Name = "libexslt-0.dll";
+   #else
+    Name = "libexslt.dll";
+   #endif
+  #endif
+End
 #endif
 
 
diff --git a/scp2/source/ooo/module_hidden_ooo.scp b/scp2/source/ooo/module_hidden_ooo.scp
index 26ec6d6..aa4ff72 100644
--- a/scp2/source/ooo/module_hidden_ooo.scp
+++ b/scp2/source/ooo/module_hidden_ooo.scp
@@ -70,6 +70,13 @@ Unixlink gid_Unixlink_File_Lib_Xslt
     Styles = (PACKED, VERSION_INDEPENDENT_COMP_ID);
     Target = STRING(CONCAT3(libxslt,UNXSUFFIX,.1));
 End
+Unixlink gid_Unixlink_File_Lib_eXslt
+    BIN_FILE_BODY;
+    Dir = SCP2_OOO_BIN_DIR;
+    Name = STRING(CONCAT2(libexslt,UNXSUFFIX));
+    Styles = (PACKED, VERSION_INDEPENDENT_COMP_ID);
+    Target = STRING(CONCAT3(libexslt,UNXSUFFIX,.0));
+End
 #endif
 #endif
 
@@ -431,6 +438,7 @@ Module gid_Module_Root_Files_5
 	gid_File_Lib_Ucppkg1,
 	gid_File_Lib_Xslt,
 	gid_Unixlink_File_Lib_Xslt,
+	gid_Unixlink_File_Lib_eXslt,
 	gid_File_Lib_LibXMLSec_xmlsecnss,
 	gid_File_Lib_LibXMLSec_xmlseccore,
 	gid_File_Lib_LibXMLSec_xmlsecmscrypto,
@@ -499,7 +507,8 @@ Module gid_Module_Root_Files_5
 	gid_Unixlink_File_Lib_Raptor,
 	gid_Unixlink_File_Lib_Rasqal,
 	gid_Unixlink_File_Lib_Rdf,
-	gid_Unixlink_File_Lib_Xslt);
+	gid_Unixlink_File_Lib_Xslt,
+	gid_Unixlink_File_Lib_eXslt);
 End
 
 Module gid_Module_Root_Files_6
diff --git a/solenv/inc/libs.mk b/solenv/inc/libs.mk
index 1efcd22..b9e2a5d 100644
--- a/solenv/inc/libs.mk
+++ b/solenv/inc/libs.mk
@@ -252,9 +252,9 @@ CPPUNITLIB = $(CPPUNIT_LIBS)
 CPPUNITLIB = -lcppunit
 .ENDIF
 .IF "$(SYSTEM_LIBXSLT)"=="YES"
-XSLTLIB=$(LIBXSLT_LIBS)
+XSLTLIB=$(LIBEXSLT_LIBS)
 .ELSE
-XSLTLIB=-lxslt $(LIBXML2LIB)
+XSLTLIB=-lexslt -lxslt $(LIBXML2LIB)
 .ENDIF
 JVMFWKLIB = -ljvmfwk
 .IF "$(SYSTEM_REDLAND)"=="YES"
@@ -491,7 +491,7 @@ PKGCHKLIB=ipkgchk.lib
 HELPLINKERLIB=ihelplinker.lib
 JVMACCESSLIB = ijvmaccess.lib
 CPPUNITLIB = icppunit_dll.lib
-XSLTLIB = libxslt.lib $(LIBXML2LIB)
+XSLTLIB = libexslt.lib libxslt.lib $(LIBXML2LIB)
 REDLANDLIB = librdf.lib
 
 JVMFWKLIB = ijvmfwk.lib
commit eadb83f281b596e441a82798660f1a27c177b2c6
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Sat May 5 23:45:56 2012 +0200

    register exslt functions for libxslt filter
    
    Change-Id: I23bb8a3cf00a9152362794281a617ad4a780faee

diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index ff57fc1..aa1411f 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -44,6 +44,7 @@
 #include <libxslt/xsltutils.h>
 #include <libxslt/variables.h>
 #include <libxslt/extensions.h>
+#include <libexslt/exslt.h>
 
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/servicefactory.hxx>
@@ -323,7 +324,12 @@ namespace XSLT
                 (const xmlChar *) m_transformer->getStyleSheetURL().getStr());
         xmlDocPtr result = NULL;
         xsltTransformContextPtr tcontext = NULL;
+        exsltRegisterAll();
         registerExtensionModule();
+#if OSL_DEBUG_LEVEL > 1
+        xsltSetGenericDebugFunc(stderr, NULL);
+        xsltDebugDumpExtensions(NULL);
+#endif
         OleHandler* oh = new OleHandler(m_transformer->getServiceFactory());
         if (styleSheet)
             {
commit b5107faa150aab3c5480708219fc8d392a97f718
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Tue May 1 00:26:25 2012 +0200

    add for exslt:set:distinct template
    
    ..for processors not supporting it natively, namely Saxon > 8.2
    
    Change-Id: I33ceedd7f70f0469c039b8e90aa8d492d5c27ce2

diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index 15874f2..6258668 100644
--- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -9145,4 +9145,25 @@
 		<xsl:param name="string"/>
 		<xsl:value-of select="translate($string, '.%()/\+[]', '')"/>
 	</xsl:template>
+	
+	<xsl:template name="set:distinct">
+		<xsl:param name="nodes" select="/.."/>
+		<xsl:param name="distinct" select="/.."/>
+		<xsl:choose>
+			<xsl:when test="$nodes">
+				<xsl:call-template name="set:distinct">
+					<xsl:with-param name="distinct" select="$distinct | $nodes[1][not(. = $distinct)]"/>
+					<xsl:with-param name="nodes" select="$nodes[position() > 1]"/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:apply-templates select="$distinct" mode="set:distinct"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<xsl:template match="node()|@*" mode="set:distinct">
+		<xsl:copy-of select="." />
+	</xsl:template>
+	
 </xsl:stylesheet>
commit 9f29890d4e4fa916d46eeae081ef6e04eb1bfe81
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Tue May 1 00:24:51 2012 +0200

    fix a problem when handling style named for conditional formatting.
    
    Change-Id: Ia8deda31dc4624b1d05d2388c90dbcb17d033269

diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index 32e4259..15874f2 100644
--- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -6981,23 +6981,29 @@
 				<xsl:with-param name="param-str" select="substring-before($condition-pos-str,$current-pos-str)"/>
 			</xsl:call-template>
 		</xsl:variable>
+		<xsl:variable name="base-style-name">
+			<xsl:choose>
+				<xsl:when test="@ss:StyleID">
+					<xsl:value-of select="@ss:StyleID"/>
+				</xsl:when>
+				<xsl:when test="../@ss:StyleID">
+					<xsl:value-of select="../@ss:StyleID"/>
+				</xsl:when>
+				<xsl:when test="../../@ss:StyleID">
+					<xsl:value-of select="../../@ss:StyleID"/>
+				</xsl:when>
+			</xsl:choose>
+		</xsl:variable>
 		<xsl:variable name="style-name">
 			<xsl:choose>
 				<xsl:when test="contains($condition-pos-str, $current-pos-str) and starts-with($temp-str, 'c')">
-					<xsl:value-of select="concat(@ss:StyleID, '-ce', substring-after($temp-str, 'c'))"/>
-				</xsl:when>
-				<xsl:otherwise>
 					<xsl:choose>
-						<xsl:when test="@ss:StyleID">
-							<xsl:value-of select="@ss:StyleID"/>
-						</xsl:when>
-						<xsl:when test="../@ss:StyleID">
-							<xsl:value-of select="../@ss:StyleID"/>
-						</xsl:when>
-						<xsl:when test="../../@ss:StyleID">
-							<xsl:value-of select="../../@ss:StyleID"/>
-						</xsl:when>
+						<xsl:when test="string-length($base-style-name) > 0"><xsl:value-of select="concat($base-style-name, '-ce', substring-after($temp-str, 'c'))"/></xsl:when>
+						<xsl:otherwise><xsl:value-of select="concat('Default-ce', substring-after($temp-str, 'c'))"/></xsl:otherwise>
 					</xsl:choose>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="$base-style-name"/>
 				</xsl:otherwise>
 			</xsl:choose>
 		</xsl:variable>
commit 3420be984986bcff03d6d127b913fc07372fe89f
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Tue May 1 00:24:01 2012 +0200

    fixed problem with template recursion in spreadsheetml import.
    
    Changed recursion to iteration in various places (creating column styles and both row styles and rows)
    Recursion when creating cells/columns remains.
    
    Change-Id: Ie5d27c576069b79225e7901671227c0ff8dce75d

diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index cd223f8..32e4259 100644
--- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -5048,17 +5048,15 @@
 		<style:style style:family="table-column" style:name="{concat('co', $table-pos)}">
 			<style:table-column-properties fo:break-before="auto" style:column-width="{$default-column-width}"/>
 		</style:style>
-		<xsl:choose>
-			<xsl:when test="ss:Column">
-				<xsl:call-template name="get-column-style-name">
-					<xsl:with-param name="finishedColumns" select="0"/>
-					<xsl:with-param name="columnCount" select="count(./ss:Column)"/>
-					<xsl:with-param name="currentCount" select="1"/>
-					<xsl:with-param name="table-pos" select="$table-pos"/>
-					<xsl:with-param name="default-column-width" select="$default-column-width"/>
-				</xsl:call-template>
-			</xsl:when>
-		</xsl:choose>
+		<xsl:variable name="columnCount" select="count(ss:Column)"/>
+		<xsl:for-each select="ss:Column">
+			<xsl:apply-templates select="." mode="create-column-style">
+				<xsl:with-param name="columnCount" select="$columnCount"/>
+				<xsl:with-param name="currentCount" select="position()"/>
+				<xsl:with-param name="table-pos" select="$table-pos"/>
+				<xsl:with-param name="default-column-width" select="$default-column-width"/>
+			</xsl:apply-templates>
+		</xsl:for-each>
 		<xsl:if test="../x:PageBreaks/x:ColBreaks">
 			<style:style style:name="{concat('cob',$table-pos)}" style:family="table-column">
 				<xsl:element name="style:table-column-properties">
@@ -5085,15 +5083,15 @@
 		<style:style style:family="table-row" style:name="{concat('ro', $table-pos)}">
 			<style:table-row-properties style:row-height="{$default-row-height}" style:use-optimal-row-height="false"/>
 		</style:style>
-		<xsl:if test="ss:Row">
-			<xsl:call-template name="get-row-style-name">
-				<xsl:with-param name="earlierRowNo" select="0"/>
-				<xsl:with-param name="rowNodeCount" select="count(./ss:Row)"/>
-				<xsl:with-param name="rowNodeIndex" select="1"/>
+		<xsl:variable name="rowCount" select="count(ss:Row)"/>
+		<xsl:for-each select="ss:Row">
+			<xsl:apply-templates select="." mode="create-row-style">
+				<xsl:with-param name="rowNodeCount" select="$rowCount"/>
+				<xsl:with-param name="rowNodeIndex" select="position()"/>
 				<xsl:with-param name="table-pos" select="$table-pos"/>
 				<xsl:with-param name="default-row-height" select="$default-row-height"/>
-			</xsl:call-template>
-		</xsl:if>
+			</xsl:apply-templates>
+		</xsl:for-each>
 		<xsl:if test="../x:PageBreaks/x:RowBreaks">
 			<style:style style:name="{concat('rob',$table-pos)}" style:family="table-row">
 				<xsl:element name="style:table-row-properties">
@@ -5129,98 +5127,82 @@
 			</xsl:element>
 		</xsl:element>
 	</xsl:template>
-	<xsl:template name="get-column-style-name">
+	<xsl:template match="ss:Column" mode="create-column-style">
 		<!-- generate stylename of colbreak after matching the column number and the colbreak number -->
-		<xsl:param name="finishedColumns"/>
 		<xsl:param name="columnCount"/>
 		<xsl:param name="currentCount"/>
 		<xsl:param name="table-pos"/>
 		<xsl:param name="default-column-width"/>
-		<xsl:if test="$currentCount < ($columnCount + 1)">
-			<xsl:variable name="span-value">
-				<xsl:choose>
-					<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
-						<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Span + 1"/>
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="0"/>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:variable>
-			<xsl:variable name="current-index">
-				<xsl:choose>
-					<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Index">
-						<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index - 1"/>
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="$finishedColumns"/>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:variable>
-			<xsl:variable name="column-break">
-				<xsl:choose>
-					<xsl:when test="$span-value = 0">
-						<xsl:if test="../x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column = $current-index">
-							<xsl:value-of select="1"/>
-						</xsl:if>
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:if test="../x:PageBreaks/x:ColBreaks[(x:ColBreak/x:Column > $finishedColumns) and (x:ColBreak/x:Column < ($finishedColumns + $span-value))]">
-							<xsl:value-of select="1"/>
-						</xsl:if>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:variable>
-			<xsl:if test="$column-break = 1">
-				<xsl:element name="style:style">
-					<xsl:attribute name="style:name">
-						<xsl:call-template name="encode-as-nc-name">
-							<xsl:with-param name="string" select="concat('cob', $table-pos, '-',$currentCount)"/>
-						</xsl:call-template>
-					</xsl:attribute>
-					<xsl:attribute name="style:family">table-column</xsl:attribute>
-					<xsl:element name="style:table-column-properties">
-						<xsl:choose>
-							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width">
-								<xsl:attribute name="style:column-width">
-									<xsl:call-template name="convert2cm">
-										<xsl:with-param name="value" select="concat(./ss:Column[position() = $currentCount]/@ss:Width,'pt')"/>
-									</xsl:call-template>
-									<xsl:text>cm</xsl:text>
-								</xsl:attribute>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:attribute name="style:column-width">
-									<xsl:value-of select="$default-column-width"/>
-								</xsl:attribute>
-							</xsl:otherwise>
-						</xsl:choose>
-						<xsl:choose>
-							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:AutoFitWidth = '0'">
-								<xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:choose>
-									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width > 0">
-										<xsl:attribute name="style:use-optimal-column-width">false</xsl:attribute>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:attribute name="style:use-optimal-column-width">true</xsl:attribute>
-									</xsl:otherwise>
-								</xsl:choose>
-							</xsl:otherwise>
-						</xsl:choose>
-						<xsl:attribute name="fo:break-before">page</xsl:attribute>
-					</xsl:element>
-				</xsl:element>
-			</xsl:if>
-			<style:style style:name="{concat('co', $table-pos, '-',$currentCount)}" style:family="table-column">
+		<xsl:variable name="span-value" select="@ss:Span + count(@ss:Span)"/>
+		<xsl:variable name="finishedColumns">
+			<xsl:choose>
+				<xsl:when test="@ss:Index">
+					<xsl:value-of select="@ss:Index -1 + $span-value"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:variable name="recent-index"
+						select="preceding-sibling::*[@ss:Index][last()]"/>
+					<xsl:choose>
+						<xsl:when test="$recent-index">
+							<xsl:variable name="nodes-up-to-current"
+								select="set:intersection(preceding-sibling::*, $recent-index/following-sibling::*)"/>
+							<xsl:variable name="allSpans" select="$nodes-up-to-current/@ss:Span"/>
+							<xsl:value-of
+								select="$recent-index/@ss:Index + count($nodes-up-to-current) + sum($allSpans) + count($allSpans)"
+							/>
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:variable name="allSpans" select="preceding-sibling::*/@ss:Span"/>
+
+							<xsl:value-of select="$currentCount + sum($allSpans) + count($allSpans)"/>
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:variable name="current-index">
+			<xsl:choose>
+				<xsl:when test="@ss:Index">
+					<xsl:value-of select="@ss:Index - 1"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="$finishedColumns"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+
+		<xsl:variable name="column-break">
+			<xsl:choose>
+				<xsl:when test="$span-value = 0">
+					<xsl:if test="../x:PageBreaks/x:ColBreaks/x:ColBreak/x:Column = $current-index">
+						<xsl:value-of select="1"/>
+					</xsl:if>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:if
+						test="../x:PageBreaks/x:ColBreaks[(x:ColBreak/x:Column > $finishedColumns) and (x:ColBreak/x:Column < ($finishedColumns + $span-value))]">
+						<xsl:value-of select="1"/>
+					</xsl:if>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:if test="$column-break = 1">
+			<xsl:element name="style:style">
+				<xsl:attribute name="style:name">
+					<xsl:call-template name="encode-as-nc-name">
+						<xsl:with-param name="string"
+							select="concat('cob', $table-pos, '-',$currentCount)"/>
+					</xsl:call-template>
+				</xsl:attribute>
+				<xsl:attribute name="style:family">table-column</xsl:attribute>
 				<xsl:element name="style:table-column-properties">
 					<xsl:choose>
-						<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Width">
+						<xsl:when test="@ss:Width">
 							<xsl:attribute name="style:column-width">
 								<xsl:call-template name="convert2cm">
-									<xsl:with-param name="value" select="concat(./ss:Column[position() = $currentCount]/@ss:Width,'pt')"/>
+									<xsl:with-param name="value"
+										select="concat(@ss:Width,'pt')"
+									/>
 								</xsl:call-template>
 								<xsl:text>cm</xsl:text>
 							</xsl:attribute>
@@ -5231,172 +5213,150 @@
 							</xsl:attribute>
 						</xsl:otherwise>
 					</xsl:choose>
-					<xsl:attribute name="fo:break-before">auto</xsl:attribute>
+					<xsl:choose>
+						<xsl:when
+							test="@ss:AutoFitWidth = '0'">
+							<xsl:attribute name="style:use-optimal-column-width"
+								>false</xsl:attribute>
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:choose>
+								<xsl:when
+									test="@ss:Width > 0">
+									<xsl:attribute name="style:use-optimal-column-width"
+										>false</xsl:attribute>
+								</xsl:when>
+								<xsl:otherwise>
+									<xsl:attribute name="style:use-optimal-column-width"
+										>true</xsl:attribute>
+								</xsl:otherwise>
+							</xsl:choose>
+						</xsl:otherwise>
+					</xsl:choose>
+					<xsl:attribute name="fo:break-before">page</xsl:attribute>
 				</xsl:element>
-			</style:style>
-			<xsl:if test="$currentCount < $columnCount">
-				<xsl:call-template name="get-column-style-name">
-					<xsl:with-param name="finishedColumns">
-						<xsl:choose>
-							<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Index">
-								<xsl:choose>
-									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
-										<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index + ./ss:Column[position() = $currentCount]/@ss:Span"/>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:value-of select="./ss:Column[position() = $currentCount]/@ss:Index"/>
-									</xsl:otherwise>
-								</xsl:choose>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:choose>
-									<xsl:when test="./ss:Column[position() = $currentCount]/@ss:Span">
-										<xsl:value-of select="$finishedColumns + ./ss:Column[position() = $currentCount]/@ss:Span + 1"/>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:value-of select="$finishedColumns + 1"/>
-									</xsl:otherwise>
-								</xsl:choose>
-							</xsl:otherwise>
-						</xsl:choose>
-					</xsl:with-param>
-					<xsl:with-param name="columnCount" select="$columnCount"/>
-					<xsl:with-param name="currentCount" select="$currentCount + 1"/>
-					<xsl:with-param name="table-pos" select="$table-pos"/>
-					<xsl:with-param name="default-column-width" select="$default-column-width"/>
-				</xsl:call-template>
-			</xsl:if>
+			</xsl:element>
 		</xsl:if>
-	</xsl:template>
-	<xsl:template name="get-row-style-name">
-		<!-- generate stylename of rowbreak after matching the row number and the rowbreak number -->
-		<xsl:param name="earlierRowNo"/>
-		<xsl:param name="rowNodeCount"/>
-		<xsl:param name="rowNodeIndex"/>
-		<xsl:param name="table-pos"/>
-		<xsl:param name="default-row-height"/>
-		<xsl:if test="$rowNodeIndex < ($rowNodeCount + 1)">
-			<xsl:variable name="span-value">
-				<xsl:choose>
-					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
-						<xsl:choose>
-							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
-								<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index - $earlierRowNo+ ./ss:Row[position() = $rowNodeIndex]/@ss:Span"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:value-of select="0"/>
-							</xsl:otherwise>
-						</xsl:choose>
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:choose>
-							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
-								<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Span + 1"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:value-of select="0"/>
-							</xsl:otherwise>
-						</xsl:choose>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:variable>
-			<xsl:variable name="current-index">
+		<style:style style:name="{concat('co', $table-pos, '-',$currentCount)}"
+			style:family="table-column">
+			<xsl:element name="style:table-column-properties">
 				<xsl:choose>
-					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
-						<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index - 1"/>
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="$earlierRowNo"/>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:variable>
-			<xsl:variable name="row-break">
-				<xsl:choose>
-					<xsl:when test="$span-value = 0">
-						<xsl:if test="../x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = $current-index">
-							<xsl:value-of select="1"/>
-						</xsl:if>
+					<xsl:when test="@ss:Width">
+						<xsl:attribute name="style:column-width">
+							<xsl:call-template name="convert2cm">
+								<xsl:with-param name="value"
+									select="concat(@ss:Width,'pt')"
+								/>
+							</xsl:call-template>
+							<xsl:text>cm</xsl:text>
+						</xsl:attribute>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:if test="../x:PageBreaks/x:RowBreaks[(x:RowBreak/x:Row > $earlierRowNo) and (x:RowBreak/x:Row < ($earlierRowNo + $span-value))]">
-							<xsl:value-of select="1"/>
-						</xsl:if>
+						<xsl:attribute name="style:column-width">
+							<xsl:value-of select="$default-column-width"/>
+						</xsl:attribute>
 					</xsl:otherwise>
 				</xsl:choose>
-			</xsl:variable>
-			<xsl:if test="$row-break = 1">
-				<xsl:element name="style:style">
+				<xsl:attribute name="fo:break-before">auto</xsl:attribute>
+			</xsl:element>
+		</style:style>
+	</xsl:template>
+	
+	<xsl:template match="ss:Row" mode="create-row-style">
+		<!-- generate stylename of rowbreak after matching the row number and the rowbreak number -->
+		<xsl:param name="rowNodeCount"/>
+		<xsl:param name="rowNodeIndex" select="position()"/>
+		<xsl:param name="table-pos"/>
+		<xsl:param name="default-row-height"/>
+		<xsl:variable name="simple-span-value" select="@ss:Span + count(@ss:Span)"/>
+		
+		<xsl:variable name="earlierRowNo">
+			<xsl:choose>
+				<xsl:when test="@ss:Index"><xsl:value-of select="@ss:Index -1 + $simple-span-value"/></xsl:when>
+				<xsl:otherwise>
+					<xsl:variable name="recent-index" select="preceding-sibling::*[@ss:Index][last()]"></xsl:variable>
 					<xsl:choose>
-						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:StyleID">
-							<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-',ss:Row[position() = $rowNodeIndex]/@ss:StyleID)"/></xsl:attribute>
+						<xsl:when test="$recent-index">
+							<xsl:variable name="nodes-up-to-current" select="set:intersection(preceding-sibling::*, $recent-index/following-sibling::*)"></xsl:variable>
+							<xsl:variable name="allSpans" select="$nodes-up-to-current/@ss:Span"/>
+							<xsl:value-of select="$recent-index/@ss:Index + count($nodes-up-to-current) + sum($allSpans) + count($allSpans)"/>
 						</xsl:when>
 						<xsl:otherwise>
-							<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex)"/></xsl:attribute>
+							<xsl:variable name="allSpans" select="preceding-sibling::*/@ss:Span"/>
+							<xsl:value-of select="position() + sum($allSpans) + count($allSpans)"/>
 						</xsl:otherwise>
 					</xsl:choose>
-					<xsl:attribute name="style:family">table-row</xsl:attribute>
-
-
-					<xsl:element name="style:table-row-properties">
-						<xsl:choose>
-							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height">
-								<xsl:attribute name="style:row-height">
-									<xsl:call-template name="convert2cm">
-										<xsl:with-param name="value" select="concat(./ss:Row[position() = $rowNodeIndex]/@ss:Height,'pt')"/>
-									</xsl:call-template>
-									<xsl:text>cm</xsl:text>
-								</xsl:attribute>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:attribute name="style:row-height">
-									<xsl:value-of select="$default-row-height"/>
-								</xsl:attribute>
-							</xsl:otherwise>
-						</xsl:choose>
-						<xsl:choose>
-							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight = '0'">
-								<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:choose>
-									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height > 0">
-										<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
-									</xsl:otherwise>
-								</xsl:choose>
-							</xsl:otherwise>
-						</xsl:choose>
-						<xsl:attribute name="fo:break-before">page</xsl:attribute>
-						<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)/ss:Interior" mode="style-style-content"/>
-					</xsl:element>
-					<!--
-						<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)" mode="style-style-content" />
-					-->
-				</xsl:element>
-			</xsl:if>
-			<!--
-			<style:style style:name="{concat('ro', $table-pos, '-',$rowNodeIndex)}" style:family="table-row">
-			-->
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:variable name="span-value">
+			<xsl:choose>
+				<xsl:when test="@ss:Index">
+					<xsl:choose>
+						<xsl:when test="@ss:Span">
+							<xsl:value-of select="@ss:Index - $earlierRowNo + @ss:Span"/>
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:value-of select="0"/>
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:choose>
+						<xsl:when test="@ss:Span">
+							<xsl:value-of select="@ss:Span + 1"/>
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:value-of select="0"/>
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+			
+		<xsl:variable name="current-index">
+			<xsl:choose>
+				<xsl:when test="@ss:Index">
+					<xsl:value-of select="@ss:Index - 1"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="$earlierRowNo"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:variable name="row-break">
+			<xsl:choose>
+				<xsl:when test="$span-value = 0">
+					<xsl:if test="../x:PageBreaks/x:RowBreaks/x:RowBreak/x:Row = $current-index">
+						<xsl:value-of select="1"/>
+					</xsl:if>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:if test="../x:PageBreaks/x:RowBreaks[(x:RowBreak/x:Row > $earlierRowNo) and (x:RowBreak/x:Row < ($earlierRowNo + $span-value))]">
+						<xsl:value-of select="1"/>
+					</xsl:if>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:if test="$row-break = 1">
 			<xsl:element name="style:style">
 				<xsl:choose>
-					<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:StyleID">
-						<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-',ss:Row[position() = $rowNodeIndex]/@ss:StyleID)"/></xsl:attribute>
+					<xsl:when test="@ss:StyleID">
+						<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-', at ss:StyleID)"/></xsl:attribute>
 					</xsl:when>
 					<xsl:otherwise>
 						<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex)"/></xsl:attribute>
 					</xsl:otherwise>
 				</xsl:choose>
 				<xsl:attribute name="style:family">table-row</xsl:attribute>
-
-
+				
+				
 				<xsl:element name="style:table-row-properties">
 					<xsl:choose>
-						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height">
+						<xsl:when test="@ss:Height">
 							<xsl:attribute name="style:row-height">
 								<xsl:call-template name="convert2cm">
-									<xsl:with-param name="value" select="concat(./ss:Row[position() = $rowNodeIndex]/@ss:Height,'pt')"/>
+									<xsl:with-param name="value" select="concat(@ss:Height,'pt')"/>
 								</xsl:call-template>
 								<xsl:text>cm</xsl:text>
 							</xsl:attribute>
@@ -5408,19 +5368,12 @@
 						</xsl:otherwise>
 					</xsl:choose>
 					<xsl:choose>
-						<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight">
-							<xsl:choose>
-								<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:AutoFitHeight = '0'">
-									<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
-								</xsl:when>
-								<xsl:otherwise>
-									<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
-								</xsl:otherwise>
-							</xsl:choose>
+						<xsl:when test="@ss:AutoFitHeight = '0'">
+							<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
 						</xsl:when>
 						<xsl:otherwise>
 							<xsl:choose>
-								<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Height > 0">
+								<xsl:when test="@ss:Height > 0">
 									<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
 								</xsl:when>
 								<xsl:otherwise>
@@ -5429,48 +5382,79 @@
 							</xsl:choose>
 						</xsl:otherwise>
 					</xsl:choose>
-					<xsl:attribute name="fo:break-before">auto</xsl:attribute>
-					<!-- apply to background  -->
-					<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)/ss:Interior" mode="style-style-content"/>
+					<xsl:attribute name="fo:break-before">page</xsl:attribute>
+					<xsl:apply-templates select="key('Style', @ss:StyleID)/ss:Interior" mode="style-style-content"/>
 				</xsl:element>
 				<!--
-				<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)" mode="style-style-content" />
+					<xsl:apply-templates select="key('Style', @ss:StyleID)" mode="style-style-content" />
 				-->
 			</xsl:element>
-			<xsl:if test="$rowNodeIndex < $rowNodeCount">
-				<xsl:call-template name="get-row-style-name">
-					<xsl:with-param name="earlierRowNo">
+		</xsl:if>
+		<!--
+			<style:style style:name="{concat('ro', $table-pos, '-',$rowNodeIndex)}" style:family="table-row">
+		-->
+		<xsl:element name="style:style">
+			<xsl:choose>
+				<xsl:when test="@ss:StyleID">
+					<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex,'-', at ss:StyleID)"/></xsl:attribute>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:attribute name="style:name"><xsl:value-of select="concat('ro', $table-pos, '-',$rowNodeIndex)"/></xsl:attribute>
+				</xsl:otherwise>
+			</xsl:choose>
+			<xsl:attribute name="style:family">table-row</xsl:attribute>
+			
+			
+			<xsl:element name="style:table-row-properties">
+				<xsl:choose>
+					<xsl:when test="@ss:Height">
+						<xsl:attribute name="style:row-height">
+							<xsl:call-template name="convert2cm">
+								<xsl:with-param name="value" select="concat(@ss:Height,'pt')"/>
+							</xsl:call-template>
+							<xsl:text>cm</xsl:text>
+						</xsl:attribute>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:attribute name="style:row-height">
+							<xsl:value-of select="$default-row-height"/>
+						</xsl:attribute>
+					</xsl:otherwise>
+				</xsl:choose>
+				<xsl:choose>
+					<xsl:when test="@ss:AutoFitHeight">
 						<xsl:choose>
-							<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Index">
-								<xsl:choose>
-									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
-										<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index + ./ss:Row[position() = $rowNodeIndex]/@ss:Span"/>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:value-of select="./ss:Row[position() = $rowNodeIndex]/@ss:Index"/>
-									</xsl:otherwise>
-								</xsl:choose>
+							<xsl:when test="@ss:AutoFitHeight = '0'">
+								<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
 							</xsl:when>
 							<xsl:otherwise>
-								<xsl:choose>
-									<xsl:when test="./ss:Row[position() = $rowNodeIndex]/@ss:Span">
-										<xsl:value-of select="$earlierRowNo + ./ss:Row[position() = $rowNodeIndex]/@ss:Span + 1"/>
-									</xsl:when>
-									<xsl:otherwise>
-										<xsl:value-of select="$earlierRowNo + 1"/>
-									</xsl:otherwise>
-								</xsl:choose>
+								<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
 							</xsl:otherwise>
 						</xsl:choose>
-					</xsl:with-param>
-					<xsl:with-param name="rowNodeCount" select="$rowNodeCount"/>
-					<xsl:with-param name="rowNodeIndex" select="$rowNodeIndex + 1"/>
-					<xsl:with-param name="table-pos" select="$table-pos"/>
-					<xsl:with-param name="default-row-height" select="$default-row-height"/>
-				</xsl:call-template>
-			</xsl:if>
-		</xsl:if>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:choose>
+							<xsl:when test="@ss:Height > 0">
+								<xsl:attribute name="style:use-optimal-row-height">false</xsl:attribute>
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:attribute name="style:use-optimal-row-height">true</xsl:attribute>
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:otherwise>
+				</xsl:choose>
+				<xsl:attribute name="fo:break-before">auto</xsl:attribute>
+				<!-- apply to background  -->
+				<xsl:apply-templates select="key('Style', @ss:StyleID)/ss:Interior" mode="style-style-content"/>
+			</xsl:element>
+			<!--
+				<xsl:apply-templates select="key('Style', ss:Row[position() = $rowNodeIndex]/@ss:StyleID)" mode="style-style-content" />
+			-->
+		</xsl:element>
+
+		
 	</xsl:template>
+
 	<xsl:template name="count-spanned-columns">
 		<xsl:param name="expandedColumnCount" select="0"/>
 		<xsl:param name="columns"/>
@@ -5582,9 +5566,25 @@
 				<xsl:variable name="condition-pos-str" select="concat($condition-pos-str1, $condition-pos-str2)"/>
 				<xsl:choose>
 					<xsl:when test="./ss:Table/ss:Row">
-						<xsl:call-template name="create-rows">
-							<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
-						</xsl:call-template>
+						<xsl:variable name="worksheetNo" select="count(preceding-sibling::ss:Worksheet)+1"/>
+						<xsl:variable name="rowNodeCount" select="count(ss:Table/ss:Row)"/>
+						<xsl:variable name="expandedRowCount">
+							<xsl:call-template name="get-expanded-row-count"/>
+						</xsl:variable>
+						<xsl:variable name="expandedColumnCount">
+							<xsl:call-template name="get-expanded-column-count"/>
+						</xsl:variable>
+						<xsl:for-each select="ss:Table/ss:Row">
+							<xsl:apply-templates select="." mode="create-rows">
+								<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
+								<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
+								<xsl:with-param name="rowNodeCount" select="$rowNodeCount"/>
+								<xsl:with-param name="rowNodeIndex" select="position()"/>
+								<xsl:with-param name="expandedRowCount" select="$expandedRowCount"/>
+								<xsl:with-param name="expandedRowCountIndex" select="1"/>
+								<xsl:with-param name="expandedColumnCount" select="$expandedColumnCount"/>
+							</xsl:apply-templates>
+						</xsl:for-each>
 					</xsl:when>
 					<xsl:otherwise>
 						<xsl:choose>
@@ -5970,11 +5970,30 @@
 	<xsl:template match="ss:Row" mode="create-rows">
 		<xsl:param name="worksheetNo"/>
 		<xsl:param name="rowNodeCount"/>
-		<xsl:param name="rowNodeIndex" select="1"/>
+		<xsl:param name="rowNodeIndex"/>
 		<xsl:param name="expandedRowCount"/>
-		<xsl:param name="expandedRowCountIndex" select="1"/>
 		<xsl:param name="expandedColumnCount"/>
 		<xsl:param name="condition-pos-str"/>
+		<xsl:variable name="simple-span-value" select="@ss:Span + count(@ss:Span)"/>
+		<xsl:variable name="expandedRowCountIndex">
+				<xsl:choose>
+					<xsl:when test="@ss:Index"><xsl:value-of select="@ss:Index -1 + $simple-span-value"/></xsl:when>
+					<xsl:otherwise>
+						<xsl:variable name="recent-index" select="preceding-sibling::*[@ss:Index][last()]"></xsl:variable>
+						<xsl:choose>
+							<xsl:when test="$recent-index">
+								<xsl:variable name="nodes-up-to-current" select="set:intersection(preceding-sibling::*, $recent-index/following-sibling::*)"></xsl:variable>
+								<xsl:variable name="allSpans" select="$nodes-up-to-current/@ss:Span"/>
+								<xsl:value-of select="$recent-index/@ss:Index + count($nodes-up-to-current) + sum($allSpans) + count($allSpans)"/>
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:variable name="allSpans" select="preceding-sibling::*/@ss:Span"/>
+								<xsl:value-of select="$rowNodeIndex + sum($allSpans) + count($allSpans)"/>
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:otherwise>
+				</xsl:choose>
+		</xsl:variable>
 		<xsl:variable name="currentRowNo">
 			<xsl:choose>
 				<xsl:when test="@ss:Index">
@@ -6026,16 +6045,16 @@
 				<!-- Excel row without content -->
 				<xsl:when test="not(*)">
 					<!-- OASIS OpenDocument Format does not allow rows without a cell -->
-				<xsl:choose>
-					<xsl:when test="$expandedColumnCount != 0">
-						<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
-					</xsl:when>
-					<xsl:otherwise>
-						<!-- OASIS XML row can not be empty -->
-						<table:table-cell table:number-columns-repeated="256"/>
-					</xsl:otherwise>
-				</xsl:choose>
-
+					<xsl:choose>
+						<xsl:when test="$expandedColumnCount != 0">
+							<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
+						</xsl:when>
+						<xsl:otherwise>
+							<!-- OASIS XML row can not be empty -->
+							<table:table-cell table:number-columns-repeated="256"/>
+						</xsl:otherwise>
+					</xsl:choose>
+					
 				</xsl:when>
 				<xsl:otherwise>
 					<xsl:call-template name="create-cells">
@@ -6046,53 +6065,9 @@
 				</xsl:otherwise>
 			</xsl:choose>
 		</xsl:element>
-		<!-- columns are painting over the expanded RowCount -->
-		<xsl:choose>
-			<xsl:when test="count(following-sibling::ss:Row) != 0">
-				<xsl:apply-templates select="following-sibling::ss:Row[1]" mode="create-rows">
-					<xsl:with-param name="worksheetNo" select="$worksheetNo"/>
-					<xsl:with-param name="rowNodeCount" select="$rowNodeCount"/>
-					<xsl:with-param name="rowNodeIndex" select="$rowNodeIndex + 1"/>
-					<xsl:with-param name="expandedRowCount" select="$expandedRowCount"/>
-					<xsl:with-param name="expandedRowCountIndex">
-						<xsl:choose>
-							<xsl:when test="@ss:Index and @ss:Span">
-								<xsl:value-of select="@ss:Index + @ss:Span + 1"/>
-							</xsl:when>
-							<xsl:when test="@ss:Index">
-								<xsl:value-of select="@ss:Index + 1"/>
-							</xsl:when>
-							<xsl:when test="@ss:Span">
-								<xsl:value-of select="$expandedRowCountIndex + @ss:Span + 1"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:value-of select="$expandedRowCountIndex + 1"/>
-							</xsl:otherwise>
-						</xsl:choose>
-					</xsl:with-param>
-					<xsl:with-param name="expandedColumnCount" select="$expandedColumnCount"/>
-					<xsl:with-param name="condition-pos-str" select="$condition-pos-str"/>
-				</xsl:apply-templates>
-			</xsl:when>
-			<xsl:when test="$currentRowNo < 65536">
-				<xsl:element name="table:table-row">
-					<!-- fill the preceding gap with rows without a cell -->
-					<xsl:attribute name="table:number-rows-repeated">
-						<xsl:value-of select="65536 - $currentRowNo"/>
-					</xsl:attribute>
-					<xsl:choose>
-						<xsl:when test="$expandedColumnCount != 0">
-							<table:table-cell table:number-columns-repeated="{$expandedColumnCount}"/>
-						</xsl:when>
-						<xsl:otherwise>
-							<!-- OASIS XML row can not be empty -->
-							<table:table-cell table:number-columns-repeated="256"/>
-						</xsl:otherwise>
-					</xsl:choose>
-				</xsl:element>
-			</xsl:when>
-		</xsl:choose>
+		
 	</xsl:template>
+
 	<xsl:template name="get-expanded-column-count">
 		<xsl:choose>
 			<xsl:when test="ss:Table/@ss:ExpandedColumnCount">
commit 8fdef3e8d8ead3903795df87cbf66256691542b1
Author: Peter Jentsch <pjotr at guineapics.de>
Date:   Tue May 1 00:16:34 2012 +0200

    optimized handling of ConditionalFormatting elements
    
    Removed ill-performing key definitions.
    Also fixes bug with bogus expression quoting within formatting conditions.
    
    Change-Id: Iab9b26f30ac7f780acb8a4e1397aaf2f4fa490f4

diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index 71f1baa..cd223f8 100644
--- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -764,117 +764,122 @@
 			</xsl:otherwise>
 		</xsl:choose>
 	</xsl:template>
-	<xsl:key match="/ss:Workbook/ss:Worksheet/ss:Table" name="tableWithConditional" use="following-sibling::x:ConditionalFormatting"/>
-	<xsl:key match="ss:Table/ss:Row/ss:Cell/@ss:StyleID" name="tableStyleIDs" use="ancestor::ss:Table"/>
+	
+	<xsl:key name="definedStyleIds" match="/ss:Workbook/ss:Styles/ss:Style/@ss:ID" use="string(.)"/>
+	<xsl:variable name="defaultStyle" select="/ss:Workbook/ss:Styles/ss:Style[@ss:ID='Default']/@ss:ID"></xsl:variable>
 	<xsl:key name="styleId" match="@ss:StyleID" use="."/>
 	<xsl:template name="CondFormat_automatic_style">
 		<!-- For each conditionalFormatting We inject a new style, which is a child of the current found style -->
-		<xsl:for-each select="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
-			<xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
-			<xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
-			<xsl:variable name="conditionalFormatting" select="."/>
-			<!-- for all 'ssStyle/@ss:ID's, which are in tables connected within this conditional formatting  -->
-			<xsl:for-each select="key('tableStyleIDs', key('tableWithConditional', .)) [generate-id(.) = generate-id(key('styleId', .)[1])] ">
-				<!-- sort the style ID by their naming -->
-				<xsl:sort select="."/>
-				<xsl:element name="style:style">
-					<xsl:attribute name="style:name">
-						<xsl:call-template name="encode-as-nc-name">
-							<xsl:with-param name="string" select="concat(.,'-ce',$table-pos,'-',$conditions)"/>
-						</xsl:call-template>
-					</xsl:attribute>
-					<xsl:attribute name="style:family">table-cell</xsl:attribute>
-					<xsl:variable name="style" select="key('Style', .)" />
-					<xsl:choose>
-						<xsl:when test="$style/@ss:Name">
-							<xsl:attribute name="style:parent-style-name">
-								<xsl:call-template name="encode-as-nc-name">
-									<xsl:with-param name="string" select="."/>
+		<xsl:for-each select="/ss:Workbook/ss:Worksheet[x:ConditionalFormatting]">
+			<xsl:variable name="table-pos" select="count(preceding-sibling::ss:Worksheet)+1"/>
+			<xsl:variable name="styleIdsUsedByTable" select="$defaultStyle | key('definedStyleIds', ss:Table/ss:Row/ss:Cell/@ss:StyleID)"/>
+			<xsl:for-each select="x:ConditionalFormatting">
+				<xsl:variable name="conditions" select="position()"/>
+				<xsl:variable name="conditionalFormatting" select="."/>
+				<!-- we want to loop over the distinct styleId attribute values of all cells within the table related to the current conditional formatting. -->
+				<!-- We'd need to add the anonymous style id "Default" to the mix. -->
+				<!-- for all 'ssStyle/@ss:ID's, which are in tables connected within this conditional formatting  -->
+				<!-- <xsl:for-each select="key('tableStyleIDs', generate-id(preceding-sibling::ss:Table)) [generate-id(.) = generate-id(key('styleId', .)[1])] "> -->
+				<xsl:for-each select="$styleIdsUsedByTable">
+					<xsl:element name="style:style">
+						<xsl:attribute name="style:name">
+							<xsl:call-template name="encode-as-nc-name">
+								<xsl:with-param name="string" select="concat(.,'-ce',$table-pos,'-',$conditions)"/>
+							</xsl:call-template>
+						</xsl:attribute>
+						<xsl:attribute name="style:family">table-cell</xsl:attribute>
+						<xsl:variable name="style" select="key('Style', .)" />
+						<xsl:choose>
+							<xsl:when test="$style/@ss:Name">
+								<xsl:attribute name="style:parent-style-name">
+									<xsl:call-template name="encode-as-nc-name">
+										<xsl:with-param name="string" select="."/>
+									</xsl:call-template>
+								</xsl:attribute>
+							</xsl:when>
+							<!-- as we create an automatic style, the parent is not allowed to be an automatic style as well
+								if the parent would be a automatic (unnamed) style, the style information have to be embedded to this style -->
+							<xsl:otherwise>
+								<xsl:attribute name="style:parent-style-name">
+									<xsl:call-template name="encode-as-nc-name">
+										<xsl:with-param name="string" select="$style/@ss:Parent"/>
+									</xsl:call-template>
+								</xsl:attribute>
+								<xsl:if test="$style/ss:NumberFormat/@ss:Format">
+									<xsl:attribute name="style:data-style-name">
+										<xsl:value-of select="concat($style/@ss:ID, 'F')"/>
+									</xsl:attribute>
+								</xsl:if>
+								<xsl:apply-templates select="$style" mode="style-style-content"/>
+							</xsl:otherwise>
+						</xsl:choose>
+						<xsl:for-each select="$conditionalFormatting/x:Condition">
+							<xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
+							<xsl:variable name="base-address">
+								<xsl:choose>
+									<xsl:when test="contains(../x:Range,',')">
+										<xsl:choose>
+											<xsl:when test="contains(substring-before(../x:Range,','),':')">
+												<xsl:value-of select="substring-before(substring-after(../x:Range,':'),',')"/>
+											</xsl:when>
+											<xsl:otherwise>
+												<xsl:value-of select="substring-before(../x:Range,',')"/>
+											</xsl:otherwise>
+										</xsl:choose>
+									</xsl:when>
+									<xsl:otherwise>
+										<xsl:value-of select="../x:Range"/>
+									</xsl:otherwise>
+								</xsl:choose>
+							</xsl:variable>
+							<xsl:variable name="columnNumber">
+								<xsl:choose>
+									<xsl:when test="contains($base-address, ':')">
+										<xsl:value-of select="substring-after(substring-after($base-address, ':'),'C')"/>
+									</xsl:when>
+									<xsl:otherwise>
+										<xsl:value-of select="substring-after($base-address,'C')"/>
+									</xsl:otherwise>
+								</xsl:choose>
+							</xsl:variable>
+							<xsl:variable name="rowNumber">
+								<xsl:choose>
+									<xsl:when test="contains($base-address, ':')">
+										<xsl:value-of select="substring-before(substring-after(substring-after($base-address, ':'),'R'),'C')"/>
+									</xsl:when>
+									<xsl:otherwise>
+										<xsl:value-of select="substring-before(substring-after($base-address,'R'),'C')"/>
+									</xsl:otherwise>
+								</xsl:choose>
+							</xsl:variable>
+							<xsl:variable name="base-cell-address">
+								<xsl:call-template name="translate-unit">
+									<xsl:with-param name="column-number" select="$columnNumber"/>
+									<xsl:with-param name="row-number" select="$rowNumber"/>
+									<xsl:with-param name="column-pos-style" select="'relative'"/>
+									<xsl:with-param name="row-pos-style" select="'relative'"/>
 								</xsl:call-template>
-							</xsl:attribute>
-						</xsl:when>
-						<!-- as we create an automatic style, the parent is not allowed to be an automatic style as well
-							 if the parent would be a automatic (unnamed) style, the style information have to be embedded to this style -->
-						<xsl:otherwise>
-							<xsl:attribute name="style:parent-style-name">
-								<xsl:call-template name="encode-as-nc-name">
-									<xsl:with-param name="string" select="$style/@ss:Parent"/>
+							</xsl:variable>
+							<xsl:variable name="condition-value">
+								<xsl:call-template name="translate-condition">
+									<xsl:with-param name="cell-column-pos" select="$columnNumber"/>
+									<xsl:with-param name="cell-row-pos" select="$rowNumber"/>
 								</xsl:call-template>
-							</xsl:attribute>
-							<xsl:if test="$style/ss:NumberFormat/@ss:Format">
-								<xsl:attribute name="style:data-style-name">
-									<xsl:value-of select="concat($style/@ss:ID, 'F')"/>
+							</xsl:variable>
+							<xsl:element name="style:map">
+								<xsl:attribute name="style:condition">
+									<xsl:value-of select="$condition-value"/>
 								</xsl:attribute>
-							</xsl:if>
-							<xsl:apply-templates select="$style" mode="style-style-content"/>
-						</xsl:otherwise>
-					</xsl:choose>
-					<xsl:for-each select="$conditionalFormatting/x:Condition">
-						<xsl:variable name="condition-number" select="count(preceding-sibling::x:Condition)+1"/>
-						<xsl:variable name="base-address">
-							<xsl:choose>
-								<xsl:when test="contains(../x:Range,',')">
-									<xsl:choose>
-										<xsl:when test="contains(substring-before(../x:Range,','),':')">
-											<xsl:value-of select="substring-before(substring-after(../x:Range,':'),',')"/>
-										</xsl:when>
-										<xsl:otherwise>
-											<xsl:value-of select="substring-before(../x:Range,',')"/>
-										</xsl:otherwise>
-									</xsl:choose>
-								</xsl:when>
-								<xsl:otherwise>
-									<xsl:value-of select="../x:Range"/>
-								</xsl:otherwise>
-							</xsl:choose>
-						</xsl:variable>
-						<xsl:variable name="columnNumber">
-							<xsl:choose>
-								<xsl:when test="contains($base-address, ':')">
-									<xsl:value-of select="substring-after(substring-after($base-address, ':'),'C')"/>
-								</xsl:when>
-								<xsl:otherwise>
-									<xsl:value-of select="substring-after($base-address,'C')"/>
-								</xsl:otherwise>
-							</xsl:choose>
-						</xsl:variable>
-						<xsl:variable name="rowNumber">
-							<xsl:choose>
-								<xsl:when test="contains($base-address, ':')">
-									<xsl:value-of select="substring-before(substring-after(substring-after($base-address, ':'),'R'),'C')"/>
-								</xsl:when>
-								<xsl:otherwise>
-									<xsl:value-of select="substring-before(substring-after($base-address,'R'),'C')"/>
-								</xsl:otherwise>
-							</xsl:choose>
-						</xsl:variable>
-						<xsl:variable name="base-cell-address">
-							<xsl:call-template name="translate-unit">
-								<xsl:with-param name="column-number" select="$columnNumber"/>
-								<xsl:with-param name="row-number" select="$rowNumber"/>
-								<xsl:with-param name="column-pos-style" select="'relative'"/>
-								<xsl:with-param name="row-pos-style" select="'relative'"/>
-							</xsl:call-template>
-						</xsl:variable>
-						<xsl:variable name="condition-value">
-							<xsl:call-template name="translate-condition">
-								<xsl:with-param name="cell-column-pos" select="$columnNumber"/>
-								<xsl:with-param name="cell-row-pos" select="$rowNumber"/>
-							</xsl:call-template>
-						</xsl:variable>
-						<xsl:element name="style:map">
-							<xsl:attribute name="style:condition">
-								<xsl:value-of select="$condition-value"/>
-							</xsl:attribute>
-							<xsl:attribute name="style:apply-style-name">
-								<xsl:value-of select="concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)"/>
-							</xsl:attribute>
-							<xsl:attribute name="style:base-cell-address">
-								<xsl:value-of select="concat(../../@ss:Name,'.',$base-cell-address)"/>
-							</xsl:attribute>
-						</xsl:element>
-					</xsl:for-each>
-				</xsl:element>
+								<xsl:attribute name="style:apply-style-name">
+									<xsl:value-of select="concat('Excel_CondFormat_',$table-pos,'_',$conditions,'_',$condition-number)"/>
+								</xsl:attribute>
+								<xsl:attribute name="style:base-cell-address">
+									<xsl:value-of select="concat(../../@ss:Name,'.',$base-cell-address)"/>
+								</xsl:attribute>
+							</xsl:element>
+						</xsl:for-each>
+					</xsl:element>
+				</xsl:for-each>				
 			</xsl:for-each>
 		</xsl:for-each>
 	</xsl:template>
@@ -895,31 +900,6 @@
 				<xsl:variable name="qualifier" select="x:Qualifier"/>
 				<xsl:variable name="first-value" select="x:Value1"/>
 				<xsl:choose>
-					<xsl:when test="$qualifier = 'Equal'">
-						<xsl:choose>
-							<xsl:when test="starts-with($first-value,'"')">
-								<xsl:value-of select="concat('cell-content()=',$address-value)"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:value-of select="concat('cell-content()=[',$address-value,']')"/>
-							</xsl:otherwise>
-						</xsl:choose>
-					</xsl:when>
-					<xsl:when test="$qualifier = 'Less'">
-						<xsl:value-of select="concat('cell-content()<[',$address-value,']')"/>
-					</xsl:when>
-					<xsl:when test="$qualifier = 'Greater'">
-						<xsl:value-of select="concat('cell-content()>[',$address-value,']')"/>
-					</xsl:when>
-					<xsl:when test="$qualifier = 'LessOrEqual'">
-						<xsl:value-of select="concat('cell-content()<=[',$address-value,']')"/>
-					</xsl:when>
-					<xsl:when test="$qualifier = 'GreaterOrEqual'">
-						<xsl:value-of select="concat('cell-content()>=[',$address-value,']')"/>
-					</xsl:when>
-					<xsl:when test="$qualifier = 'NotEqual'">
-						<xsl:value-of select="concat('cell-content()!=[',$address-value,']')"/>
-					</xsl:when>
 					<xsl:when test="$qualifier = 'Between'">
 						<xsl:variable name="second-value">
 							<xsl:call-template name="translate-expression">
@@ -929,7 +909,7 @@
 								<xsl:with-param name="return-value" select="''"/>
 							</xsl:call-template>
 						</xsl:variable>
-						<xsl:value-of select="concat('cell-content-is-between([',$address-value,'],[',$second-value,'])')"/>
+						<xsl:value-of select="concat('cell-content-is-between(',$address-value,',',$second-value,')')"/>
 					</xsl:when>
 					<xsl:when test="$qualifier = 'NotBetween'">
 						<xsl:variable name="second-value">
@@ -940,8 +920,22 @@
 								<xsl:with-param name="return-value" select="''"/>
 							</xsl:call-template>
 						</xsl:variable>
-						<xsl:value-of select="concat('cell-content-is-not-between([',$address-value,'],[',$second-value,'])')"/>
+						<xsl:value-of select="concat('cell-content-is-not-between(',$address-value,',',$second-value,')')"/>
 					</xsl:when>
+					<xsl:otherwise>
+						<xsl:variable name="translatedQualifier">
+							<xsl:choose>
+								<xsl:when test="$qualifier = 'Equal'">=</xsl:when>
+								<xsl:when test="$qualifier = 'Less'"><</xsl:when>
+								<xsl:when test="$qualifier = 'Greater'">></xsl:when>
+								<xsl:when test="$qualifier = 'LessOrEqual'"><=</xsl:when>
+								<xsl:when test="$qualifier = 'GreaterOrEqual'">>=</xsl:when>
+								<xsl:when test="$qualifier = 'NotEqual'">!=</xsl:when>
+							</xsl:choose>
+						</xsl:variable>
+						<xsl:value-of select="concat('cell-content()', $translatedQualifier, $address-value)"/>
+					</xsl:otherwise>
+					
 				</xsl:choose>
 			</xsl:when>
 			<xsl:otherwise>


More information about the Libreoffice-commits mailing list