diff options
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/makefile.mk | 119 | ||||
-rw-r--r-- | sc/source/ui/undo/refundo.cxx | 232 | ||||
-rw-r--r-- | sc/source/ui/undo/target.cxx | 110 | ||||
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 374 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 1909 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk2.cxx | 308 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 2053 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 1154 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 2147 | ||||
-rw-r--r-- | sc/source/ui/undo/undodraw.cxx | 304 | ||||
-rw-r--r-- | sc/source/ui/undo/undoolk.cxx | 138 | ||||
-rw-r--r-- | sc/source/ui/undo/undostyl.cxx | 327 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 1383 | ||||
-rw-r--r-- | sc/source/ui/undo/undoutil.cxx | 229 |
14 files changed, 10787 insertions, 0 deletions
diff --git a/sc/source/ui/undo/makefile.mk b/sc/source/ui/undo/makefile.mk new file mode 100644 index 000000000000..b5242a2bfe6b --- /dev/null +++ b/sc/source/ui/undo/makefile.mk @@ -0,0 +1,119 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:45:06 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sc +TARGET=undo + +PROJECTPCH4DLL=TRUE +PROJECTPCH=ui_pch +PDBTARGET=ui_pch +PROJECTPCHSOURCE=..\pch\ui_pch + +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : scpre.mk +.INCLUDE : settings.mk +.INCLUDE : sc.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +CXXFILES = \ + target.cxx \ + refundo.cxx \ + undobase.cxx \ + undoutil.cxx \ + undocell.cxx \ + undostyl.cxx \ + undoolk.cxx \ + undoblk.cxx \ + undoblk2.cxx \ + undoblk3.cxx \ + undodat.cxx \ + undodraw.cxx \ + undotab.cxx + + + +SLOFILES = \ + $(SLO)$/target.obj \ + $(SLO)$/refundo.obj \ + $(SLO)$/undobase.obj \ + $(SLO)$/undoutil.obj \ + $(SLO)$/undocell.obj \ + $(SLO)$/undostyl.obj \ + $(SLO)$/undoolk.obj \ + $(SLO)$/undoblk.obj \ + $(SLO)$/undoblk2.obj \ + $(SLO)$/undoblk3.obj \ + $(SLO)$/undodat.obj \ + $(SLO)$/undodraw.obj \ + $(SLO)$/undotab.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx new file mode 100644 index 000000000000..23c0a8a133f6 --- /dev/null +++ b/sc/source/ui/undo/refundo.cxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: refundo.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// ----------------------------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "refundo.hxx" +#include "undobase.hxx" +#include "document.hxx" +#include "dbcolect.hxx" +#include "rangenam.hxx" +#include "pivot.hxx" +#include "chartarr.hxx" +#include "stlpool.hxx" +#include "conditio.hxx" +#include "detdata.hxx" +#include "prnsave.hxx" +#include "chartlis.hxx" +#include "dpobject.hxx" + +// ----------------------------------------------------------------------- + +ScRefUndoData::ScRefUndoData( const ScDocument* pDoc ) +{ + ScDBCollection* pOldDBColl = pDoc->GetDBCollection(); + pDBCollection = pOldDBColl ? new ScDBCollection(*pOldDBColl) : NULL; + + ScRangeName* pOldRanges = ((ScDocument*)pDoc)->GetRangeName(); //! const + pRangeName = pOldRanges ? new ScRangeName(*pOldRanges) : NULL; + + pPrintRanges = pDoc->CreatePrintRangeSaver(); // neu erzeugt + + ScPivotCollection* pOldPivot = pDoc->GetPivotCollection(); + pPivotCollection = pOldPivot ? new ScPivotCollection(*pOldPivot) : NULL; + //! bei Pivot nur Bereiche merken ??? + + ScDPCollection* pOldDP = ((ScDocument*)pDoc)->GetDPCollection(); //! const + pDPCollection = pOldDP ? new ScDPCollection(*pOldDP) : NULL; + + ScConditionalFormatList* pOldCond = pDoc->GetCondFormList(); + pCondFormList = pOldCond ? new ScConditionalFormatList(*pOldCond) : NULL; + + ScDetOpList* pOldDetOp = pDoc->GetDetOpList(); + pDetOpList = pOldDetOp ? new ScDetOpList(*pOldDetOp) : 0; + + ScChartListenerCollection* pOldChartListenerCollection = + pDoc->GetChartListenerCollection(); + pChartListenerCollection = pOldChartListenerCollection ? + new ScChartListenerCollection( *pOldChartListenerCollection ) : NULL; +} + +ScRefUndoData::~ScRefUndoData() +{ + delete pDBCollection; + delete pRangeName; + delete pPrintRanges; + delete pPivotCollection; + delete pDPCollection; + delete pCondFormList; + delete pDetOpList; + delete pChartListenerCollection; +} + +void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) +{ + if (pDBCollection) + { + ScDBCollection* pNewDBColl = pDoc->GetDBCollection(); + if ( pNewDBColl && *pDBCollection == *pNewDBColl ) + DELETEZ(pDBCollection); + } + if (pRangeName) + { + ScRangeName* pNewRanges = ((ScDocument*)pDoc)->GetRangeName(); //! const + if ( pNewRanges && *pRangeName == *pNewRanges ) + DELETEZ(pRangeName); + } + + if (pPrintRanges) + { + ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver(); + if ( pNewRanges && *pPrintRanges == *pNewRanges ) + DELETEZ(pPrintRanges); + delete pNewRanges; + } + + if (pPivotCollection) + { + ScPivotCollection* pNewPivot = pDoc->GetPivotCollection(); + if ( pNewPivot && *pPivotCollection == *pNewPivot ) + DELETEZ(pPivotCollection); + } + + if (pDPCollection) + { + ScDPCollection* pNewDP = ((ScDocument*)pDoc)->GetDPCollection(); //! const + if ( pNewDP && pDPCollection->RefsEqual(*pNewDP) ) + DELETEZ(pDPCollection); + } + + if (pCondFormList) + { + ScConditionalFormatList* pNewCond = pDoc->GetCondFormList(); + if ( pNewCond && *pCondFormList == *pNewCond ) + DELETEZ(pCondFormList); + } + + if (pDetOpList) + { + ScDetOpList* pNewDetOp = pDoc->GetDetOpList(); + if ( pNewDetOp && *pDetOpList == *pNewDetOp ) + DELETEZ(pDetOpList); + } + + if ( pChartListenerCollection ) + { + ScChartListenerCollection* pNewChartListenerCollection = + pDoc->GetChartListenerCollection(); + if ( pNewChartListenerCollection && + *pChartListenerCollection == *pNewChartListenerCollection ) + DELETEZ( pChartListenerCollection ); + } +} + +void ScRefUndoData::DoUndo( ScDocument* pDoc, BOOL bUndoRefFirst ) +{ + if (pDBCollection) + pDoc->SetDBCollection( new ScDBCollection(*pDBCollection) ); + if (pRangeName) + pDoc->SetRangeName( new ScRangeName(*pRangeName) ); + + if (pPrintRanges) + pDoc->RestorePrintRanges(*pPrintRanges); + + if (pPivotCollection) + pDoc->SetPivotCollection( new ScPivotCollection(*pPivotCollection) ); + + if (pDPCollection) + { + ScDPCollection* pDocDP = pDoc->GetDPCollection(); + if (pDocDP) + pDPCollection->WriteRefsTo( *pDocDP ); + } + + if (pCondFormList) + pDoc->SetCondFormList( new ScConditionalFormatList(*pCondFormList) ); + if (pDetOpList) + pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) ); + + // #65055# bUndoRefFirst ist bSetChartRangeLists + if ( pChartListenerCollection ) + pDoc->SetChartListenerCollection( new ScChartListenerCollection( + *pChartListenerCollection ), bUndoRefFirst ); + + if (pDBCollection || pRangeName) + { + BOOL bOldAutoCalc = pDoc->GetAutoCalc(); + pDoc->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden + pDoc->CompileAll(); + pDoc->SetDirty(); + pDoc->SetAutoCalc( bOldAutoCalc ); + } +} + + + + diff --git a/sc/source/ui/undo/target.cxx b/sc/source/ui/undo/target.cxx new file mode 100644 index 000000000000..eaf203bde4a3 --- /dev/null +++ b/sc/source/ui/undo/target.cxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * $RCSfile: target.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "target.hxx" + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScTabViewTarget, SfxRepeatTarget); + +SEG_EOFGLOBALS() + +#pragma SEG_FUNCDEF(target_01) + +__EXPORT ScTabViewTarget::~ScTabViewTarget() +{ +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.3 2000/09/17 14:09:28 willem.vandorp + OpenOffice header added. + + Revision 1.2 2000/08/31 16:38:39 willem.vandorp + Header and footer replaced + + Revision 1.1 1995/10/09 14:48:40 NN + Initial revision. + + + Rev 1.0 09 Oct 1995 15:48:40 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx new file mode 100644 index 000000000000..2c952af778f9 --- /dev/null +++ b/sc/source/ui/undo/undobase.cxx @@ -0,0 +1,374 @@ +/************************************************************************* + * + * $RCSfile: undobase.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/virdev.hxx> + +#include "undobase.hxx" +#include "refundo.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "undoolk.hxx" +#include "undodraw.hxx" + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScSimpleUndo, SfxUndoAction); +TYPEINIT1(ScBlockUndo, SfxUndoAction); +TYPEINIT1(ScMoveUndo, SfxUndoAction); + +// ----------------------------------------------------------------------- + +ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) : + pDocShell( pDocSh ), + pDetectiveUndo( NULL ) +{ +} + +__EXPORT ScSimpleUndo::~ScSimpleUndo() +{ + delete pDetectiveUndo; +} + +BOOL __EXPORT ScSimpleUndo::Merge( SfxUndoAction *pNextAction ) +{ + // Zu jeder Undo-Action kann eine SdrUndoGroup fuer das Aktualisieren + // der Detektiv-Pfeile gehoeren. + // DetectiveRefresh kommt immer hinterher, die SdrUndoGroup ist in + // eine ScUndoDraw Action verpackt. + // Nur beim automatischen Aktualisieren wird AddUndoAction mit + // bTryMerg=TRUE gerufen. + + if ( !pDetectiveUndo && pNextAction->ISA(ScUndoDraw) ) + { + // SdrUndoAction aus der ScUndoDraw Action uebernehmen, + // ScUndoDraw wird dann vom UndoManager geloescht + + ScUndoDraw* pCalcUndo = (ScUndoDraw*)pNextAction; + pDetectiveUndo = pCalcUndo->GetDrawUndo(); + pCalcUndo->ForgetDrawUndo(); + return TRUE; + } + + return FALSE; +} + +void ScSimpleUndo::BeginUndo() +{ + pDocShell->SetInUndo( TRUE ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->HideAllCursors(); // z.B. wegen zusammengefassten Zellen +} + +void ScSimpleUndo::EndUndo() +{ + if (pDetectiveUndo) + pDetectiveUndo->Undo(); + + pDocShell->SetDocumentModified(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->UpdateAutoFillMark(); + pViewShell->UpdateInputHandler(); + pViewShell->ShowAllCursors(); + } + + pDocShell->SetInUndo( FALSE ); +} + +void ScSimpleUndo::BeginRedo() +{ + pDocShell->SetInUndo( TRUE ); //! eigenes Flag fuer Redo? + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->HideAllCursors(); // z.B. wegen zusammengefassten Zellen +} + +void ScSimpleUndo::EndRedo() +{ + if (pDetectiveUndo) + pDetectiveUndo->Redo(); + + pDocShell->SetDocumentModified(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->UpdateAutoFillMark(); + pViewShell->UpdateInputHandler(); + pViewShell->ShowAllCursors(); + } + + pDocShell->SetInUndo( FALSE ); +} + +void ScSimpleUndo::ShowTable( USHORT nTab ) // static +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetTabNo( nTab ); +} + +void ScSimpleUndo::ShowTable( const ScRange& rRange ) // static +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + USHORT nStart = rRange.aStart.Tab(); + USHORT nEnd = rRange.aEnd.Tab(); + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + if ( nTab < nStart || nTab > nEnd ) // wenn nicht im Bereich: + pViewShell->SetTabNo( nStart ); // auf erste des Bereiches + } +} + + +// ----------------------------------------------------------------------- + +ScBlockUndo::ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange, + ScBlockUndoMode eBlockMode ) : + ScSimpleUndo( pDocSh ), + aBlockRange( rRange ), + eMode( eBlockMode ) +{ + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); +} + +__EXPORT ScBlockUndo::~ScBlockUndo() +{ + DeleteSdrUndoAction( pDrawUndo ); +} + +void ScBlockUndo::BeginUndo() +{ + ScSimpleUndo::BeginUndo(); + EnableDrawAdjust( pDocShell->GetDocument(), FALSE ); +} + +void ScBlockUndo::EndUndo() +{ + if (eMode == SC_UNDO_AUTOHEIGHT) + AdjustHeight(); + + EnableDrawAdjust( pDocShell->GetDocument(), TRUE ); + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); + + ShowBlock(); + ScSimpleUndo::EndUndo(); +} + +/* +void ScBlockUndo::BeginRedo() +{ + ScSimpleUndo::BeginRedo(); +} +*/ + +void ScBlockUndo::EndRedo() +{ + if (eMode == SC_UNDO_AUTOHEIGHT) + AdjustHeight(); + + ShowBlock(); + ScSimpleUndo::EndRedo(); +} + +BOOL ScBlockUndo::AdjustHeight() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + VirtualDevice aVirtDev; + Fraction aZoomX( 1, 1 ); + Fraction aZoomY = aZoomX; + double nPPTX, nPPTY; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + ScViewData* pData = pViewShell->GetViewData(); + nPPTX = pData->GetPPTX(); + nPPTY = pData->GetPPTY(); + aZoomX = pData->GetZoomX(); + aZoomY = pData->GetZoomY(); + } + else + { + // Zoom auf 100 lassen + nPPTX = ScGlobal::nScreenPPTX; + nPPTY = ScGlobal::nScreenPPTY; + } + + BOOL bRet = pDoc->SetOptimalHeight( aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), +/*!*/ aBlockRange.aStart.Tab(), 0, &aVirtDev, + nPPTX, nPPTY, aZoomX, aZoomY, FALSE ); + + if (bRet) + pDocShell->PostPaint( 0, aBlockRange.aStart.Row(), aBlockRange.aStart.Tab(), + MAXCOL, MAXROW, aBlockRange.aEnd.Tab(), + PAINT_GRID | PAINT_LEFT ); + + return bRet; +} + +void ScBlockUndo::ShowBlock() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + ShowTable( aBlockRange ); // bei mehreren Tabs im Range ist jede davon gut + pViewShell->MoveCursorAbs( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), + SC_FOLLOW_JUMP, FALSE, FALSE ); + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + ScRange aRange = aBlockRange; + aRange.aStart.SetTab( nTab ); + aRange.aEnd.SetTab( nTab ); + pViewShell->MarkRange( aRange ); + + // nicht per SetMarkArea an MarkData, wegen evtl. fehlendem Paint + } +} + + +// ----------------------------------------------------------------------- + +ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocument* pRefDoc, ScRefUndoData* pRefData, + ScMoveUndoMode eRefMode ) : + ScSimpleUndo( pDocSh ), + pRefUndoDoc( pRefDoc ), + pRefUndoData( pRefData ), + eMode( eRefMode ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + if (pRefUndoData) + pRefUndoData->DeleteUnchanged(pDoc); + pDrawUndo = GetSdrUndoAction( pDoc ); +} + +__EXPORT ScMoveUndo::~ScMoveUndo() +{ + delete pRefUndoData; + delete pRefUndoDoc; + DeleteSdrUndoAction( pDrawUndo ); +} + +void ScMoveUndo::UndoRef() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScRange aRange(0,0,0, MAXCOL,MAXROW,pRefUndoDoc->GetTableCount()-1); + pRefUndoDoc->CopyToDocument( aRange, IDF_FORMULA, FALSE, pDoc, NULL, FALSE ); + if (pRefUndoData) + pRefUndoData->DoUndo( pDoc, (eMode == SC_UNDO_REFFIRST) ); + // #65055# HACK: ScDragDropUndo ist der einzige mit REFFIRST. + // Falls nicht, resultiert daraus evtl. ein zu haeufiges Anpassen + // der ChartRefs, nicht schoen, aber auch nicht schlecht.. +} + +void ScMoveUndo::BeginUndo() +{ + ScSimpleUndo::BeginUndo(); + + EnableDrawAdjust( pDocShell->GetDocument(), FALSE ); + + if (pRefUndoDoc && eMode == SC_UNDO_REFFIRST) + UndoRef(); +} + +void ScMoveUndo::EndUndo() +{ + if (pDrawUndo) //@17.12.97 Reihenfolge der Fkt.s geaendert + DoSdrUndoAction( pDrawUndo ); + + if (pRefUndoDoc && eMode == SC_UNDO_REFLAST) + UndoRef(); + + EnableDrawAdjust( pDocShell->GetDocument(), TRUE ); + + ScSimpleUndo::EndUndo(); +} + +/* +void ScMoveUndo::BeginRedo() +{ + ScSimpleUndo::BeginRedo(); +} +*/ + +/* +void ScMoveUndo::EndRedo() +{ + ScSimpleUndo::EndRedo(); +} +*/ + + + diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx new file mode 100644 index 000000000000..8ddc8308f4c1 --- /dev/null +++ b/sc/source/ui/undo/undoblk.cxx @@ -0,0 +1,1909 @@ +/************************************************************************* + * + * $RCSfile: undoblk.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SVDSURO_HXX + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <vcl/virdev.hxx> +#include <vcl/waitobj.hxx> +#include <svx/boxitem.hxx> + +#include "undoblk.hxx" +#include "undoutil.hxx" +#include "document.hxx" +#include "patattr.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "rangenam.hxx" +#include "rangeutl.hxx" +#include "dbcolect.hxx" +#include "stlpool.hxx" +#include "stlsheet.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "target.hxx" +#include "docpool.hxx" +#include "docfunc.hxx" +#include "attrib.hxx" +#include "chgtrack.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScUndoInsertCells, SfxUndoAction); +TYPEINIT1(ScUndoDeleteCells, SfxUndoAction); +TYPEINIT1(ScUndoDeleteMulti, SfxUndoAction); +TYPEINIT1(ScUndoCut, ScBlockUndo); +TYPEINIT1(ScUndoPaste, SfxUndoAction); +TYPEINIT1(ScUndoDragDrop, SfxUndoAction); +TYPEINIT1(ScUndoListNames, SfxUndoAction); +TYPEINIT1(ScUndoUseScenario, SfxUndoAction); +TYPEINIT1(ScUndoSelectionStyle, SfxUndoAction); +TYPEINIT1(ScUndoEnterMatrix, ScBlockUndo); +TYPEINIT1(ScUndoIndent, ScBlockUndo); +TYPEINIT1(ScUndoClearItems, ScBlockUndo); +TYPEINIT1(ScUndoRemoveBreaks, SfxUndoAction); +TYPEINIT1(ScUndoRemoveMerge, ScBlockUndo); +TYPEINIT1(ScUndoBorder, ScBlockUndo); + + + +// To Do: +/*A*/ // SetOptimalHeight auf Dokument, wenn keine View +/*B*/ // gelinkte Tabellen +/*C*/ // ScArea +//? // spaeter mal pruefen + + +// ----------------------------------------------------------------------- +// +// Zellen einfuegen +// Zeilen einfgen +// einzeln oder Block +// + +ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell, + const ScRange& rRange, InsCellCmd eNewCmd, + ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : + ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), + aEffRange( rRange ), + eCmd( eNewCmd ) +{ + if (eCmd == INS_INSROWS) // ganze Zeilen? + { + aEffRange.aStart.SetCol(0); + aEffRange.aEnd.SetCol(MAXCOL); + } + + if (eCmd == INS_INSCOLS) // ganze Spalten? + { + aEffRange.aStart.SetRow(0); + aEffRange.aEnd.SetRow(MAXROW); + } + + SetChangeTrack(); +} + +__EXPORT ScUndoInsertCells::~ScUndoInsertCells() +{ +} + +String __EXPORT ScUndoInsertCells::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_INSERTCELLS ); // "Einfuegen" +} + +void ScUndoInsertCells::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + pChangeTrack->AppendInsert( aEffRange ); + nEndChangeAction = pChangeTrack->GetActionMax(); + } + else + nEndChangeAction = 0; +} + +void ScUndoInsertCells::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + if ( bUndo ) + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); + } + else + SetChangeTrack(); + + ScRange aWorkRange( aEffRange ); + if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? + pDoc->ExtendMerge( aWorkRange, TRUE ); + + switch (eCmd) + { + case INS_INSROWS: + case INS_CELLSDOWN: + if (bUndo) + pDoc->DeleteRow( aEffRange ); + else + pDoc->InsertRow( aEffRange ); + break; + case INS_INSCOLS: + case INS_CELLSRIGHT: + if (bUndo) + pDoc->DeleteCol( aEffRange ); + else + pDoc->InsertCol( aEffRange ); + break; + } + +//? Undo fuer herausgeschobene Attribute ? + + USHORT nPaint = PAINT_GRID; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + switch (eCmd) + { + case INS_INSROWS: + nPaint |= PAINT_LEFT; + aWorkRange.aEnd.SetRow(MAXROW); + break; + case INS_CELLSDOWN: + aWorkRange.aEnd.SetRow(MAXROW); // bis ganz nach unten +/*A*/ if ( (pViewShell) && pViewShell->AdjustRowHeight( + aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), FALSE ) ) + { + aWorkRange.aStart.SetCol(0); + aWorkRange.aEnd.SetCol(MAXCOL); + nPaint |= PAINT_LEFT; + } + break; + case INS_INSCOLS: + nPaint |= PAINT_TOP; // obere Leiste + case INS_CELLSRIGHT: + aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts +/*A*/ if ( (pViewShell) && pViewShell->AdjustRowHeight( + aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), FALSE ) ) + { // AdjustDraw zeichnet PAINT_TOP nicht, + aWorkRange.aStart.SetCol(0); // daher so geloest + aWorkRange.aEnd.SetRow(MAXROW); + nPaint |= PAINT_LEFT; + } + break; + } + pDocShell->PostPaint( aWorkRange, nPaint ); + pDocShell->PostDataChanged(); + if (pViewShell) + pViewShell->CellContentChanged(); + + ShowTable( aEffRange.aStart.Tab() ); +} + +void __EXPORT ScUndoInsertCells::Undo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + +void __EXPORT ScUndoInsertCells::Redo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoInsertCells::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->InsertCells( eCmd, TRUE ); +} + +BOOL __EXPORT ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Zellen loeschen +// Zeilen lschen +// einzeln oder Block +// + +ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell, + const ScRange& rRange, DelCellCmd eNewCmd, + ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : + ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), + aEffRange( rRange ), + eCmd( eNewCmd ) +{ + if (eCmd == DEL_DELROWS) // gaze Zeilen? + { + aEffRange.aStart.SetCol(0); + aEffRange.aEnd.SetCol(MAXCOL); + } + + if (eCmd == DEL_DELCOLS) // ganze Spalten? + { + aEffRange.aStart.SetRow(0); + aEffRange.aEnd.SetRow(MAXROW); + } + + SetChangeTrack(); +} + +__EXPORT ScUndoDeleteCells::~ScUndoDeleteCells() +{ +} + +String __EXPORT ScUndoDeleteCells::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // "Loeschen" +} + +void ScUndoDeleteCells::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->AppendDeleteRange( aEffRange, pRefUndoDoc, + nStartChangeAction, nEndChangeAction ); + else + nStartChangeAction = nEndChangeAction = 0; +} + +void ScUndoDeleteCells::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + if ( bUndo ) + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + } + else + SetChangeTrack(); + + // Ausfuehren + switch (eCmd) + { + case DEL_DELROWS: + case DEL_CELLSUP: + if (bUndo) + pDoc->InsertRow( aEffRange ); + else + pDoc->DeleteRow( aEffRange ); + break; + case DEL_DELCOLS: + case DEL_CELLSLEFT: + if (bUndo) + pDoc->InsertCol( aEffRange ); + else + pDoc->DeleteCol( aEffRange ); + break; + } + + // bei Undo Referenzen wiederherstellen + if (bUndo) + pRefUndoDoc->CopyToDocument( aEffRange, IDF_ALL, FALSE, pDoc ); + +//? Datenbank muss vor ExtendMerge sein ????? + + // Zusammengefasste Zellen? + ScRange aWorkRange( aEffRange ); + if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) + { +/*? if ( !bUndo && ( eCmd==DEL_DELCOLS || eCmd==DEL_DELROWS ) ) + { + if (eCmd==DEL_DELCOLS) aWorkRange.aEnd.SetCol(MAXCOL); + if (eCmd==DEL_DELROWS) aWorkRange.aEnd.SetRow(MAXROW); + ScMarkData aMarkData; + aMarkData.SelectOneTable( aWorkRange.aStart.Tab() ); + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( ScMergeFlagAttr() ); + pDoc->ApplyPatternArea( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), + aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), + aMarkData, aPattern ); + } +?*/ + pDoc->ExtendMerge( aWorkRange, TRUE ); + } + + // Zeichnen + USHORT nPaint = PAINT_GRID; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + switch (eCmd) + { + case DEL_DELROWS: + nPaint |= PAINT_LEFT; + aWorkRange.aEnd.SetRow(MAXROW); + break; + case DEL_CELLSUP: + aWorkRange.aEnd.SetRow(MAXROW); +/*A*/ if ( (pViewShell) && pViewShell->AdjustRowHeight( + aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), FALSE ) ) + { + aWorkRange.aStart.SetCol(0); + aWorkRange.aEnd.SetCol(MAXCOL); + nPaint |= PAINT_LEFT; + } + break; + case DEL_DELCOLS: + nPaint |= PAINT_TOP; // obere Leiste + case DEL_CELLSLEFT: + aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts +/*A*/ if ( (pViewShell) && pViewShell->AdjustRowHeight( + aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), FALSE ) ) + { + aWorkRange.aStart.SetCol(0); + aWorkRange.aEnd.SetRow(MAXROW); + nPaint |= PAINT_LEFT; + } + } + pDocShell->PostPaint( aWorkRange, nPaint, SC_PF_LINES ); //! auf Lines testen + + // Markierung erst nach EndUndo + + pDocShell->PostDataChanged(); + // CellContentChanged kommt mit der Markierung + + ShowTable( aEffRange.aStart.Tab() ); +} + +void __EXPORT ScUndoDeleteCells::Undo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginUndo(); + DoChange( TRUE ); + EndUndo(); + + // Markierung erst nach EndUndo + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->MarkRange( aEffRange ); +} + +void __EXPORT ScUndoDeleteCells::Redo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginRedo(); + DoChange( FALSE); + EndRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->DoneBlockMode(); // aktuelle weg +} + +void __EXPORT ScUndoDeleteCells::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( eCmd, TRUE ); +} + +BOOL __EXPORT ScUndoDeleteCells::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Zellen loeschen auf Mehrfachselektion +// + +ScUndoDeleteMulti::ScUndoDeleteMulti( ScDocShell* pNewDocShell, + BOOL bNewRows, USHORT nNewTab, + const USHORT* pRng, USHORT nRngCnt, + ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : + ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), + bRows( bNewRows ), + nTab( nNewTab ), + nRangeCnt( nRngCnt ) +{ + pRanges = new USHORT[ 2 * nRangeCnt ]; + memcpy(pRanges,pRng,nRangeCnt*2*sizeof(USHORT)); + SetChangeTrack(); +} + +__EXPORT ScUndoDeleteMulti::~ScUndoDeleteMulti() +{ + delete pRanges; +} + +String __EXPORT ScUndoDeleteMulti::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // wie DeleteCells +} + +void ScUndoDeleteMulti::DoChange() const +{ + if (bRows) + pDocShell->PostPaint( 0,pRanges[0],nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT ); + else + pDocShell->PostPaint( pRanges[0],0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_TOP ); + + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); + + ShowTable( nTab ); +} + +void ScUndoDeleteMulti::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + nStartChangeAction = pChangeTrack->GetActionMax() + 1; + ScRange aRange( 0, 0, nTab, 0, 0, nTab ); + if ( bRows ) + aRange.aEnd.SetCol( MAXCOL ); + else + aRange.aEnd.SetRow( MAXROW ); + // rueckwaerts loeschen + USHORT* pOneRange = &pRanges[2*nRangeCnt]; + for ( USHORT nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++ ) + { + USHORT nEnd = *(--pOneRange); + USHORT nStart = *(--pOneRange); + if ( bRows ) + { + aRange.aStart.SetRow( nStart ); + aRange.aEnd.SetRow( nEnd ); + } + else + { + aRange.aStart.SetCol( nStart ); + aRange.aEnd.SetCol( nEnd ); + } + ULONG nDummyStart; + pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc, + nDummyStart, nEndChangeAction ); + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +void __EXPORT ScUndoDeleteMulti::Undo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT* pOneRange; + USHORT nRangeNo; + + // rueckwaerts geloescht -> vorwaerts einfuegen + pOneRange = pRanges; + for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nStart = *(pOneRange++); + USHORT nEnd = *(pOneRange++); + if (bRows) + pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nStart,nEnd-nStart+1 ); + else + pDoc->InsertCol( 0,nTab, MAXROW,nTab, nStart,nEnd-nStart+1 ); + } + + pOneRange = pRanges; + for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nStart = *(pOneRange++); + USHORT nEnd = *(pOneRange++); + if (bRows) + pRefUndoDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,FALSE,pDoc ); + else + pRefUndoDoc->CopyToDocument( nStart,0,nTab, nEnd,MAXROW,nTab, IDF_ALL,FALSE,pDoc ); + } + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + DoChange(); + + //! Markierung wieder einzeichnen + //! geht im Moment nicht, da keine Daten fuer Markierung vorhanden! + + EndUndo(); +} + +void __EXPORT ScUndoDeleteMulti::Redo() +{ + WaitObject aWait( pDocShell->GetDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + // rueckwaerts loeschen + USHORT* pOneRange = &pRanges[2*nRangeCnt]; + for (USHORT nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nEnd = *(--pOneRange); + USHORT nStart = *(--pOneRange); + if (bRows) + pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart,nEnd-nStart+1 ); + else + pDoc->DeleteCol( 0,nTab, MAXROW,nTab, nStart,nEnd-nStart+1 ); + } + + SetChangeTrack(); + + DoChange(); + +//! Markierung loeschen, derzeit unnoetig (s.o.) +//! ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); +//! if (pViewShell) +//! DoneBlockMode(); + + EndRedo(); +} + +void __EXPORT ScUndoDeleteMulti::Repeat(SfxRepeatTarget& rTarget) +{ + // DeleteCells, falls einfache Selektion + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( DEL_DELROWS, TRUE ); +} + +BOOL __EXPORT ScUndoDeleteMulti::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Ausschneiden (Cut) +// + +ScUndoCut::ScUndoCut( ScDocShell* pNewDocShell, + ScRange aRange, ScAddress aOldEnd, + ScDocument* pNewUndoDoc ) : + ScBlockUndo( pNewDocShell, ScRange(aRange.aStart, aOldEnd), SC_UNDO_AUTOHEIGHT ), + aExtendedRange( aRange ), + pUndoDoc( pNewUndoDoc ) +{ + SetChangeTrack(); +} + +__EXPORT ScUndoCut::~ScUndoCut() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoCut::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_CUT ); // "Ausschneiden" +} + +void ScUndoCut::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, + nStartChangeAction, nEndChangeAction, SC_CACM_CUT ); + else + nStartChangeAction = nEndChangeAction = 0; +} + +void ScUndoCut::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nExtFlags = 0; + + if (bUndo) // nur bei Undo + { + pUndoDoc->CopyToDocument( aExtendedRange, IDF_ALL, FALSE, pDoc ); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + } + else // nur bei Redo + { + if (pDoc->HasAttrib( aExtendedRange, HASATTR_PAINTEXT )) + nExtFlags = SC_PF_LINES; + pDoc->DeleteAreaTab( aBlockRange, IDF_ALL ); + SetChangeTrack(); + } + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) +/*A*/ pDocShell->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags ); + + pDocShell->PostDataChanged(); + if (pViewShell) + pViewShell->CellContentChanged(); +} + +void __EXPORT ScUndoCut::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + +void __EXPORT ScUndoCut::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoCut::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->CutToClip(); +} + +BOOL __EXPORT ScUndoCut::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Einfuegen (Paste) +// + +ScUndoPaste::ScUndoPaste( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + const ScMarkData& rMark, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, + USHORT nNewFlags, + ScRangeName* pNewUndoRange, ScRangeName* pNewRedoRange, + ScDBCollection* pNewUndoDB, ScDBCollection* pNewRedoDB, + BOOL bRedoIsFilled ) : + ScSimpleUndo( pNewDocShell ), + aRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), + aMarkData( rMark ), + pUndoDoc( pNewUndoDoc ), + pRedoDoc( pNewRedoDoc ), + nFlags( nNewFlags ), + pUndoRange( pNewUndoRange ), + pRedoRange( pNewRedoRange ), + pUndoDB( pNewUndoDB ), + pRedoDB( pNewRedoDB ), + bRedoFilled( bRedoIsFilled ) +{ + if ( !aMarkData.IsMarked() ) // keine Zelle markiert: + aMarkData.SetMarkArea( aRange ); // Paste-Block markieren + SetChangeTrack(); +} + +__EXPORT ScUndoPaste::~ScUndoPaste() +{ + delete pUndoDoc; + delete pRedoDoc; + delete pUndoRange; + delete pRedoRange; + delete pUndoDB; + delete pRedoDB; +} + +String __EXPORT ScUndoPaste::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_PASTE ); // "Einfuegen" +} + +void ScUndoPaste::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack && (nFlags & IDF_CONTENTS) ) + pChangeTrack->AppendContentRange( aRange, pUndoDoc, + nStartChangeAction, nEndChangeAction, SC_CACM_PASTE ); + else + nStartChangeAction = nEndChangeAction = 0; +} + +void ScUndoPaste::DoChange( const BOOL bUndo ) +{ + ScRangeName* pWorkRange = bUndo ? pUndoRange : pRedoRange; + ScDBCollection* pWorkDB = bUndo ? pUndoDB : pRedoDB; + + // fuer Undo immer alle oder keine Inhalte sichern + USHORT nUndoFlags = IDF_NONE; + if (nFlags & IDF_CONTENTS) + nUndoFlags |= IDF_CONTENTS; + if (nFlags & IDF_ATTRIB) + nUndoFlags |= IDF_ATTRIB; + + BOOL bPaintAll = FALSE; + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aRange ); + + if ( bUndo && !bRedoFilled ) + { + if (!pRedoDoc) + { + BOOL bColInfo = ( aRange.aStart.Row()==0 && aRange.aEnd.Row()==MAXROW ); + BOOL bRowInfo = ( aRange.aStart.Col()==0 && aRange.aEnd.Col()==MAXCOL ); + pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRedoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aStart.Tab(), + bColInfo, bRowInfo ); + } + // Redo-Daten beim ersten Undo aus dem Dokument lesen + pDoc->CopyToDocument( aRange, nUndoFlags, FALSE, pRedoDoc ); + bRedoFilled = TRUE; + } + + BOOL bHasLines = pDoc->HasAttrib( aRange, HASATTR_PAINTEXT ); + + aMarkData.MarkToMulti(); + pDoc->DeleteSelection( nUndoFlags, aMarkData ); + aMarkData.MarkToSimple(); + + if ( !bUndo && pRedoDoc ) // Redo: UndoToDocument vorher + pRedoDoc->UndoToDocument( aRange, nUndoFlags, FALSE, pDoc ); + + if (pWorkRange) + pDoc->SetRangeName( new ScRangeName( *pWorkRange ) ); + if (pWorkDB) + { + pDoc->SetDBCollection( new ScDBCollection( *pWorkDB ) ); + if ( pDoc->RefreshAutoFilter( 0,0, MAXCOL,MAXROW, aRange.aStart.Tab() ) ) + bPaintAll = TRUE; + } + + if (bUndo) // Undo: UndoToDocument hinterher + pUndoDoc->UndoToDocument( aRange, nUndoFlags, FALSE, pDoc ); + + if ( bUndo ) + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + } + else + SetChangeTrack(); + + ScRange aDrawRange( aRange ); + USHORT nPaint = PAINT_GRID; + USHORT nPaintExt = 0; + if (bPaintAll) + { + aDrawRange.aStart.SetCol(0); + aDrawRange.aStart.SetRow(0); + aDrawRange.aEnd.SetCol(MAXCOL); + aDrawRange.aEnd.SetRow(MAXROW); + nPaint |= PAINT_TOP | PAINT_LEFT; +/*A*/ if (pViewShell) + pViewShell->AdjustBlockHeight(FALSE); + } + else + { + if ( aRange.aStart.Row() == 0 && aRange.aEnd.Row() == MAXROW ) // ganze Spalte + { + nPaint |= PAINT_TOP; + aDrawRange.aEnd.SetCol(MAXCOL); + } + if ( aRange.aStart.Col() == 0 && aRange.aEnd.Col() == MAXCOL ) // ganze Zeile + { + nPaint |= PAINT_LEFT; + aDrawRange.aEnd.SetRow(MAXROW); + } +/*A*/ if ((pViewShell) && pViewShell->AdjustBlockHeight(FALSE)) + { + aDrawRange.aStart.SetCol(0); + aDrawRange.aStart.SetRow(0); + aDrawRange.aEnd.SetCol(MAXCOL); + aDrawRange.aEnd.SetRow(MAXROW); + nPaint |= PAINT_LEFT; + } + bHasLines |= pDoc->HasAttrib( aDrawRange, HASATTR_PAINTEXT ); + if (bHasLines) nPaintExt = SC_PF_LINES; + } + pDocShell->PostPaint( aDrawRange, nPaint, nPaintExt ); + + pDocShell->PostDataChanged(); + if (pViewShell) + pViewShell->CellContentChanged(); +} + +void __EXPORT ScUndoPaste::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + ShowTable( aRange ); + EndUndo(); +} + +void __EXPORT ScUndoPaste::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoPaste::Repeat(SfxRepeatTarget& rTarget) +{ +//? Extra-Flags sichern ? + + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->PasteFromClip( nFlags ); +} + +BOOL __EXPORT ScUndoPaste::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Verschieben/Kopieren (Drag & Drop) +// + +ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell, + const ScRange& rRange, ScAddress aNewDestPos, BOOL bNewCut, + ScDocument* pUndoDocument, ScRefUndoData* pRefData, BOOL bScenario ) : + ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFFIRST ), + aSrcRange( rRange ), + bCut( bNewCut ), + bKeepScenarioFlags( bScenario ) +{ + ScAddress aDestEnd(aNewDestPos); + aDestEnd.IncRow(aSrcRange.aEnd.Row() - aSrcRange.aStart.Row()); + aDestEnd.IncCol(aSrcRange.aEnd.Col() - aSrcRange.aStart.Col()); + aDestEnd.IncTab(aSrcRange.aEnd.Tab() - aSrcRange.aStart.Tab()); + + aDestRange.aStart = aNewDestPos; + aDestRange.aEnd = aDestEnd; + + SetChangeTrack(); +} + +__EXPORT ScUndoDragDrop::~ScUndoDragDrop() +{ +} + +String __EXPORT ScUndoDragDrop::GetComment() const +{ // "Verschieben" : "Kopieren" + return bCut ? + ScGlobal::GetRscString( STR_UNDO_MOVE ) : + ScGlobal::GetRscString( STR_UNDO_COPY ); +} + +void ScUndoDragDrop::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + if ( bCut ) + { + nStartChangeAction = pChangeTrack->GetActionMax() + 1; + pChangeTrack->AppendMove( aSrcRange, aDestRange, pRefUndoDoc ); + nEndChangeAction = pChangeTrack->GetActionMax(); + } + else + pChangeTrack->AppendContentRange( aDestRange, pRefUndoDoc, + nStartChangeAction, nEndChangeAction ); + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +void ScUndoDragDrop::PaintArea( ScRange aRange ) const +{ + USHORT nExtFlags = PAINT_GRID; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + if (pViewShell) + { + VirtualDevice aVirtDev; + ScViewData* pViewData = pViewShell->GetViewData(); + + if ( pDoc->SetOptimalHeight( aRange.aStart.Row(), aRange.aEnd.Row(), + aRange.aStart.Tab(), 0, &aVirtDev, + pViewData->GetPPTX(), pViewData->GetPPTY(), + pViewData->GetZoomX(), pViewData->GetZoomY(), + FALSE ) ) + { + aRange.aStart.SetCol(0); + aRange.aEnd.SetCol(MAXCOL); + aRange.aEnd.SetRow(MAXROW); + nExtFlags |= PAINT_LEFT; + } + } + + if ( bKeepScenarioFlags ) + { + // Szenarien mitkopiert -> auch Szenario-Rahmen painten + aRange.aStart.SetCol(0); + aRange.aStart.SetRow(0); + aRange.aEnd.SetCol(MAXCOL); + aRange.aEnd.SetRow(MAXROW); + } + + pDocShell->PostPaint( aRange, nExtFlags ); +} + + +void ScUndoDragDrop::DoUndo( ScRange aRange ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + +//? DB-Areas vor Daten, damit bei ExtendMerge die Autofilter-Knoepfe stimmen + + ScRange aPaintRange = aRange; + pDoc->ExtendMerge( aPaintRange ); // vor dem Loeschen + + pDoc->DeleteAreaTab( aRange, IDF_ALL ); + pRefUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc ); + if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) ) + pDoc->ExtendMerge( aRange, TRUE ); + + aPaintRange.aEnd.SetCol( Max( aPaintRange.aEnd.Col(), aRange.aEnd.Col() ) ); + aPaintRange.aEnd.SetRow( Max( aPaintRange.aEnd.Row(), aRange.aEnd.Row() ) ); + PaintArea( aPaintRange ); +} + +void __EXPORT ScUndoDragDrop::Undo() +{ + BeginUndo(); + DoUndo(aDestRange); + if (bCut) + DoUndo(aSrcRange); + EndUndo(); +} + +void __EXPORT ScUndoDragDrop::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); + + USHORT nTab; + ScMarkData aSourceMark; + for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++) + aSourceMark.SelectTable( nTab, TRUE ); + pDoc->CopyToClip( aSrcRange.aStart.Col(), aSrcRange.aStart.Row(), + aSrcRange.aEnd.Col(), aSrcRange.aEnd.Row(), + bCut, pClipDoc, FALSE, &aSourceMark, bKeepScenarioFlags ); + + if (bCut) + { + ScRange aSrcPaintRange = aSrcRange; + pDoc->ExtendMerge( aSrcPaintRange ); // vor dem Loeschen + pDoc->DeleteAreaTab( aSrcRange, IDF_ALL ); + PaintArea( aSrcPaintRange ); + } + + ScMarkData aDestMark; + for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++) + aDestMark.SelectTable( nTab, TRUE ); + pDoc->CopyFromClip( aDestRange, aDestMark, IDF_ALL, NULL, pClipDoc, TRUE ); + for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++) + { + USHORT nEndCol = aDestRange.aEnd.Col(); + USHORT nEndRow = aDestRange.aEnd.Row(); + pDoc->ExtendMerge( aDestRange.aStart.Col(), aDestRange.aStart.Row(), + nEndCol, nEndRow, nTab, TRUE ); + PaintArea( ScRange( aDestRange.aStart.Col(), aDestRange.aStart.Row(), nTab, + nEndCol, nEndRow, nTab ) ); + } + + SetChangeTrack(); + + delete pClipDoc; + ShowTable( aDestRange.aStart.Tab() ); + EndRedo(); +} + +void __EXPORT ScUndoDragDrop::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoDragDrop::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht +} + + +// ----------------------------------------------------------------------- +// +// Liste der Bereichsnamen einfuegen +// (Einfuegen|Name|Einfuegen =>[Liste]) +// + +ScUndoListNames::ScUndoListNames( ScDocShell* pNewDocShell, const ScRange& rRange, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ) : + ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ), + pUndoDoc( pNewUndoDoc ), + pRedoDoc( pNewRedoDoc ) +{ +} + +__EXPORT ScUndoListNames::~ScUndoListNames() +{ + delete pUndoDoc; + delete pRedoDoc; +} + +String __EXPORT ScUndoListNames::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_LISTNAMES ); +} + +void ScUndoListNames::DoChange( ScDocument* pSrcDoc ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + pDoc->DeleteAreaTab( aBlockRange, IDF_ALL ); + pSrcDoc->CopyToDocument( aBlockRange, IDF_ALL, FALSE, pDoc ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID ); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); +} + +void __EXPORT ScUndoListNames::Undo() +{ + BeginUndo(); + DoChange(pUndoDoc); + EndUndo(); +} + +void __EXPORT ScUndoListNames::Redo() +{ + BeginRedo(); + DoChange(pRedoDoc); + EndRedo(); +} + +void __EXPORT ScUndoListNames::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->InsertNameList(); +} + +BOOL __EXPORT ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Szenario anwenden +// (Extras|Szenarien) +// + +ScUndoUseScenario::ScUndoUseScenario( ScDocShell* pNewDocShell, + const ScMarkData& rMark, +/*C*/ const ScArea& rDestArea, + ScDocument* pNewUndoDoc, + const String& rNewName ) : + ScSimpleUndo( pNewDocShell ), + pUndoDoc( pNewUndoDoc ), + aMarkData( rMark ), + aName( rNewName ) +{ + aRange.aStart.SetCol(rDestArea.nColStart); + aRange.aStart.SetRow(rDestArea.nRowStart); + aRange.aStart.SetTab(rDestArea.nTab); + aRange.aEnd.SetCol(rDestArea.nColEnd); + aRange.aEnd.SetRow(rDestArea.nRowEnd); + aRange.aEnd.SetTab(rDestArea.nTab); +} + +__EXPORT ScUndoUseScenario::~ScUndoUseScenario() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoUseScenario::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_USESCENARIO ); +} + +void __EXPORT ScUndoUseScenario::Undo() +{ + BeginUndo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + } + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->DeleteSelection( IDF_ALL, aMarkData ); + pUndoDoc->CopyToDocument( aRange, IDF_ALL, TRUE, pDoc, &aMarkData ); + + // Szenario-Tabellen + BOOL bFrame = FALSE; + USHORT nTab = aRange.aStart.Tab(); + USHORT nEndTab = nTab; + while ( pUndoDoc->HasTable(nEndTab+1) && pUndoDoc->IsScenario(nEndTab+1) ) + ++nEndTab; + for (USHORT i = nTab+1; i<=nEndTab; i++) + { + // Flags immer + String aComment; + Color aColor; + USHORT nScenFlags; + pUndoDoc->GetScenarioData( i, aComment, aColor, nScenFlags ); + pDoc->SetScenarioData( i, aComment, aColor, nScenFlags ); + BOOL bActive = pUndoDoc->IsActiveScenario( i ); + pDoc->SetActiveScenario( i, bActive ); + // Bei Zurueckkopier-Szenarios auch Inhalte + if ( nScenFlags & SC_SCENARIO_TWOWAY ) + { + pDoc->DeleteAreaTab( 0,0, MAXCOL,MAXROW, i, IDF_ALL ); + pUndoDoc->CopyToDocument( 0,0,i, MAXCOL,MAXROW,i, IDF_ALL,FALSE, pDoc ); + } + if ( nScenFlags & SC_SCENARIO_SHOWFRAME ) + bFrame = TRUE; + } + + // Wenn sichtbare Rahmen, dann alles painten + if (bFrame) + pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_EXTRAS ); + else + pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS ); + pDocShell->PostDataChanged(); + if (pViewShell) + pViewShell->CellContentChanged(); + + ShowTable( aRange.aStart.Tab() ); + + EndUndo(); +} + +void __EXPORT ScUndoUseScenario::Redo() +{ + USHORT nTab = aRange.aStart.Tab(); + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->SetTabNo( nTab ); + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + } + + pDocShell->UseScenario( nTab, aName, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoUseScenario::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + String aTemp = aName; + ((ScTabViewTarget&)rTarget).GetViewShell()->UseScenario(aTemp); + } +} + +BOOL __EXPORT ScUndoUseScenario::CanRepeat(SfxRepeatTarget& rTarget) const +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData(); + return !pViewData->GetDocument()->IsScenario( pViewData->GetTabNo() ); + } + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Vorlage anwenden +// (Format|Vorlagenkatalog) +// + +ScUndoSelectionStyle::ScUndoSelectionStyle( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + const ScRange& rRange, + const String& rName, + ScDocument* pNewUndoDoc ) : + ScSimpleUndo( pNewDocShell ), + aMarkData( rMark ), + aRange( rRange ), + aStyleName( rName ), + pUndoDoc( pNewUndoDoc ) +{ + aMarkData.MarkToMulti(); +} + +__EXPORT ScUndoSelectionStyle::~ScUndoSelectionStyle() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoSelectionStyle::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_APPLYCELLSTYLE ); +} + +void ScUndoSelectionStyle::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + ScRange aWorkRange( aRange ); + if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? + pDoc->ExtendMerge( aWorkRange, TRUE ); + + BOOL bHasLines = pDoc->HasAttrib( aWorkRange, HASATTR_PAINTEXT ); + + if (bUndo) // bei Undo alte Daten wieder reinschubsen + { + USHORT nTabCount = pDoc->GetTableCount(); + ScRange aCopyRange = aWorkRange; + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData ); + } + else // bei Redo Style wieder zuweisen + { + ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); + ScStyleSheet* pStyleSheet = + (ScStyleSheet*) pStlPool->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); + if (!pStyleSheet) + { + DBG_ERROR("StyleSheet not found"); + return; + } + pDoc->ApplySelectionStyle( *pStyleSheet, aMarkData ); + } + + bHasLines = bHasLines || pDoc->HasAttrib( aWorkRange, HASATTR_PAINTEXT ); + + if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) +/*A*/ pDocShell->PostPaint( aWorkRange, PAINT_GRID | PAINT_EXTRAS, (bHasLines ? SC_PF_LINES : 0) ); + + ShowTable( aWorkRange.aStart.Tab() ); +} + +void __EXPORT ScUndoSelectionStyle::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + +void __EXPORT ScUndoSelectionStyle::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoSelectionStyle::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScDocument* pDoc = pDocShell->GetDocument(); + ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); + ScStyleSheet* pStyleSheet = (ScStyleSheet*) pStlPool-> + Find( aStyleName, SFX_STYLE_FAMILY_PARA ); + if (!pStyleSheet) + { + DBG_ERROR("StyleSheet not found"); + return; + } + + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + rViewShell.SetStyleSheetToMarked( pStyleSheet, TRUE ); + } +} + +BOOL __EXPORT ScUndoSelectionStyle::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +USHORT __EXPORT ScUndoSelectionStyle::GetId() const +{ + return STR_UNDO_APPLYCELLSTYLE; +} + + +// ----------------------------------------------------------------------- +// +// Matrix-Formel eingeben +// + +ScUndoEnterMatrix::ScUndoEnterMatrix( ScDocShell* pNewDocShell, const ScRange& rArea, + ScDocument* pNewUndoDoc, const String& rForm ) : + ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ), + pUndoDoc( pNewUndoDoc ), + aFormula( rForm ) +{ + SetChangeTrack(); +} + +__EXPORT ScUndoEnterMatrix::~ScUndoEnterMatrix() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoEnterMatrix::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_ENTERMATRIX ); +} + +void ScUndoEnterMatrix::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, + nStartChangeAction, nEndChangeAction ); + else + nStartChangeAction = nEndChangeAction = 0; +} + +void __EXPORT ScUndoEnterMatrix::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + pDoc->DeleteAreaTab( aBlockRange, IDF_ALL ); + pUndoDoc->CopyToDocument( aBlockRange, IDF_ALL, FALSE, pDoc ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID ); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + EndUndo(); +} + +void __EXPORT ScUndoEnterMatrix::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + ScMarkData aDestMark; + aDestMark.SelectOneTable( aBlockRange.aStart.Tab() ); + aDestMark.SetMarkArea( aBlockRange ); + + pDoc->InsertMatrixFormula( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), + aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), + aDestMark, aFormula ); +// pDocShell->PostPaint( aBlockRange, PAINT_GRID ); // nicht noetig ??? + + SetChangeTrack(); + + EndRedo(); +} + +void __EXPORT ScUndoEnterMatrix::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + String aTemp = aFormula; + ((ScTabViewTarget&)rTarget).GetViewShell()->EnterMatrix(aTemp); + } +} + +BOOL __EXPORT ScUndoEnterMatrix::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// Einzug vermindern / erhoehen +// + +ScRange lcl_GetMultiMarkRange( const ScMarkData& rMark ) +{ + ScRange aRange; + rMark.GetMultiMarkArea( aRange ); + return aRange; +} + +ScUndoIndent::ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark, + ScDocument* pNewUndoDoc, BOOL bIncrement ) : + ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), + aMarkData( rMark ), + pUndoDoc( pNewUndoDoc ), + bIsIncrement( bIncrement ) +{ +} + +__EXPORT ScUndoIndent::~ScUndoIndent() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoIndent::GetComment() const +{ + USHORT nId = bIsIncrement ? STR_UNDO_INC_INDENT : STR_UNDO_DEC_INDENT; + return ScGlobal::GetRscString( nId ); +} + +void __EXPORT ScUndoIndent::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTabCount = pDoc->GetTableCount(); + ScRange aCopyRange = aBlockRange; + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndUndo(); +} + +void __EXPORT ScUndoIndent::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->ChangeSelectionIndent( bIsIncrement, aMarkData ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndRedo(); +} + +void __EXPORT ScUndoIndent::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->ChangeIndent( bIsIncrement ); +} + +BOOL __EXPORT ScUndoIndent::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// einzelne Items per Which-IDs aus Bereich loeschen +// + +ScUndoClearItems::ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark, + ScDocument* pNewUndoDoc, const USHORT* pW ) : + ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), + aMarkData( rMark ), + pUndoDoc( pNewUndoDoc ), + pWhich( NULL ) +{ + DBG_ASSERT( pW, "ScUndoClearItems: Which-Pointer ist 0" ); + + USHORT nCount = 0; + while ( pW[nCount] ) + ++nCount; + pWhich = new USHORT[nCount+1]; + for (USHORT i=0; i<=nCount; i++) + pWhich[i] = pW[i]; +} + +__EXPORT ScUndoClearItems::~ScUndoClearItems() +{ + delete pUndoDoc; + delete pWhich; +} + +String __EXPORT ScUndoClearItems::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); +} + +void __EXPORT ScUndoClearItems::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndUndo(); +} + +void __EXPORT ScUndoClearItems::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->ClearSelectionItems( pWhich, aMarkData ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndRedo(); +} + +void __EXPORT ScUndoClearItems::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData(); + ScDocFunc aFunc(*pViewData->GetDocShell()); + aFunc.ClearItems( pViewData->GetMarkData(), pWhich, FALSE ); + } +} + +BOOL __EXPORT ScUndoClearItems::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// Alle Umbrueche einer Tabelle loeschen +// + +ScUndoRemoveBreaks::ScUndoRemoveBreaks( ScDocShell* pNewDocShell, + USHORT nNewTab, ScDocument* pNewUndoDoc ) : + ScSimpleUndo( pNewDocShell ), + nTab( nNewTab ), + pUndoDoc( pNewUndoDoc ) +{ +} + +__EXPORT ScUndoRemoveBreaks::~ScUndoRemoveBreaks() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoRemoveBreaks::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_REMOVEBREAKS ); +} + +void __EXPORT ScUndoRemoveBreaks::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pDoc ); + if (pViewShell) + pViewShell->UpdatePageBreakData( TRUE ); + pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); + + EndUndo(); +} + +void __EXPORT ScUndoRemoveBreaks::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + pDoc->RemoveManualBreaks(nTab); + pDoc->UpdatePageBreaks(nTab); + if (pViewShell) + pViewShell->UpdatePageBreakData( TRUE ); + pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); + + EndRedo(); +} + +void __EXPORT ScUndoRemoveBreaks::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + rViewShell.RemoveManualBreaks(); + } +} + +BOOL __EXPORT ScUndoRemoveBreaks::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// Zusammenfassung aufheben (fuer einen ganzen Bereich) +// + +ScUndoRemoveMerge::ScUndoRemoveMerge( ScDocShell* pNewDocShell, + const ScRange& rArea, ScDocument* pNewUndoDoc ) : + ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ), + pUndoDoc( pNewUndoDoc ) +{ +} + +__EXPORT ScUndoRemoveMerge::~ScUndoRemoveMerge() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoRemoveMerge::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_REMERGE ); // "Zusammenfassung aufheben" +} + +void __EXPORT ScUndoRemoveMerge::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + ScRange aExtended = aBlockRange; + pUndoDoc->ExtendMerge( aExtended ); + + pDoc->DeleteAreaTab( aExtended, IDF_ATTRIB ); + pUndoDoc->CopyToDocument( aExtended, IDF_ATTRIB, FALSE, pDoc ); + + BOOL bDidPaint = FALSE; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if ( pViewShell ) + { + pViewShell->SetTabNo( aExtended.aStart.Tab() ); + bDidPaint = pViewShell->AdjustRowHeight( aExtended.aStart.Row(), aExtended.aEnd.Row() ); + } + if (!bDidPaint) + ScUndoUtil::PaintMore( pDocShell, aExtended ); + + EndUndo(); +} + +void __EXPORT ScUndoRemoveMerge::Redo() +{ + BeginRedo(); + + USHORT nTab = aBlockRange.aStart.Tab(); + ScDocument* pDoc = pDocShell->GetDocument(); + ScRange aExtended = aBlockRange; + pDoc->ExtendMerge( aExtended ); + ScRange aRefresh = aExtended; + pDoc->ExtendOverlapped( aRefresh ); + + // ausfuehren + + const SfxPoolItem& rDefAttr = pDoc->GetPool()->GetDefaultItem( ATTR_MERGE ); + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( rDefAttr ); + pDoc->ApplyPatternAreaTab( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), + aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), nTab, + aPattern ); + + pDoc->RemoveFlagsTab( aExtended.aStart.Col(), aExtended.aStart.Row(), + aExtended.aEnd.Col(), aExtended.aEnd.Row(), nTab, + SC_MF_HOR | SC_MF_VER ); + + pDoc->ExtendMerge( aRefresh, TRUE, FALSE ); + + // Paint + + BOOL bDidPaint = FALSE; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if ( pViewShell ) + { + pViewShell->SetTabNo( aExtended.aStart.Tab() ); + bDidPaint = pViewShell->AdjustRowHeight( aExtended.aStart.Row(), aExtended.aEnd.Row() ); + } + if (!bDidPaint) + ScUndoUtil::PaintMore( pDocShell, aExtended ); + + EndRedo(); +} + +void __EXPORT ScUndoRemoveMerge::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveMerge(); +} + +BOOL __EXPORT ScUndoRemoveMerge::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// nur Umrandung setzen, per ScRangeList (StarOne) +// + +ScRange lcl_TotalRange( const ScRangeList& rRanges ) +{ + ScRange aTotal; + ULONG nCount = rRanges.Count(); + for (ULONG i=0; i<nCount; i++) + { + ScRange aRange = *rRanges.GetObject(i); + if (i==0) + aTotal = aRange; + else + { + if (aRange.aStart.Col() < aTotal.aStart.Col()) + aTotal.aStart.SetCol(aRange.aStart.Col()); + if (aRange.aStart.Row() < aTotal.aStart.Row()) + aTotal.aStart.SetRow(aRange.aStart.Row()); + if (aRange.aStart.Tab() < aTotal.aStart.Tab()) + aTotal.aStart.SetTab(aRange.aStart.Tab()); + if (aRange.aEnd.Col() > aTotal.aEnd.Col()) + aTotal.aEnd.SetCol(aRange.aEnd.Col()); + if (aRange.aEnd.Row() > aTotal.aEnd.Row()) + aTotal.aEnd.SetRow(aRange.aEnd.Row()); + if (aRange.aEnd.Tab() > aTotal.aEnd.Tab()) + aTotal.aEnd.SetTab(aRange.aEnd.Tab()); + } + } + return aTotal; +} + +ScUndoBorder::ScUndoBorder( ScDocShell* pNewDocShell, + const ScRangeList& rRangeList, ScDocument* pNewUndoDoc, + const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner ) : + ScBlockUndo( pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE ), + pUndoDoc( pNewUndoDoc ) +{ + pRanges = new ScRangeList(rRangeList); + pOuter = new SvxBoxItem(rNewOuter); + pInner = new SvxBoxInfoItem(rNewInner); +} + +__EXPORT ScUndoBorder::~ScUndoBorder() +{ + delete pUndoDoc; + delete pRanges; + delete pOuter; + delete pInner; +} + +String __EXPORT ScUndoBorder::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_SELATTRLINES ); //! eigener String? +} + +void __EXPORT ScUndoBorder::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScMarkData aMarkData; + aMarkData.MarkFromRangeList( *pRanges, FALSE ); + pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData ); + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndUndo(); +} + +void __EXPORT ScUndoBorder::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); //! Funktion an docfunc aufrufen + ULONG nCount = pRanges->Count(); + ULONG i; + for (i=0; i<nCount; i++) + { + ScRange aRange = *pRanges->GetObject(i); + USHORT nTab = aRange.aStart.Tab(); + + ScMarkData aMark; + aMark.SetMarkArea( aRange ); + aMark.SelectTable( nTab, TRUE ); + + pDoc->ApplySelectionFrame( aMark, pOuter, pInner ); + } + for (i=0; i<nCount; i++) + pDocShell->PostPaint( *pRanges->GetObject(i), PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + EndRedo(); +} + +void __EXPORT ScUndoBorder::Repeat(SfxRepeatTarget& rTarget) +{ + //! spaeter (wenn die Funktion aus cellsuno nach docfunc gewandert ist) +} + +BOOL __EXPORT ScUndoBorder::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // s.o. +} + + + + diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx new file mode 100644 index 000000000000..041a9f9c2239 --- /dev/null +++ b/sc/source/ui/undo/undoblk2.cxx @@ -0,0 +1,308 @@ +/************************************************************************* + * + * $RCSfile: undoblk2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SVDSURO_HXX + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include "scitems.hxx" // SearchItem +//#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "undoblk.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "olinetab.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "target.hxx" + +#include "undoolk.hxx" //! GetUndo ins Document verschieben! + + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScUndoWidthOrHeight, SfxUndoAction); + +// ----------------------------------------------------------------------- + + + +// +// Spaltenbreiten oder Zeilenhoehen aendern +// + +ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + USHORT nNewStart, USHORT nNewStartTab, USHORT nNewEnd, USHORT nNewEndTab, + ScDocument* pNewUndoDoc, USHORT nNewCnt, USHORT* pNewRanges, + ScOutlineTable* pNewUndoTab, + ScSizeMode eNewMode, USHORT nNewSizeTwips, BOOL bNewWidth ) : + ScSimpleUndo( pNewDocShell ), + aMarkData( rMark ), + nStart( nNewStart ), + nEnd( nNewEnd ), + nStartTab( nNewStartTab ), + nEndTab( nNewEndTab ), + pUndoDoc( pNewUndoDoc ), + nRangeCnt( nNewCnt ), + pRanges( pNewRanges ), + pUndoTab( pNewUndoTab ), + eMode( eNewMode ), + nNewSize( nNewSizeTwips ), + bWidth( bNewWidth ), + pDrawUndo( NULL ) +{ + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); +} + +__EXPORT ScUndoWidthOrHeight::~ScUndoWidthOrHeight() +{ + delete[] pRanges; + delete pUndoDoc; + delete pUndoTab; + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoWidthOrHeight::GetComment() const +{ + // [ "optimale " ] "Spaltenbreite" | "Zeilenhoehe" + return ( bWidth ? + ( ( eMode == SC_SIZE_OPTIMAL )? + ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH ) : + ScGlobal::GetRscString( STR_UNDO_COLWIDTH ) + ) : + ( ( eMode == SC_SIZE_OPTIMAL )? + ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT ) : + ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT ) + ) ); +} + +void __EXPORT ScUndoWidthOrHeight::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (eMode==SC_SIZE_OPTIMAL) + { + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + } + + if (pUndoTab) // Outlines mit gespeichert? + pDoc->SetOutlineTable( nStartTab, pUndoTab ); + + USHORT nPaintStart = nStart ? nStart-1 : 0; + if (bWidth) // Width + { + pUndoDoc->CopyToDocument( nStart, 0, nStartTab, nEnd, MAXROW, nEndTab, IDF_NONE, FALSE, pDoc ); + for (USHORT i=nStartTab; i<=nEndTab; i++) + pDoc->UpdatePageBreaks( i ); + pDocShell->PostPaint( nPaintStart, 0, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID | PAINT_TOP ); + } + else // Height + { + pUndoDoc->CopyToDocument( 0, nStart, nStartTab, MAXCOL, nEnd, nEndTab, IDF_NONE, FALSE, pDoc ); + for (USHORT i=nStartTab; i<=nEndTab; i++) + pDoc->UpdatePageBreaks( i ); + pDocShell->PostPaint( 0, nPaintStart, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID | PAINT_LEFT ); + } + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); + + if (pViewShell) + { + pViewShell->UpdateScrollBars(); + + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + if ( nTab < nStartTab || nTab > nEndTab ) + pViewShell->SetTabNo( nStartTab ); + } + + EndUndo(); +} + +void __EXPORT ScUndoWidthOrHeight::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (eMode==SC_SIZE_OPTIMAL) + { + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + } + + if (pViewShell) + { + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + if ( nTab < nStartTab || nTab > nEndTab ) + pViewShell->SetTabNo( nStartTab ); + } + + // SetWidthOrHeight aendert aktuelle Tabelle ! + pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize, TRUE ); +} + +BOOL __EXPORT ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.18 2000/09/17 14:09:28 willem.vandorp + OpenOffice header added. + + Revision 1.17 2000/08/31 16:38:39 willem.vandorp + Header and footer replaced + + Revision 1.16 1999/10/27 14:46:07 hr + #65293#: removed SEG_EOFGLOBALS() SEG_FUNCDEF + + Revision 1.15 1996/09/04 17:46:18 RJ + ueberarbeitet + + + Rev 1.14 04 Sep 1996 19:46:18 RJ + ueberarbeitet + + Rev 1.13 19 Aug 1996 21:29:44 NN + Markierungen werden nicht mehr am Dokument gehalten + + Rev 1.12 08 Dec 1995 14:31:46 NN + ScSimpleUndo + + Rev 1.11 10 Oct 1995 09:52:12 NN + Paint beim Ausblenden + + Rev 1.10 09 Oct 1995 15:49:16 NN + ScTabViewTarget fuer Repeat + + Rev 1.9 04 Oct 1995 19:51:52 NN + Repeat mit ViewShell als RepeatTarget + + Rev 1.8 12 Jul 1995 15:07:26 NN + __EXPORT bei Destruktoren + + Rev 1.7 11 Jul 1995 12:39:06 HJS + add: __EXPORT + + Rev 1.6 17 Jun 1995 14:00:04 TRI + EXPORTS + + Rev 1.5 15 Jun 1995 08:52:46 TRI + EXPORT + + Rev 1.4 06 Jun 1995 12:35:28 NN + Abfrage, ob ViewShell vorhanden + + Rev 1.3 24 Mar 1995 18:39:00 SC + out of keys hack + + Rev 1.2 22 Mar 1995 16:39:10 STE + undoblk3 abgesplittet + + Rev 1.1 21 Mar 1995 14:40:08 TRI + Out of Keys - Defines eingebaut + + Rev 1.0 08 Mar 1995 02:51:52 SC + aufgeteilt + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx new file mode 100644 index 000000000000..5bd8bcd8a87c --- /dev/null +++ b/sc/source/ui/undo/undoblk3.cxx @@ -0,0 +1,2053 @@ +/************************************************************************* + * + * $RCSfile: undoblk3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//---------------------------------------------------------------------------- + +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SVDSURO_HXX + +// INCLUDE ------------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/boxitem.hxx> +#include <svx/srchitem.hxx> +#include <svx/linkmgr.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/virdev.hxx> + +#include "undoblk.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "global.hxx" +#include "rangenam.hxx" +#include "arealink.hxx" +#include "patattr.hxx" +#include "target.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "table.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "undoolk.hxx" +#include "undoutil.hxx" +#include "chgtrack.hxx" +#include "dociter.hxx" + +// STATIC DATA --------------------------------------------------------------- + +TYPEINIT1(ScUndoDeleteContents, SfxUndoAction); +TYPEINIT1(ScUndoFillTable, SfxUndoAction); +TYPEINIT1(ScUndoSelectionAttr, SfxUndoAction); +TYPEINIT1(ScUndoAutoFill, SfxUndoAction); +TYPEINIT1(ScUndoMerge, SfxUndoAction); +TYPEINIT1(ScUndoAutoFormat, SfxUndoAction); +TYPEINIT1(ScUndoReplace, SfxUndoAction); +TYPEINIT1(ScUndoTabOp, SfxUndoAction); +TYPEINIT1(ScUndoSpelling, SfxUndoAction); +TYPEINIT1(ScUndoRefreshLink, SfxUndoAction); +TYPEINIT1(ScUndoInsertAreaLink, SfxUndoAction); +TYPEINIT1(ScUndoRemoveAreaLink, SfxUndoAction); +TYPEINIT1(ScUndoUpdateAreaLink, SfxUndoAction); + + +// To Do: +/*A*/ // SetOptimalHeight auf Dokument, wenn keine View + + +//============================================================================ +// class ScUndoDeleteContents +// +// Inhalte loeschen + +//---------------------------------------------------------------------------- + +ScUndoDeleteContents::ScUndoDeleteContents( + ScDocShell* pNewDocShell, + const ScMarkData& rMark, const ScRange& rRange, + ScDocument* pNewUndoDoc, BOOL bNewMulti, + USHORT nNewFlags, BOOL bObjects ) + // + : ScSimpleUndo( pNewDocShell ), + // + aMarkData ( rMark ), + aRange ( rRange ), + pUndoDoc ( pNewUndoDoc ), + bMulti ( bNewMulti ), // ueberliquid + nFlags ( nNewFlags ), + pDrawUndo ( NULL ) +{ + if (bObjects) + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); + + if ( !(aMarkData.IsMarked() || aMarkData.IsMultiMarked()) ) // keine Zelle markiert: + aMarkData.SetMarkArea( aRange ); // Zelle unter Cursor markieren + + SetChangeTrack(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoDeleteContents::~ScUndoDeleteContents() +{ + delete pUndoDoc; + DeleteSdrUndoAction( pDrawUndo ); +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoDeleteContents::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); // "Loeschen" +} + + +void ScUndoDeleteContents::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack && (nFlags & IDF_CONTENTS) ) + pChangeTrack->AppendContentRange( aRange, pUndoDoc, + nStartChangeAction, nEndChangeAction ); + else + nStartChangeAction = nEndChangeAction = 0; +} + + +//---------------------------------------------------------------------------- + +void ScUndoDeleteContents::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + BOOL bPaintExt = FALSE; + + if (bUndo) // nur Undo + { + USHORT nUndoFlags = IDF_NONE; // entweder alle oder keine Inhalte kopieren + if (nFlags & IDF_CONTENTS) // (es sind nur die richtigen ins UndoDoc kopiert worden) + nUndoFlags |= IDF_CONTENTS; + if (nFlags & IDF_ATTRIB) + nUndoFlags |= IDF_ATTRIB; + if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute + nUndoFlags |= IDF_STRING; // -> Zellen werden geaendert + + ScRange aCopyRange = aRange; + USHORT nTabCount = pDoc->GetTableCount(); + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + + pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, bMulti, pDoc, &aMarkData ); + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + bPaintExt = pDoc->HasAttrib( aRange, HASATTR_PAINTEXT ); // hinterher + } + else // nur Redo + { + bPaintExt = pDoc->HasAttrib( aRange, HASATTR_PAINTEXT ); // vorher + + aMarkData.MarkToMulti(); + if (pDrawUndo) + pDoc->DeleteObjectsInSelection( aMarkData ); + pDoc->DeleteSelection( nFlags, aMarkData ); + aMarkData.MarkToSimple(); + + SetChangeTrack(); + } + + USHORT nExtFlags = bPaintExt ? SC_PF_LINES : 0; + if ( !( (pViewShell) && pViewShell->AdjustRowHeight( + aRange.aStart.Row(), aRange.aEnd.Row() ) ) ) +/*A*/ pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags ); + + pDocShell->PostDataChanged(); + if (pViewShell) + pViewShell->CellContentChanged(); + + ShowTable( aRange ); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoDeleteContents::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoDeleteContents::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoDeleteContents::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteContents( nFlags, TRUE ); +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoDeleteContents::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoFillTable +// +// Tabellen ausfuellen +// (Bearbeiten|Ausfuellen|...) + +//---------------------------------------------------------------------------- + +ScUndoFillTable::ScUndoFillTable( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScDocument* pNewUndoDoc, BOOL bNewMulti, USHORT nSrc, + USHORT nFlg, USHORT nFunc, BOOL bSkip, BOOL bLink ) + // + : ScSimpleUndo( pNewDocShell ), + // + aMarkData ( rMark ), + aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), + pUndoDoc ( pNewUndoDoc ), + bMulti ( bNewMulti ), + nSrcTab ( nSrc ), + nFlags ( nFlg ), + nFunction ( nFunc ), + bSkipEmpty ( bSkip ), + bAsLink ( bLink ) +{ + SetChangeTrack(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoFillTable::~ScUndoFillTable() +{ + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoFillTable::GetComment() const +{ + return ScGlobal::GetRscString( STR_FILL_TAB ); +} + + +void ScUndoFillTable::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + USHORT nTabCount = pDocShell->GetDocument()->GetTableCount(); + ScRange aWorkRange(aRange); + nStartChangeAction = 0; + ULONG nTmpAction; + for ( USHORT i = 0; i < nTabCount; i++ ) + { + if (i != nSrcTab && aMarkData.GetTableSelect(i)) + { + aWorkRange.aStart.SetTab(i); + aWorkRange.aEnd.SetTab(i); + pChangeTrack->AppendContentRange( aWorkRange, pUndoDoc, + nTmpAction, nEndChangeAction ); + if ( !nStartChangeAction ) + nStartChangeAction = nTmpAction; + } + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + + +//---------------------------------------------------------------------------- + +void ScUndoFillTable::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + if (bUndo) // nur Undo + { + USHORT nTabCount = pDoc->GetTableCount(); + ScRange aWorkRange(aRange); + for ( USHORT i = 0; i < nTabCount; i++ ) + if (i != nSrcTab && aMarkData.GetTableSelect(i)) + { + aWorkRange.aStart.SetTab(i); + aWorkRange.aEnd.SetTab(i); + if (bMulti) + pDoc->DeleteSelectionTab( i, IDF_ALL, aMarkData ); + else + pDoc->DeleteAreaTab( aWorkRange, IDF_ALL ); + pUndoDoc->CopyToDocument( aWorkRange, IDF_ALL, bMulti, pDoc, &aMarkData ); + } + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + } + else // nur Redo + { + aMarkData.MarkToMulti(); + pDoc->FillTabMarked( nSrcTab, aMarkData, nFlags, nFunction, bSkipEmpty, bAsLink ); + aMarkData.MarkToSimple(); + SetChangeTrack(); + } + + pDocShell->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_EXTRAS); + pDocShell->PostDataChanged(); + + // CellContentChanged kommt mit der Markierung + + if (pViewShell) + { + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + if ( !aMarkData.GetTableSelect(nTab) ) + pViewShell->SetTabNo( nSrcTab ); + + pViewShell->DoneBlockMode(); // gibt sonst Probleme, weil Markierung auf falscher Tabelle + } +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoFillTable::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoFillTable::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoFillTable::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink ); +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoFillTable::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoSelectionAttr +// +// Zellformat aendern + +//---------------------------------------------------------------------------- + +ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScDocument* pNewUndoDoc, BOOL bNewMulti, + const ScPatternAttr* pNewApply, + const SvxBoxItem* pNewOuter, const SvxBoxInfoItem* pNewInner ) + // + : ScSimpleUndo( pNewDocShell ), + // + aMarkData ( rMark ), + aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), + pUndoDoc ( pNewUndoDoc ), + bMulti ( bNewMulti ) +{ + ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); + pApplyPattern = (ScPatternAttr*) &pPool->Put( *pNewApply ); + pLineOuter = pNewOuter ? (SvxBoxItem*) &pPool->Put( *pNewOuter ) : NULL; + pLineInner = pNewInner ? (SvxBoxInfoItem*) &pPool->Put( *pNewInner ) : NULL; +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoSelectionAttr::~ScUndoSelectionAttr() +{ + ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); + pPool->Remove(*pApplyPattern); + if (pLineOuter) + pPool->Remove(*pLineOuter); + if (pLineInner) + pPool->Remove(*pLineInner); + + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoSelectionAttr::GetComment() const +{ + //"Attribute" "/Linien" + return ScGlobal::GetRscString( pLineOuter ? STR_UNDO_SELATTRLINES : STR_UNDO_SELATTR ); +} + + +//---------------------------------------------------------------------------- + +void ScUndoSelectionAttr::DoChange( const BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + ScRange aEffRange( aRange ); + if ( pDoc->HasAttrib( aEffRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? + pDoc->ExtendMerge( aEffRange ); + + BOOL bHasLines = pDoc->HasAttrib( aEffRange, HASATTR_PAINTEXT ); + + if (bUndo) // nur bei Undo + { + ScRange aCopyRange = aRange; + USHORT nTabCount = pDoc->GetTableCount(); + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pDoc, &aMarkData ); + } + else // nur bei Redo + { + aMarkData.MarkToMulti(); + pDoc->ApplySelectionPattern( *pApplyPattern, aMarkData ); + aMarkData.MarkToSimple(); + + if (pLineOuter) + pDoc->ApplySelectionFrame( aMarkData, pLineOuter, pLineInner ); + } + + if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) +/*A*/ pDocShell->PostPaint( aEffRange, PAINT_GRID | PAINT_EXTRAS, (bHasLines ? SC_PF_LINES : 0) ); + + ShowTable( aRange ); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSelectionAttr::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSelectionAttr::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSelectionAttr::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + if (pLineOuter) + rViewShell.ApplyPatternLines( *pApplyPattern, pLineOuter, pLineInner, TRUE ); + else + rViewShell.ApplySelectionPattern( *pApplyPattern, TRUE ); + } +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoSelectionAttr::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoAutoFill +// +// Auto-Fill (nur einfache Bloecke) + +//---------------------------------------------------------------------------- + +ScUndoAutoFill::ScUndoAutoFill( ScDocShell* pNewDocShell, + const ScRange& rRange, const ScRange& rSourceArea, + ScDocument* pNewUndoDoc, const ScMarkData& rMark, + FillDir eNewFillDir, FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd, + double fNewStartValue, double fNewStepValue, double fNewMaxValue, + USHORT nMaxShIndex ) + // + : ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ), + // + aSource ( rSourceArea ), + aMarkData ( rMark ), + pUndoDoc ( pNewUndoDoc ), + eFillDir ( eNewFillDir ), + eFillCmd ( eNewFillCmd ), + eFillDateCmd ( eNewFillDateCmd ), + fStartValue ( fNewStartValue ), + fStepValue ( fNewStepValue ), + fMaxValue ( fNewMaxValue ), + nMaxSharedIndex ( nMaxShIndex) +{ + SetChangeTrack(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoAutoFill::~ScUndoAutoFill() +{ + pDocShell->GetDocument()->EraseNonUsedSharedNames(nMaxSharedIndex); + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoAutoFill::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_AUTOFILL ); //"Ausfuellen" +} + + +void ScUndoAutoFill::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, + nStartChangeAction, nEndChangeAction ); + else + nStartChangeAction = nEndChangeAction = 0; +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFill::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nTabCount; nTab++) + { + if (aMarkData.GetTableSelect(nTab)) + { + ScRange aWorkRange = aBlockRange; + aWorkRange.aStart.SetTab(nTab); + aWorkRange.aEnd.SetTab(nTab); + + BOOL bHasLines = pDoc->HasAttrib( aWorkRange, HASATTR_PAINTEXT ); + pDoc->DeleteAreaTab( aWorkRange, IDF_ALL ); + pUndoDoc->CopyToDocument( aWorkRange, IDF_ALL, FALSE, pDoc ); + + pDoc->ExtendMerge( aWorkRange, TRUE ); + pDocShell->PostPaint( aWorkRange, PAINT_GRID, (bHasLines ? SC_PF_LINES : 0) ); + } + } + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); + +// Shared-Names loeschen +// Falls Undo ins Dokument gespeichert +// => automatisches Loeschen am Ende +// umarbeiten!! + + String aName = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("___SC_")); + aName += String::CreateFromInt32(nMaxSharedIndex); + aName += '_'; + ScRangeName* pRangeName = pDoc->GetRangeName(); + BOOL bHasFound = FALSE; + for (USHORT i = 0; i < pRangeName->GetCount(); i++) + { + ScRangeData* pRangeData = (*pRangeName)[i]; + if (pRangeData) + { + String aRName; + pRangeData->GetName(aRName); + if (aRName.Search(aName) != STRING_NOTFOUND) + { + pRangeName->AtFree(i); + bHasFound = TRUE; + } + } + } + if (bHasFound) + pRangeName->SetSharedMaxIndex(pRangeName->GetSharedMaxIndex()-1); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFill::Redo() +{ + BeginRedo(); + +//! Tabellen selektieren + + USHORT nCount; + switch (eFillDir) + { + case FILL_TO_BOTTOM: + nCount = aBlockRange.aEnd.Row() - aSource.aEnd.Row(); + break; + case FILL_TO_RIGHT: + nCount = aBlockRange.aEnd.Col() - aSource.aEnd.Col(); + break; + case FILL_TO_TOP: + nCount = aSource.aStart.Row() - aBlockRange.aStart.Row(); + break; + case FILL_TO_LEFT: + nCount = aSource.aStart.Col() - aBlockRange.aStart.Col(); + break; + } + + ScDocument* pDoc = pDocShell->GetDocument(); + if ( fStartValue != MAXDOUBLE ) + { + USHORT nValX = (eFillDir == FILL_TO_LEFT) ? aSource.aEnd.Col() : aSource.aStart.Col(); + USHORT nValY = (eFillDir == FILL_TO_TOP ) ? aSource.aEnd.Row() : aSource.aStart.Row(); + USHORT nTab = aSource.aStart.Tab(); + pDoc->SetValue( nValX, nValY, nTab, fStartValue ); + } + pDoc->Fill( aSource.aStart.Col(), aSource.aStart.Row(), + aSource.aEnd.Col(), aSource.aEnd.Row(), + aMarkData, nCount, + eFillDir, eFillCmd, eFillDateCmd, + fStepValue, fMaxValue ); + + SetChangeTrack(); + + pDocShell->PostPaint( aBlockRange, PAINT_GRID ); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); + + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFill::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + if (eFillCmd==FILL_SIMPLE) + rViewShell.FillSimple( eFillDir, TRUE ); + else + rViewShell.FillSeries( eFillDir, eFillCmd, eFillDateCmd, + fStartValue, fStepValue, fMaxValue, TRUE ); + } +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoMerge +// +// Zellen zusammenfassen / Zusammenfassung aufheben + +//---------------------------------------------------------------------------- + +ScUndoMerge::ScUndoMerge( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + BOOL bNewDoMerge, ScDocument* pNewUndoDoc ) + // + : ScSimpleUndo( pNewDocShell ), + // + aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), + bDoMerge( bNewDoMerge ), + pUndoDoc( pNewUndoDoc ) +{ +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoMerge::~ScUndoMerge() +{ + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoMerge::GetComment() const +{ + // "Zusammenfassen" "Zusammenfassung aufheben" + return bDoMerge ? + ScGlobal::GetRscString( STR_UNDO_MERGE ) : + ScGlobal::GetRscString( STR_UNDO_REMERGE ); +} + + +//---------------------------------------------------------------------------- + +void ScUndoMerge::DoChange( const BOOL bUndo ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aRange ); + + if (bDoMerge == bUndo) + pDoc->RemoveMerge( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() ); +//! pDoc->RemoveMerge( aRange.aStart ); + else +/*!*/ pDoc->DoMerge( aRange.aStart.Tab(), + aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row() ); + + if (pUndoDoc) + if (bUndo) + { + pDoc->DeleteAreaTab( aRange, IDF_CONTENTS ); + pUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc ); + } + else +/*!*/ pDoc->DoMergeContents( aRange.aStart.Tab(), + aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row() ); + + BOOL bDidPaint = FALSE; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if ( pViewShell ) + { + pViewShell->SetTabNo( aRange.aStart.Tab() ); + bDidPaint = pViewShell->AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row() ); + } + + if (!bDidPaint) + ScUndoUtil::PaintMore( pDocShell, aRange ); + + ShowTable( aRange ); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoMerge::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoMerge::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoMerge::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + + if (bDoMerge) + { + BOOL bCont = FALSE; + rViewShell.MergeCells( FALSE, bCont, TRUE ); + } + else + rViewShell.RemoveMerge( TRUE ); + } +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoMerge::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoAutoFormat +// +// Auto-Format (nur einfache Bloecke) + +//---------------------------------------------------------------------------- + +ScUndoAutoFormat::ScUndoAutoFormat( ScDocShell* pNewDocShell, + const ScRange& rRange, ScDocument* pNewUndoDoc, + const ScMarkData& rMark, BOOL bNewSize, USHORT nNewFormatNo ) + // + : ScBlockUndo( pNewDocShell, rRange, bNewSize ? SC_UNDO_MANUALHEIGHT : SC_UNDO_AUTOHEIGHT ), + // + aMarkData ( rMark ), + pUndoDoc ( pNewUndoDoc ), + bSize ( bNewSize ), + nFormatNo ( nNewFormatNo ) +{ +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoAutoFormat::~ScUndoAutoFormat() +{ + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoAutoFormat::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_AUTOFORMAT ); //"Auto-Format" +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFormat::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + // Attribute +// pDoc->DeleteAreaTab( aBlockRange, IDF_ATTRIB ); +// pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, FALSE, pDoc ); + + USHORT nTabCount = pDoc->GetTableCount(); + pDoc->DeleteArea( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), + aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), + aMarkData, IDF_ATTRIB ); + ScRange aCopyRange = aBlockRange; + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, FALSE, pDoc, &aMarkData ); + + // Zellhoehen und -breiten (IDF_NONE) + if (bSize) + { + USHORT nStartX = aBlockRange.aStart.Col(); + USHORT nStartY = aBlockRange.aStart.Row(); + USHORT nStartZ = aBlockRange.aStart.Tab(); + USHORT nEndX = aBlockRange.aEnd.Col(); + USHORT nEndY = aBlockRange.aEnd.Row(); + USHORT nEndZ = aBlockRange.aEnd.Tab(); + + pUndoDoc->CopyToDocument( nStartX, 0, 0, nEndX, MAXROW, nTabCount-1, + IDF_NONE, FALSE, pDoc, &aMarkData ); + pUndoDoc->CopyToDocument( 0, nStartY, 0, MAXCOL, nEndY, nTabCount-1, + IDF_NONE, FALSE, pDoc, &aMarkData ); + pDocShell->PostPaint( 0, 0, nStartZ, MAXCOL, MAXROW, nEndZ, + PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES ); + } + else + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES ); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFormat::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nStartX = aBlockRange.aStart.Col(); + USHORT nStartY = aBlockRange.aStart.Row(); + USHORT nStartZ = aBlockRange.aStart.Tab(); + USHORT nEndX = aBlockRange.aEnd.Col(); + USHORT nEndY = aBlockRange.aEnd.Row(); + USHORT nEndZ = aBlockRange.aEnd.Tab(); + + pDoc->AutoFormat( nStartX, nStartY, nEndX, nEndY, nFormatNo, aMarkData ); + + if (bSize) + { + VirtualDevice aVirtDev; + Fraction aZoomX(1,1); + Fraction aZoomY = aZoomX; + double nPPTX,nPPTY; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + ScViewData* pData = pViewShell->GetViewData(); + nPPTX = pData->GetPPTX(); + nPPTY = pData->GetPPTY(); + aZoomX = pData->GetZoomX(); + aZoomY = pData->GetZoomY(); + } + else + { + // Zoom auf 100 lassen + nPPTX = ScGlobal::nScreenPPTX; + nPPTY = ScGlobal::nScreenPPTY; + } + + BOOL bFormula = FALSE; //! merken + + for (USHORT nTab=nStartZ; nTab<=nEndZ; nTab++) + { + ScMarkData aDestMark; + aDestMark.SelectOneTable( nTab ); + aDestMark.SetMarkArea( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) ); + aDestMark.MarkToMulti(); + + // wie SC_SIZE_VISOPT + for (USHORT nRow=nStartY; nRow<=nEndY; nRow++) + { + BYTE nOld = pDoc->GetRowFlags(nRow,nTab); + if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) ) + pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE ); + } + pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev, + nPPTX, nPPTY, aZoomX, aZoomY, FALSE ); + + for (USHORT nCol=nStartX; nCol<=nEndX; nCol++) + if ((pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0) + { + USHORT nThisSize = STD_EXTRA_WIDTH + pDoc->GetOptimalColWidth( nCol, nTab, + &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula, + &aDestMark ); + pDoc->SetColWidth( nCol, nTab, nThisSize ); + pDoc->ShowCol( nCol, nTab, TRUE ); + } + } + + pDocShell->PostPaint( 0, 0, nStartZ, + MAXCOL, MAXROW, nEndZ, + PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES); + } + else + pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES ); + + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoAutoFormat::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->AutoFormat( nFormatNo, TRUE ); +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoAutoFormat::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoReplace +// +// Ersetzen + +//---------------------------------------------------------------------------- + +ScUndoReplace::ScUndoReplace( ScDocShell* pNewDocShell, const ScMarkData& rMark, + USHORT nCurX, USHORT nCurY, USHORT nCurZ, + const String& rNewUndoStr, ScDocument* pNewUndoDoc, + const SvxSearchItem* pItem ) + // + : ScSimpleUndo( pNewDocShell ), + // + aMarkData ( rMark ), + aCursorPos ( nCurX, nCurY, nCurZ ), + aUndoStr ( rNewUndoStr ), + pUndoDoc ( pNewUndoDoc ) +{ + pSearchItem = new SvxSearchItem( *pItem ); + SetChangeTrack(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoReplace::~ScUndoReplace() +{ + delete pUndoDoc; + delete pSearchItem; +} + + +//---------------------------------------------------------------------------- + +void ScUndoReplace::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + { + if ( pUndoDoc ) + { //! im UndoDoc stehen nur die geaenderten Zellen, + // deswegen per Iterator moeglich + pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc, + nStartChangeAction, nEndChangeAction ); + } + else + { + nStartChangeAction = pChangeTrack->GetActionMax() + 1; + ScAddress aPos( aCursorPos.GetCol(), aCursorPos.GetRow(), + aCursorPos.GetTab() ); + ScChangeActionContent* pContent = new ScChangeActionContent( + ScRange( aPos, aPos ) ); + pContent->SetOldValue( aUndoStr, pDoc ); + pContent->SetNewValue( pDoc->GetCell( aPos ), pDoc ); + pChangeTrack->Append( pContent ); + nEndChangeAction = pChangeTrack->GetActionMax(); + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoReplace::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_REPLACE ); // "Ersetzen" +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoReplace::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ShowTable( aCursorPos.GetTab() ); + + if (pUndoDoc) // nur bei ReplaceAll !! + { + DBG_ASSERT(pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL, + "ScUndoReplace:: Falscher Modus"); + + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + +//! markierte Tabellen +//! Bereich merken ? + + // Undo-Dokument hat keine Zeilen-/Spalten-Infos, also mit bColRowFlags = FALSE + // kopieren, um Outline-Gruppen nicht kaputtzumachen. + + USHORT nUndoFlags = (pSearchItem->GetPattern()) ? IDF_ATTRIB : IDF_CONTENTS; + pUndoDoc->CopyToDocument( 0, 0, 0, + MAXCOL, MAXROW, MAXTAB, + nUndoFlags, FALSE, pDoc, NULL, FALSE ); // ohne Row-Flags + pDocShell->PostPaintGridAll(); + } + else if (pSearchItem->GetPattern() && + pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE) + { + String aTempStr = pSearchItem->GetSearchString(); // vertauschen + pSearchItem->SetSearchString(pSearchItem->GetReplaceString()); + pSearchItem->SetReplaceString(aTempStr); + pDoc->ReplaceStyle( *pSearchItem, + aCursorPos.GetCol(), aCursorPos.GetRow(), aCursorPos.GetTab(), + aMarkData, TRUE); + pSearchItem->SetReplaceString(pSearchItem->GetSearchString()); + pSearchItem->SetSearchString(aTempStr); + if (pViewShell) + pViewShell->MoveCursorAbs( aCursorPos.GetCol(), aCursorPos.GetRow(), + SC_FOLLOW_JUMP, FALSE, FALSE ); + pDocShell->PostPaintGridAll(); + } + else if (pSearchItem->GetCellType() == SVX_SEARCHIN_NOTE) + { + ScPostIt aNote; + if (pDoc->GetNote(aCursorPos.GetCol(), aCursorPos.GetRow(), + aCursorPos.GetTab(), aNote)) + { + aNote.SetText(aUndoStr); + pDoc->SetNote(aCursorPos.GetCol(), aCursorPos.GetRow(), + aCursorPos.GetTab(), aNote); + } + else + DBG_ERROR("ScUndoReplace: Hier ist keine Notizzelle"); + if (pViewShell) + pViewShell->MoveCursorAbs( aCursorPos.GetCol(), aCursorPos.GetRow(), + SC_FOLLOW_JUMP, FALSE, FALSE ); + } + else + { + pDoc->SetString( aCursorPos.GetCol(), aCursorPos.GetRow(), aCursorPos.GetTab(), aUndoStr ); + if (pViewShell) + pViewShell->MoveCursorAbs( aCursorPos.GetCol(), aCursorPos.GetRow(), + SC_FOLLOW_JUMP, FALSE, FALSE ); + pDocShell->PostPaintGridAll(); + } + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoReplace::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + pViewShell->MoveCursorAbs( aCursorPos.GetCol(), aCursorPos.GetRow(), + SC_FOLLOW_JUMP, FALSE, FALSE ); + if (pUndoDoc) + { + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + + pViewShell->SearchAndReplace( pSearchItem, FALSE, TRUE ); + } + } + else if (pSearchItem->GetPattern() && + pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE) + { + pDoc->ReplaceStyle( *pSearchItem, + aCursorPos.GetCol(), aCursorPos.GetRow(), aCursorPos.GetTab(), + aMarkData, TRUE); + pDocShell->PostPaintGridAll(); + } + else + if (pViewShell) + pViewShell->SearchAndReplace( pSearchItem, FALSE, TRUE ); + + SetChangeTrack(); + + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoReplace::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->SearchAndReplace( pSearchItem, TRUE, FALSE ); +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoReplace::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoTabOp +// +// Mehrfachoperation (nur einfache Bloecke) + +//---------------------------------------------------------------------------- + +ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, ScDocument* pNewUndoDoc, + const ScRefTripel& rFormulaCell, + const ScRefTripel& rFormulaEnd, + const ScRefTripel& rRowCell, + const ScRefTripel& rColCell, + BYTE nMd ) + // + : ScSimpleUndo( pNewDocShell ), + // + aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), + pUndoDoc ( pNewUndoDoc ), + theFormulaCell ( rFormulaCell ), + theFormulaEnd ( rFormulaEnd ), + theRowCell ( rRowCell ), + theColCell ( rColCell ), + nMode ( nMd ) +{ +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoTabOp::~ScUndoTabOp() +{ + delete pUndoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoTabOp::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_TABOP ); // "Mehrfachoperation" +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoTabOp::Undo() +{ + BeginUndo(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aRange ); + + ScDocument* pDoc = pDocShell->GetDocument(); + BOOL bHasLines = pDoc->HasAttrib( aRange, HASATTR_PAINTEXT ); + + pDoc->DeleteAreaTab( aRange,IDF_ALL ); + pUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc ); + pDocShell->PostPaint( aRange, PAINT_GRID, (bHasLines ? SC_PF_LINES : 0) ); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoTabOp::Redo() +{ + BeginRedo(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aRange ); + + ScTabOpParam aParam( theFormulaCell, theFormulaEnd, + theRowCell, theColCell, + nMode ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->TabOp( aParam, FALSE); + + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoTabOp::Repeat(SfxRepeatTarget& rTarget) +{ +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoTabOp::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//============================================================================ +// class ScUndoSpelling +// +// Spelling + +//---------------------------------------------------------------------------- + +ScUndoSpelling::ScUndoSpelling( ScDocShell* pNewDocShell, + const ScMarkData& rMark, + USHORT nCurX, USHORT nCurY, USHORT nCurZ, + ScDocument* pNewUndoDoc, + USHORT nNewX, USHORT nNewY, USHORT nNewZ, + ScDocument* pNewRedoDoc) + // + : ScSimpleUndo( pNewDocShell ), + // + aMarkData ( rMark ), + aCursorPos ( nCurX, nCurY, nCurZ ), + aNewCursorPos ( nNewX, nNewY, nNewZ ), + pUndoDoc ( pNewUndoDoc ), + pRedoDoc ( pNewRedoDoc ) +{ + SetChangeTrack(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoSpelling::~ScUndoSpelling() +{ + delete pUndoDoc; + delete pRedoDoc; +} + + +//---------------------------------------------------------------------------- + +void ScUndoSpelling::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + { + if ( pUndoDoc ) + pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc, + nStartChangeAction, nEndChangeAction ); + else + { + DBG_ERROR( "ScUndoSpelling::SetChangeTrack: kein UndoDoc" ); + nStartChangeAction = nEndChangeAction = 0; + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoSpelling::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_SPELLING); // "Rechtschreibung" +} + + +//---------------------------------------------------------------------------- + +void ScUndoSpelling::DoChange( ScDocument* pRefDoc, const ScTripel& rCursorPos ) +{ + if (pRefDoc) + { + ScDocument* pDoc = pDocShell->GetDocument(); + ShowTable( rCursorPos.GetTab() ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + USHORT nTabCount = pDoc->GetTableCount(); + // Undo/Redo-doc has only selected tables + + BOOL bMulti = aMarkData.IsMultiMarked(); + pRefDoc->CopyToDocument( 0, 0, 0, + MAXCOL, MAXROW, nTabCount-1, + IDF_CONTENTS, bMulti, pDoc, &aMarkData ); + pDocShell->PostPaintGridAll(); + } + else + { + DBG_ERROR("Kein Un-/RedoDoc bei Un-/RedoSpelling"); + } +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSpelling::Undo() +{ + BeginUndo(); + DoChange( pUndoDoc, aCursorPos ); + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSpelling::Redo() +{ + BeginRedo(); + DoChange( pRedoDoc, aNewCursorPos ); + SetChangeTrack(); + EndRedo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoSpelling::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->DoSpellingChecker( TRUE ); +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoSpelling::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//============================================================================ +// class ScUndoRefreshLink +// +// Link aktualisieren / aendern + +//---------------------------------------------------------------------------- + +ScUndoRefreshLink::ScUndoRefreshLink( ScDocShell* pNewDocShell, + ScDocument* pNewUndoDoc ) + // + : ScSimpleUndo( pNewDocShell ), + // + pUndoDoc( pNewUndoDoc ), + pRedoDoc( NULL ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoRefreshLink::~ScUndoRefreshLink() +{ + delete pUndoDoc; + delete pRedoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoRefreshLink::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRefreshLink::Undo() +{ + BeginUndo(); + + BOOL bMakeRedo = !pRedoDoc; + if (bMakeRedo) + pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + + BOOL bFirst = TRUE; + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nCount; nTab++) + if (pUndoDoc->HasTable(nTab)) + { + ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab); + if (bMakeRedo) + { + if (bFirst) + pRedoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE ); + else + pRedoDoc->AddUndoTab( nTab, nTab, TRUE, TRUE ); + bFirst = FALSE; + pDoc->CopyToDocument(aRange, IDF_ALL, FALSE, pRedoDoc); +// pRedoDoc->TransferDrawPage( pDoc, nTab, nTab ); + pRedoDoc->SetLink( nTab, + pDoc->GetLinkMode(nTab), + pDoc->GetLinkDoc(nTab), + pDoc->GetLinkFlt(nTab), + pDoc->GetLinkOpt(nTab), + pDoc->GetLinkTab(nTab) ); + } + + pDoc->DeleteAreaTab( aRange,IDF_ALL ); +// pDoc->ClearDrawPage(nTab); + pUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc ); +// pDoc->TransferDrawPage( pUndoDoc, nTab, nTab ); + pDoc->SetLink( nTab, pUndoDoc->GetLinkMode(nTab), pUndoDoc->GetLinkDoc(nTab), + pUndoDoc->GetLinkFlt(nTab), pUndoDoc->GetLinkOpt(nTab), + pUndoDoc->GetLinkTab(nTab) ); + } + + pDocShell->PostPaintGridAll(); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRefreshLink::Redo() +{ + DBG_ASSERT(pRedoDoc, "Kein RedoDoc bei ScUndoRefreshLink::Redo"); + + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nCount; nTab++) + if (pRedoDoc->HasTable(nTab)) + { + ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab); + + pDoc->DeleteAreaTab( aRange, IDF_ALL ); +// pDoc->ClearDrawPage(nTab); + pRedoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc ); +// pDoc->TransferDrawPage( pRedoDoc, nTab, nTab ); + pDoc->SetLink( nTab, + pRedoDoc->GetLinkMode(nTab), + pRedoDoc->GetLinkDoc(nTab), + pRedoDoc->GetLinkFlt(nTab), + pRedoDoc->GetLinkOpt(nTab), + pRedoDoc->GetLinkTab(nTab) ); + } + + pDocShell->PostPaintGridAll(); + + EndUndo(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRefreshLink::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoRefreshLink::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//---------------------------------------------------------------------------- + +ScAreaLink* lcl_FindAreaLink( SvxLinkManager* pLinkManager, const String& rDoc, + const String& rFlt, const String& rOpt, + const String& rSrc, const ScRange& rDest ) +{ + const SvBaseLinks& rLinks = pLinkManager->GetLinks(); + USHORT nCount = pLinkManager->GetLinks().Count(); + for (USHORT i=0; i<nCount; i++) + { + SvBaseLink* pBase = *rLinks[i]; + if (pBase->ISA(ScAreaLink)) + if ( ((ScAreaLink*)pBase)->IsEqual( rDoc, rFlt, rOpt, rSrc, rDest ) ) + return (ScAreaLink*)pBase; + } + + DBG_ERROR("ScAreaLink nicht gefunden"); + return NULL; +} + + +//============================================================================ +// class ScUndoInsertAreaLink +// +// Bereichs-Verknuepfung einfuegen + +//---------------------------------------------------------------------------- + +ScUndoInsertAreaLink::ScUndoInsertAreaLink( ScDocShell* pShell, + const String& rDoc, + const String& rFlt, const String& rOpt, + const String& rArea, const ScRange& rDestRange ) + // + : ScSimpleUndo( pShell ), + // + aDocName ( rDoc ), + aFltName ( rFlt ), + aOptions ( rOpt ), + aAreaName ( rArea ), + aRange ( rDestRange ) +{ +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoInsertAreaLink::~ScUndoInsertAreaLink() +{ +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoInsertAreaLink::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_INSERTAREALINK ); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoInsertAreaLink::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions, + aAreaName, aRange ); + if (pLink) + pLinkManager->Remove(*pLink); + + SFX_BINDINGS().Invalidate(SID_LINKS); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoInsertAreaLink::Redo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions, + aAreaName, aRange.aStart ); + pLink->SetInCreate( TRUE ); + pLink->SetDestArea( aRange ); + pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName ); + pLink->Update(); + pLink->SetInCreate( FALSE ); + + SFX_BINDINGS().Invalidate(SID_LINKS); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoInsertAreaLink::Repeat(SfxRepeatTarget& rTarget) +{ + //! .... +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoInsertAreaLink::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//============================================================================ +// class ScUndoRemoveAreaLink +// +// Bereichs-Verknuepfung loeschen + +//---------------------------------------------------------------------------- + +ScUndoRemoveAreaLink::ScUndoRemoveAreaLink( ScDocShell* pShell, + const String& rDoc, const String& rFlt, const String& rOpt, + const String& rArea, const ScRange& rDestRange ) + // + : ScSimpleUndo( pShell ), + // + aDocName ( rDoc ), + aFltName ( rFlt ), + aOptions ( rOpt ), + aAreaName ( rArea ), + aRange ( rDestRange ) +{ +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoRemoveAreaLink::~ScUndoRemoveAreaLink() +{ +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoRemoveAreaLink::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_REMOVELINK ); //! eigener Text ?? +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRemoveAreaLink::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions, + aAreaName, aRange.aStart ); + pLink->SetInCreate( TRUE ); + pLink->SetDestArea( aRange ); + pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName ); + pLink->Update(); + pLink->SetInCreate( FALSE ); + + SFX_BINDINGS().Invalidate(SID_LINKS); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRemoveAreaLink::Redo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions, + aAreaName, aRange ); + if (pLink) + pLinkManager->Remove(*pLink); + + SFX_BINDINGS().Invalidate(SID_LINKS); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoRemoveAreaLink::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoRemoveAreaLink::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//============================================================================ +// class ScUndoUpdateAreaLink +// +// Bereichs-Verknuepfung aktualisieren + +//---------------------------------------------------------------------------- + +ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell, + const String& rOldD, const String& rOldF, const String& rOldO, + const String& rOldA, const ScRange& rOldR, + const String& rNewD, const String& rNewF, const String& rNewO, + const String& rNewA, const ScRange& rNewR, + ScDocument* pUndo, ScDocument* pRedo, BOOL bDoInsert ) + // + : ScSimpleUndo( pShell ), + // + aOldDoc ( rOldD ), + aOldFlt ( rOldF ), + aOldOpt ( rOldO ), + aOldArea ( rOldA ), + aOldRange ( rOldR ), + aNewDoc ( rNewD ), + aNewFlt ( rNewF ), + aNewOpt ( rNewO ), + aNewArea ( rNewA ), + aNewRange ( rNewR ), + pUndoDoc ( pUndo ), + pRedoDoc ( pRedo ), + bWithInsert ( bDoInsert ) +{ + DBG_ASSERT( aOldRange.aStart == aNewRange.aStart, "AreaLink verschoben ??!??" ); +} + + +//---------------------------------------------------------------------------- + +__EXPORT ScUndoUpdateAreaLink::~ScUndoUpdateAreaLink() +{ + delete pUndoDoc; + delete pRedoDoc; +} + + +//---------------------------------------------------------------------------- + +String __EXPORT ScUndoUpdateAreaLink::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); //! eigener Text ?? +} + + +//---------------------------------------------------------------------------- + +void ScUndoUpdateAreaLink::DoChange( const BOOL bUndo ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nEndX = Max( aOldRange.aEnd.Col(), aNewRange.aEnd.Col() ); + USHORT nEndY = Max( aOldRange.aEnd.Row(), aNewRange.aEnd.Row() ); + USHORT nEndZ = Max( aOldRange.aEnd.Tab(), aNewRange.aEnd.Tab() ); //? + + if ( bUndo ) + { + if ( bWithInsert ) + { + pDoc->FitBlock( aNewRange, aOldRange ); + pUndoDoc->UndoToDocument( aOldRange, IDF_ALL, FALSE, pDoc ); + } + else + pUndoDoc->CopyToDocument( + ScRange(aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ)), + IDF_ALL, FALSE, pDoc ); + } + else + { + if ( bWithInsert ) + { + pDoc->FitBlock( aOldRange, aNewRange ); + pRedoDoc->CopyToDocument( aNewRange, IDF_ALL, FALSE, pDoc ); + } + else + pRedoDoc->CopyToDocument( + ScRange(aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ)), + IDF_ALL, FALSE, pDoc ); + } + + ScRange aWorkRange( aNewRange.aStart, ScTripel( nEndX, nEndY, nEndZ ) ); + pDoc->ExtendMerge( aWorkRange, TRUE ); + + // Paint + + if ( aNewRange.aEnd.Col() != aOldRange.aEnd.Col() ) + aWorkRange.aEnd.SetCol(MAXCOL); + if ( aNewRange.aEnd.Row() != aOldRange.aEnd.Row() ) + aWorkRange.aEnd.SetRow(MAXROW); + pDocShell->PostPaint( aWorkRange, PAINT_GRID ); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoUpdateAreaLink::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aNewDoc, aNewFlt, aNewOpt, + aNewArea, aNewRange ); + if (pLink) + { + pLink->SetSource( aOldDoc, aOldFlt, aOldOpt, aOldArea ); // alte Werte im Link + pLink->SetDestArea( aOldRange ); + } + + DoChange(TRUE); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoUpdateAreaLink::Redo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aOldDoc, aOldFlt, aOldOpt, + aOldArea, aOldRange ); + if (pLink) + { + pLink->SetSource( aNewDoc, aNewFlt, aNewOpt, aNewArea ); // neue Werte im Link + pLink->SetDestArea( aNewRange ); + } + + DoChange(FALSE); +} + + +//---------------------------------------------------------------------------- + +void __EXPORT ScUndoUpdateAreaLink::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + + +//---------------------------------------------------------------------------- + +BOOL __EXPORT ScUndoUpdateAreaLink::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + + + diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx new file mode 100644 index 000000000000..41f12d0fdc4c --- /dev/null +++ b/sc/source/ui/undo/undocell.cxx @@ -0,0 +1,1154 @@ +/************************************************************************* + * + * $RCSfile: undocell.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/editobj.hxx> +#include <svtools/zforlist.hxx> +#include <sfx2/app.hxx> + +#include "undocell.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "patattr.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "cell.hxx" +#include "target.hxx" +#include "undoolk.hxx" +#include "detdata.hxx" +#include "stlpool.hxx" +#include "printfun.hxx" +#include "rangenam.hxx" +#include "chgtrack.hxx" +#include "sc.hrc" + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo); +TYPEINIT1(ScUndoEnterData, ScSimpleUndo); +TYPEINIT1(ScUndoEnterValue, ScSimpleUndo); +TYPEINIT1(ScUndoPutCell, ScSimpleUndo); +TYPEINIT1(ScUndoPageBreak, ScSimpleUndo); +TYPEINIT1(ScUndoPrintZoom, ScSimpleUndo); +TYPEINIT1(ScUndoThesaurus, ScSimpleUndo); +TYPEINIT1(ScUndoNote, ScSimpleUndo); +TYPEINIT1(ScUndoEditNote, ScSimpleUndo); +TYPEINIT1(ScUndoDetective, ScSimpleUndo); +TYPEINIT1(ScUndoRangeNames, ScSimpleUndo); + + +// ----------------------------------------------------------------------- +// +// Attribute auf Cursor anwenden +// + +ScUndoCursorAttr::ScUndoCursorAttr( ScDocShell* pNewDocShell, + USHORT nNewCol, USHORT nNewRow, USHORT nNewTab, + const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat, + const ScPatternAttr* pApplyPat, BOOL bAutomatic ) : + ScSimpleUndo( pNewDocShell ), + nCol( nNewCol ), + nRow( nNewRow ), + nTab( nNewTab ), + bIsAutomatic( bAutomatic ) +{ + ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); + pNewPattern = (ScPatternAttr*) &pPool->Put( *pNewPat ); + pOldPattern = (ScPatternAttr*) &pPool->Put( *pOldPat ); + pApplyPattern = (ScPatternAttr*) &pPool->Put( *pApplyPat ); +} + +__EXPORT ScUndoCursorAttr::~ScUndoCursorAttr() +{ + ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); + pPool->Remove(*pNewPattern); + pPool->Remove(*pOldPattern); + pPool->Remove(*pApplyPattern); +} + +String __EXPORT ScUndoCursorAttr::GetComment() const +{ + //! eigener Text fuer automatische Attributierung + + USHORT nId = STR_UNDO_CURSORATTR; // "Attribute" + return ScGlobal::GetRscString( nId ); +} + +void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern ) const +{ + pDocShell->GetDocument()->SetPattern( nCol, nRow, nTab, *pWhichPattern, TRUE ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->SetTabNo( nTab ); + pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE ); + pViewShell->AdjustBlockHeight(); + } + + const SfxItemSet& rApplySet = pApplyPattern->GetItemSet(); + BOOL bPaintExt = ( rApplySet.GetItemState( ATTR_SHADOW, TRUE ) != SFX_ITEM_DEFAULT || + rApplySet.GetItemState( ATTR_CONDITIONAL, TRUE ) != SFX_ITEM_DEFAULT ); + + USHORT nFlags = SC_PF_TESTMERGE; + if (bPaintExt) + nFlags |= SC_PF_LINES; + pDocShell->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nFlags ); +} + +void __EXPORT ScUndoCursorAttr::Undo() +{ + BeginUndo(); + DoChange(pOldPattern); + + if ( bIsAutomatic ) + { + // wenn automatische Formatierung rueckgaengig gemacht wird, + // soll auch nicht weiter automatisch formatiert werden: + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->ForgetFormatArea(); + } + + EndUndo(); +} + +void __EXPORT ScUndoCursorAttr::Redo() +{ + BeginRedo(); + DoChange(pNewPattern); + EndRedo(); +} + +void __EXPORT ScUndoCursorAttr::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->ApplySelectionPattern( *pApplyPattern ); +} + +BOOL __EXPORT ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Daten eingeben +// + +ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell, + USHORT nNewCol, USHORT nNewRow, USHORT nNewTab, + USHORT nNewCount, USHORT* pNewTabs, ScBaseCell** ppOldData, + BOOL* pHasForm, ULONG* pOldForm, + const String& rNewStr, EditTextObject* pObj ) : + ScSimpleUndo( pNewDocShell ), + nCol( nNewCol ), + nRow( nNewRow ), + nTab( nNewTab ), + nCount( nNewCount ), + pTabs( pNewTabs ), + ppOldCells( ppOldData ), + pHasFormat( pHasForm ), + pOldFormats( pOldForm ), + aNewString( rNewStr ), + pNewEditData( pObj ) +{ + SetChangeTrack(); +} + +__EXPORT ScUndoEnterData::~ScUndoEnterData() +{ + ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); + for (USHORT i=0; i<nCount; i++) + if (ppOldCells[i]) + ppOldCells[i]->Delete(); + delete ppOldCells; + delete pHasFormat; + delete pOldFormats; + delete pTabs; + delete pNewEditData; +} + +String __EXPORT ScUndoEnterData::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe" +} + +void ScUndoEnterData::DoChange() const +{ + // Zeilenhoehe anpassen + //! nur wenn noetig (alte oder neue EditZelle, oder Attribute) ?? + for (USHORT i=0; i<nCount; i++) + pDocShell->AdjustRowHeight( nRow, nRow, pTabs[i] ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->SetTabNo( nTab ); + pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE ); + } + + pDocShell->PostDataChanged(); +} + +void ScUndoEnterData::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + nEndChangeAction = pChangeTrack->GetActionMax() + 1; + ScAddress aPos( nCol, nRow, nTab ); + for (USHORT i=0; i<nCount; i++) + { + aPos.SetTab( pTabs[i] ); + ULONG nFormat = 0; + if ( pHasFormat && pOldFormats ) + { + if ( pHasFormat[i] ) + nFormat = pOldFormats[i]; + } + pChangeTrack->AppendContent( aPos, ppOldCells[i], nFormat ); + } + if ( nEndChangeAction > pChangeTrack->GetActionMax() ) + nEndChangeAction = 0; // nichts appended + } + else + nEndChangeAction = 0; +} + +void __EXPORT ScUndoEnterData::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + for (USHORT i=0; i<nCount; i++) + { + ScBaseCell* pNewCell; + if ( ppOldCells[i] ) + { + // Formelzelle mit CompileTokenArray() ! + if ( ppOldCells[i]->GetCellType() == CELLTYPE_FORMULA ) + pNewCell = ((ScFormulaCell*)ppOldCells[i])->Clone( pDoc, + ScAddress( nCol, nRow, pTabs[i] ) ); + else + pNewCell = ppOldCells[i]->Clone(pDoc); + } + else + pNewCell = NULL; + pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell ); + + if (pHasFormat && pOldFormats) + { + if ( pHasFormat[i] ) + pDoc->ApplyAttr( nCol, nRow, pTabs[i], + SfxUInt32Item( ATTR_VALUE_FORMAT, pOldFormats[i] ) ); + else + { + ScPatternAttr aPattern( *pDoc->GetPattern( nCol, nRow, pTabs[i] ) ); + aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT ); + pDoc->SetPattern( nCol, nRow, pTabs[i], aPattern, TRUE ); + } + } + pDocShell->PostPaintCell( nCol, nRow, pTabs[i] ); + } + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack && nEndChangeAction >= nCount ) + pChangeTrack->Undo( nEndChangeAction - nCount + 1, nEndChangeAction ); + + DoChange(); + EndUndo(); +} + +void __EXPORT ScUndoEnterData::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + for (USHORT i=0; i<nCount; i++) + { + if (pNewEditData) + pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell( pNewEditData, + pDoc, NULL ) ); + else + pDoc->SetString( nCol, nRow, pTabs[i], aNewString ); + pDocShell->PostPaintCell( nCol, nRow, pTabs[i] ); + } + + SetChangeTrack(); + + DoChange(); + EndRedo(); +} + +void __EXPORT ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + String aTemp = aNewString; + ((ScTabViewTarget&)rTarget).GetViewShell()->EnterDataAtCursor( aTemp ); + } +} + +BOOL __EXPORT ScUndoEnterData::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Wert aendern +// + +ScUndoEnterValue::ScUndoEnterValue( ScDocShell* pNewDocShell, const ScAddress& rNewPos, + ScBaseCell* pUndoCell, double nVal, BOOL bHeight ) : + ScSimpleUndo( pNewDocShell ), + aPos ( rNewPos ), + pOldCell ( pUndoCell ), + nValue ( nVal ), + bNeedHeight ( bHeight ) +{ + SetChangeTrack(); +} + +__EXPORT ScUndoEnterValue::~ScUndoEnterValue() +{ + if (pOldCell) + pOldCell->Delete(); +} + +String __EXPORT ScUndoEnterValue::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe" +} + +void ScUndoEnterValue::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + { + nEndChangeAction = pChangeTrack->GetActionMax() + 1; + pChangeTrack->AppendContent( aPos, pOldCell ); + if ( nEndChangeAction > pChangeTrack->GetActionMax() ) + nEndChangeAction = 0; // nichts appended + } + else + nEndChangeAction = 0; +} + +void __EXPORT ScUndoEnterValue::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScBaseCell* pNewCell; + if ( pOldCell ) + { + // Formelzelle mit CompileTokenArray() ! + if ( pOldCell->GetCellType() == CELLTYPE_FORMULA ) + pNewCell = ((ScFormulaCell*)pOldCell)->Clone( pDoc, aPos ); + else + pNewCell = pOldCell->Clone(pDoc); + } + else + pNewCell = NULL; + + pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); + + pDocShell->PostPaintCell( aPos.Col(), aPos.Row(), aPos.Tab() ); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); + + EndUndo(); +} + +void __EXPORT ScUndoEnterValue::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->SetValue( aPos.Col(), aPos.Row(), aPos.Tab(), nValue ); + pDocShell->PostPaintCell( aPos.Col(), aPos.Row(), aPos.Tab() ); + + SetChangeTrack(); + + EndRedo(); +} + +void __EXPORT ScUndoEnterValue::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + +BOOL __EXPORT ScUndoEnterValue::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Beliebige Zelle eingeben +// + +ScUndoPutCell::ScUndoPutCell( ScDocShell* pNewDocShell, const ScAddress& rNewPos, + ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, BOOL bHeight ) : + ScSimpleUndo( pNewDocShell ), + aPos ( rNewPos ), + pOldCell ( pUndoCell ), + pEnteredCell( pRedoCell ), + bNeedHeight ( bHeight ) +{ + SetChangeTrack(); +} + +__EXPORT ScUndoPutCell::~ScUndoPutCell() +{ + if (pOldCell) + pOldCell->Delete(); + if (pEnteredCell) + pEnteredCell->Delete(); +} + +String __EXPORT ScUndoPutCell::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe" +} + +void ScUndoPutCell::SetChangeTrack() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + { + nEndChangeAction = pChangeTrack->GetActionMax() + 1; + pChangeTrack->AppendContent( aPos, pOldCell ); + if ( nEndChangeAction > pChangeTrack->GetActionMax() ) + nEndChangeAction = 0; // nichts appended + } + else + nEndChangeAction = 0; +} + +void __EXPORT ScUndoPutCell::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScBaseCell* pNewCell; + if ( pOldCell ) + { + // Formelzelle mit CompileTokenArray() ! + if ( pOldCell->GetCellType() == CELLTYPE_FORMULA ) + pNewCell = ((ScFormulaCell*)pOldCell)->Clone( pDoc, aPos ); + else + pNewCell = pOldCell->Clone(pDoc); + } + else + pNewCell = NULL; + + pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); + + pDocShell->PostPaintCell( aPos.Col(), aPos.Row(), aPos.Tab() ); + + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); + + EndUndo(); +} + +void __EXPORT ScUndoPutCell::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); +// pDoc->SetValue( aPos.Col(), aPos.Row(), aPos.Tab(), nValue ); + + ScBaseCell* pNewCell; + if ( pEnteredCell ) + { + // Formelzelle mit CompileTokenArray() ! + if ( pEnteredCell->GetCellType() == CELLTYPE_FORMULA ) + pNewCell = ((ScFormulaCell*)pEnteredCell)->Clone( pDoc, aPos ); + else + pNewCell = pEnteredCell->Clone(pDoc); + } + else + pNewCell = NULL; + + pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell ); + + pDocShell->PostPaintCell( aPos.Col(), aPos.Row(), aPos.Tab() ); + + SetChangeTrack(); + + EndRedo(); +} + +void __EXPORT ScUndoPutCell::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + +BOOL __EXPORT ScUndoPutCell::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Seitenumbrueche +// + +ScUndoPageBreak::ScUndoPageBreak( ScDocShell* pNewDocShell, + USHORT nNewCol, USHORT nNewRow, USHORT nNewTab, + BOOL bNewColumn, BOOL bNewInsert ) : + ScSimpleUndo( pNewDocShell ), + nCol( nNewCol ), + nRow( nNewRow ), + nTab( nNewTab ), + bColumn( bNewColumn ), + bInsert( bNewInsert ) +{ +} + +__EXPORT ScUndoPageBreak::~ScUndoPageBreak() +{ +} + +String __EXPORT ScUndoPageBreak::GetComment() const +{ + //"Spaltenumbruch" | "Zeilenumbruch" "einfuegen" | "loeschen" + return String ( bColumn ? + ( bInsert ? + ScGlobal::GetRscString( STR_UNDO_INSCOLBREAK ) : + ScGlobal::GetRscString( STR_UNDO_DELCOLBREAK ) + ) : + ( bInsert ? + ScGlobal::GetRscString( STR_UNDO_INSROWBREAK ) : + ScGlobal::GetRscString( STR_UNDO_DELROWBREAK ) + ) ); +} + +void ScUndoPageBreak::DoChange( BOOL bInsert ) const +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + { + pViewShell->SetTabNo( nTab ); + pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE ); + + if (bInsert) + pViewShell->InsertPageBreak(bColumn, FALSE); + else + pViewShell->DeletePageBreak(bColumn, FALSE); + } +} + +void __EXPORT ScUndoPageBreak::Undo() +{ + BeginUndo(); + DoChange(!bInsert); + EndUndo(); +} + +void __EXPORT ScUndoPageBreak::Redo() +{ + BeginRedo(); + DoChange(bInsert); + EndRedo(); +} + +void __EXPORT ScUndoPageBreak::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + + if (bInsert) + rViewShell.InsertPageBreak(bColumn, TRUE); + else + rViewShell.DeletePageBreak(bColumn, TRUE); + } +} + +BOOL __EXPORT ScUndoPageBreak::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// Druck-Skalierung +// + +ScUndoPrintZoom::ScUndoPrintZoom( ScDocShell* pNewDocShell, + USHORT nT, USHORT nOS, USHORT nOP, USHORT nNS, USHORT nNP ) : + ScSimpleUndo( pNewDocShell ), + nTab( nT ), + nOldScale( nOS ), + nOldPages( nOP ), + nNewScale( nNS ), + nNewPages( nNP ) +{ +} + +__EXPORT ScUndoPrintZoom::~ScUndoPrintZoom() +{ +} + +String __EXPORT ScUndoPrintZoom::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_PRINTSCALE ); +} + +void ScUndoPrintZoom::DoChange( BOOL bUndo ) +{ + USHORT nScale = bUndo ? nOldScale : nNewScale; + USHORT nPages = bUndo ? nOldPages : nNewPages; + + ScDocument* pDoc = pDocShell->GetDocument(); + String aStyleName = pDoc->GetPageStyle( nTab ); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE ); + DBG_ASSERT( pStyleSheet, "PageStyle not found" ); + if ( pStyleSheet ) + { + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) ); + rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) ); + + ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ); + aPrintFunc.UpdatePages(); + } +} + +void __EXPORT ScUndoPrintZoom::Undo() +{ + BeginUndo(); + DoChange(TRUE); + EndUndo(); +} + +void __EXPORT ScUndoPrintZoom::Redo() +{ + BeginRedo(); + DoChange(FALSE); + EndRedo(); +} + +void __EXPORT ScUndoPrintZoom::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + ScViewData* pViewData = rViewShell.GetViewData(); + pViewData->GetDocShell()->SetPrintZoom( pViewData->GetTabNo(), nNewScale, nNewPages ); + } +} + +BOOL __EXPORT ScUndoPrintZoom::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Thesaurus +// + +ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell, + USHORT nNewCol, USHORT nNewRow, USHORT nNewTab, + const String& rNewUndoStr, const EditTextObject* pUndoTObj, + const String& rNewRedoStr, const EditTextObject* pRedoTObj) : + ScSimpleUndo( pNewDocShell ), + nCol( nNewCol ), + nRow( nNewRow ), + nTab( nNewTab ), + aUndoStr( rNewUndoStr ), + aRedoStr( rNewRedoStr ) +{ + pUndoTObject = (pUndoTObj) ? pUndoTObj->Clone() : NULL; + pRedoTObject = (pRedoTObj) ? pRedoTObj->Clone() : NULL; + + ScBaseCell* pOldCell; + if ( pUndoTObject ) + pOldCell = new ScEditCell( pUndoTObject, pDocShell->GetDocument(), NULL ); + else + pOldCell = new ScStringCell( aUndoStr ); + SetChangeTrack( pOldCell ); + pOldCell->Delete(); +} + +__EXPORT ScUndoThesaurus::~ScUndoThesaurus() +{ + delete pUndoTObject; + delete pRedoTObject; +} + +String __EXPORT ScUndoThesaurus::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_THESAURUS ); // "Thesaurus" +} + +void ScUndoThesaurus::SetChangeTrack( ScBaseCell* pOldCell ) +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + nEndChangeAction = pChangeTrack->GetActionMax() + 1; + pChangeTrack->AppendContent( ScAddress( nCol, nRow, nTab ), pOldCell ); + if ( nEndChangeAction > pChangeTrack->GetActionMax() ) + nEndChangeAction = 0; // nichts appended + } + else + nEndChangeAction = 0; +} + +void __EXPORT ScUndoThesaurus::DoChange( BOOL bUndo, const String& rStr, + const EditTextObject* pTObj ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->SetTabNo( nTab ); + pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE ); + } + + if (pTObj) + { + ScBaseCell* pCell; + pDoc->GetCell( nCol, nRow, nTab, pCell ); + if (pCell) + { + if (pCell->GetCellType() == CELLTYPE_EDIT ) + { + ScEditCell* pNewCell = new ScEditCell( pTObj, pDoc, NULL ); + pDoc->PutCell( nCol, nRow, nTab, pNewCell ); + if ( !bUndo ) + SetChangeTrack( pCell ); + } + else + { + DBG_ERROR("Nicht CELLTYPE_EDIT bei Un/RedoThesaurus"); + } + } + } + else + { + ScBaseCell* pCell; + if ( !bUndo ) + pDoc->GetCell( nCol, nRow, nTab, pCell ); + pDoc->SetString( nCol, nRow, nTab, rStr ); + if ( !bUndo ) + SetChangeTrack( pCell ); + } + + pDocShell->PostPaintCell( nCol, nRow, nTab ); +} + +void __EXPORT ScUndoThesaurus::Undo() +{ + BeginUndo(); + DoChange( TRUE, aUndoStr, pUndoTObject ); + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); + EndUndo(); +} + +void __EXPORT ScUndoThesaurus::Redo() +{ + BeginRedo(); + DoChange( FALSE, aRedoStr, pRedoTObject ); + EndRedo(); +} + +void __EXPORT ScUndoThesaurus::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->DoThesaurus( TRUE ); +} + +BOOL __EXPORT ScUndoThesaurus::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Notizen ein-/ausblenden +// + +ScUndoNote::ScUndoNote( ScDocShell* pNewDocShell, BOOL bShow, + const ScAddress& rNewPos, SdrUndoAction* pDraw ) : + ScSimpleUndo( pNewDocShell ), + bIsShow ( bShow ), + aPos ( rNewPos ), + pDrawUndo ( pDraw ) + +{ +} + +__EXPORT ScUndoNote::~ScUndoNote() +{ + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoNote::GetComment() const +{ + if ( bIsShow ) + return ScGlobal::GetRscString( STR_UNDO_SHOWNOTE ); // Notiz anzeigen + else + return ScGlobal::GetRscString( STR_UNDO_HIDENOTE ); // Notiz ausblenden +} + + +void __EXPORT ScUndoNote::Undo() +{ + BeginUndo(); + + if (pDrawUndo) + DoSdrUndoAction(pDrawUndo); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScPostIt aNote; + pDoc->GetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aNote ); + aNote.SetShown( !bIsShow ); + pDoc->SetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aNote ); + + EndUndo(); +} + +void __EXPORT ScUndoNote::Redo() +{ + BeginRedo(); + + if (pDrawUndo) + RedoSdrUndoAction(pDrawUndo); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScPostIt aNote; + pDoc->GetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aNote ); + aNote.SetShown( bIsShow ); + pDoc->SetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aNote ); + + EndRedo(); +} + +void __EXPORT ScUndoNote::Repeat(SfxRepeatTarget& rTarget) +{ + // hammanich +} + +BOOL __EXPORT ScUndoNote::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Text von Notiz aendern (ohne Drawing-Krempel) +// + +ScUndoEditNote::ScUndoEditNote( ScDocShell* pNewDocShell, const ScAddress& rNewPos, + const ScPostIt& rOld, const ScPostIt& rNew ) : + ScSimpleUndo( pNewDocShell ), + aPos ( rNewPos ), + aOldNote ( rOld ), + aNewNote ( rNew ) +{ +} + +__EXPORT ScUndoEditNote::~ScUndoEditNote() +{ +} + +String __EXPORT ScUndoEditNote::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_SHOWNOTE ); +} + +void __EXPORT ScUndoEditNote::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->SetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aOldNote ); + + EndUndo(); +} + +void __EXPORT ScUndoEditNote::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->SetNote( aPos.Col(), aPos.Row(), aPos.Tab(), aNewNote ); + + EndRedo(); +} + +void __EXPORT ScUndoEditNote::Repeat(SfxRepeatTarget& rTarget) +{ + // hammanich +} + +BOOL __EXPORT ScUndoEditNote::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Detektiv +// + +ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell, + SdrUndoAction* pDraw, const ScDetOpData* pOperation, + ScDetOpList* pUndoList ) : + ScSimpleUndo( pNewDocShell ), + pDrawUndo ( pDraw ), + nAction ( 0 ), + pOldList ( pUndoList ) +{ + bIsDelete = ( pOperation == NULL ); + if (!bIsDelete) + { + nAction = (USHORT) pOperation->GetOperation(); + aPos = pOperation->GetPos(); + } +} + +__EXPORT ScUndoDetective::~ScUndoDetective() +{ + DeleteSdrUndoAction( pDrawUndo ); + delete pOldList; +} + +String __EXPORT ScUndoDetective::GetComment() const +{ + USHORT nId = STR_UNDO_DETDELALL; + if ( !bIsDelete ) + switch ( (ScDetOpType) nAction ) + { + case SCDETOP_ADDSUCC: nId = STR_UNDO_DETADDSUCC; break; + case SCDETOP_DELSUCC: nId = STR_UNDO_DETDELSUCC; break; + case SCDETOP_ADDPRED: nId = STR_UNDO_DETADDPRED; break; + case SCDETOP_DELPRED: nId = STR_UNDO_DETDELPRED; break; + case SCDETOP_ADDERROR: nId = STR_UNDO_DETADDERROR; break; + } + + return ScGlobal::GetRscString( nId ); +} + + +void __EXPORT ScUndoDetective::Undo() +{ + BeginUndo(); + + if (pDrawUndo) + DoSdrUndoAction(pDrawUndo); + + ScDocument* pDoc = pDocShell->GetDocument(); + + if (bIsDelete) + { + if ( pOldList ) + pDoc->SetDetOpList( new ScDetOpList(*pOldList) ); + } + else + { + // Eintrag aus der Liste loeschen + + ScDetOpList* pList = pDoc->GetDetOpList(); + if (pList && pList->Count()) + { + USHORT nPos = pList->Count() - 1; + ScDetOpData* pData = (*pList)[nPos]; + if ( pData->GetOperation() == (ScDetOpType) nAction && pData->GetPos() == aPos ) + pList->DeleteAndDestroy( nPos, 1 ); + else + DBG_ERROR("Detektiv-Eintrag in der Liste nicht gefunden"); + } + } + + EndUndo(); +} + +void __EXPORT ScUndoDetective::Redo() +{ + BeginRedo(); + + if (pDrawUndo) + RedoSdrUndoAction(pDrawUndo); + + ScDocument* pDoc = pDocShell->GetDocument(); + + if (bIsDelete) + pDoc->ClearDetectiveOperations(); + else + pDoc->AddDetectiveOperation( ScDetOpData( aPos, (ScDetOpType) nAction ) ); + + EndRedo(); +} + +void __EXPORT ScUndoDetective::Repeat(SfxRepeatTarget& rTarget) +{ + // hammanich +} + +BOOL __EXPORT ScUndoDetective::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + +// ----------------------------------------------------------------------- +// +// Benannte Bereiche +// + +ScUndoRangeNames::ScUndoRangeNames( ScDocShell* pNewDocShell, + ScRangeName* pOld, ScRangeName* pNew ) : + ScSimpleUndo( pNewDocShell ), + pOldRanges ( pOld ), + pNewRanges ( pNew ) +{ +} + +__EXPORT ScUndoRangeNames::~ScUndoRangeNames() +{ + delete pOldRanges; + delete pNewRanges; +} + +String __EXPORT ScUndoRangeNames::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_RANGENAMES ); +} + +void ScUndoRangeNames::DoChange( BOOL bUndo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->CompileNameFormula( TRUE ); // CreateFormulaString + + if ( bUndo ) + pDoc->SetRangeName( new ScRangeName( *pOldRanges ) ); + else + pDoc->SetRangeName( new ScRangeName( *pNewRanges ) ); + + pDoc->CompileNameFormula( FALSE ); // CompileFormulaString + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) ); +} + +void __EXPORT ScUndoRangeNames::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + +void __EXPORT ScUndoRangeNames::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoRangeNames::Repeat(SfxRepeatTarget& rTarget) +{ + // hammanich +} + +BOOL __EXPORT ScUndoRangeNames::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + + + diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx new file mode 100644 index 000000000000..f0562d01b06f --- /dev/null +++ b/sc/source/ui/undo/undodat.cxx @@ -0,0 +1,2147 @@ +/************************************************************************* + * + * $RCSfile: undodat.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/app.hxx> + +#include "undodat.hxx" +#include "undoutil.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "olinetab.hxx" +#include "dbcolect.hxx" +#include "rangenam.hxx" +#include "pivot.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "target.hxx" +#include "chartarr.hxx" +#include "dbdocfun.hxx" +#include "olinefun.hxx" +#include "dpobject.hxx" +#include "sc.hrc" + +// ----------------------------------------------------------------------- + +TYPEINIT1(ScUndoDoOutline, SfxUndoAction); +TYPEINIT1(ScUndoMakeOutline, SfxUndoAction); +TYPEINIT1(ScUndoOutlineLevel, SfxUndoAction); +TYPEINIT1(ScUndoOutlineBlock, SfxUndoAction); +TYPEINIT1(ScUndoRemoveAllOutlines, SfxUndoAction); +TYPEINIT1(ScUndoAutoOutline, SfxUndoAction); +TYPEINIT1(ScUndoSubTotals, SfxUndoAction); +TYPEINIT1(ScUndoSort, SfxUndoAction); +TYPEINIT1(ScUndoQuery, SfxUndoAction); +TYPEINIT1(ScUndoDBData, SfxUndoAction); +TYPEINIT1(ScUndoImportData, SfxUndoAction); +TYPEINIT1(ScUndoRepeatDB, SfxUndoAction); +TYPEINIT1(ScUndoPivot, SfxUndoAction); +TYPEINIT1(ScUndoDataPilot, SfxUndoAction); +TYPEINIT1(ScUndoConsolidate, SfxUndoAction); +TYPEINIT1(ScUndoChartData, SfxUndoAction); + +// ----------------------------------------------------------------------- + + +// +// Outline-Gruppen ein- oder ausblenden +// + +ScUndoDoOutline::ScUndoDoOutline( ScDocShell* pNewDocShell, + USHORT nNewStart, USHORT nNewEnd, USHORT nNewTab, + ScDocument* pNewUndoDoc, BOOL bNewColumns, + USHORT nNewLevel, USHORT nNewEntry, BOOL bNewShow ) : + ScSimpleUndo( pNewDocShell ), + nStart( nNewStart ), + nEnd( nNewEnd ), + nTab( nNewTab ), + pUndoDoc( pNewUndoDoc ), + bColumns( bNewColumns ), + nLevel( nNewLevel ), + nEntry( nNewEntry ), + bShow( bNewShow ) +{ +} + +__EXPORT ScUndoDoOutline::~ScUndoDoOutline() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoDoOutline::GetComment() const +{ // Detail einblenden" "Detail ausblenden" + return bShow ? + ScGlobal::GetRscString( STR_UNDO_DOOUTLINE ) : + ScGlobal::GetRscString( STR_UNDO_REDOOUTLINE ); +} + +void __EXPORT ScUndoDoOutline::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // Tabelle muss vorher umgeschaltet sein (#46952#) !!! + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + // inverse Funktion ausfuehren + + if (bShow) + pViewShell->HideOutline( bColumns, nLevel, nEntry, FALSE, FALSE ); + else + pViewShell->ShowOutline( bColumns, nLevel, nEntry, FALSE, FALSE ); + + // Original Spalten-/Zeilenstatus + + if (bColumns) + pUndoDoc->CopyToDocument( nStart, 0, nTab, nEnd, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + else + pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pDoc ); + + pViewShell->UpdateScrollBars(); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP); + + EndUndo(); +} + +void __EXPORT ScUndoDoOutline::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // Tabelle muss vorher umgeschaltet sein (#46952#) !!! + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + if (bShow) + pViewShell->ShowOutline( bColumns, nLevel, nEntry, FALSE ); + else + pViewShell->HideOutline( bColumns, nLevel, nEntry, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoDoOutline::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoDoOutline::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht +} + +// +// Outline-Gruppen erzeugen oder loeschen +// + +ScUndoMakeOutline::ScUndoMakeOutline( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScOutlineTable* pNewUndoTab, BOOL bNewColumns, BOOL bNewMake ) : + ScSimpleUndo( pNewDocShell ), + aBlockStart( nStartX, nStartY, nStartZ ), + aBlockEnd( nEndX, nEndY, nEndZ ), + pUndoTable( pNewUndoTab ), + bColumns( bNewColumns ), + bMake( bNewMake ) +{ +} + +__EXPORT ScUndoMakeOutline::~ScUndoMakeOutline() +{ + delete pUndoTable; +} + +String __EXPORT ScUndoMakeOutline::GetComment() const +{ // "Gruppierung" "Gruppierung aufheben" + return bMake ? + ScGlobal::GetRscString( STR_UNDO_MAKEOUTLINE ) : + ScGlobal::GetRscString( STR_UNDO_REMAKEOUTLINE ); +} + +void __EXPORT ScUndoMakeOutline::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + + EndUndo(); +} + +void __EXPORT ScUndoMakeOutline::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); + + if (bMake) + pViewShell->MakeOutline( bColumns, FALSE ); + else + pViewShell->RemoveOutline( bColumns, FALSE ); + + pDocShell->PostPaint(0,0,aBlockStart.GetTab(),MAXCOL,MAXROW,aBlockEnd.GetTab(),PAINT_GRID); + + EndRedo(); +} + +void __EXPORT ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + + if (bMake) + rViewShell.MakeOutline( bColumns, TRUE ); + else + rViewShell.RemoveOutline( bColumns, TRUE ); + } +} + +BOOL __EXPORT ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// Outline-Ebene auswaehlen +// + +ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell, + USHORT nNewStart, USHORT nNewEnd, USHORT nNewTab, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + BOOL bNewColumns, USHORT nNewLevel ) : + ScSimpleUndo( pNewDocShell ), + nStart( nNewStart ), + nEnd( nNewEnd ), + nTab( nNewTab ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ), + bColumns( bNewColumns ), + nLevel( nNewLevel ) +{ +} + +__EXPORT ScUndoOutlineLevel::~ScUndoOutlineLevel() +{ + delete pUndoDoc; + delete pUndoTable; +} + +String __EXPORT ScUndoOutlineLevel::GetComment() const +{ // "Gliederungsebene auswaehlen"; + return ScGlobal::GetRscString( STR_UNDO_OUTLINELEVEL ); +} + +void __EXPORT ScUndoOutlineLevel::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + if (bColumns) + pUndoDoc->CopyToDocument( nStart, 0, nTab, nEnd, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + else + pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pDoc ); + + pDoc->UpdatePageBreaks( nTab ); + + pViewShell->UpdateScrollBars(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP); + + EndUndo(); +} + +void __EXPORT ScUndoOutlineLevel::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // Tabelle muss vorher umgeschaltet sein (#46952#) !!! + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pViewShell->SelectLevel( bColumns, nLevel, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->SelectLevel( bColumns, nLevel, TRUE ); +} + +BOOL __EXPORT ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// Outline ueber Blockmarken ein- oder ausblenden +// + +ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, BOOL bNewShow ) : + ScSimpleUndo( pNewDocShell ), + aBlockStart( nStartX, nStartY, nStartZ ), + aBlockEnd( nEndX, nEndY, nEndZ ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ), + bShow( bNewShow ) +{ +} + +__EXPORT ScUndoOutlineBlock::~ScUndoOutlineBlock() +{ + delete pUndoDoc; + delete pUndoTable; +} + +String __EXPORT ScUndoOutlineBlock::GetComment() const +{ // "Detail einblenden" "Detail ausblenden" + return bShow ? + ScGlobal::GetRscString( STR_UNDO_DOOUTLINEBLK ) : + ScGlobal::GetRscString( STR_UNDO_REDOOUTLINEBLK ); +} + +void __EXPORT ScUndoOutlineBlock::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + USHORT nStartCol = aBlockStart.GetCol(); + USHORT nEndCol = aBlockEnd.GetCol(); + USHORT nStartRow = aBlockStart.GetRow(); + USHORT nEndRow = aBlockEnd.GetRow(); + + if (!bShow) + { // Groesse des ausgeblendeten Blocks + USHORT nLevel; + pUndoTable->GetColArray()->FindTouchedLevel( nStartCol, nEndCol, nLevel ); + pUndoTable->GetColArray()->ExtendBlock( nLevel, nStartCol, nEndCol ); + pUndoTable->GetRowArray()->FindTouchedLevel( nStartRow, nEndRow, nLevel ); + pUndoTable->GetRowArray()->ExtendBlock( nLevel, nStartRow, nEndRow ); + } + + pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc ); + + pDoc->UpdatePageBreaks( nTab ); + + pViewShell->UpdateScrollBars(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP); + + EndUndo(); +} + +void __EXPORT ScUndoOutlineBlock::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); + if (bShow) + pViewShell->ShowMarkedOutlines( FALSE ); + else + pViewShell->HideMarkedOutlines( FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + + if (bShow) + rViewShell.ShowMarkedOutlines( TRUE ); + else + rViewShell.HideMarkedOutlines( TRUE ); + } +} + +BOOL __EXPORT ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// alle Outlines loeschen +// + +ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) : + ScSimpleUndo( pNewDocShell ), + aBlockStart( nStartX, nStartY, nStartZ ), + aBlockEnd( nEndX, nEndY, nEndZ ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ) +{ +} + +__EXPORT ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines() +{ + delete pUndoDoc; + delete pUndoTable; +} + +String __EXPORT ScUndoRemoveAllOutlines::GetComment() const +{ // "Gliederung entfernen" + return ScGlobal::GetRscString( STR_UNDO_REMOVEALLOTLNS ); +} + +void __EXPORT ScUndoRemoveAllOutlines::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + USHORT nStartCol = aBlockStart.GetCol(); + USHORT nEndCol = aBlockEnd.GetCol(); + USHORT nStartRow = aBlockStart.GetRow(); + USHORT nEndRow = aBlockEnd.GetRow(); + + pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc ); + + pDoc->UpdatePageBreaks( nTab ); + + pViewShell->UpdateScrollBars(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + + EndUndo(); +} + +void __EXPORT ScUndoRemoveAllOutlines::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // Tabelle muss vorher umgeschaltet sein (#46952#) !!! + + USHORT nTab = aBlockStart.GetTab(); + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pViewShell->RemoveAllOutlines( FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveAllOutlines( TRUE ); +} + +BOOL __EXPORT ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// Auto-Outline +// + +ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) : + ScSimpleUndo( pNewDocShell ), + aBlockStart( nStartX, nStartY, nStartZ ), + aBlockEnd( nEndX, nEndY, nEndZ ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ) +{ +} + +__EXPORT ScUndoAutoOutline::~ScUndoAutoOutline() +{ + delete pUndoDoc; + delete pUndoTable; +} + +String __EXPORT ScUndoAutoOutline::GetComment() const +{ // "Auto-Gliederung" + return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE ); +} + +void __EXPORT ScUndoAutoOutline::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + if (pUndoDoc && pUndoTable) + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol ); + pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow ); + + pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc ); + + pViewShell->UpdateScrollBars(); + } + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + + EndUndo(); +} + +void __EXPORT ScUndoAutoOutline::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nTab = aBlockStart.GetTab(); + if (pViewShell) + { + // Tabelle muss vorher umgeschaltet sein (#46952#) !!! + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + } + + ScRange aRange( aBlockStart.GetCol(), aBlockStart.GetRow(), nTab, + aBlockEnd.GetCol(), aBlockEnd.GetRow(), nTab ); + ScOutlineDocFunc aFunc( *pDocShell ); + aFunc.AutoOutline( aRange, FALSE, FALSE ); + + // auf der View markieren + // Wenn's beim Aufruf eine Mehrfachselektion war, ist es jetzt der + // umschliessende Bereich... + + if (pViewShell) + pViewShell->MarkRange( aRange ); + + EndRedo(); +} + +void __EXPORT ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->AutoOutline( TRUE ); +} + +BOOL __EXPORT ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// Zwischenergebnisse +// + +ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, USHORT nNewTab, + const ScSubTotalParam& rNewParam, USHORT nNewEndY, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) : + ScSimpleUndo( pNewDocShell ), + nTab( nNewTab ), + aParam( rNewParam ), + nNewEndRow( nNewEndY ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ), + pUndoRange( pNewUndoRange ), + pUndoDB( pNewUndoDB ) +{ +} + +__EXPORT ScUndoSubTotals::~ScUndoSubTotals() +{ + delete pUndoDoc; + delete pUndoTable; + delete pUndoRange; + delete pUndoDB; +} + +String __EXPORT ScUndoSubTotals::GetComment() const +{ // "Teilergebnisse" + return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS ); +} + +void __EXPORT ScUndoSubTotals::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + // um einzelnen DB-Bereich anzupassen +/* ScDBData* pOldDBData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab, + aParam.nCol1, aParam.nRow1, aParam.nCol2, nNewEndRow ); +*/ + + if (nNewEndRow > aParam.nRow2) + { + pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aParam.nRow2+1, nNewEndRow-aParam.nRow2 ); + } + else if (nNewEndRow < aParam.nRow2) + { + pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, nNewEndRow-aParam.nRow2 ); + } + + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + if (pUndoDoc && pUndoTable) + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol ); + pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow ); + + pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc ); + + pViewShell->UpdateScrollBars(); + } + + // Original-Daten & Referenzen + + ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aParam.nRow1+1, nTab, + MAXCOL, aParam.nRow2, nTab ); + + pDoc->DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, IDF_ALL ); + + pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, + IDF_NONE, FALSE, pDoc ); // Flags + pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, + IDF_ALL, FALSE, pDoc ); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab, + aParam.nCol2,aParam.nRow2,nTab ); + +/* if (pUndoDBData) + *pOldDBData = *pUndoDBData; +*/ + if (pUndoRange) + pDoc->SetRangeName( new ScRangeName( *pUndoRange ) ); + if (pUndoDB) + pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ) ); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + pDocShell->PostDataChanged(); + + EndUndo(); +} + +void __EXPORT ScUndoSubTotals::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab, + aParam.nCol2,aParam.nRow2,nTab ); + pViewShell->DoSubTotals( aParam, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoSubTotals::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoSubTotals::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht wegen Spaltennummern +} + +// +// Sortieren +// + +ScUndoSort::ScUndoSort( ScDocShell* pNewDocShell, + USHORT nNewTab, const ScSortParam& rParam, + BOOL bQuery, ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB, + const ScRange* pDest ) : + ScSimpleUndo( pNewDocShell ), + nTab( nNewTab ), + aSortParam( rParam ), + bRepeatQuery( bQuery ), + pUndoDoc( pNewUndoDoc ), + pUndoDB( pNewUndoDB ), + bDestArea( FALSE ) +{ + if ( pDest ) + { + bDestArea = TRUE; + aDestRange = *pDest; + } +} + +__EXPORT ScUndoSort::~ScUndoSort() +{ + delete pUndoDoc; + delete pUndoDB; +} + +String __EXPORT ScUndoSort::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_SORT ); +} + +void __EXPORT ScUndoSort::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + USHORT nStartCol = aSortParam.nCol1; + USHORT nStartRow = aSortParam.nRow1; + USHORT nEndCol = aSortParam.nCol2; + USHORT nEndRow = aSortParam.nRow2; + USHORT nSortTab = nTab; + if ( !aSortParam.bInplace ) + { + nStartCol = aSortParam.nDestCol; + nStartRow = aSortParam.nDestRow; + nEndCol = nStartCol + ( aSortParam.nCol2 - aSortParam.nCol1 ); + nEndRow = nStartRow + ( aSortParam.nRow2 - aSortParam.nRow1 ); + nSortTab = aSortParam.nDestTab; + } + + ScUndoUtil::MarkSimpleBlock( pDocShell, nStartCol, nStartRow, nSortTab, + nEndCol, nEndRow, nSortTab ); + + pDoc->DeleteAreaTab( nStartCol,nStartRow, nEndCol,nEndRow, nSortTab, IDF_ALL ); + + pUndoDoc->CopyToDocument( nStartCol, nStartRow, nSortTab, nEndCol, nEndRow, nSortTab, + IDF_ALL, FALSE, pDoc ); + + if (bDestArea) + { + pDoc->DeleteAreaTab( aDestRange, IDF_ALL ); + pUndoDoc->CopyToDocument( aDestRange, IDF_ALL, FALSE, pDoc ); + } + + // Zeilenhoehen immer (wegen automatischer Anpassung) + //! auf ScBlockUndo umstellen +// if (bRepeatQuery) + pUndoDoc->CopyToDocument( 0, nStartRow, nSortTab, MAXCOL, nEndRow, nSortTab, + IDF_NONE, FALSE, pDoc ); + + if (pUndoDB) + pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ) ); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nSortTab ) + pViewShell->SetTabNo( nSortTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + pDocShell->PostDataChanged(); + + EndUndo(); +} + +void __EXPORT ScUndoSort::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + +// pViewShell->DoneBlockMode(); +// pViewShell->InitOwnBlockMode(); +// pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + + pViewShell->MarkRange( ScRange( aSortParam.nCol1, aSortParam.nRow1, nTab, + aSortParam.nCol2, aSortParam.nRow2, nTab ) ); + + pViewShell->Sort( aSortParam, FALSE ); + + // Quellbereich painten wegen Markierung + if ( !aSortParam.bInplace ) + pDocShell->PostPaint( aSortParam.nCol1, aSortParam.nRow1, nTab, + aSortParam.nCol2, aSortParam.nRow2, nTab, PAINT_GRID ); + + EndRedo(); +} + +void __EXPORT ScUndoSort::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoSort::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht wegen Spaltennummern +} + +// +// Filtern +// + +ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, USHORT nNewTab, const ScQueryParam& rParam, + ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB, + const ScRange* pOld, BOOL bSize, const ScRange* pAdvSrc ) : + ScSimpleUndo( pNewDocShell ), + nTab( nNewTab ), + aQueryParam( rParam ), + pUndoDoc( pNewUndoDoc ), +// pUndoDBData( pNewData ) + pUndoDB( pNewUndoDB ), + bIsAdvanced( FALSE ), + bDestArea( FALSE ), + bDoSize( bSize ) +{ + if ( pOld ) + { + bDestArea = TRUE; + aOldDest = *pOld; + } + if ( pAdvSrc ) + { + bIsAdvanced = TRUE; + aAdvSource = *pAdvSrc; + } +} + +__EXPORT ScUndoQuery::~ScUndoQuery() +{ + delete pUndoDoc; +// delete pUndoDBData; + delete pUndoDB; +} + +String __EXPORT ScUndoQuery::GetComment() const +{ // "Filtern"; + return ScGlobal::GetRscString( STR_UNDO_QUERY ); +} + +void __EXPORT ScUndoQuery::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + BOOL bCopy = !aQueryParam.bInplace; + USHORT nDestEndCol = 0; + USHORT nDestEndRow = 0; + if (bCopy) + { + nDestEndCol = aQueryParam.nDestCol + ( aQueryParam.nCol2-aQueryParam.nCol1 ); + nDestEndRow = aQueryParam.nDestRow + ( aQueryParam.nRow2-aQueryParam.nRow1 ); + + ScDBData* pData = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow, + aQueryParam.nDestTab, TRUE ); + if (pData) + { + ScRange aNewDest; + pData->GetArea( aNewDest ); + nDestEndCol = aNewDest.aEnd.Col(); + nDestEndRow = aNewDest.aEnd.Row(); + } + + if ( bDoSize && bDestArea ) + { + // aDestRange ist der alte Bereich + pDoc->FitBlock( ScRange( + aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, + nDestEndCol, nDestEndRow, aQueryParam.nDestTab ), + aOldDest ); + } + + ScUndoUtil::MarkSimpleBlock( pDocShell, + aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, + nDestEndCol, nDestEndRow, aQueryParam.nDestTab ); + pDoc->DeleteAreaTab( aQueryParam.nDestCol, aQueryParam.nDestRow, + nDestEndCol, nDestEndRow, aQueryParam.nDestTab, IDF_ALL ); + + pViewShell->DoneBlockMode(); + + pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, + nDestEndCol, nDestEndRow, aQueryParam.nDestTab, + IDF_ALL, FALSE, pDoc ); + // Attribute werden immer mitkopiert (#49287#) + + // Rest von altem Bereich + if ( bDestArea && !bDoSize ) + { + pDoc->DeleteAreaTab( aOldDest, IDF_ALL ); + pUndoDoc->CopyToDocument( aOldDest, IDF_ALL, FALSE, pDoc ); + } + } + else + pUndoDoc->CopyToDocument( 0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab, + IDF_NONE, FALSE, pDoc ); + + if (pUndoDB) + pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ) ); + + if (!bCopy) + pDoc->UpdatePageBreaks( nTab ); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + // Paint + + if (bCopy) + { + USHORT nEndX = nDestEndCol; + USHORT nEndY = nDestEndRow; + if (bDestArea) + { + if ( aOldDest.aEnd.Col() > nEndX ) + nEndX = aOldDest.aEnd.Col(); + if ( aOldDest.aEnd.Row() > nEndY ) + nEndY = aOldDest.aEnd.Row(); + } + if (bDoSize) + nEndY = MAXROW; + pDocShell->PostPaint( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, + nEndY, nEndY, aQueryParam.nDestTab, PAINT_GRID ); + } + else + pDocShell->PostPaint( 0, aQueryParam.nRow1, nTab, MAXCOL, MAXROW, nTab, + PAINT_GRID | PAINT_LEFT ); + pDocShell->PostDataChanged(); + + EndUndo(); +} + +void __EXPORT ScUndoQuery::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + if ( bIsAdvanced ) + pViewShell->Query( aQueryParam, &aAdvSource, FALSE ); + else + pViewShell->Query( aQueryParam, NULL, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoQuery::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoQuery::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht wegen Spaltennummern +} + +// +// Datenbankbereiche aendern (Dialog) +// + +ScUndoDBData::ScUndoDBData( ScDocShell* pNewDocShell, + ScDBCollection* pNewUndoColl, ScDBCollection* pNewRedoColl ) : + ScSimpleUndo( pNewDocShell ), + pUndoColl( pNewUndoColl ), + pRedoColl( pNewRedoColl ) +{ +} + +__EXPORT ScUndoDBData::~ScUndoDBData() +{ + delete pUndoColl; + delete pRedoColl; +} + +String __EXPORT ScUndoDBData::GetComment() const +{ // "Datenbankbereiche aendern"; + return ScGlobal::GetRscString( STR_UNDO_DBDATA ); +} + +void __EXPORT ScUndoDBData::Undo() +{ + BeginUndo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + BOOL bOldAutoCalc = pDoc->GetAutoCalc(); + pDoc->SetAutoCalc( FALSE ); // unnoetige Berechnungen vermeiden + pDoc->CompileDBFormula( TRUE ); // CreateFormulaString + pDoc->SetDBCollection( new ScDBCollection(*pUndoColl) ); + pDoc->CompileDBFormula( FALSE ); // CompileFormulaString + pDoc->SetAutoCalc( bOldAutoCalc ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); + + EndUndo(); +} + +void __EXPORT ScUndoDBData::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + BOOL bOldAutoCalc = pDoc->GetAutoCalc(); + pDoc->SetAutoCalc( FALSE ); // unnoetige Berechnungen vermeiden + pDoc->CompileDBFormula( TRUE ); // CreateFormulaString + pDoc->SetDBCollection( new ScDBCollection(*pRedoColl) ); + pDoc->CompileDBFormula( FALSE ); // CompileFormulaString + pDoc->SetAutoCalc( bOldAutoCalc ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); + + EndRedo(); +} + +void __EXPORT ScUndoDBData::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoDBData::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // geht nicht +} + +// +// Import +// + +ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, USHORT nNewTab, + const ScImportParam& rParam, USHORT nNewEndX, USHORT nNewEndY, + USHORT nNewFormula, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, + ScDBData* pNewUndoData, ScDBData* pNewRedoData ) : + ScSimpleUndo( pNewDocShell ), + nTab( nNewTab ), + aImportParam( rParam ), + nEndCol( nNewEndX ), + nEndRow( nNewEndY ), + pUndoDoc( pNewUndoDoc ), + pRedoDoc( pNewRedoDoc ), + pUndoDBData( pNewUndoData ), + pRedoDBData( pNewRedoData ), + nFormulaCols( nNewFormula ), + bRedoFilled( FALSE ) +{ + // redo doc doesn't contain imported data (but everything else) +} + +__EXPORT ScUndoImportData::~ScUndoImportData() +{ + delete pUndoDoc; + delete pRedoDoc; + delete pUndoDBData; + delete pRedoDBData; +} + +String __EXPORT ScUndoImportData::GetComment() const +{ // "Importieren"; + return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA ); +} + +void __EXPORT ScUndoImportData::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol,nEndRow,nTab ); + + USHORT nTable, nCol1, nRow1, nCol2, nRow2; + ScDBData* pCurrentData = NULL; + if (pUndoDBData && pRedoDBData) + { + pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, pDoc, nTab, + nCol1, nRow1, nCol2, nRow2 ); + + if ( !bRedoFilled ) + { + // read redo data from document at first undo + // imported data is deleted later anyway, + // so now delete each column after copying to save memory (#41216#) + + BOOL bOldAutoCalc = pDoc->GetAutoCalc(); + pDoc->SetAutoCalc( FALSE ); // outside of the loop + for (USHORT nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++) + { + pDoc->CopyToDocument( nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab, + IDF_CONTENTS, FALSE, pRedoDoc ); + pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS ); + pDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 ); + } + pDoc->SetAutoCalc( bOldAutoCalc ); + bRedoFilled = TRUE; + } + } + BOOL bMoveCells = pUndoDBData && pRedoDBData && + pRedoDBData->IsDoSize(); // in alt und neu gleich + if (bMoveCells) + { + // Undo: erst die neuen Daten loeschen, dann FitBlock rueckwaerts + + ScRange aOld, aNew; + pUndoDBData->GetArea( aOld ); + pRedoDBData->GetArea( aNew ); + + pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(), + aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL ); + + aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock auch fuer Formeln + aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols ); + pDoc->FitBlock( aNew, aOld, FALSE ); // rueckwaerts + } + else + pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1, + nEndCol,nEndRow, nTab, IDF_ALL ); + + pUndoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol+nFormulaCols,nEndRow,nTab, + IDF_ALL, FALSE, pDoc ); + + if (pCurrentData) + { + *pCurrentData = *pUndoDBData; + + pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable ); + } + +// erack! it's broadcasted +// pDoc->SetDirty(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + if (bMoveCells) + pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); + else + pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol,nEndRow,nTab, PAINT_GRID ); + pDocShell->PostDataChanged(); + + EndUndo(); +} + +void __EXPORT ScUndoImportData::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol,nEndRow,nTab ); + + USHORT nTable, nCol1, nRow1, nCol2, nRow2; + ScDBData* pCurrentData = NULL; + if (pUndoDBData && pRedoDBData) + { + pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab, + nCol1, nRow1, nCol2, nRow2 ); + } + BOOL bMoveCells = pUndoDBData && pRedoDBData && + pRedoDBData->IsDoSize(); // in alt und neu gleich + if (bMoveCells) + { + // Redo: FitBlock, dann Daten loeschen (noetig fuer CopyToDocument) + + ScRange aOld, aNew; + pUndoDBData->GetArea( aOld ); + pRedoDBData->GetArea( aNew ); + + aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock auch fuer Formeln + aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols ); + pDoc->FitBlock( aOld, aNew ); + + pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(), + aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL ); + + pRedoDoc->CopyToDocument( aNew, IDF_ALL, FALSE, pDoc ); // incl. Formeln + } + else + { + pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1, + nEndCol,nEndRow, nTab, IDF_ALL ); + pRedoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol,nEndRow,nTab, IDF_ALL, FALSE, pDoc ); + } + + if (pCurrentData) + { + *pCurrentData = *pRedoDBData; + + pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable ); + } + +// erack! it's broadcasted +// pDoc->SetDirty(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + if (bMoveCells) + pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); + else + pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab, + nEndCol,nEndRow,nTab, PAINT_GRID ); + pDocShell->PostDataChanged(); + + EndRedo(); +} + +void __EXPORT ScUndoImportData::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); + + USHORT nDummy; + ScImportParam aNewParam(aImportParam); + ScDBData* pDBData = rViewShell.GetDBData(); + pDBData->GetArea( nDummy, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + + rViewShell.ImportData( aNewParam ); + } +} + +BOOL __EXPORT ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const +{ + // Repeat nur fuer Import per DB-Bereich, dann ist pUndoDBData gesetzt + + if (pUndoDBData) + return (rTarget.ISA(ScTabViewTarget)); + else + return FALSE; // Adressbuch +} + +// +// Operationen wiederholen +// + +ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, USHORT nNewTab, + USHORT nStartX, USHORT nStartY, USHORT nEndX, USHORT nEndY, + USHORT nResultEndRow, USHORT nCurX, USHORT nCurY, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB, + const ScRange* pOldQ, const ScRange* pNewQ ) : + ScSimpleUndo( pNewDocShell ), + aBlockStart( nStartX,nStartY,nNewTab ), + aBlockEnd( nEndX,nEndY,nNewTab ), + nNewEndRow( nResultEndRow ), + aCursorPos( nCurX,nCurY,nNewTab ), + pUndoDoc( pNewUndoDoc ), + pUndoTable( pNewUndoTab ), + pUndoRange( pNewUndoRange ), + pUndoDB( pNewUndoDB ), + bQuerySize( FALSE ) +{ + if ( pOldQ && pNewQ ) + { + aOldQuery = *pOldQ; + aNewQuery = *pNewQ; + bQuerySize = TRUE;; + } +} + +__EXPORT ScUndoRepeatDB::~ScUndoRepeatDB() +{ + delete pUndoDoc; + delete pUndoTable; + delete pUndoRange; + delete pUndoDB; +} + +String __EXPORT ScUndoRepeatDB::GetComment() const +{ // "Wiederholen"; //! bessere Beschreibung! + return ScGlobal::GetRscString( STR_UNDO_REPEATDB ); +} + +void __EXPORT ScUndoRepeatDB::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + if (bQuerySize) + { + pDoc->FitBlock( aNewQuery, aOldQuery, FALSE ); + + if ( aNewQuery.aEnd.Col() == aOldQuery.aEnd.Col() ) + { + USHORT nFormulaCols = 0; + USHORT nCol = aOldQuery.aEnd.Col() + 1; + USHORT nRow = aOldQuery.aStart.Row() + 1; //! Header testen + while ( nCol <= MAXCOL && + pDoc->GetCellType(ScAddress( nCol, nRow, nTab )) == CELLTYPE_FORMULA ) + ++nCol, ++nFormulaCols; + + if ( nFormulaCols ) + { + ScRange aOldForm = aOldQuery; + aOldForm.aStart.SetCol( aOldQuery.aEnd.Col() + 1 ); + aOldForm.aEnd.SetCol( aOldQuery.aEnd.Col() + nFormulaCols ); + ScRange aNewForm = aOldForm; + aNewForm.aEnd.SetRow( aNewQuery.aEnd.Row() ); + pDoc->FitBlock( aNewForm, aOldForm, FALSE ); + } + } + } + + //! Daten von Filter in anderen Bereich fehlen noch !!!!!!!!!!!!!!!!! + + if (nNewEndRow > aBlockEnd.GetRow()) + { + pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aBlockEnd.GetRow()+1, nNewEndRow-aBlockEnd.GetRow() ); + } + else if (nNewEndRow < aBlockEnd.GetRow()) + { + pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, nNewEndRow-aBlockEnd.GetRow() ); + } + + // Original Outline-Table + + pDoc->SetOutlineTable( nTab, pUndoTable ); + + // Original Spalten-/Zeilenstatus + + if (pUndoDoc && pUndoTable) + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol ); + pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow ); + + pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc ); + pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc ); + + pViewShell->UpdateScrollBars(); + } + + // Original-Daten & Referenzen + + ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aBlockStart.GetRow(), nTab, + MAXCOL, aBlockEnd.GetRow(), nTab ); + pDoc->DeleteAreaTab( 0, aBlockStart.GetRow(), + MAXCOL, aBlockEnd.GetRow(), nTab, IDF_ALL ); + + pUndoDoc->CopyToDocument( 0, aBlockStart.GetRow(), nTab, MAXCOL, aBlockEnd.GetRow(), nTab, + IDF_NONE, FALSE, pDoc ); // Flags + pUndoDoc->UndoToDocument( 0, aBlockStart.GetRow(), nTab, MAXCOL, aBlockEnd.GetRow(), nTab, + IDF_ALL, FALSE, pDoc ); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.GetCol(),aBlockStart.GetRow(),nTab, + aBlockEnd.GetCol(),aBlockEnd.GetRow(),nTab ); + + if (pUndoRange) + pDoc->SetRangeName( new ScRangeName( *pUndoRange ) ); + if (pUndoDB) + pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ) ); + +// erack! it's broadcasted +// pDoc->SetDirty(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE); + pDocShell->PostDataChanged(); + + EndUndo(); +} + +void __EXPORT ScUndoRepeatDB::Redo() +{ + BeginRedo(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + USHORT nTab = aBlockStart.GetTab(); + + USHORT nVisTab = pViewShell->GetViewData()->GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); + + ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.GetCol(),aBlockStart.GetRow(),nTab, + aBlockEnd.GetCol(),aBlockEnd.GetRow(),nTab ); + pViewShell->SetCursor( aCursorPos.GetCol(), aCursorPos.GetRow() ); + + pViewShell->RepeatDB( FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + ((ScTabViewTarget&)rTarget).GetViewShell()->RepeatDB( TRUE ); +} + +BOOL __EXPORT ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// +// Pivot-Tabellen +// + +ScUndoPivot::ScUndoPivot( ScDocShell* pNewDocShell, + const ScArea& rOld, const ScArea& rNew, + ScDocument* pOldDoc, ScDocument* pNewDoc, + const ScPivot* pOldPivot, const ScPivot* pNewPivot ) : + ScSimpleUndo( pNewDocShell ), + aOldArea( rOld ), + aNewArea( rNew ), + pOldUndoDoc( pOldDoc ), + pNewUndoDoc( pNewDoc ) +{ + if (pNewPivot) + { + pNewPivot->GetParam( aNewParam, aNewQuery, aNewSrc ); + aNewName = pNewPivot->GetName(); + aNewTag = pNewPivot->GetTag(); + } + if (pOldPivot) + { + pOldPivot->GetParam( aOldParam, aOldQuery, aOldSrc ); + aOldName = pOldPivot->GetName(); + aOldTag = pOldPivot->GetTag(); + } +} + +__EXPORT ScUndoPivot::~ScUndoPivot() +{ + delete pOldUndoDoc; + delete pNewUndoDoc; +} + +String __EXPORT ScUndoPivot::GetComment() const +{ + USHORT nIndex; + if ( pOldUndoDoc && pNewUndoDoc ) + nIndex = STR_UNDO_PIVOT_MODIFY; + else if ( pNewUndoDoc ) + nIndex = STR_UNDO_PIVOT_NEW; + else + nIndex = STR_UNDO_PIVOT_DELETE; + + return ScGlobal::GetRscString( nIndex ); +} + +void __EXPORT ScUndoPivot::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + if (pNewUndoDoc) + { + pDoc->DeleteAreaTab( aNewArea.nColStart,aNewArea.nRowStart, + aNewArea.nColEnd,aNewArea.nRowEnd, aNewArea.nTab, IDF_ALL ); + pNewUndoDoc->CopyToDocument( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab, + aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab, + IDF_ALL, FALSE, pDoc ); + } + if (pOldUndoDoc) + { + pDoc->DeleteAreaTab( aOldArea.nColStart,aOldArea.nRowStart, + aOldArea.nColEnd,aOldArea.nRowEnd, aOldArea.nTab, IDF_ALL ); + pOldUndoDoc->CopyToDocument( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab, + aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab, + IDF_ALL, FALSE, pDoc ); + } + + ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection(); + if ( pNewUndoDoc ) + { + ScPivot* pNewPivot = pPivotCollection->GetPivotAtCursor( + aNewParam.nCol, aNewParam.nRow, aNewParam.nTab ); + if (pNewPivot) + pPivotCollection->Free( pNewPivot ); + } + if ( pOldUndoDoc ) + { + ScPivot* pOldPivot = new ScPivot( pDoc ); + pOldPivot->SetParam( aOldParam, aOldQuery, aOldSrc ); + pOldPivot->SetName( aOldName ); + pOldPivot->SetTag( aOldTag ); + if (pOldPivot->CreateData()) // Felder berechnen + pOldPivot->ReleaseData(); + pPivotCollection->Insert( pOldPivot ); + } + +// erack! it's broadcasted +// pDoc->SetDirty(); + if (pNewUndoDoc) + pDocShell->PostPaint( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab, + aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab, + PAINT_GRID, SC_PF_LINES ); + if (pOldUndoDoc) + pDocShell->PostPaint( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab, + aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab, + PAINT_GRID, SC_PF_LINES ); + pDocShell->PostDataChanged(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + USHORT nTab = pViewShell->GetViewData()->GetTabNo(); + if ( pOldUndoDoc ) + { + if ( nTab != aOldArea.nTab ) + pViewShell->SetTabNo( aOldArea.nTab ); + } + else if ( pNewUndoDoc ) + { + if ( nTab != aNewArea.nTab ) + pViewShell->SetTabNo( aNewArea.nTab ); + } + } + + EndUndo(); +} + +void __EXPORT ScUndoPivot::Redo() +{ + BeginRedo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection(); + ScPivot* pOldPivot = pPivotCollection->GetPivotAtCursor( + aOldParam.nCol, aOldParam.nRow, aOldParam.nTab ); + + ScPivot* pNewPivot = NULL; + if (pNewUndoDoc) + { + pNewPivot = new ScPivot( pDoc ); + pNewPivot->SetParam( aNewParam, aNewQuery, aNewSrc ); + pNewPivot->SetName( aNewName ); + pNewPivot->SetTag( aNewTag ); + } + + pDocShell->PivotUpdate( pOldPivot, pNewPivot, FALSE ); + + EndRedo(); +} + +void __EXPORT ScUndoPivot::Repeat(SfxRepeatTarget& rTarget) +{ + // Wiederholen: nur loeschen + + if ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) ) + ((ScTabViewTarget&)rTarget).GetViewShell()->DeletePivotTable(); +} + +BOOL __EXPORT ScUndoPivot::CanRepeat(SfxRepeatTarget& rTarget) const +{ + // Wiederholen: nur loeschen + + return ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) ); +} + + +// +// data pilot +// + +ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell, + ScDocument* pOldDoc, ScDocument* pNewDoc, + const ScDPObject* pOldObj, const ScDPObject* pNewObj ) : + ScSimpleUndo( pNewDocShell ), + pOldDPObject( NULL ), + pNewDPObject( NULL ), + pOldUndoDoc( pOldDoc ), + pNewUndoDoc( pNewDoc ) +{ + if (pOldObj) + pOldDPObject = new ScDPObject( *pOldObj ); + if (pNewObj) + pNewDPObject = new ScDPObject( *pNewObj ); +} + +__EXPORT ScUndoDataPilot::~ScUndoDataPilot() +{ + delete pOldDPObject; + delete pNewDPObject; + delete pOldUndoDoc; + delete pNewUndoDoc; +} + +String __EXPORT ScUndoDataPilot::GetComment() const +{ + USHORT nIndex; + if ( pOldUndoDoc && pNewUndoDoc ) + nIndex = STR_UNDO_PIVOT_MODIFY; + else if ( pNewUndoDoc ) + nIndex = STR_UNDO_PIVOT_NEW; + else + nIndex = STR_UNDO_PIVOT_DELETE; + + return ScGlobal::GetRscString( nIndex ); +} + +void __EXPORT ScUndoDataPilot::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + + ScRange aOldRange; + ScRange aNewRange; + + if ( pNewDPObject && pNewUndoDoc ) + { + aNewRange = pNewDPObject->GetOutRange(); + pDoc->DeleteAreaTab( aNewRange, IDF_ALL ); + pNewUndoDoc->CopyToDocument( aNewRange, IDF_ALL, FALSE, pDoc ); + } + if ( pOldDPObject && pOldUndoDoc ) + { + aOldRange = pOldDPObject->GetOutRange(); + pDoc->DeleteAreaTab( aOldRange, IDF_ALL ); + pOldUndoDoc->CopyToDocument( aOldRange, IDF_ALL, FALSE, pDoc ); + } + + // update objects in collection + + if ( pNewDPObject ) + { + // find updated object + //! find by name! + + ScDPObject* pDocObj = pDoc->GetDPAtCursor( + aNewRange.aStart.Col(), aNewRange.aStart.Row(), aNewRange.aStart.Tab() ); + DBG_ASSERT(pDocObj, "DPObject not found"); + if (pDocObj) + { + if ( pOldDPObject ) + { + // restore old settings + pOldDPObject->WriteSourceDataTo( *pDocObj ); + ScDPSaveData* pData = pOldDPObject->GetSaveData(); + if (pData) + pDocObj->SetSaveData(*pData); + pDocObj->SetOutRange( pOldDPObject->GetOutRange() ); + } + else + { + // delete inserted object + pDoc->GetDPCollection()->Free(pDocObj); + } + } + } + else if ( pOldDPObject ) + { + // re-insert deleted object + + ScDPObject* pDestObj = new ScDPObject( *pOldDPObject ); + pDestObj->SetAlive(TRUE); + if ( !pDoc->GetDPCollection()->Insert(pDestObj) ) + { + DBG_ERROR("cannot insert DPObject"); + DELETEZ( pDestObj ); + } + } + + if (pNewUndoDoc) + pDocShell->PostPaint( aNewRange, PAINT_GRID, SC_PF_LINES ); + if (pOldUndoDoc) + pDocShell->PostPaint( aOldRange, PAINT_GRID, SC_PF_LINES ); + pDocShell->PostDataChanged(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + //! set current sheet + } + + EndUndo(); +} + +void __EXPORT ScUndoDataPilot::Redo() +{ + BeginRedo(); + + //! copy output data instead of repeating the change, + //! in case external data have changed! + + ScDocument* pDoc = pDocShell->GetDocument(); + + ScDPObject* pSourceObj = NULL; + if ( pOldDPObject ) + { + // find object to modify + //! find by name! + + ScRange aOldRange = pOldDPObject->GetOutRange(); + pSourceObj = pDoc->GetDPAtCursor( + aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() ); + DBG_ASSERT(pSourceObj, "DPObject not found"); + } + + ScDBDocFunc aFunc( *pDocShell ); + aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, FALSE, FALSE ); // no new undo action + + EndRedo(); +} + +void __EXPORT ScUndoDataPilot::Repeat(SfxRepeatTarget& rTarget) +{ + //! allow deletion +} + +BOOL __EXPORT ScUndoDataPilot::CanRepeat(SfxRepeatTarget& rTarget) const +{ + //! allow deletion + return FALSE; +} + + +// +// Konsolidieren +// + +ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea, + const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc, + BOOL bReference, USHORT nInsCount, ScOutlineTable* pTab, + ScDBData* pData ) : + ScSimpleUndo( pNewDocShell ), + aDestArea( rArea ), + aParam( rPar ), + pUndoDoc( pNewUndoDoc ), + bInsRef( bReference ), + nInsertCount( nInsCount ), + pUndoTab( pTab ), + pUndoData( pData ) +{ +} + +__EXPORT ScUndoConsolidate::~ScUndoConsolidate() +{ + delete pUndoDoc; + delete pUndoTab; + delete pUndoData; +} + +String __EXPORT ScUndoConsolidate::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE ); +} + +void __EXPORT ScUndoConsolidate::Undo() +{ + BeginUndo(); + + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTab = aDestArea.nTab; + + ScRange aOldRange; + if (pUndoData) + pUndoData->GetArea(aOldRange); + + if (bInsRef) + { + // Zeilen loeschen + pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount ); + + // Outlines + pDoc->SetOutlineTable( nTab, pUndoTab ); + + // Zeilenstatus + pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pDoc ); + + // Daten & Referenzen + pDoc->DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, IDF_ALL ); + pUndoDoc->UndoToDocument( 0, aDestArea.nRowStart, nTab, + MAXCOL, aDestArea.nRowEnd, nTab, + IDF_ALL, FALSE, pDoc ); + + // Original-Bereich + if (pUndoData) + { + pDoc->DeleteAreaTab(aOldRange, IDF_ALL); + pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, FALSE, pDoc); + } + + pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab, + PAINT_GRID | PAINT_LEFT | PAINT_SIZE ); + } + else + { + pDoc->DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart, + aDestArea.nColEnd,aDestArea.nRowEnd, nTab, IDF_ALL ); + pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab, + aDestArea.nColEnd, aDestArea.nRowEnd, nTab, + IDF_ALL, FALSE, pDoc ); + + // Original-Bereich + if (pUndoData) + { + pDoc->DeleteAreaTab(aOldRange, IDF_ALL); + pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, FALSE, pDoc); + } + + USHORT nEndX = aDestArea.nColEnd; + USHORT nEndY = aDestArea.nRowEnd; + if ( pUndoData ) + { + if ( aOldRange.aEnd.Col() > nEndX ) + nEndX = aOldRange.aEnd.Col(); + if ( aOldRange.aEnd.Row() > nEndY ) + nEndY = aOldRange.aEnd.Row(); + } + pDocShell->PostPaint( aDestArea.nColStart, aDestArea.nRowStart, nTab, + nEndX, nEndY, nTab, PAINT_GRID ); + } + + // DB-Bereich wieder anpassen + if (pUndoData) + { + ScDBCollection* pColl = pDoc->GetDBCollection(); + if (pColl) + { + USHORT nIndex; + if (pColl->SearchName( pUndoData->GetName(), nIndex )) + { + ScDBData* pDocData = (*pColl)[nIndex]; + if (pDocData) + *pDocData = *pUndoData; + } + else + DBG_ERROR("alte DB-Daten nicht gefunden"); + } + } + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + USHORT nViewTab = pViewShell->GetViewData()->GetTabNo(); + if ( nViewTab != nTab ) + pViewShell->SetTabNo( nTab ); + } + + EndUndo(); +} + +void __EXPORT ScUndoConsolidate::Redo() +{ + BeginRedo(); + + pDocShell->DoConsolidate( aParam, FALSE ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + USHORT nViewTab = pViewShell->GetViewData()->GetTabNo(); + if ( nViewTab != aParam.nTab ) + pViewShell->SetTabNo( aParam.nTab ); + } + + EndRedo(); +} + +void __EXPORT ScUndoConsolidate::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoConsolidate::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// +// Quell-Daten von Chart aendern +// + +void ScUndoChartData::Init() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + BOOL bFound = FALSE;; + + SchMemChart* pOld = pDoc->FindChartData(aChartName); + if (pOld) + { + ScChartArray aData(pDoc,*pOld); + aOldRangeListRef = aData.GetRangeList(); + bOldColHeaders = aData.HasColHeaders(); + bOldRowHeaders = aData.HasRowHeaders(); + } + else // war vorher nicht initialisiert + { //! bei Undo zuruecksetzen ? + aOldRangeListRef = aNewRangeListRef; + bOldColHeaders = bNewColHeaders; + bOldRowHeaders = bNewRowHeaders; + } +} + +ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName, + const ScRange& rNew, BOOL bColHdr, BOOL bRowHdr, + BOOL bAdd ) : + ScSimpleUndo( pNewDocShell ), + aChartName( rName ), + bNewColHeaders( bColHdr ), + bNewRowHeaders( bRowHdr ), + bAddRange( bAdd ) +{ + aNewRangeListRef = new ScRangeList; + aNewRangeListRef->Append( rNew ); + + Init(); +} + +ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName, + const ScRangeListRef& rNew, BOOL bColHdr, BOOL bRowHdr, + BOOL bAdd ) : + ScSimpleUndo( pNewDocShell ), + aChartName( rName ), + aNewRangeListRef( rNew ), + bNewColHeaders( bColHdr ), + bNewRowHeaders( bRowHdr ), + bAddRange( bAdd ) +{ + Init(); +} + +__EXPORT ScUndoChartData::~ScUndoChartData() +{ +} + +String __EXPORT ScUndoChartData::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_CHARTDATA ); +} + +void __EXPORT ScUndoChartData::Undo() +{ + BeginUndo(); + + Window* pDataWin = NULL; + ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); + if (pViewSh) + pDataWin = pViewSh->GetActiveWin(); + + pDocShell->GetDocument()->UpdateChartArea( aChartName, aOldRangeListRef, + bOldColHeaders, bOldRowHeaders, FALSE, pDataWin ); + + EndUndo(); +} + +void __EXPORT ScUndoChartData::Redo() +{ + BeginRedo(); + + Window* pDataWin = NULL; + ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); + if (pViewSh) + pDataWin = pViewSh->GetActiveWin(); + + pDocShell->GetDocument()->UpdateChartArea( aChartName, aNewRangeListRef, + bNewColHeaders, bNewRowHeaders, bAddRange, pDataWin ); + + EndRedo(); +} + +void __EXPORT ScUndoChartData::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL __EXPORT ScUndoChartData::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + + + + + diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx new file mode 100644 index 000000000000..712d413fcda6 --- /dev/null +++ b/sc/source/ui/undo/undodraw.cxx @@ -0,0 +1,304 @@ +/************************************************************************* + * + * $RCSfile: undodraw.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +//#define _STATUS_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + + +#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +#define _SI_NOOTHERFORMS +#define _SI_NOCONTROL +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdundo.hxx> + +#include "undodraw.hxx" +#include "docsh.hxx" + + +// ----------------------------------------------------------------------- + +TYPEINIT1(ScUndoDraw, SfxUndoAction); + +// ----------------------------------------------------------------------- + +ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) : + pDrawUndo( pUndo ), + pDocShell( pDocSh ) +{ +} + +__EXPORT ScUndoDraw::~ScUndoDraw() +{ + delete pDrawUndo; +} + +void ScUndoDraw::ForgetDrawUndo() +{ + pDrawUndo = NULL; // nicht loeschen (Draw-Undo muss dann von aussen gemerkt werden) +} + +String __EXPORT ScUndoDraw::GetComment() const +{ + if (pDrawUndo) + return pDrawUndo->GetComment(); + else + return String(); +} + +String __EXPORT ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const +{ + if (pDrawUndo) + return pDrawUndo->GetRepeatComment(rTarget); + else + return String(); +} + +USHORT __EXPORT ScUndoDraw::GetId() const +{ + if (pDrawUndo) + return pDrawUndo->GetId(); + else + return 0; +} + +BOOL __EXPORT ScUndoDraw::IsLinked() +{ + if (pDrawUndo) + return pDrawUndo->IsLinked(); + else + return FALSE; +} + +void __EXPORT ScUndoDraw::SetLinked( BOOL bIsLinked ) +{ + if (pDrawUndo) + pDrawUndo->SetLinked(bIsLinked); +} + +BOOL __EXPORT ScUndoDraw::Merge( SfxUndoAction* pNextAction ) +{ + if (pDrawUndo) + return pDrawUndo->Merge(pNextAction); + else + return FALSE; +} + +void __EXPORT ScUndoDraw::Undo() +{ + if (pDrawUndo) + { + pDrawUndo->Undo(); + pDocShell->SetDrawModified(); + } +} + +void __EXPORT ScUndoDraw::Redo() +{ + if (pDrawUndo) + { + pDrawUndo->Redo(); + pDocShell->SetDrawModified(); + } +} + +void __EXPORT ScUndoDraw::Repeat(SfxRepeatTarget& rTarget) +{ + if (pDrawUndo) + pDrawUndo->Repeat(rTarget); +} + +BOOL __EXPORT ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const +{ + if (pDrawUndo) + return pDrawUndo->CanRepeat(rTarget); + else + return FALSE; +} + + + diff --git a/sc/source/ui/undo/undoolk.cxx b/sc/source/ui/undo/undoolk.cxx new file mode 100644 index 000000000000..386afa0a74a0 --- /dev/null +++ b/sc/source/ui/undo/undoolk.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: undoolk.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +//sfx +//#define _BASEDLGS_HXX //* +#define _DLGCFG_HXX +#define _SFXBASIC_HXX +#define _MODALDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXIMGMGR_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX +#define _PASSWD_HXX +#define _SFXFILEDLG_HXX +#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX +#define _SFXMSGPOOL_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSG_HXX +#define _INTRO_HXX +#define _SFX_PRNMON_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdundo.hxx> + +#include "document.hxx" +#include "drwlayer.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +SdrUndoAction* GetSdrUndoAction( ScDocument* pDoc ) +{ + ScDrawLayer* pLayer = pDoc->GetDrawLayer(); + if (pLayer) + return pLayer->GetCalcUndo(); // muss vorhanden sein + else + return NULL; +} + +void DoSdrUndoAction( SdrUndoAction* pUndoAction ) +{ + pUndoAction->Undo(); +} + + +void RedoSdrUndoAction( SdrUndoAction* pUndoAction ) +{ + pUndoAction->Redo(); +} + +void DeleteSdrUndoAction( SdrUndoAction* pUndoAction ) +{ + delete pUndoAction; +} + +void EnableDrawAdjust( ScDocument* pDoc, BOOL bEnable ) +{ + ScDrawLayer* pLayer = pDoc->GetDrawLayer(); + if (pLayer) + pLayer->EnableAdjust(bEnable); +} + + + diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx new file mode 100644 index 000000000000..6d10173438ac --- /dev/null +++ b/sc/source/ui/undo/undostyl.cxx @@ -0,0 +1,327 @@ +/************************************************************************* + * + * $RCSfile: undostyl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <svtools/itemset.hxx> +#include <vcl/virdev.hxx> + +#include "undostyl.hxx" +#include "docsh.hxx" +#include "stlpool.hxx" +#include "printfun.hxx" +#include "globstr.hrc" + +// ----------------------------------------------------------------------- + +TYPEINIT1(ScUndoModifyStyle, ScSimpleUndo); +TYPEINIT1(ScUndoApplyPageStyle, ScSimpleUndo); + +// ----------------------------------------------------------------------- +// +// modify style (cell or page style) +// + +ScStyleSaveData::ScStyleSaveData() : + pItems( NULL ) +{ +} + +ScStyleSaveData::ScStyleSaveData( const ScStyleSaveData& rOther ) : + aName( rOther.aName ), + aParent( rOther.aParent ) +{ + if (rOther.pItems) + pItems = new SfxItemSet( *rOther.pItems ); + else + pItems = NULL; +} + +ScStyleSaveData::~ScStyleSaveData() +{ + delete pItems; +} + +ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther ) +{ + aName = rOther.aName; + aParent = rOther.aParent; + + delete pItems; + if (rOther.pItems) + pItems = new SfxItemSet( *rOther.pItems ); + else + pItems = NULL; + + return *this; +} + +void ScStyleSaveData::InitFromStyle( const SfxStyleSheetBase* pSource ) +{ + if ( pSource ) + { + aName = pSource->GetName(); + aParent = pSource->GetParent(); + delete pItems; + pItems = new SfxItemSet( ((SfxStyleSheetBase*)pSource)->GetItemSet() ); + } + else + *this = ScStyleSaveData(); // empty +} + +// ----------------------------------------------------------------------- + +ScUndoModifyStyle::ScUndoModifyStyle( ScDocShell* pDocSh, SfxStyleFamily eFam, + const ScStyleSaveData& rOld, const ScStyleSaveData& rNew ) : + ScSimpleUndo( pDocSh ), + eFamily( eFam ), + aOldData( rOld ), + aNewData( rNew ) +{ +} + +ScUndoModifyStyle::~ScUndoModifyStyle() +{ +} + +String ScUndoModifyStyle::GetComment() const +{ + USHORT nId = (eFamily == SFX_STYLE_FAMILY_PARA) ? + STR_UNDO_EDITCELLSTYLE : + STR_UNDO_EDITPAGESTYLE; + return ScGlobal::GetRscString( nId ); +} + +void lcl_DocStyleChanged( ScDocument* pDoc, SfxStyleSheetBase* pStyle, BOOL bRemoved ) +{ + //! move to document or docshell + + VirtualDevice aVDev; + Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); + double nPPTX = aLogic.X() / 1000.0; + double nPPTY = aLogic.Y() / 1000.0; + Fraction aZoom(1,1); + pDoc->StyleSheetChanged( pStyle, bRemoved, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); +} + +// static +void ScUndoModifyStyle::DoChange( ScDocShell* pDocSh, const String& rName, + SfxStyleFamily eStyleFamily, const ScStyleSaveData& rData ) +{ + ScDocument* pDoc = pDocSh->GetDocument(); + ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); + String aNewName = rData.GetName(); + BOOL bDelete = ( aNewName.Len() == 0 ); // no new name -> delete style + BOOL bNew = ( rName.Len() == 0 && !bDelete ); // creating new style + + SfxStyleSheetBase* pStyle = NULL; + if ( rName.Len() ) + { + // find old style to modify + pStyle = pStlPool->Find( rName, eStyleFamily ); + DBG_ASSERT( pStyle, "style not found" ); + + if ( pStyle && !bDelete ) + { + // set new name + pStyle->SetName( aNewName ); + } + } + else if ( !bDelete ) + { + // create style (with new name) + pStyle = &pStlPool->Make( aNewName, eStyleFamily, SFXSTYLEBIT_USERDEF ); + } + + if ( pStyle ) + { + if ( bDelete ) + { + if ( eStyleFamily == SFX_STYLE_FAMILY_PARA ) + lcl_DocStyleChanged( pDoc, pStyle, TRUE ); // TRUE: remove usage of style + else + pDoc->RemovePageStyleInUse( rName ); + + // delete style + pStlPool->Erase( pStyle ); + } + else + { + // modify style + + String aNewParent = rData.GetParent(); + if ( aNewParent != pStyle->GetParent() ) + pStyle->SetParent( aNewParent ); + + SfxItemSet& rStyleSet = pStyle->GetItemSet(); + const SfxItemSet* pNewSet = rData.GetItems(); + DBG_ASSERT( pNewSet, "no ItemSet for style" ); + if (pNewSet) + rStyleSet.Set( *pNewSet, FALSE ); + + if ( eStyleFamily == SFX_STYLE_FAMILY_PARA ) + { + lcl_DocStyleChanged( pDoc, pStyle, FALSE ); // cell styles: row heights + } + else + { + // page styles + + if ( bNew && aNewName != rName ) + pDoc->RenamePageStyleInUse( rName, aNewName ); + + if (pNewSet) + pDoc->ModifyStyleSheet( *pStyle, *pNewSet ); + + pDocSh->PageStyleModified( aNewName, TRUE ); + } + } + } + + pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); + + //! undo/redo document modifications for deleted styles + //! undo/redo modifications of number formatter +} + +void ScUndoModifyStyle::Undo() +{ + BeginUndo(); + DoChange( pDocShell, aNewData.GetName(), eFamily, aOldData ); + EndUndo(); +} + +void ScUndoModifyStyle::Redo() +{ + BeginRedo(); + DoChange( pDocShell, aOldData.GetName(), eFamily, aNewData ); + EndRedo(); +} + +void ScUndoModifyStyle::Repeat(SfxRepeatTarget& rTarget) +{ +} + +BOOL ScUndoModifyStyle::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // no repeat possible +} + +// ----------------------------------------------------------------------- +// +// apply page style +// + +ScUndoApplyPageStyle::ScUndoApplyPageStyle( ScDocShell* pDocSh, USHORT nT, + const String& rOld, const String& rNew ) : + ScSimpleUndo( pDocSh ), + nTab( nT ), + aOldStyle( rOld ), + aNewStyle( rNew ) +{ +} + +ScUndoApplyPageStyle::~ScUndoApplyPageStyle() +{ +} + +String ScUndoApplyPageStyle::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_APPLYPAGESTYLE ); +} + +void ScUndoApplyPageStyle::Undo() +{ + BeginUndo(); + + pDocShell->GetDocument()->SetPageStyle( nTab, aOldStyle ); + + ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages(); + EndUndo(); +} + +void ScUndoApplyPageStyle::Redo() +{ + BeginRedo(); + + pDocShell->GetDocument()->SetPageStyle( nTab, aNewStyle ); + + ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages(); + EndRedo(); +} + +void ScUndoApplyPageStyle::Repeat(SfxRepeatTarget& rTarget) +{ + //! set same page style to current tab +} + +BOOL ScUndoApplyPageStyle::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx new file mode 100644 index 000000000000..c8a7fd10cdbb --- /dev/null +++ b/sc/source/ui/undo/undotab.cxx @@ -0,0 +1,1383 @@ +/************************************************************************* + * + * $RCSfile: undotab.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// ?#define _MACRODLG_HXX +// ? #define _BIGINT_HXX +// ? #define _SVDXOUT_HXX +// ? #define _SVDATTR_HXX +// ? #define _SVDSURO_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svtools/smplhint.hxx> + +#include "undotab.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "sc.hrc" +#include "undoolk.hxx" +#include "target.hxx" +#include "uiitems.hxx" +#include "prnsave.hxx" +#include "printfun.hxx" +#include "chgtrack.hxx" + +extern BOOL bDrawIsInUndo; //! irgendwo als Member !!! + +// STATIC DATA ----------------------------------------------------------- + +TYPEINIT1(ScUndoInsertTab, SfxUndoAction); +TYPEINIT1(ScUndoInsertTables, SfxUndoAction); +TYPEINIT1(ScUndoDeleteTab, SfxUndoAction); +TYPEINIT1(ScUndoRenameTab, SfxUndoAction); +TYPEINIT1(ScUndoMoveTab, SfxUndoAction); +TYPEINIT1(ScUndoCopyTab, SfxUndoAction); +TYPEINIT1(ScUndoMakeScenario, SfxUndoAction); +TYPEINIT1(ScUndoImportTab, SfxUndoAction); +TYPEINIT1(ScUndoRemoveLink, SfxUndoAction); +TYPEINIT1(ScUndoShowHideTab, SfxUndoAction); +TYPEINIT1(ScUndoProtect, SfxUndoAction); +TYPEINIT1(ScUndoPrintRange, SfxUndoAction); +TYPEINIT1(ScUndoScenarioFlags, SfxUndoAction); + + +// ----------------------------------------------------------------------- +// +// Tabelle einfuegen +// + +ScUndoInsertTab::ScUndoInsertTab( ScDocShell* pNewDocShell, + USHORT nTabNum, + BOOL bApp, + const String& rNewName) : + ScSimpleUndo( pNewDocShell ), + nTab( nTabNum ), + bAppend( bApp ), + sNewName( rNewName ), + pDrawUndo( NULL ) +{ + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); + SetChangeTrack(); +} + +__EXPORT ScUndoInsertTab::~ScUndoInsertTab() +{ + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoInsertTab::GetComment() const +{ + if (bAppend) + return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB ); + else + return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB ); +} + +void ScUndoInsertTab::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ); + pChangeTrack->AppendInsert( aRange ); + nEndChangeAction = pChangeTrack->GetActionMax(); + } + else + nEndChangeAction = 0; +} + +void __EXPORT ScUndoInsertTab::Undo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + pViewShell->SetTabNo(nTab); + + pDocShell->SetInUndo( TRUE ); //! BeginUndo + bDrawIsInUndo = TRUE; + pViewShell->DeleteTable( nTab, FALSE ); + bDrawIsInUndo = FALSE; + pDocShell->SetInUndo( FALSE ); //! EndUndo + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); + + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); + + // SetTabNo(...,TRUE) for all views to sync with drawing layer pages + pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) ); +} + +void __EXPORT ScUndoInsertTab::Redo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pDrawUndo) + RedoSdrUndoAction( pDrawUndo ); // Draw Redo vorneweg + + pDocShell->SetInUndo( TRUE ); //! BeginRedo + bDrawIsInUndo = TRUE; + if (bAppend) + pViewShell->AppendTable( sNewName, FALSE ); + else + { + pViewShell->SetTabNo(nTab); + pViewShell->InsertTable( sNewName, nTab, FALSE ); + } + bDrawIsInUndo = FALSE; + pDocShell->SetInUndo( FALSE ); //! EndRedo + + SetChangeTrack(); +} + +void __EXPORT ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget) +{ + SFX_DISPATCHER().Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); +} + +BOOL __EXPORT ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +// ----------------------------------------------------------------------- +// +// Tabellen einfuegen +// + +ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell, + USHORT nTabNum, + BOOL bApp,SvStrings *pNewNameList) : + ScSimpleUndo( pNewDocShell ), + nTab( nTabNum ), + bAppend( bApp ), + pDrawUndo( NULL ) +{ + pNameList = pNewNameList; + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); + + SetChangeTrack(); +} + +__EXPORT ScUndoInsertTables::~ScUndoInsertTables() +{ + String *pStr=NULL; + if(pNameList!=NULL) + { + for(int i=0;i<pNameList->Count();i++) + { + pStr=pNameList->GetObject(i); + delete pStr; + } + pNameList->Remove(0,pNameList->Count()); + delete pNameList; + } + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoInsertTables::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB ); +} + +void ScUndoInsertTables::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + nStartChangeAction = pChangeTrack->GetActionMax() + 1; + nEndChangeAction = 0; + ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab ); + for( int i = 0; i < pNameList->Count(); i++ ) + { + aRange.aStart.SetTab( nTab + i ); + aRange.aEnd.SetTab( nTab + i ); + pChangeTrack->AppendInsert( aRange ); + nEndChangeAction = pChangeTrack->GetActionMax(); + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +void __EXPORT ScUndoInsertTables::Undo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + pViewShell->SetTabNo(nTab); + + pDocShell->SetInUndo( TRUE ); //! BeginUndo + bDrawIsInUndo = TRUE; + + SvUShorts TheTabs; + for(int i=0;i<pNameList->Count();i++) + { + TheTabs.Insert(nTab+i,TheTabs.Count()); + } + + pViewShell->DeleteTables( TheTabs, FALSE ); + TheTabs.Remove(0,TheTabs.Count()); + + bDrawIsInUndo = FALSE; + pDocShell->SetInUndo( FALSE ); //! EndUndo + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); + + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + // SetTabNo(...,TRUE) for all views to sync with drawing layer pages + pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) ); +} + +void __EXPORT ScUndoInsertTables::Redo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pDrawUndo) + RedoSdrUndoAction( pDrawUndo ); // Draw Redo vorneweg + + pDocShell->SetInUndo( TRUE ); //! BeginRedo + bDrawIsInUndo = TRUE; + pViewShell->SetTabNo(nTab); + pViewShell->InsertTables( pNameList, nTab,pNameList->Count(),FALSE ); + + bDrawIsInUndo = FALSE; + pDocShell->SetInUndo( FALSE ); //! EndRedo + + SetChangeTrack(); +} + +void __EXPORT ScUndoInsertTables::Repeat(SfxRepeatTarget& rTarget) +{ + SFX_DISPATCHER().Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); +} + +BOOL __EXPORT ScUndoInsertTables::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//---------------------------------------------------------------------------------- +// +// Tabelle loeschen +// + +ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell,const SvUShorts &aTab, //USHORT nNewTab, + ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : + ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ) +{ + for(int i=0;i<aTab.Count();i++) + theTabs.Insert(aTab[i],theTabs.Count()); + + SetChangeTrack(); +} + +__EXPORT ScUndoDeleteTab::~ScUndoDeleteTab() +{ + theTabs.Remove(0,theTabs.Count()); +} + +String __EXPORT ScUndoDeleteTab::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB ); +} + +void ScUndoDeleteTab::SetChangeTrack() +{ + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + { + ULONG nTmpChangeAction; + nStartChangeAction = pChangeTrack->GetActionMax() + 1; + nEndChangeAction = 0; + ScRange aRange( 0, 0, 0, MAXCOL, MAXROW, 0 ); + for ( int i = 0; i < theTabs.Count(); i++ ) + { + aRange.aStart.SetTab( theTabs[i] ); + aRange.aEnd.SetTab( theTabs[i] ); + pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc, + nTmpChangeAction, nEndChangeAction, (short) i ); + } + } + else + nStartChangeAction = nEndChangeAction = 0; +} + +void __EXPORT ScUndoDeleteTab::Undo() +{ + BeginUndo(); + int i=0; + ScDocument* pDoc = pDocShell->GetDocument(); + + BOOL bLink = FALSE; + String aName; + + for(i=0;i<theTabs.Count();i++) + { + pRefUndoDoc->GetName( theTabs[i], aName ); + + bDrawIsInUndo = TRUE; + BOOL bOk = pDoc->InsertTab( theTabs[i], aName ); + bDrawIsInUndo = FALSE; + if (bOk) + { + // Ref-Undo passiert in EndUndo + // pUndoDoc->UndoToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pDoc ); + pRefUndoDoc->CopyToDocument(0,0,theTabs[i], MAXCOL,MAXROW,theTabs[i], IDF_ALL,FALSE, pDoc ); + + String aOldName; + pRefUndoDoc->GetName( theTabs[i], aOldName ); + pDoc->RenameTab( theTabs[i], aOldName, FALSE ); + if (pRefUndoDoc->IsLinked(theTabs[i])) + { + pDoc->SetLink( theTabs[i], pRefUndoDoc->GetLinkMode(theTabs[i]), pRefUndoDoc->GetLinkDoc(theTabs[i]), + pRefUndoDoc->GetLinkFlt(theTabs[i]), pRefUndoDoc->GetLinkOpt(theTabs[i]), + pRefUndoDoc->GetLinkTab(theTabs[i]) ); + bLink = TRUE; + } + + if ( pRefUndoDoc->IsScenario(theTabs[i]) ) + { + pDoc->SetScenario( theTabs[i], TRUE ); + String aComment; + Color aColor; + USHORT nScenFlags; + pRefUndoDoc->GetScenarioData( theTabs[i], aComment, aColor, nScenFlags ); + pDoc->SetScenarioData( theTabs[i], aComment, aColor, nScenFlags ); + BOOL bActive = pRefUndoDoc->IsActiveScenario( theTabs[i] ); + pDoc->SetActiveScenario( theTabs[i], bActive ); + } + + // Drawing-Layer passiert beim MoveUndo::EndUndo + // pDoc->TransferDrawPage(pRefUndoDoc, nTab,nTab); + } + } + if (bLink) + { + pDocShell->UpdateLinks(); // Link-Manager updaten + SFX_BINDINGS().Invalidate(SID_LINKS); + } + + EndUndo(); // Draw-Undo muss vor dem Broadcast kommen! + + ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); + + for(i=0;i<theTabs.Count();i++) + { + pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[i]) ); + } + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator + + pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_ALL ); // incl. Extras + + // nicht ShowTable wegen SetTabNo(..., TRUE): + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetTabNo( theTabs[0], TRUE ); + +// EndUndo(); +} + +void __EXPORT ScUndoDeleteTab::Redo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + pViewShell->SetTabNo( theTabs[0] ); + + if (pDrawUndo) + RedoSdrUndoAction( pDrawUndo ); // Draw Redo vorneweg + + pDocShell->SetInUndo( TRUE ); //! BeginRedo + bDrawIsInUndo = TRUE; + pViewShell->DeleteTables( theTabs, FALSE ); + bDrawIsInUndo = FALSE; + pDocShell->SetInUndo( TRUE ); //! EndRedo + + SetChangeTrack(); + + // SetTabNo(...,TRUE) for all views to sync with drawing layer pages + pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) ); +} + +void __EXPORT ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ScTabViewShell* pViewShell = ((ScTabViewTarget&)rTarget).GetViewShell(); + pViewShell->DeleteTable( pViewShell->GetViewData()->GetTabNo(), TRUE ); + } +} + +BOOL __EXPORT ScUndoDeleteTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +//--------------------------------------------------------------------------------- +// +// Tabelle umbenennen +// + +ScUndoRenameTab::ScUndoRenameTab( ScDocShell* pNewDocShell, + USHORT nT, + const String& rOldName, + const String& rNewName) : + ScSimpleUndo( pNewDocShell ), + nTab ( nT ) +{ + sOldName = rOldName; + sNewName = rNewName; +} + +__EXPORT ScUndoRenameTab::~ScUndoRenameTab() +{ +} + +String __EXPORT ScUndoRenameTab::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB ); +} + +void ScUndoRenameTab::DoChange( USHORT nTab, const String& rName ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->RenameTab( nTab, rName ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator + + pDocShell->PostPaintGridAll(); + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); + + // Der Tabellenname koennte in einer Formel vorkommen... + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->UpdateInputHandler(); +} + +void __EXPORT ScUndoRenameTab::Undo() +{ + DoChange(nTab, sOldName); +} + +void __EXPORT ScUndoRenameTab::Redo() +{ + DoChange(nTab, sNewName); +} + +void __EXPORT ScUndoRenameTab::Repeat(SfxRepeatTarget& rTarget) +{ + // Repeat macht keinen Sinn +} + +BOOL __EXPORT ScUndoRenameTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//---------------------------------------------------------------------------------- +// +// Tabelle verschieben +// + +ScUndoMoveTab::ScUndoMoveTab( ScDocShell* pNewDocShell, + const SvUShorts &aOldTab, + const SvUShorts &aNewTab) : + ScSimpleUndo( pNewDocShell ) +{ + int i; + for(i=0;i<aOldTab.Count();i++) + theOldTabs.Insert(aOldTab[i],theOldTabs.Count()); + + for(i=0;i<aNewTab.Count();i++) + theNewTabs.Insert(aNewTab[i],theNewTabs.Count()); +} + +__EXPORT ScUndoMoveTab::~ScUndoMoveTab() +{ + theNewTabs.Remove(0,theNewTabs.Count()); + theOldTabs.Remove(0,theOldTabs.Count()); +} + +String __EXPORT ScUndoMoveTab::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_MOVE_TAB ); +} + +void ScUndoMoveTab::DoChange( BOOL bUndo ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (bUndo) // UnDo + { + for(int i=theNewTabs.Count()-1;i>=0;i--) + { + USHORT nDestTab = theNewTabs[i]; + USHORT nNewTab = theNewTabs[i]; + USHORT nOldTab = theOldTabs[i]; + if (nDestTab > MAXCOL) // angehaengt ? + nDestTab = pDoc->GetTableCount() - 1; + + pDoc->MoveTab( nDestTab, nOldTab ); + pViewShell->GetViewData()->MoveTab( nDestTab, nOldTab ); + pViewShell->SetTabNo( nOldTab, TRUE ); + } + } + else + { + for(int i=0;i<theNewTabs.Count();i++) + { + USHORT nDestTab = theNewTabs[i]; + USHORT nNewTab = theNewTabs[i]; + USHORT nOldTab = theOldTabs[i]; + if (nDestTab > MAXCOL) // angehaengt ? + nDestTab = pDoc->GetTableCount() - 1; + + pDoc->MoveTab( nOldTab, nNewTab ); + pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab ); + pViewShell->SetTabNo( nDestTab, TRUE ); + } + } + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator + + pDocShell->PostPaintGridAll(); + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); +} + +void __EXPORT ScUndoMoveTab::Undo() +{ + DoChange( TRUE ); +} + +void __EXPORT ScUndoMoveTab::Redo() +{ + DoChange( FALSE ); +} + +void __EXPORT ScUndoMoveTab::Repeat(SfxRepeatTarget& rTarget) +{ + // kein Repeat ! ? ! +} + +BOOL __EXPORT ScUndoMoveTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +//---------------------------------------------------------------------------------- +// +// Tabelle kopieren +// + +ScUndoCopyTab::ScUndoCopyTab( ScDocShell* pNewDocShell, + const SvUShorts &aOldTab, + const SvUShorts &aNewTab) : + ScSimpleUndo( pNewDocShell ), + pDrawUndo( NULL ) +{ + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); + + int i; + for(i=0;i<aOldTab.Count();i++) + theOldTabs.Insert(aOldTab[i],theOldTabs.Count()); + + for(i=0;i<aNewTab.Count();i++) + theNewTabs.Insert(aNewTab[i],theNewTabs.Count()); +} + +__EXPORT ScUndoCopyTab::~ScUndoCopyTab() +{ + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoCopyTab::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_COPY_TAB ); +} + +void ScUndoCopyTab::DoChange() const +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + if (pViewShell) + pViewShell->SetTabNo(theOldTabs[0],TRUE); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator + + pDocShell->PostPaintGridAll(); + pDocShell->PostPaintExtras(); + pDocShell->PostDataChanged(); +} + +void __EXPORT ScUndoCopyTab::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); // before the sheets are deleted + + int i; + for(i=theNewTabs.Count()-1;i>=0;i--) + { + USHORT nDestTab = theNewTabs[i]; + if (nDestTab > MAXTAB) // append? + nDestTab = pDoc->GetTableCount() - 1; + + bDrawIsInUndo = TRUE; + pDoc->DeleteTab(nDestTab); + bDrawIsInUndo = FALSE; + } + + // ScTablesHint broadcasts after all sheets have been deleted, + // so sheets and draw pages are in sync! + + for(i=theNewTabs.Count()-1;i>=0;i--) + { + USHORT nDestTab = theNewTabs[i]; + if (nDestTab > MAXTAB) // append? + nDestTab = pDoc->GetTableCount() - 1; + + pDocShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nDestTab ) ); + } + + DoChange(); +} + +void __EXPORT ScUndoCopyTab::Redo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + + USHORT nDestTab = 0; + for(int i=0;i<theNewTabs.Count();i++) + { + nDestTab = theNewTabs[i]; + USHORT nNewTab = theNewTabs[i]; + USHORT nOldTab = theOldTabs[i]; + if (nDestTab > MAXCOL) // angehaengt ? + nDestTab = pDoc->GetTableCount() - 1; + + bDrawIsInUndo = TRUE; + pDoc->CopyTab( nOldTab, nNewTab ); + bDrawIsInUndo = FALSE; + + pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab ); + + if ( pDoc->IsScenario(nOldTab) ) + { + pDoc->SetScenario(nNewTab, TRUE ); + String aComment; + Color aColor; + USHORT nScenFlags; + pDoc->GetScenarioData(nOldTab, aComment, aColor, nScenFlags ); + pDoc->SetScenarioData(nNewTab, aComment, aColor, nScenFlags ); + BOOL bActive = pDoc->IsActiveScenario(nOldTab); + pDoc->SetActiveScenario(nNewTab, bActive ); + BOOL bVisible=pDoc->IsVisible(nOldTab); + pDoc->SetVisible(nNewTab,bVisible ); + } + } + + if (pDrawUndo) + RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted + + pViewShell->SetTabNo( nDestTab, TRUE ); // after draw-undo + + DoChange(); + +} + +void __EXPORT ScUndoCopyTab::Repeat(SfxRepeatTarget& rTarget) +{ + // kein Repeat ! ? ! +} + +BOOL __EXPORT ScUndoCopyTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Szenario anlegen +// + +ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell* pNewDocShell, + USHORT nSrc, USHORT nDest, ScDocument* pUndo, + const String& rN, const String& rC, + const Color& rCol, USHORT nF, + const ScMarkData& rMark ) : + ScSimpleUndo( pNewDocShell ), + nSrcTab( nSrc ), + nDestTab( nDest ), + pUndoDoc( pUndo ), + aName( rN ), + aComment( rC ), + aColor( rCol ), + nFlags( nF ), + aMarkData( rMark ) +{ +} + +__EXPORT ScUndoMakeScenario::~ScUndoMakeScenario() +{ + delete pUndoDoc; +} + +String __EXPORT ScUndoMakeScenario::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_MAKESCENARIO ); +} + +void __EXPORT ScUndoMakeScenario::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->DeleteTab( nDestTab ); + pDocShell->PostPaint(0,0,nDestTab,MAXCOL,MAXROW,MAXTAB, PAINT_ALL); + pDocShell->PostDataChanged(); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetTabNo( nSrcTab, TRUE ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); +} + +void __EXPORT ScUndoMakeScenario::Redo() +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->DoneBlockMode(); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo + } + + pDocShell->MakeScenario( nSrcTab, aName, aComment, aColor, nFlags, aMarkData, FALSE ); + + if (pViewShell) + pViewShell->SetTabNo( nDestTab, TRUE ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); +} + +void __EXPORT ScUndoMakeScenario::Repeat(SfxRepeatTarget& rTarget) +{ + if (rTarget.ISA(ScTabViewTarget)) + { + ((ScTabViewTarget&)rTarget).GetViewShell()->MakeScenario( aName, aComment, aColor, nFlags ); + } +} + +BOOL __EXPORT ScUndoMakeScenario::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Tabelle einfuegen +// + +ScUndoImportTab::ScUndoImportTab( ScDocShell* pShell, + USHORT nNewTab, USHORT nNewCount, BOOL bNewLink ) : + ScSimpleUndo( pShell ), + nTab( nNewTab ), + nCount( nNewCount ), + bLink( bNewLink ), + pRedoDoc( NULL ), + pDrawUndo( NULL ) +{ + pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() ); +} + +__EXPORT ScUndoImportTab::~ScUndoImportTab() +{ + delete pRedoDoc; + DeleteSdrUndoAction( pDrawUndo ); +} + +String __EXPORT ScUndoImportTab::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB ); +} + +void ScUndoImportTab::DoChange() const +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nCount = pDoc->GetTableCount(); + if (pViewShell) + { + if(nTab<nCount) + { + pViewShell->SetTabNo(nTab,TRUE); + } + else + { + pViewShell->SetTabNo(nTab-1,TRUE); + } + } + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator + pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, + PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS ); +} + +void __EXPORT ScUndoImportTab::Undo() +{ + //! eingefuegte Bereichsnamen etc. + + USHORT i; + ScDocument* pDoc = pDocShell->GetDocument(); + BOOL bMakeRedo = !pRedoDoc; + if (bMakeRedo) + { + pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRedoDoc->InitUndo( pDoc, nTab,nTab+nCount-1, TRUE,TRUE ); + + String aOldName; + for (i=0; i<nCount; i++) + { + USHORT nTabPos=nTab+i; + + pDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,FALSE, pRedoDoc ); + pDoc->GetName( nTabPos, aOldName ); + pRedoDoc->RenameTab( nTabPos, aOldName, FALSE ); + + if ( pDoc->IsScenario(nTabPos) ) + { + pRedoDoc->SetScenario(nTabPos, TRUE ); + String aComment; + Color aColor; + USHORT nScenFlags; + pDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + pRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + BOOL bActive = pDoc->IsActiveScenario(nTabPos); + pRedoDoc->SetActiveScenario(nTabPos, bActive ); + BOOL bVisible=pDoc->IsVisible(nTabPos); + pRedoDoc->SetVisible(nTabPos,bVisible ); + } + } + + } + + if (pDrawUndo) + DoSdrUndoAction( pDrawUndo ); // before the sheets are deleted + + bDrawIsInUndo = TRUE; + for (i=0; i<nCount; i++) + pDoc->DeleteTab( nTab ); + bDrawIsInUndo = FALSE; + + DoChange(); +} + +void __EXPORT ScUndoImportTab::Redo() +{ + if (!pRedoDoc) + { + DBG_ERROR("wo ist mein Redo-Document?"); + return; + } + + ScDocument* pDoc = pDocShell->GetDocument(); + String aName; + USHORT i; + for (i=0; i<nCount; i++) // first insert all sheets (#63304#) + { + USHORT nTabPos=nTab+i; + pRedoDoc->GetName(nTabPos,aName); + bDrawIsInUndo = TRUE; + pDoc->InsertTab(nTabPos,aName); + bDrawIsInUndo = FALSE; + } + for (i=0; i<nCount; i++) // then copy into inserted sheets + { + USHORT nTabPos=nTab+i; + pRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,FALSE, pDoc ); + + if ( pRedoDoc->IsScenario(nTabPos) ) + { + pDoc->SetScenario(nTabPos, TRUE ); + String aComment; + Color aColor; + USHORT nScenFlags; + pRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + pDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + BOOL bActive = pRedoDoc->IsActiveScenario(nTabPos); + pDoc->SetActiveScenario(nTabPos, bActive ); + BOOL bVisible=pRedoDoc->IsVisible(nTabPos); + pDoc->SetVisible(nTabPos,bVisible ); + } + } + + if (pDrawUndo) + RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted + + DoChange(); +} + +void __EXPORT ScUndoImportTab::Repeat(SfxRepeatTarget& rTarget) +{ + SFX_DISPATCHER().Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); +} + +BOOL __EXPORT ScUndoImportTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + + +// ----------------------------------------------------------------------- +// +// Tabellen-Verknuepfung aufheben +// + +ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell* pShell, const String& rDoc ) : + ScSimpleUndo( pShell ), + aDocName( rDoc ), + nCount( 0 ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTabCount = pDoc->GetTableCount(); + pTabs = new USHORT[nTabCount]; + pModes = new BYTE[nTabCount]; + pTabNames = new String[nTabCount]; + + for (USHORT i=0; i<nTabCount; i++) + { + BYTE nMode = pDoc->GetLinkMode(i); + if (nMode) + if (pDoc->GetLinkDoc(i) == aDocName) + { + if (!nCount) + { + aFltName = pDoc->GetLinkFlt(i); + aOptions = pDoc->GetLinkOpt(i); + } + else + DBG_ASSERT(aFltName == pDoc->GetLinkFlt(i) && + aOptions == pDoc->GetLinkOpt(i), + "verschiedene Filter fuer ein Dokument?"); + pTabs[nCount] = i; + pModes[nCount] = nMode; + pTabNames[nCount] = pDoc->GetLinkTab(i); + ++nCount; + } + } +} + +__EXPORT ScUndoRemoveLink::~ScUndoRemoveLink() +{ + delete pTabs; + delete pModes; + delete[] pTabNames; +} + +String __EXPORT ScUndoRemoveLink::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_REMOVELINK ); +} + +void ScUndoRemoveLink::DoChange( BOOL bLink ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + String aEmpty; + for (USHORT i=0; i<nCount; i++) + if (bLink) // establish link + pDoc->SetLink( pTabs[i], pModes[i], aDocName, aFltName, aOptions, pTabNames[i] ); + else // remove link + pDoc->SetLink( pTabs[i], SC_LINK_NONE, aEmpty, aEmpty, aEmpty, aEmpty ); + pDocShell->UpdateLinks(); + SFX_BINDINGS().Invalidate(SID_LINKS); +} + +void __EXPORT ScUndoRemoveLink::Undo() +{ + DoChange( TRUE ); +} + +void __EXPORT ScUndoRemoveLink::Redo() +{ + DoChange( FALSE ); +} + +void __EXPORT ScUndoRemoveLink::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + +BOOL __EXPORT ScUndoRemoveLink::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + +// ----------------------------------------------------------------------- +// +// Tabellen ein-/ausblenden +// + +ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell* pShell, USHORT nNewTab, BOOL bNewShow ) : + ScSimpleUndo( pShell ), + nTab( nNewTab ), + bShow( bNewShow ) +{ +} + +__EXPORT ScUndoShowHideTab::~ScUndoShowHideTab() +{ +} + +void ScUndoShowHideTab::DoChange( BOOL bShow ) const +{ + ScDocument* pDoc = pDocShell->GetDocument(); + pDoc->SetVisible( nTab, bShow ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetTabNo(nTab,TRUE); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pDocShell->SetDocumentModified(); +} + +void __EXPORT ScUndoShowHideTab::Undo() +{ + DoChange(!bShow); +} + +void __EXPORT ScUndoShowHideTab::Redo() +{ + DoChange(bShow); +} + +void __EXPORT ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget) +{ + SFX_DISPATCHER().Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE, + SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); +} + +BOOL __EXPORT ScUndoShowHideTab::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return (rTarget.ISA(ScTabViewTarget)); +} + +String __EXPORT ScUndoShowHideTab::GetComment() const +{ + USHORT nId = bShow ? STR_UNDO_SHOWTAB : STR_UNDO_HIDETAB; + return ScGlobal::GetRscString( nId ); +} + +// ----------------------------------------------------------------------- +// +// Tabelle/Dokument schuetzen oder Schutz aufheben +// + +ScUndoProtect::ScUndoProtect( ScDocShell* pShell, USHORT nNewTab, + BOOL bNewProtect, const String& rNewPassword ) : + ScSimpleUndo( pShell ), + nTab( nNewTab ), + bProtect( bNewProtect ), + aPassword( rNewPassword ) +{ +} + +__EXPORT ScUndoProtect::~ScUndoProtect() +{ +} + +void ScUndoProtect::DoProtect( BOOL bDo ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + if (bDo) + { + if ( nTab == TABLEID_DOC ) + pDoc->SetDocProtection( TRUE, aPassword ); + else + pDoc->SetTabProtection( nTab, TRUE, aPassword ); + } + else + { + if ( nTab == TABLEID_DOC ) + pDoc->SetDocProtection( FALSE, EMPTY_STRING ); + else + pDoc->SetTabProtection( nTab, FALSE, EMPTY_STRING ); + } + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + pViewShell->UpdateLayerLocks(); + pViewShell->UpdateInputHandler(TRUE); // damit sofort wieder eingegeben werden kann + } + + pDocShell->PostPaintGridAll(); +} + +void __EXPORT ScUndoProtect::Undo() +{ + BeginUndo(); + DoProtect( !bProtect ); + EndUndo(); +} + +void __EXPORT ScUndoProtect::Redo() +{ + BeginRedo(); + DoProtect( bProtect ); + EndRedo(); +} + +void __EXPORT ScUndoProtect::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + +BOOL __EXPORT ScUndoProtect::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // gippsnich +} + +String __EXPORT ScUndoProtect::GetComment() const +{ + USHORT nId; + if ( nTab == TABLEID_DOC ) + nId = bProtect ? STR_UNDO_PROTECT_DOC : STR_UNDO_UNPROTECT_DOC; + else + nId = bProtect ? STR_UNDO_PROTECT_TAB : STR_UNDO_UNPROTECT_TAB; + return ScGlobal::GetRscString( nId ); +} + +// ----------------------------------------------------------------------- +// +// Druck-/Wiederholungsbereiche aendern +// + +ScUndoPrintRange::ScUndoPrintRange( ScDocShell* pShell, USHORT nNewTab, + ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew ) : + ScSimpleUndo( pShell ), + nTab( nNewTab ), + pOldRanges( pOld ), + pNewRanges( pNew ) +{ +} + +__EXPORT ScUndoPrintRange::~ScUndoPrintRange() +{ + delete pOldRanges; + delete pNewRanges; +} + +void ScUndoPrintRange::DoChange(BOOL bUndo) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + if (bUndo) + pDoc->RestorePrintRanges( *pOldRanges ); + else + pDoc->RestorePrintRanges( *pNewRanges ); + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetTabNo( nTab ); + + ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages(); + + pDocShell->PostPaint( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), PAINT_GRID ); +} + +void __EXPORT ScUndoPrintRange::Undo() +{ + BeginUndo(); + DoChange( TRUE ); + EndUndo(); +} + +void __EXPORT ScUndoPrintRange::Redo() +{ + BeginRedo(); + DoChange( FALSE ); + EndRedo(); +} + +void __EXPORT ScUndoPrintRange::Repeat(SfxRepeatTarget& rTarget) +{ + // gippsnich +} + +BOOL __EXPORT ScUndoPrintRange::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; // gippsnich +} + +String __EXPORT ScUndoPrintRange::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES ); +} + + +//------------------------------------------------------------------------ + +//--------------------------------------------------------------------------------- +// +// Szenario-Flags +// + +ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell* pNewDocShell, USHORT nT, + const String& rON, const String& rNN, const String& rOC, const String& rNC, + const Color& rOCol, const Color& rNCol, USHORT nOF, USHORT nNF ) : + ScSimpleUndo( pNewDocShell ), + nTab ( nT ), + aOldName ( rON ), + aNewName ( rNN ), + aOldComment ( rOC ), + aNewComment ( rNC ), + aOldColor ( rOCol ), + aNewColor ( rNCol ), + nOldFlags ( nOF ), + nNewFlags ( nNF ) +{ +} + +__EXPORT ScUndoScenarioFlags::~ScUndoScenarioFlags() +{ +} + +String __EXPORT ScUndoScenarioFlags::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO ); +} + +void __EXPORT ScUndoScenarioFlags::Undo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + pDoc->RenameTab( nTab, aOldName ); + pDoc->SetScenarioData( nTab, aOldComment, aOldColor, nOldFlags ); + + pDocShell->PostPaintGridAll(); + // Der Tabellenname koennte in einer Formel vorkommen... + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->UpdateInputHandler(); + + if ( aOldName != aNewName ) + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); +} + +void __EXPORT ScUndoScenarioFlags::Redo() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + pDoc->RenameTab( nTab, aNewName ); + pDoc->SetScenarioData( nTab, aNewComment, aNewColor, nNewFlags ); + + pDocShell->PostPaintGridAll(); + // Der Tabellenname koennte in einer Formel vorkommen... + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->UpdateInputHandler(); + + if ( aOldName != aNewName ) + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); +} + +void __EXPORT ScUndoScenarioFlags::Repeat(SfxRepeatTarget& rTarget) +{ + // Repeat macht keinen Sinn +} + +BOOL __EXPORT ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget& rTarget) const +{ + return FALSE; +} + + + + diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx new file mode 100644 index 000000000000..d877b832a228 --- /dev/null +++ b/sc/source/ui/undo/undoutil.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * $RCSfile: undoutil.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "undoutil.hxx" + +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "dbcolect.hxx" +#include "globstr.hrc" +#include "global.hxx" + +// STATIC DATA ----------------------------------------------------------- + +SEG_EOFGLOBALS() + + +#pragma SEG_FUNCDEF(undoutil_01) + +void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, + USHORT nStartX, USHORT nStartY, USHORT nStartZ, + USHORT nEndX, USHORT nEndY, USHORT nEndZ ) +{ + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + { + USHORT nViewTab = pViewShell->GetViewData()->GetTabNo(); + if ( nViewTab < nStartZ || nViewTab > nEndZ ) + pViewShell->SetTabNo( nStartZ ); + + pViewShell->DoneBlockMode(); + pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, FALSE, FALSE ); + pViewShell->InitOwnBlockMode(); + pViewShell->GetViewData()->GetMarkData(). + SetMarkArea( ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ) ); + } +} + +#pragma SEG_FUNCDEF(undoutil_02) + +void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, + const ScTripel& rBlockStart, + const ScTripel& rBlockEnd ) +{ + MarkSimpleBlock( pDocShell, rBlockStart.GetCol(), rBlockStart.GetRow(), rBlockStart.GetTab(), + rBlockEnd.GetCol(), rBlockEnd.GetRow(), rBlockEnd.GetTab() ); +} + +#pragma SEG_FUNCDEF(undoutil_05) + +void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, + const ScRange& rRange ) +{ + MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(), + rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() ); +} + + +#pragma SEG_FUNCDEF(undoutil_03) + +ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, USHORT nTab, + USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2 ) +{ + ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 ); + + if (!pRet) + { + BOOL bWasTemp = FALSE; + if ( pUndoData ) + { + String aName; + pUndoData->GetName( aName ); + if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) ) + bWasTemp = TRUE; + } + if (!bWasTemp) + DBG_ERROR("Undo: DB-Bereich nicht gefunden"); + + USHORT nIndex; + ScDBCollection* pColl = pDoc->GetDBCollection(); + if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex )) + pRet = (*pColl)[nIndex]; + else + { + pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab, + nCol1,nRow1, nCol2,nRow2, TRUE, + pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) ); + pColl->Insert( pRet ); + } + } + + return pRet; +} + +#pragma SEG_FUNCDEF(undoutil_04) + +void ScUndoUtil::PaintMore( ScDocShell* pDocShell, + const ScRange& rRange ) +{ + USHORT nCol1 = rRange.aStart.Col(); + USHORT nRow1 = rRange.aStart.Row(); + USHORT nCol2 = rRange.aEnd.Col(); + USHORT nRow2 = rRange.aEnd.Row(); + if (nCol1) --nCol1; + if (nRow1) --nRow1; + if (nCol2<MAXCOL) ++nCol2; + if (nRow2<MAXROW) ++nRow2; + + pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(), + nCol2,nRow2,rRange.aEnd.Tab(), PAINT_GRID ); +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.11 2000/09/17 14:09:28 willem.vandorp + OpenOffice header added. + + Revision 1.10 2000/08/31 16:38:40 willem.vandorp + Header and footer replaced + + Revision 1.9 1996/09/04 17:48:18 RJ + MarkSimpleBlock mit ScRange-Parameter + + + Rev 1.8 04 Sep 1996 19:48:18 RJ + MarkSimpleBlock mit ScRange-Parameter + + Rev 1.7 19 Aug 1996 21:29:56 NN + Markierungen werden nicht mehr am Dokument gehalten + + Rev 1.6 16 Aug 1996 13:52:14 RJ + kleine Umstellung in ::MarkSimpleBlock + + Rev 1.5 10 Apr 1996 11:14:54 NN + MarkSimpleBlock: Tabelle umstellen + + Rev 1.4 10 Oct 1995 12:21:26 NN + PaintMore + + Rev 1.3 03 Feb 1995 09:45:34 GT + Umstellung auf Resource-Strings + + Rev 1.2 19 Jan 1995 18:51:20 NN + GetOldDBArea + + Rev 1.1 18 Jan 1995 15:06:08 TRI + Pragmas zur Segementierung eingebaut + + Rev 1.0 12 Jan 1995 12:19:10 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + |