[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: [Patch] kspread bug #58097
From: Stefan Hetzl <shetzl () chello ! at>
Date: 2003-10-07 13:06:58
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
This patch fixes bug #58097: http://bugs.kde.org/show_bug.cgi?id=58097
The problem is that the DependingOnMe list of a cell is removed when a cell is
cut from the sheet.
There is another variant of the bug which is not corrected by the patch: When
an entire row or column is removed then the DependingOnMe lists of all the
(non-default) cells in that row/column are removed (see the TODO in the
patch).
This is my first contribution to kspread so I don't know the code very well
and before fixing this for a whole row/column I just want to ask if the
direction taken in this patch is ok (i.e. adding the preserveDoM flags and a
new KSpreadCell constructor).
Greetings,
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
iD8DBQE/grpyKN/5Ocgn19gRAl9TAJ9JfGR2wSyraHae4mOICASjGl5tqACfR7cQ
WJvM1XHzhWi7TZ2XzQjuIpg=
=IjkS
-----END PGP SIGNATURE-----
["kspread_58097.patch" (text/x-diff)]
Index: kspread_cell.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_cell.cc,v
retrieving revision 1.521
diff -u -3 -p -r1.521 kspread_cell.cc
--- kspread_cell.cc 23 Aug 2003 21:08:03 -0000 1.521
+++ kspread_cell.cc 7 Oct 2003 12:52:55 -0000
@@ -129,6 +129,41 @@ KSpreadCell::KSpreadCell( KSpreadSheet *
clearAllErrors();
}
+KSpreadCell::KSpreadCell( KSpreadSheet *_table, QPtrList<KSpreadDependency> \
_deponme, int _column, int _row ) + : KSpreadFormat( _table, \
_table->doc()->styleManager()->defaultStyle() ), + m_iRow( _row ),
+ m_iColumn( _column ),
+ m_dOutTextWidth( 0.0 ),
+ m_dOutTextHeight( 0.0 ),
+ m_dTextX( 0.0 ),
+ m_dTextY( 0.0 ),
+ m_iMergedXCells( 0 ),
+ m_iMergedYCells( 0 ),
+ m_iExtraXCells( 0 ),
+ m_iExtraYCells( 0 ),
+ m_dExtraWidth( 0.0 ),
+ m_dExtraHeight( 0.0 ),
+ m_style( ST_Normal ),
+ m_pPrivate( 0 ),
+ m_content( Text ),
+ m_value( KSpreadValue::empty() ),
+ m_pQML( 0 ),
+ m_pCode( 0 ),
+ m_conditions( 0 ),
+ m_nbLines( 0 ),
+ m_Validity( 0 ),
+ m_nextCell( 0 ),
+ m_previousCell( 0 )
+{
+ m_ObscuringCells.clear();
+
+ m_lstDepends.setAutoDelete( true );
+ m_lstDependingOnMe = _deponme ;
+ m_lstDependingOnMe.setAutoDelete( true );
+
+ clearAllErrors();
+}
+
KSpreadSheet * KSpreadCell::sheet() const
{
return m_pTable;
@@ -5681,6 +5716,20 @@ void KSpreadCell::NotifyDependancyList(Q
}
}
}
+}
+
+QPtrList<KSpreadDependency> KSpreadCell::getDepending ()
+{
+ QPtrList<KSpreadDependency> retval ;
+ KSpreadDependency *d = NULL ;
+
+ for (d = m_lstDependingOnMe.first() ; d != NULL ; d = m_lstDependingOnMe.next())
+ {
+ KSpreadDependency *d_copy = new KSpreadDependency (*d) ;
+ retval.prepend (d_copy) ;
+ }
+
+ return retval ;
}
QValueList<KSpreadConditional> KSpreadCell::conditionList() const
Index: kspread_cell.h
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_cell.h,v
retrieving revision 1.159
diff -u -3 -p -r1.159 kspread_cell.h
--- kspread_cell.h 30 Jun 2003 22:13:12 -0000 1.159
+++ kspread_cell.h 7 Oct 2003 12:52:56 -0000
@@ -131,6 +131,7 @@ public:
KSpreadCell( KSpreadSheet *_table, int _column, int _row );
KSpreadCell( KSpreadSheet * _table, KSpreadStyle * _style, int _column, int _row \
); + KSpreadCell( KSpreadSheet *_table, QPtrList<KSpreadDependency> _deponme, int \
_column, int _row ); /**
* @see #tableDies
*/
@@ -515,6 +516,12 @@ public:
* depending on it.
*/
void NotifyDepending( int col, int row, KSpreadSheet* table, bool isDepending );
+
+ /**
+ * get the list of dependencies of this cell
+ * this is a deep copy of the m_lstDependingOnMe (the KSpreadDepenency objects \
are also copied) + **/
+ QPtrList<KSpreadDependency> getDepending (void) ;
/**
* Causes the format to be recalculated when the cell is drawn next time.
Index: kspread_sheet.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_sheet.cc,v
retrieving revision 1.517
diff -u -3 -p -r1.517 kspread_sheet.cc
--- kspread_sheet.cc 20 Sep 2003 10:51:53 -0000 1.517
+++ kspread_sheet.cc 7 Oct 2003 12:52:58 -0000
@@ -5364,7 +5364,7 @@ void KSpreadSheet::copySelection( KSprea
void KSpreadSheet::cutSelection( KSpreadSelection* selectionInfo )
{
copySelection( selectionInfo );
- deleteSelection( selectionInfo );
+ deleteSelection( selectionInfo, true, true );
}
void KSpreadSheet::paste( const QRect &pasteArea, bool makeUndo,
@@ -5757,7 +5757,7 @@ bool KSpreadSheet::testAreaPasteInsert()
return false;
}
-void KSpreadSheet::deleteCells( const QRect& rect )
+void KSpreadSheet::deleteCells( const QRect& rect, bool preserveDoM )
{
// A list of all cells we want to delete.
QPtrStack<KSpreadCell> cellStack;
@@ -5807,6 +5807,10 @@ void KSpreadSheet::deleteCells( const QR
KSpreadCell * cell = cellStack.pop();
m_cells.remove( cell->column(), cell->row() );
+ if (preserveDoM) {
+ KSpreadCell * emptycell = new KSpreadCell (this, cell->getDepending(), \
cell->column(), cell->row()) ; + insertCell (emptycell) ;
+ }
cell->setCalcDirtyFlag();
setRegionPaintDirty(cell->cellRect());
@@ -5830,7 +5834,7 @@ void KSpreadSheet::deleteCells( const QR
m_pDoc->setModified( true );
}
-void KSpreadSheet::deleteSelection( KSpreadSelection* selectionInfo, bool undo )
+void KSpreadSheet::deleteSelection( KSpreadSelection* selectionInfo, bool undo, bool \
preserveDoM ) {
QRect r( selectionInfo->selection() );
@@ -5840,6 +5844,8 @@ void KSpreadSheet::deleteSelection( KSpr
m_pDoc->undoBuffer()->appendUndo( undo );
}
+ // TODO: also use preserveDoM when entire row/column is selected
+
// Entire rows selected ?
if ( util_isRowSelected(r) )
{
@@ -5865,7 +5871,7 @@ void KSpreadSheet::deleteSelection( KSpr
else
{
- deleteCells( r );
+ deleteCells( r, preserveDoM );
}
refreshMergedCell();
emit sig_updateView( this );
Index: kspread_sheet.h
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_sheet.h,v
retrieving revision 1.249
diff -u -3 -p -r1.249 kspread_sheet.h
--- kspread_sheet.h 30 Jun 2003 22:13:14 -0000 1.249
+++ kspread_sheet.h 7 Oct 2003 12:52:59 -0000
@@ -513,8 +513,13 @@ public:
* @param _marker is used if there is no selection currently.
* In this case the cell on which the marker is will
* be deleted.
+ *
+ * @param preserveDoM preserve the DependingOnMe list (set this to true if you \
want + * the cells in the selection to remember which cells depend on \
them) + *
*/
- void deleteSelection( KSpreadSelection* selectionInfo, bool undo = true );
+ void deleteSelection( KSpreadSelection* selectionInfo, bool undo = true, bool \
preserveDoM = false ); +
/**
* @param _marker is used if there is no selection currently.
* In this case the cell on which the marker is will
@@ -868,9 +873,14 @@ public:
* This function can be used to clear an area before you paste something from \
the clipboard
* in this area.
*
+ * @param rect The rectangle that contains the cells that should be deleted
+ *
+ * @param preserveDoM preserve the DependingOnMe list (set this to true if you \
want + * the cells in rect to remember which cells depend on them)
+ *
* @see #loadCells
*/
- void deleteCells( const QRect& rect );
+ void deleteCells( const QRect& rect, bool preserveDoM = false );
/**
_______________________________________________
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