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

List:       koffice-devel
Subject:    Patch for KSpread
From:       Philipp =?iso-8859-1?q?M=FCller?= <philipp.mueller () gmx ! de>
Date:       2002-02-28 23:21:58
[Download RAW message or body]

Following patch adresses 2 issues:

1. Row limitation:
Rows were limited by 10000 lines (see also BR 11819):

I don't know if all the changes were realy necessary, but from my point all 
are obvious:
file kspread_canvas.cc: Limitation should be more than 9999 lines/columns

file kspread_cluster.h: This is the main reason for the limitation. 

file kspread/kspread_layout.cc: Again a limitation by 10000

file kspread_table.cc: Don't know if this part is necessary, but I think 
int=0x10000 is wrong, it should be maximum int=0xFFFF.
But this should be left to one, that knows the difference better.
Even in the worst case 0x8000 should already be the end.

2. Limitation of column labels:
file: kspread_util.cc
I already sent this to the koffice mailing list and still think, that this 
single part doesn't have an logical influence on the other part of the code.
Again this patch makes only possible that this routine can generate senseful 
text labels for values > 26*26. It can now generate texts for values up to 
2^16 values, even if it is limited by code to 2^15.

Please apply.

Philipp

["kspread_patch.diff" (text/x-diff)]

Index: kspread/kspread_canvas.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_canvas.cc,v
retrieving revision 1.217
diff -u -3 -p -u -r1.217 kspread_canvas.cc
--- kspread/kspread_canvas.cc	2002/02/08 16:22:15	1.217
+++ kspread/kspread_canvas.cc	2002/02/28 22:53:22
@@ -2239,8 +2239,8 @@ void KSpreadCanvas::updateSelection( con
     QRect uni = old_sel.unite( new_sel ).unite( old_outer ).unite( old_marker \
).unite( new_marker );

     // Limit the number of cells
-    uni.rBottom() = QMIN( 9999, uni.bottom() );
-    uni.rRight() = QMIN( 9999, uni.right() );
+    uni.rBottom() = QMIN( 0x7FFF, uni.bottom() );
+    uni.rRight() = QMIN( 0x7FFF, uni.right() );

     //qDebug("UNI left/top :%i/%i right/bottom :%i/%i", uni.left(), uni.top(), \
uni.right(), uni.bottom() );

Index: kspread/kspread_cluster.h
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_cluster.h,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 kspread_cluster.h
--- kspread/kspread_cluster.h	2000/07/13 19:35:01	1.4
+++ kspread/kspread_cluster.h	2002/02/28 22:53:22
@@ -7,9 +7,10 @@ class RowLayout;

 class QPoint;

-#define KSPREAD_CLUSTER_LEVEL1 100
-#define KSPREAD_CLUSTER_LEVEL2 100
-#define KSPREAD_CLUSTER_MAX (100*100)
+#define KSPREAD_CLUSTER_LEVEL1 256
+#define KSPREAD_CLUSTER_LEVEL2 256
+/* KSPREAD_CLUSTER_MAX is CURRENTLY 2^15 only, so it's 256*256 divided by 2 */
+#define KSPREAD_CLUSTER_MAX (256*256/2)

 class KSpreadCluster
 {
Index: kspread/kspread_layout.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_layout.cc,v
retrieving revision 1.68
diff -u -3 -p -u -r1.68 kspread_layout.cc
--- kspread/kspread_layout.cc	2001/10/25 08:35:26	1.68
+++ kspread/kspread_layout.cc	2002/02/28 22:53:22
@@ -1757,7 +1757,7 @@ bool RowLayout::load( const QDomElement&
 	kdDebug(36001) << "Value height=" << m_fHeight << " out of range" << endl;
 	return false;
     }
-    if ( m_iRow < 1 || m_iRow >= 10000 )
+    if ( m_iRow < 1 || m_iRow >= 0x7FFF )
     {
 	kdDebug(36001) << "Value row=" << m_iRow << " out of range" << endl;
 	return false;
@@ -1934,7 +1934,7 @@ bool ColumnLayout::load( const QDomEleme
 	kdDebug(36001) << "Value width=" << m_fWidth << " out of range" << endl;
 	return false;
     }
-    if ( m_iColumn < 1 || m_iColumn >= 10000 )
+    if ( m_iColumn < 1 || m_iColumn >= 0x7FFF )
     {
 	kdDebug(36001) << "Value col=" << m_iColumn << " out of range" << endl;
 	return false;
Index: kspread/kspread_table.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_table.cc,v
retrieving revision 1.315
diff -u -3 -p -u -r1.315 kspread_table.cc
--- kspread/kspread_table.cc	2002/02/26 13:36:22	1.315
+++ kspread/kspread_table.cc	2002/02/28 22:53:25
@@ -274,7 +274,7 @@ int KSpreadTable::leftColumn( int _xpos,
     while ( x < _xpos )
     {
         // Should never happen
-        if ( col == 0x10000 )
+        if ( col == 0x8000 )
             return 1;
         _left += columnLayout( col )->width( _canvas );
         col++;
@@ -294,8 +294,8 @@ int KSpreadTable::rightColumn( int _xpos
     while ( x < _xpos )
     {
         // Should never happen
-        if ( col == 0x10000 )
-            return 0x10000;
+        if ( col == 0x8000 )
+            return 0x8000;
         x += columnLayout( col )->width( _canvas );
         col++;
     }
@@ -318,7 +318,7 @@ int KSpreadTable::topRow( int _ypos, int
     while ( y < _ypos )
     {
         // Should never happen
-        if ( row == 0x10000 )
+        if ( row == 0x8000 )
             return 1;
         _top += rowLayout( row )->height( _canvas );
         row++;
@@ -338,8 +338,8 @@ int KSpreadTable::bottomRow( int _ypos,
     while ( y < _ypos )
     {
         // Should never happen
-        if ( row == 0x10000 )
-            return 0x10000;
+        if ( row == 0x8000 )
+            return 0x8000;
         y += rowLayout( row )->height( _canvas );
         row++;
     }
@@ -355,7 +355,7 @@ int KSpreadTable::columnPos( int _col, K
     for ( int col = 1; col < _col; col++ )
     {
         // Should never happen
-        if ( col == 0x10000 )
+        if ( col == 0x8000 )
             return x;

         x += columnLayout( col )->width( _canvas );
@@ -372,7 +372,7 @@ int KSpreadTable::rowPos( int _row, KSpr
     for ( int row = 1 ; row < _row ; row++ )
     {
         // Should never happen
-        if ( row == 0x10000 )
+        if ( row == 0x8000 )
             return y;

         y += rowLayout( row )->height( _canvas );
@@ -5039,7 +5039,7 @@ bool KSpreadTable::isOnNewPageX( int _co
     while ( col <= _column )
     {
         // Should never happen
-        if ( col == 0x10000 )
+        if ( col == 0x8000 )
             return FALSE;

         if ( x > m_pDoc->printableWidth() )
@@ -5064,7 +5064,7 @@ bool KSpreadTable::isOnNewPageY( int _ro
     while ( row <= _row )
     {
         // Should never happen
-        if ( row == 0x10000 )
+        if ( row == 0x8000 )
             return FALSE;

         if ( y > m_pDoc->printableHeight() )
Index: kspread/kspread_util.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_util.cc,v
retrieving revision 1.26
diff -u -3 -p -u -r1.26 kspread_util.cc
--- kspread/kspread_util.cc	2001/10/11 13:55:20	1.26
+++ kspread/kspread_util.cc	2002/02/28 22:53:25
@@ -268,14 +268,33 @@ util_dateFormat(KLocale * locale, QDate

 QString util_columnLabel(int column)
 {
-    if (column <= 26)
-	return QString("%1").arg((char) ('A' + column - 1));
+    int tmp;

-    if (column <= 26 * 26)
-	return QString("%1%2").arg((char)('A' + ((column - 1) / 26) - 1)).arg((char)('A' +
-								      ((column - 1) % 26)));
+    /* we start with zero */
+    tmp = column - 1;

-    /* limit is 26*26 */
+    if (tmp < 26) /* A-Z */
+	return QString("%1").arg((char) ('A' + tmp));
+
+    tmp -= 26;
+    if (tmp < 26*26) /* AA-ZZ */
+	return QString("%1%2").arg( (char) ('A' + tmp / 26) )
+			      .arg( (char) ('A' + tmp % 26) );
+
+    tmp -= 26*26;
+    if (tmp < 26 * 26 * 26 ) /* AAA-ZZZ */
+	return QString("%1%2%3").arg( (char) ('A' + tmp / (26 * 26)) )
+				.arg( (char) ('A' + (tmp / 26) % 26 ) )
+				.arg( (char) ('A' + tmp % 26) );
+
+    tmp -= 26*26*26;
+    if (tmp < 26 * 26 * 26 * 26) /* AAAA-ZZZZ */
+	return QString("%1%2%3%4").arg( (char) ('A' + (tmp / (26 * 26 * 26 )      ) ))
+				  .arg( (char) ('A' + (tmp / (26 * 26      ) % 26 ) ))
+				  .arg( (char) ('A' + (tmp / (26           ) % 26 ) ))
+				  .arg( (char) ('A' + (tmp                   % 26 ) ));
+
+    /* limit is currently 26^4 + 26^3 + 26^2 + 26^1 = 475254 */
     kdDebug(36001) << "invalid column\n";
     return QString("@@@");
 }


_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://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