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

List:       koffice-devel
Subject:    [Patch] Autofill
From:       Lenny <kudling () kde ! org>
Date:       2002-01-12 15:42:28
[Download RAW message or body]

> I believe he means that selecting a range in kspread from bottom right =
to
> top left does not always copy the contents and selecting from top left
> to bottom right does.

Hm, this patch works for me. Can anyone comment about it's (in-)saneness?

Lenny

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

Index: kspread_autofill.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_autofill.cc,v
retrieving revision 1.28
diff -u -b -p -r1.28 kspread_autofill.cc
--- kspread_autofill.cc	2001/12/15 12:56:22	1.28
+++ kspread_autofill.cc	2002/01/12 15:40:15
@@ -381,53 +381,43 @@ void AutoFillSequence::fillCell( KSpread
 
 void KSpreadTable::autofill( QRect &src, QRect &dest )
 {
-    if(src==dest || ( src.right() >= dest.right() &&  src.bottom() >= dest.bottom()))
+    if(src==dest)
         return;
+
     if ( !m_pDoc->undoBuffer()->isLocked() )
         {
             KSpreadUndoAutofill *undo = new KSpreadUndoAutofill( m_pDoc, this, dest );
             m_pDoc->undoBuffer()->appendUndo( undo );
         }
-    // Fill from left to right
-    if ( src.left() == dest.left() && src.right() < dest.right() )
-    {
-        for ( int y = src.top(); y <= src.bottom(); y++ )
-        {
+
+	const int start_x = QMIN( dest.right(), dest.left() );
+	const int end_x   = QMAX( dest.right(), dest.left() );
+	const int start_y = QMIN( dest.bottom(), dest.top() );
+	const int end_y   = QMAX( dest.bottom(), dest.top() );
+
             int x;
-            QPtrList<KSpreadCell> destList;
-            for ( x = src.right() + 1; x <= dest.right(); x++ )
-                destList.append( nonDefaultCell( x, y ) );
+	int y;
+
             QPtrList<KSpreadCell> srcList;
-            for ( x = src.left(); x <= src.right(); x++ )
-                srcList.append( cellAt( x, y ) );
+	QPtrList<KSpreadCell> destList;
             QPtrList<AutoFillSequence> seqList;
-            seqList.setAutoDelete( TRUE );
-            for ( x = src.left(); x <= src.right(); x++ )
-                seqList.append( new AutoFillSequence( cellAt( x, y ) ) );
-            fillSequence( srcList, destList, seqList );
-        }
+
+	for ( y = src.top(); y <= src.bottom(); ++y )
+	{
+		for ( x = src.left(); x <= src.right(); ++x )
+			srcList.append( cellAt( x, y ) );
     }
 
-    // Fill from top to bottom
-    if ( src.top() == dest.top() && src.bottom() < dest.bottom() )
+	for ( y = start_y; y <= end_y; ++y )
     {
-        for ( int x = src.left(); x <= dest.right(); x++ )
+		for ( x = start_x; x <= end_x; ++x )
         {
-            int y;
-            QPtrList<KSpreadCell> destList;
-            for ( y = src.bottom() + 1; y <= dest.bottom(); y++ )
                 destList.append( nonDefaultCell( x, y ) );
-            QPtrList<KSpreadCell> srcList;
-            for ( y = src.top(); y <= src.bottom(); y++ )
-                srcList.append( cellAt( x, y ) );
-            QPtrList<AutoFillSequence> seqList;
-            seqList.setAutoDelete( TRUE );
-            for ( y = src.top(); y <= src.bottom(); y++ )
                 seqList.append( new AutoFillSequence( cellAt( x, y ) ) );
-            fillSequence( srcList, destList, seqList );
         }
     }
 
+	fillSequence( srcList, destList, seqList );
 }
 
 void KSpreadTable::fillSequence( QPtrList<KSpreadCell>& _srcList, QPtrList<KSpreadCell>& _destList,

_______________________________________________
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