diff -uNr old/sc/source/ui/docshell/dbdocfun.cxx new/sc/source/ui/docshell/dbdocfun.cxx --- old/sc/source/ui/docshell/dbdocfun.cxx 2009-04-29 15:36:12.468750000 +0800 +++ new/sc/source/ui/docshell/dbdocfun.cxx 2009-05-11 10:31:25.781250000 +0800 @@ -58,6 +58,7 @@ #include "editable.hxx" #include "attrib.hxx" #include "drwlayer.hxx" +#include "dpshttab.hxx" // ----------------------------------------------------------------- @@ -1299,6 +1300,21 @@ BOOL bOverflow = FALSE; ScRange aNewOut = pDestObj->GetNewOutputRange( bOverflow ); + + //! test for overlap with other data pilot tables + if( pOldObj ) + { + const ScSheetSourceDesc* pSheetDesc = pOldObj->GetSheetDesc(); + if( pSheetDesc && pSheetDesc->aSourceRange.Intersects( aNewOut ) ) + { + ScRange aOldRange = pOldObj->GetOutRange(); + USHORT nDiff = aOldRange.aStart.Row()-aNewOut.aStart.Row(); + aNewOut.aStart.SetRow( aOldRange.aStart.Row() ); + aNewOut.aEnd.SetRow( aNewOut.aEnd.Row()+nDiff ); + pDestObj->SetOutRange( aNewOut ); + } + } + if ( bOverflow ) { // like with STR_PROTECTIONERR, use undo to reverse everything @@ -1354,8 +1370,6 @@ pDoc->CopyToDocument( aNewOut, IDF_ALL, FALSE, pNewUndoDoc ); } - //! test for overlap with other data pilot tables - pDestObj->Output(); rDocShell.PostPaintGridAll(); //! only necessary parts