diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-07-23 09:53:34 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-07-23 09:53:34 +0000 |
commit | 8ec2d5023e4224f7b1053e0118e4c3214678dc57 (patch) | |
tree | 8f06c06bf77e9b2e0abd47bf6364eb16806a216c /sc/source/ui/undo/undobase.cxx | |
parent | f6cbcf03a9082b904a6e3b75f19a61a982e43dd5 (diff) |
INTEGRATION: CWS calcundo (1.3.452); FILE MERGED
2004/07/14 00:27:41 nn 1.3.452.2: RESYNC: (1.3-1.4); FILE MERGED
2004/07/13 18:21:55 nn 1.3.452.1: #i21498# undo for AutoFilter
Diffstat (limited to 'sc/source/ui/undo/undobase.cxx')
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 104 |
1 files changed, 102 insertions, 2 deletions
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index c37f812efb44..0068e418234b 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -2,9 +2,9 @@ * * $RCSfile: undobase.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: obo $ $Date: 2004-06-04 11:50:31 $ + * last change: $Author: kz $ $Date: 2004-07-23 10:53:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,12 +75,16 @@ #include "tabvwsh.hxx" #include "undoolk.hxx" #include "undodraw.hxx" +#include "dbcolect.hxx" +#include "attrib.hxx" +#include "globstr.hrc" // STATIC DATA ----------------------------------------------------------- TYPEINIT1(ScSimpleUndo, SfxUndoAction); TYPEINIT1(ScBlockUndo, SfxUndoAction); TYPEINIT1(ScMoveUndo, SfxUndoAction); +TYPEINIT1(ScDBFuncUndo, SfxUndoAction); TYPEINIT1(ScUndoWrapper, SfxUndoAction); // ----------------------------------------------------------------------- @@ -374,6 +378,102 @@ void ScMoveUndo::EndRedo() // ----------------------------------------------------------------------- +ScDBFuncUndo::ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal ) : + ScSimpleUndo( pDocSh ), + aOriginalRange( rOriginal ) +{ + pAutoDBRange = pDocSh->GetOldAutoDBRange(); +} + +ScDBFuncUndo::~ScDBFuncUndo() +{ + delete pAutoDBRange; +} + +void ScDBFuncUndo::BeginUndo() +{ + ScSimpleUndo::BeginUndo(); +} + +void ScDBFuncUndo::EndUndo() +{ + ScSimpleUndo::EndUndo(); + + if ( pAutoDBRange ) + { + USHORT nNoNameIndex; + ScDocument* pDoc = pDocShell->GetDocument(); + ScDBCollection* pColl = pDoc->GetDBCollection(); + if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + { + ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; + + SCCOL nRangeX1; + SCROW nRangeY1; + SCCOL nRangeX2; + SCROW nRangeY2; + SCTAB nRangeTab; + pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + + *pNoNameData = *pAutoDBRange; + + if ( pAutoDBRange->HasAutoFilter() ) + { + // restore AutoFilter buttons + pAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + pDoc->ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO ); + pDocShell->PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID ); + } + } + } +} + +void ScDBFuncUndo::BeginRedo() +{ + if ( pAutoDBRange ) + { + // move the database range to this function's position again (see ScDocShell::GetDBData) + + USHORT nNoNameIndex; + ScDocument* pDoc = pDocShell->GetDocument(); + ScDBCollection* pColl = pDoc->GetDBCollection(); + if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) + { + ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; + + SCCOL nRangeX1; + SCROW nRangeY1; + SCCOL nRangeX2; + SCROW nRangeY2; + SCTAB nRangeTab; + pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); + + pNoNameData->SetSortParam( ScSortParam() ); + pNoNameData->SetQueryParam( ScQueryParam() ); + pNoNameData->SetSubTotalParam( ScSubTotalParam() ); + + pNoNameData->SetArea( aOriginalRange.aStart.Tab(), + aOriginalRange.aStart.Col(), aOriginalRange.aStart.Row(), + aOriginalRange.aEnd.Col(), aOriginalRange.aEnd.Row() ); + + pNoNameData->SetByRow( TRUE ); + pNoNameData->SetAutoFilter( FALSE ); + // header is always set with the operation in redo + } + } + + ScSimpleUndo::BeginRedo(); +} + +void ScDBFuncUndo::EndRedo() +{ + ScSimpleUndo::EndRedo(); +} + +// ----------------------------------------------------------------------- + ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) : pWrappedUndo( pUndo ) { |