[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    branches/koffice/1.5/koffice/kspread trunk/koffice/kspread
From:       Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date:       2006-03-26 13:10:27
Message-ID: 1143378627.119711.11478.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 522682 by nikolaus:

OpenDocument	Minor loading speedup
			Don't process rows/columns, which are out of scope for
			KSpread. This was already in. Copied to further places.

			KSpread's table size is 32768x32768, OO.o Calc's
			256x65536 and there might be other spreadsheet apps,
			that implement other fixed table sizes.
			KSpread do not preserve the data of a file, which cannot
			be processed. The truncation to the table size of
			KSpread means, that data loss is possible.
			The OpenDocument spec says nothing about this.
			We should at least warn our users, that data of a file
			with more rows/columns as KSpread support will be lost
			on saving.
			A better approach will be a dynamic table size, but with
			the current design this is not possible.
CCMAIL: koffice-devel@kde.org


 M  +20 -9     branches/koffice/1.5/koffice/kspread/kspread_sheet.cc  
 M  +20 -9     trunk/koffice/kspread/kspread_sheet.cc  


--- branches/koffice/1.5/koffice/kspread/kspread_sheet.cc #522681:522682
@@ -6412,7 +6412,10 @@
     int rowIndex = 1;
     int indexCol = 1;
     QDomNode rowNode = sheetElement.firstChild();
-    while( !rowNode.isNull() )
+    // Some spreadsheet programs may support more rows than
+    // KSpread so limit the number of repeated rows.
+    // FIXME POSSIBLE DATA LOSS!
+    while( !rowNode.isNull() && indexCol <= KS_colMax && rowIndex <= KS_rowMax )
     {
         kdDebug()<<" rowIndex :"<<rowIndex<<" indexCol :"<<indexCol<<endl;
         QDomElement rowElement = rowNode.toElement();
@@ -6663,9 +6666,12 @@
     if ( column.hasAttributeNS( KoXmlNS::table, "number-columns-repeated" ) )
     {
         bool ok = true;
-        number = column.attributeNS( KoXmlNS::table, "number-columns-repeated", \
                QString::null ).toInt( &ok );
-        if ( !ok )
-            number = 1;
+        int n = column.attributeNS( KoXmlNS::table, "number-columns-repeated", \
QString::null ).toInt( &ok ); +        if ( ok )
+          // Some spreadsheet programs may support more rows than KSpread so
+          // limit the number of repeated rows.
+          // FIXME POSSIBLE DATA LOSS!
+          number = QMIN( n, KS_colMax - indexCol + 1 );
         kdDebug() << "Repeated: " << number << endl;
     }
 
@@ -6782,8 +6788,10 @@
         bool ok = true;
         int n = row.attributeNS( KoXmlNS::table, "number-rows-repeated", \
QString::null ).toInt( &ok );  if ( ok )
-	    //Some spreadsheet programs may support more rows than KSpread so limit the \
                number of repeated rows
-            number = min(n,KS_rowMax);
+            // Some spreadsheet programs may support more rows than KSpread so
+            // limit the number of repeated rows.
+            // FIXME POSSIBLE DATA LOSS!
+            number = QMIN( n, KS_rowMax - rowIndex + 1 );
     }
     bool collapse = false;
     if ( row.hasAttributeNS( KoXmlNS::table, "visibility" ) )
@@ -6864,10 +6872,13 @@
                 if( (number > 1) || cellElement.hasAttributeNS( KoXmlNS::table, \
"number-columns-repeated" ) )  {
                     bool ok = false;
-                    cols = cellElement.attributeNS( KoXmlNS::table, \
"number-columns-repeated", QString::null ).toInt( &ok ); +                    int n = \
cellElement.attributeNS( KoXmlNS::table, "number-columns-repeated", QString::null \
).toInt( &ok );  
-		    if (!ok)
-			    cols = 1;
+                    if (ok)
+                      // Some spreadsheet programs may support more rows than
+                      // KSpread so limit the number of repeated rows.
+                      // FIXME POSSIBLE DATA LOSS!
+                      cols = QMIN( n, KS_colMax - columnIndex + 1 );
 
 		    if ( !haveStyle && ( cell->isEmpty() && cell->format()->comment( columnIndex, \
backupRow ).isEmpty() ) )  {
--- trunk/koffice/kspread/kspread_sheet.cc #522681:522682
@@ -6412,7 +6412,10 @@
     int rowIndex = 1;
     int indexCol = 1;
     QDomNode rowNode = sheetElement.firstChild();
-    while( !rowNode.isNull() )
+    // Some spreadsheet programs may support more rows than
+    // KSpread so limit the number of repeated rows.
+    // FIXME POSSIBLE DATA LOSS!
+    while( !rowNode.isNull() && indexCol <= KS_colMax && rowIndex <= KS_rowMax )
     {
         kdDebug()<<" rowIndex :"<<rowIndex<<" indexCol :"<<indexCol<<endl;
         QDomElement rowElement = rowNode.toElement();
@@ -6663,9 +6666,12 @@
     if ( column.hasAttributeNS( KoXmlNS::table, "number-columns-repeated" ) )
     {
         bool ok = true;
-        number = column.attributeNS( KoXmlNS::table, "number-columns-repeated", \
                QString::null ).toInt( &ok );
-        if ( !ok )
-            number = 1;
+        int n = column.attributeNS( KoXmlNS::table, "number-columns-repeated", \
QString::null ).toInt( &ok ); +        if ( ok )
+          // Some spreadsheet programs may support more rows than KSpread so
+          // limit the number of repeated rows.
+          // FIXME POSSIBLE DATA LOSS!
+          number = QMIN( n, KS_colMax - indexCol + 1 );
         kdDebug() << "Repeated: " << number << endl;
     }
 
@@ -6782,8 +6788,10 @@
         bool ok = true;
         int n = row.attributeNS( KoXmlNS::table, "number-rows-repeated", \
QString::null ).toInt( &ok );  if ( ok )
-	    //Some spreadsheet programs may support more rows than KSpread so limit the \
                number of repeated rows
-            number = min(n,KS_rowMax);
+            // Some spreadsheet programs may support more rows than KSpread so
+            // limit the number of repeated rows.
+            // FIXME POSSIBLE DATA LOSS!
+            number = QMIN( n, KS_rowMax - rowIndex + 1 );
     }
     bool collapse = false;
     if ( row.hasAttributeNS( KoXmlNS::table, "visibility" ) )
@@ -6864,10 +6872,13 @@
                 if( (number > 1) || cellElement.hasAttributeNS( KoXmlNS::table, \
"number-columns-repeated" ) )  {
                     bool ok = false;
-                    cols = cellElement.attributeNS( KoXmlNS::table, \
"number-columns-repeated", QString::null ).toInt( &ok ); +                    int n = \
cellElement.attributeNS( KoXmlNS::table, "number-columns-repeated", QString::null \
).toInt( &ok );  
-		    if (!ok)
-			    cols = 1;
+                    if (ok)
+                      // Some spreadsheet programs may support more rows than
+                      // KSpread so limit the number of repeated rows.
+                      // FIXME POSSIBLE DATA LOSS!
+                      cols = QMIN( n, KS_colMax - columnIndex + 1 );
 
 		    if ( !haveStyle && ( cell->isEmpty() && cell->format()->comment( columnIndex, \
backupRow ).isEmpty() ) )  {
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic