--Boundary-00=_yprg/bFQ8zoOt9f Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, This patch fixes bug #58097: http://bugs.kde.org/show_bug.cgi?id=3D58097 The problem is that the DependingOnMe list of a cell is removed when a cell= is=20 cut from the sheet. There is another variant of the bug which is not corrected by the patch: Wh= en=20 an entire row or column is removed then the DependingOnMe lists of all the= =20 (non-default) cells in that row/column are removed (see the TODO in the=20 patch). This is my first contribution to kspread so I don't know the code very well= =20 and before fixing this for a whole row/column I just want to ask if the=20 direction taken in this patch is ok (i.e. adding the preserveDoM flags and = a=20 new KSpreadCell constructor). Greetings, Stefan =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/grpyKN/5Ocgn19gRAl9TAJ9JfGR2wSyraHae4mOICASjGl5tqACfR7cQ WJvM1XHzhWi7TZ2XzQjuIpg=3D =3DIjkS =2D----END PGP SIGNATURE----- --Boundary-00=_yprg/bFQ8zoOt9f Content-Type: text/x-diff; charset="us-ascii"; name="kspread_58097.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kspread_58097.patch" 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 _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 KSpreadCell::getDepending () +{ + QPtrList 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 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 _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 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 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 ); /** --Boundary-00=_yprg/bFQ8zoOt9f Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_yprg/bFQ8zoOt9f--